Archived
Ten summaries rewritten from the dossiers, fact-checked by a read-only checker (one fair flag fixed), scenario sequences and flag proposals recorded, 16 contradictions logged for Sofia in batches/contradictions-01.md. Procedure in VERIFICATION-PROCEDURE.md; apply_batch.py applies a batch to the stores; batches/WRITER-PROMPT.md drives the writer agents for later batches. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GZZENdTLzNGsbNy4DyF1yt
87 lines
4.7 KiB
Python
87 lines
4.7 KiB
Python
"""
|
|
Apply a verification batch (batches/batch-NN.json) to the stores.
|
|
|
|
- summary -> summary-overrides.json (rendered by build_cases.py as the revised summary)
|
|
- sequence etc. -> scenario-sequences.json
|
|
- flag proposals -> detention-flag-corrections.json (kidnappings) and
|
|
batches/flag-proposals.json (all six), status "proposed <date> (batch NN)"
|
|
- contradictions, off-case links, notes -> batches/contradictions-NN.md, and a pointer section on
|
|
sofia-worklist.md
|
|
Idempotent per case. Run build_cases.py --all and verify_all.py afterwards.
|
|
"""
|
|
|
|
import json
|
|
import re
|
|
import sys
|
|
from datetime import date
|
|
from pathlib import Path
|
|
|
|
BASE = Path(__file__).resolve().parent
|
|
OV = BASE / "summary-overrides.json"
|
|
SEQ = BASE / "scenario-sequences.json"
|
|
DET = BASE / "detention-flag-corrections.json"
|
|
FLAGS = BASE / "batches" / "flag-proposals.json"
|
|
WL = BASE / "sofia-worklist.md"
|
|
|
|
|
|
def main():
|
|
path = Path(sys.argv[1])
|
|
nn = re.search(r"batch-(\d+)", path.name).group(1)
|
|
batch = json.loads(path.read_text(encoding="utf-8"))
|
|
today = date.today().isoformat()
|
|
ov = json.loads(OV.read_text(encoding="utf-8"))
|
|
seq = json.loads(SEQ.read_text(encoding="utf-8"))
|
|
det = json.loads(DET.read_text(encoding="utf-8"))
|
|
fl = json.loads(FLAGS.read_text(encoding="utf-8")) if FLAGS.exists() else []
|
|
lines = [f"# Batch {nn} — contradictions, flag proposals and notes for Sofia ({today})", ""]
|
|
for c in batch:
|
|
cid = str(c["id"])
|
|
ov[cid] = c["summary"]
|
|
seq[cid] = {"sequence": c["sequence"], "attempted": c.get("attempted", []), "gaps": c.get("gaps", []),
|
|
"v1_label_supported": c.get("v1_label_supported", True), "rationale": c["rationale"],
|
|
"facts": c.get("facts"), "batch": nn}
|
|
for k, f in c["flags"].items():
|
|
if not f.get("supported") and f.get("proposed") is not None:
|
|
entry = {"id": c["id"], "flag": k, "record": f["record"], "proposed": f["proposed"],
|
|
"evidence": f["evidence"], "status": f"proposed {today} (batch {nn})"}
|
|
fl = [x for x in fl if not (x["id"] == c["id"] and x["flag"] == k)] + [entry]
|
|
if k == "kidnappings" and f["proposed"] in (0, 1):
|
|
det = [x for x in det if x["target"] != f"DB id {c['id']}"]
|
|
det.append({"target": f"DB id {c['id']}", "field": "kidnappings (detention)",
|
|
"current": None if f["record"] == "null" else f["record"], "proposed": f["proposed"],
|
|
"confidence": "BATCH", "basis": f["evidence"], "status": f"proposed {today} (batch {nn})"})
|
|
lines.append(f"## case {cid}")
|
|
for x in c.get("contradictions", []):
|
|
lines.append(f"- **{x['field']}** — record: {x['record']!s} | article ({x['source']}): {x['article']}")
|
|
for k, f in c["flags"].items():
|
|
if not f.get("supported"):
|
|
lines.append(f"- flag `{k}` = {f['record']} -> propose **{f.get('proposed', '?')}**: {f['evidence']}")
|
|
for x in c.get("off_case_links", []):
|
|
lines.append(f"- OFF-CASE link: {x}")
|
|
if c.get("gaps"):
|
|
lines.append(f"- label gaps: {'; '.join(c['gaps'])}")
|
|
if c.get("notes_for_sofia"):
|
|
lines.append(f"- note: {c['notes_for_sofia']}")
|
|
lines.append("")
|
|
OV.write_text(json.dumps(ov, ensure_ascii=False, indent=2), encoding="utf-8")
|
|
SEQ.write_text(json.dumps(seq, ensure_ascii=False, indent=1), encoding="utf-8")
|
|
DET.write_text(json.dumps(det, ensure_ascii=False, indent=1), encoding="utf-8")
|
|
FLAGS.write_text(json.dumps(fl, ensure_ascii=False, indent=1), encoding="utf-8")
|
|
out = BASE / "batches" / f"contradictions-{nn}.md"
|
|
out.write_text("\n".join(lines) + "\n", encoding="utf-8")
|
|
wl = WL.read_text(encoding="utf-8")
|
|
marker = "## Verification batches (contradictions per batch)"
|
|
if marker not in wl:
|
|
wl += f"\n{marker}\nEach batch's record-vs-article contradictions, flag proposals and notes are in\nmerge-output/batches/contradictions-NN.md. Flag proposals from batches accumulate in\nmerge-output/batches/flag-proposals.json.\n"
|
|
line = f"- batch {nn} ({today}): cases {', '.join(str(c['id']) for c in batch)} -> batches/contradictions-{nn}.md"
|
|
if line not in wl:
|
|
wl += line + "\n"
|
|
WL.write_text(wl, encoding="utf-8")
|
|
print(f"applied batch {nn}: {len(batch)} summaries, {len(batch)} sequences, "
|
|
f"{sum(1 for c in batch for f in c['flags'].values() if not f.get('supported'))} flag proposals, "
|
|
f"{sum(len(c.get('contradictions', [])) for c in batch)} contradictions -> {out.name}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|