#!/usr/bin/env python3 """Record the owner's decision on one verified case. Usage: decide.py "" Appends a bullet under '## Batch NN decisions — owner, ' in corrections-approved.md (creating the section if needed) and stamps the case in batches/batch-NN.json.""" import json, sys, datetime, re from pathlib import Path bn, cid, text = int(sys.argv[1]), int(sys.argv[2]), sys.argv[3].strip() today = datetime.date.today().isoformat() p = Path('corrections-approved.md'); s = p.read_text(encoding='utf-8') head = f"## Batch {bn:02d} decisions — owner, " if head not in s: s = s.rstrip('\n') + f"\n\n---\n\n{head}{today}\n\nTaken case by case from `batches/contradictions-{bn:02d}.md`; evidence in `batches/batch-{bn:02d}.json`.\n" s = s.rstrip('\n') + f"\n- **DB id {cid}** — {text}\n" p.write_text(s, encoding='utf-8') bp = Path(f'batches/batch-{bn:02d}.json'); b = json.loads(bp.read_text(encoding='utf-8')) for c in b: if c['id'] == cid: c['notes_for_sofia'] = (c.get('notes_for_sofia') or '').rstrip() + f" DECIDED {today}: {text}" c['checked'] = f"{today} owner decision recorded" bp.write_text(json.dumps(b, ensure_ascii=False, indent=1), encoding='utf-8') print(f"recorded: batch {bn:02d} case {cid}")