from pathlib import Path import csv, hashlib, json, re, runpy from datetime import datetime, timedelta out=Path('output'); archive=out/'original-submission'; archive.mkdir(exist_ok=True) names=['action-plan.csv','decision-log.md','update-email.txt','build_deliverables.py'] for name in names: dest=archive/name if dest.exists(): raise RuntimeError('Archive already exists; refusing to overwrite original') dest.write_bytes((out/name).read_bytes()) original_hashes={name:hashlib.sha256((archive/name).read_bytes()).hexdigest() for name in names} (archive/'sha256-manifest.json').write_text(json.dumps(original_hashes,indent=2)+'\n',encoding='utf-8') input_paths=[Path('COMMON.md'),Path('PROMPT.md')]+sorted(Path('inputs').iterdir()) input_hashes={str(p):hashlib.sha256(p.read_bytes()).hexdigest() for p in input_paths} s=(out/'build_deliverables.py').read_text(encoding='utf-8') def change(old,new): global s assert old in s, old s=s.replace(old,new) change("'Use live-only default unless A03 yields written consent; do not wait for consent to remove unsupported promise'", "''") change("Keep draft pending tests and approval.", "Keep draft pending tests and approval. Use live-only default unless written consent permits a revised promise; do not wait for consent to remove unsupported wording.") change("'No dependency on A05 for drafting; use live-only default from A03/A04'", "''") change("recipient selection may remain unresolved in draft.", "recipient selection may remain unresolved in draft. Use live-only default; drafting need not await consent follow-up or audience selection.") change("'A04; A06; A07 pass; A03 outcome or live-only default'", "'A04; A06; A07 PASS'") change("'A07; A08','S3-P; S4; escalation process proposed'", "'Trigger: A07 fails or misses the approval review, or A08 approval is not obtained by its deadline; do not wait for successful completion','S3-P; S4; escalation process proposed'") change("'A07 pass on Oct 22; A08 approval; A04; resolve operator before opening'", "'A04; A07 PASS on Oct 22; A08 approval; A15 publication operator confirmed'") change("'TBD — sending owner not assigned (Mei owns copy only)'", "'Mei (invitations); send execution/operator to confirm'") change("'BLOCKED — audience, sender and schedule unresolved'", "'BLOCKED — audience, send execution and schedule unresolved'") change("'A05; A06; A08; A10'", "'A05; A06; A08; A10; A15 send execution confirmed (post-opening sequence proposed)'") change("'A03 outcome or live-only default','S1; S4'", "'','S1; S4'") change("Complete and supply host slides for the final event details and consent mode.", "Complete and supply host slides for the final event details; use live-only mode absent written consent. Consent follow-up does not block slide drafting.") change("'A10; A12; A03 outcome/default; ongoing captions requirement'", "'A10; A12; live-only default unless written consent covers recording/replay; captions required'") change("'Priya (approval); campaign executor TBD'", "'TBD — campaign approver/executor not explicitly assigned; Priya coordinates'") change("'S2; S3-P; S4')\n]", "'S2; S3-P; S4'),\n('A15','Confirm publication operator and invitation send execution with Mei; propose a send time after registration is open. Priya to coordinate confirmation, not assumed to execute these tasks.','Priya (coordination proposed); operator(s) to confirm','2026-10-22 17:00 Pacific (PROPOSED; publication operator needed before opening; sender needed before send)','PROPOSED — execution assignments and send time unresolved','','S1; S4; S5; proposed coordination target')\n]") change("The CSV uses these source keys.", "The CSV uses these source keys. Its dependencies column lists actual gates or explicit contingency triggers, not all contextual action references. Blank means no blocking action dependency; live-only defaults let drafting proceed without waiting for consent. Proposed sequencing is labelled.") change("S4 supersedes S2's speaker-confirmation-only prerequisite.", "S4 adds a separate written campaign-approval requirement beyond S2's speaker-confirmation prerequisite. S2 never said confirmation alone would authorize spending.") change("Budget headroom is not campaign permission.", "Budget headroom is not campaign permission; the separate campaign approver is not named in the supplied documents.") change("S4 invitation deadline is treated as a copy deadline, not a send authorization, given draft hold and unresolved recipients (S3-P, S5).", "S4 assigns Mei ownership of invitations. Treating the October 22 noon deliverable as draft copy rather than a send deadline is an interpretation of the draft hold and unresolved recipients (S3-P, S5), not an explicit limitation of Mei's role to copy only. Confirm send execution and timing.") change("Hold sending until permission evidence and recipient selection are resolved.", "Proposed operational safeguard: hold sending until permission evidence and recipient selection are resolved; this is not a separately documented Priya approval.") change("5. **Publication and send execution (A10–A11):** No publication operator, invitation sender or invitation send time is assigned in S1–S5. Do not infer these from Jonah's design or Mei's copy role. Propose assigning operators before opening and sending invitations after registration is available.", "5. **Publication and send execution (A10–A11, A15):** S4 assigns Mei invitations but does not specify send execution or timing; no publication operator is explicitly identified in S1–S5. Do not narrow Mei's ownership to copy only, or assume Jonah executes publication. Propose Priya coordinate confirmation of publication/send operators by the October 22, 17:00 review and propose sending after registration is available. These coordination targets are not approved deadlines.") change("unresolved recipient permission blocks sending, not drafting.", "the proposed safeguard holds sending while recipient permission is unresolved, without blocking drafting.") change("`output/build_deliverables.py` is the reproducible generation/validation helper.", "`output/build_deliverables.py` is the revised reproducible generation/validation helper. The original four submission files are preserved byte-for-byte in `output/original-submission/` with a SHA-256 manifest. Review details are in `output/change-log.md`; `output/review-and-revise.py` records the one-time revision process (do not rerun against the existing archive).") # Replace email to make the draft/send interpretation explicit within the word limit. a=s.index("email='''"); b=s.index("'''",a+9)+3 new_email="""email='''To: Field Notes project team Subject: DRAFT — October 20 status and launch gates Team, Current plan: October 30, 11:00 Pacific, 45 minutes, MeetRoom, 80 attendees, free entry, CAD 1,200 cap (inputs/03-email-thread.txt, Priya, October 18). CR-07 sets these deadlines (inputs/04-approved-change.md, Approved change request — CR-07): • Priya: assign test owner by October 21 noon; final launch approval October 22, 17:00. • Jonah: landing corrections October 21, 17:00; remove unsupported replay promises. • Alex: written speaker consent follow-up October 21; slides October 27, 17:00. Without consent, run live-only. • Mei: invitations October 22 noon. We interpret this as draft delivery, not send authorization, given the draft hold and unresolved recipients. Captions/capacity tests must pass October 22. Registration opens October 23, 09:00 only after required tests and approval. Keep launch copy in draft pending test pass (inputs/03-email-thread.txt, Priya, October 18). Proposed: schedule tests before approval with remediation time; escalate missed gates to Priya for rescheduling. Confirm publication operator, invitation send execution with Mei, and send timing. Recipient scope is unresolved (inputs/05-open-questions.txt, Mei to Priya, October 20). Proposed: designate a verifier/decision owner and hold sending until permission and recipients are verified; drafting can continue. Paid advertising remains on hold for separate written approval (CR-07). Draft only; nothing sent. '''""" s=s[:a]+new_email+s[b:] change("assert len(data)==14", "assert len(data)==15") change("PASS: 14 CSV rows", "PASS: 15 CSV rows") (out/'build_deliverables.py').write_text(s,encoding='utf-8') runpy.run_path(str(out/'build_deliverables.py'),run_name='__main__') # Independent output checks, beyond the generation helper. with (out/'action-plan.csv').open(newline='',encoding='utf-8') as f: reader=csv.DictReader(f); records=list(reader) assert reader.fieldnames==['action_id','action','owner','due','status','dependencies','source'] ids={r['action_id'] for r in records}; assert len(ids)==15 valid_sources={'S1','S2','S3-P','S3-A','S3-J','S4','S5'} log=(out/'decision-log.md').read_text(encoding='utf-8') for r in records: assert set(re.findall(r'\bS\d(?:-[A-Z])?\b', r['source'])) <= valid_sources for source in re.findall(r'\bS\d(?:-[A-Z])?\b', r['source']): assert '**'+source+':**' in log # Conditional trigger A09 is not a success dependency. Check the remaining ID graph for cycles. graph={r['action_id']:set(re.findall(r'\bA\d{2}\b',r['dependencies'])) for r in records} assert not graph['A06'] and not graph['A04'] and not graph['A12'] seen=set(); active=set() def visit(node): assert node not in active, 'Dependency cycle' if node in seen: return active.add(node) for parent in graph[node]: visit(parent) active.remove(node); seen.add(node) for node in graph: visit(node) assert (datetime(2026,10,30,11)+timedelta(minutes=45)).strftime('%H:%M')=='11:45' email=(out/'update-email.txt').read_text(encoding='utf-8'); count=len(email.split()); assert count<=220 assert email.startswith('To: Field Notes project team\n') and 'DRAFT' in email for name,digest in original_hashes.items(): assert hashlib.sha256((archive/name).read_bytes()).hexdigest()==digest for path,digest in input_hashes.items(): assert hashlib.sha256(Path(path).read_bytes()).hexdigest()==digest report=f'''# Review change log ## Revised submission - `output/action-plan.csv` — 15 actions, seven required columns. - `output/decision-log.md` — authority, decisions, proposals and source register. - `output/update-email.txt` — {count} whitespace-delimited words including headers; draft addressed to the project team. - `output/build_deliverables.py` — updated generation/validation helper. ## Original preserved The four original submission files are preserved byte-for-byte under `output/original-submission/`. `sha256-manifest.json` records their hashes. No raw input was edited. Archive hashes were checked after revision. `output/review-and-revise.py` records the one-time preservation, edits and independent checks; it refuses to overwrite the archive if rerun. ## Corrections and why 1. **Campaign approval ownership:** removed the unsupported assertion that Priya is the campaign approver. CR-07 requires separate written approval but does not name its approver (`inputs/04-approved-change.md`, “Approved change request — CR-07”). Priya remains project coordinator (`inputs/01-original-brief.md`, “Original brief — October 14, 09:00 Pacific”). Also corrected wording that could imply the October 16 notes had authorized spend once the speaker confirmed; they stated a prerequisite, not sufficient authorization (`inputs/02-meeting-notes.md`, “Planning notes — October 16, 14:00 Pacific”). 2. **Mei's ownership:** removed “Mei owns copy only.” CR-07 assigns Mei invitations, without an explicit copy-only restriction. Draft delivery is a stated interpretation of the draft hold and unresolved audience, not a direct quotation of CR-07. Send execution and timing remain to be confirmed, rather than denying Mei's invitation ownership (`inputs/03-email-thread.txt`, Priya, October 18, 09:00; `inputs/05-open-questions.txt`, Mei to Priya, October 20, 09:30). 3. **Dependencies:** removed consent/audience context from drafting prerequisites so that safe live-only copy and slides are not blocked unnecessarily. Identified the failure/escalation row as a trigger rather than requiring successful approval. Marked post-opening invitation sequence as proposed. 4. **Executable next step:** added A15, explicitly proposed coordination to confirm publication/send execution before launch, rather than leaving operator confirmation only inside the opening/send rows. Its October 22 target is proposed, not an approved deadline. 5. **Decision/proposal distinction:** explicitly labelled the mailing hold and verification process as proposed safeguards responding to the unresolved consent scope, not a new approval found in the evidence. Email now states the interpretation of Mei's draft deadline and preserves the <=220-word limit. ## Review and checks actually performed - Reread `COMMON.md`, `PROMPT.md`, all five project inputs and all four original output files. Compared approved dates, roles, event parameters, superseded instructions and consent limitations against the source records. - Recalculated 11:00 + 45 minutes = 11:45 Pacific. No timezone conversion is necessary; all source times and deliverable times remain Pacific. - Regenerated the three deliverables; parsed the UTF-8 CSV with Python's standard-library CSV reader. Verified exact headers, 15 unique action IDs, seven fields per record, nonempty required deliverables, valid referenced action IDs and valid source keys mapped in the decision log. - Checked the action-reference graph for cycles; none found. This is a structural check, not a scheduling simulation or proof that external deadlines can be met. - Counted the entire email including headers: **{count} words** using whitespace separation (limit 220). Checked team addressee and draft marking. - Verified preserved original-file hashes and unchanged hashes for all seven supplied input files. - No external access, platform tests, consent verification, operational actions or message sending occurred. These checks validate the documents, not project readiness. ## Remaining limitations and handoff Test assignment, test slot/criteria/results, written speaker consent, subscriber permission evidence, recipient decision, publication/send execution and any campaign approver remain unverified or unresolved. No revised opening date is invented. Captions, 80-seat capacity and Priya's approval remain launch gates; live-only remains the no-consent default (CR-07 and cited records in the decision log). Estimated human review/triage: **20–30 minutes**, excluding waiting for decisions, platform testing, copy production and event execution. This is a planning estimate, not measured work time. ''' (out/'change-log.md').write_text(report,encoding='utf-8') print(f'REVIEW PASS: {len(records)} actions; email {count} words; valid source/action references; acyclic dependency graph; duration calculation; original/archive and raw-input hashes unchanged.')