def _targeted_revision(self, reports: dict[str, Path], revision_number: int) -> None: packet_path = self._packet_path() self._verify_reporting_record(packet_path, reports, packet_sha256(packet_path)) original = json.loads(packet_path.read_text(encoding="utf-8-sig")) contract_findings = self._origin_contract_findings( original, reports, ) prompt = (ROOT / "docs/codex_weekly_editorial_job.md").read_text(encoding="utf-8") prompt += ( "\n\n## Runner context\n\n" f"Target Friday: {self.target_friday.isoformat()}\n" "Packet output: output/packet.json\n\n" "Treat this date as authoritative. Research only events known by the end of that Friday, " "even when this is a delayed catch-up run.\n\n" "## Required targeted correction\n" f"Read these independent review reports: {reports['facts']} and {reports['editorial']}. " "Correct every blocking finding from the supplied revision-base.json into output/packet.json. " "Preserve supported reporting and improve only identified defects. " "Preserve reader_link_scheme exactly, including its absence, and keep links in that convention. " "This is a revision of reviewed copy, so the fresh-weekly convention instruction does not add a marker here. " "Do not edit other files, commit, push, approve, or publish. The runner will start new independent reviews.\n" ) if contract_findings is not None: findings_path = self._contract_findings_path(reports, contract_findings) if (not findings_path.is_file() or json.loads(findings_path.read_text(encoding="utf-8")) != contract_findings): raise WeeklyRunError("Publication-contract findings are missing or do not match this packet and its reviews") prompt += ( "\nThe reviewers' original reports are retained unchanged. Their approve decisions did not satisfy " f"the publication contract. Read the exact machine findings at {findings_path}. " "Repair each identified provenance defect while keeping supported reporting and good prose. " "Do not edit review reports or machine findings, change verification flags, or hide a required " "family declaration by deleting or downgrading it. Supply inspectable, correct provenance, or " "remove optional unverifiable evidence and dependent claims consistently in both languages, " "Sucre and continuity. Preserve all source-quality requirements; necessary unresolved evidence " "must hold publication. Both independent reviewers will inspect the resulting exact packet anew.\n" ) if self.correction_id: prompt += self._correction_instructions() if self.run_kind == "retrospective": prompt += self._historical_instructions() if self.run.get("external_review_path"): prompt += ("\nAlso inspect the additional provider's advisory assessment at " f"{self._resolve_ref(self.run['external_review_path'])}. Treat its findings as claims to verify " "against the source evidence, not automatic truth. Resolve each material finding; the next " "attempt starts fresh mandatory and additional reviews of the changed packet.\n") prompt += self._external_findings_instructions() prompt += self._reference_preflight_instructions(packet_path) prompt, workspace = self._stage_author(prompt, packet_path, revision=True, reports=reports) self.save("author_revision", revision_number=revision_number) prompt = self._author_analytical_input(prompt, f"revision-{revision_number}", workspace=workspace) self._verify_staged_author_input(workspace) self._progress("revision_started", attempt=revision_number) self._codex( prompt, output=self.work_dir / f"revision-{revision_number}.txt", timeout=self._run_codex_timeout("generation_timeout_seconds"), tool_workspace=workspace, ) self._import_author(workspace, packet_path) self._complete_author_analytical_input() revised = json.loads(packet_path.read_text(encoding="utf-8-sig")) if (revised.get("reader_link_scheme") != original.get("reader_link_scheme") or ("reader_link_scheme" in revised) != ("reader_link_scheme" in original)): raise WeeklyRunError("Targeted revision changed the reviewed reader_link_scheme")