Files
Jyotisha/scripts/minute_rectification_holdout_intake.py
T
Jesse_Chen a3f4e7128b docs(rectification): mark v4 intake cases as already seen, not sealed
Keep the four migrated cases in the queue. Record prior score exposures, distinguish migrated review from a fresh biography audit, and reject exposed or auto-attested cases from blind holdout use.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-29 01:33:20 +08:00

80 lines
3.0 KiB
Python

#!/usr/bin/env python3
"""Append one independently reviewed case to a non-production v4 intake queue."""
from __future__ import annotations
import argparse
import json
from datetime import UTC, datetime
from pathlib import Path
from typing import Any
try:
from scripts.minute_rectification_holdout_validator import (
FRESH_HUMAN_REVIEW_KIND,
case_errors,
)
except ModuleNotFoundError: # pragma: no cover - direct script execution
from minute_rectification_holdout_validator import (
FRESH_HUMAN_REVIEW_KIND,
case_errors,
)
INTAKE_SCHEMA_VERSION = "minute-rectification-holdout-v4-intake"
DEFAULT_INTAKE = (
Path(__file__).resolve().parents[1]
/ "references"
/ "real_case_calibration"
/ "minute_rectification_holdout_v4_intake.json"
)
def append_case(path: Path, case: dict[str, Any]) -> dict[str, Any]:
data = json.loads(path.read_text(encoding="utf-8"))
if data.get("schema_version") != INTAKE_SCHEMA_VERSION:
return {"appended": False, "errors": ["intake_schema_required"]}
gate = data.get("minimum_gate") if isinstance(data.get("minimum_gate"), dict) else {}
cases = data.get("cases") if isinstance(data.get("cases"), list) else []
case_id = str(case.get("case_id") or "").strip()
if not case_id:
return {"appended": False, "errors": ["missing_case_id"]}
if any(isinstance(existing, dict) and existing.get("case_id") == case_id for existing in cases):
return {"appended": False, "errors": ["duplicate_case_id"]}
# Never auto-attest independent review. A true flag is accepted only when
# the caller already supplied a fresh biography-level human-review kind.
if (
case.get("independent_human_reviewed") is True
and case.get("human_review_kind") != FRESH_HUMAN_REVIEW_KIND
):
return {"appended": False, "errors": ["independent_review_requires_fresh_biography_audit"]}
errors = case_errors(case, gate, require_review_safeguards=True)
if errors:
return {"appended": False, "errors": errors}
cases.append({**case, "ingested_at": datetime.now(UTC).isoformat().replace("+00:00", "Z")})
data["cases"] = cases
data["status"] = "collecting_independently_reviewed_cases"
data["production_tuning_allowed"] = False
data["verified_minute_claim_allowed"] = False
path.write_text(json.dumps(data, ensure_ascii=False, indent=2, sort_keys=True) + "\n", encoding="utf-8")
return {
"appended": True,
"errors": [],
"case_count": len(cases),
"verified_minute_claim_allowed": False,
}
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("manifest", nargs="?", type=Path, default=DEFAULT_INTAKE)
parser.add_argument("--case-json", required=True)
args = parser.parse_args()
result = append_case(args.manifest, json.loads(args.case_json))
print(json.dumps(result, ensure_ascii=False, indent=2, sort_keys=True))
return 0 if result["appended"] else 1
if __name__ == "__main__":
raise SystemExit(main())