psyclaw 0.27.22 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1048) hide show
  1. package/README.md +11 -5
  2. package/dist/apps/panel/index.html +2 -2
  3. package/dist/src/adapters/pi/extension.js +225 -92
  4. package/dist/src/adapters/pi/extension.js.map +1 -1
  5. package/dist/src/agents/import.js +44 -32
  6. package/dist/src/agents/import.js.map +1 -1
  7. package/dist/src/analysis/hooks.d.ts +1 -0
  8. package/dist/src/analysis/hooks.js +20 -1
  9. package/dist/src/analysis/hooks.js.map +1 -1
  10. package/dist/src/ars/bridge.d.ts +20 -0
  11. package/dist/src/ars/bridge.js +132 -0
  12. package/dist/src/ars/bridge.js.map +1 -0
  13. package/dist/src/ars/contracts.d.ts +55 -0
  14. package/dist/src/ars/contracts.js +2 -0
  15. package/dist/src/ars/contracts.js.map +1 -0
  16. package/dist/src/ars/panel-plan.d.ts +4 -0
  17. package/dist/src/ars/panel-plan.js +11 -0
  18. package/dist/src/ars/panel-plan.js.map +1 -0
  19. package/dist/src/ars/pi-panel-executor.d.ts +30 -0
  20. package/dist/src/ars/pi-panel-executor.js +140 -0
  21. package/dist/src/ars/pi-panel-executor.js.map +1 -0
  22. package/dist/src/ars/profile.d.ts +36 -0
  23. package/dist/src/ars/profile.js +119 -0
  24. package/dist/src/ars/profile.js.map +1 -0
  25. package/dist/src/ars/re-review.d.ts +22 -0
  26. package/dist/src/ars/re-review.js +172 -0
  27. package/dist/src/ars/re-review.js.map +1 -0
  28. package/dist/src/branding.d.ts +2 -4
  29. package/dist/src/branding.js +3 -5
  30. package/dist/src/branding.js.map +1 -1
  31. package/dist/src/bundled-tools.d.ts +3 -0
  32. package/dist/src/bundled-tools.js +21 -0
  33. package/dist/src/bundled-tools.js.map +1 -0
  34. package/dist/src/chat.js +6 -5
  35. package/dist/src/chat.js.map +1 -1
  36. package/dist/src/creation/contracts.d.ts +38 -0
  37. package/dist/src/creation/contracts.js +2 -0
  38. package/dist/src/creation/contracts.js.map +1 -0
  39. package/dist/src/creation/service.d.ts +7 -0
  40. package/dist/src/creation/service.js +196 -0
  41. package/dist/src/creation/service.js.map +1 -0
  42. package/dist/src/index.d.ts +10 -0
  43. package/dist/src/index.js +10 -0
  44. package/dist/src/index.js.map +1 -1
  45. package/dist/src/install/installer.js +32 -10
  46. package/dist/src/install/installer.js.map +1 -1
  47. package/dist/src/orchestration/personas.d.ts +15 -0
  48. package/dist/src/orchestration/personas.js +51 -0
  49. package/dist/src/orchestration/personas.js.map +1 -0
  50. package/dist/src/orchestration/pi-executor.d.ts +1 -0
  51. package/dist/src/orchestration/pi-executor.js +1 -1
  52. package/dist/src/orchestration/pi-executor.js.map +1 -1
  53. package/dist/src/panel/extension.js +29 -8
  54. package/dist/src/panel/extension.js.map +1 -1
  55. package/dist/src/panel/server.js +14 -5
  56. package/dist/src/panel/server.js.map +1 -1
  57. package/dist/src/project/paths.d.ts +3 -0
  58. package/dist/src/project/paths.js +7 -0
  59. package/dist/src/project/paths.js.map +1 -1
  60. package/dist/src/rules/user-rules.d.ts +8 -0
  61. package/dist/src/rules/user-rules.js +36 -0
  62. package/dist/src/rules/user-rules.js.map +1 -0
  63. package/dist/src/skills/contracts.d.ts +4 -4
  64. package/dist/src/skills/recommended.js +1 -1
  65. package/dist/src/skills/registry.js +49 -28
  66. package/dist/src/skills/registry.js.map +1 -1
  67. package/dist/src/style/cli-ui.js +0 -1
  68. package/dist/src/style/cli-ui.js.map +1 -1
  69. package/package.json +14 -3
  70. package/scripts/rebrand-pi.mjs +6 -0
  71. package/skills/recommended/catalog.json +2 -11
  72. package/vendor/ars/.claude/CLAUDE.md +371 -0
  73. package/vendor/ars/.command-invariants.toml +24 -0
  74. package/vendor/ars/CITATION.cff +35 -0
  75. package/vendor/ars/LICENSE +417 -0
  76. package/vendor/ars/MODE_REGISTRY.md +76 -0
  77. package/vendor/ars/NOTICE.md +26 -0
  78. package/vendor/ars/POSITIONING.md +99 -0
  79. package/vendor/ars/PSYCLAW_SOURCE.json +10 -0
  80. package/vendor/ars/README.md +751 -0
  81. package/vendor/ars/SECURITY.md +52 -0
  82. package/vendor/ars/THIRD_PARTY.md +70 -0
  83. package/vendor/ars/academic-paper/SKILL.md +542 -0
  84. package/vendor/ars/academic-paper/agents/abstract_bilingual_agent.md +171 -0
  85. package/vendor/ars/academic-paper/agents/argument_builder_agent.md +276 -0
  86. package/vendor/ars/academic-paper/agents/citation_compliance_agent.md +422 -0
  87. package/vendor/ars/academic-paper/agents/draft_writer_agent.md +656 -0
  88. package/vendor/ars/academic-paper/agents/formatter_agent.md +999 -0
  89. package/vendor/ars/academic-paper/agents/intake_agent.md +393 -0
  90. package/vendor/ars/academic-paper/agents/literature_strategist_agent.md +626 -0
  91. package/vendor/ars/academic-paper/agents/peer_reviewer_agent.md +516 -0
  92. package/vendor/ars/academic-paper/agents/revision_coach_agent.md +334 -0
  93. package/vendor/ars/academic-paper/agents/socratic_mentor_agent.md +527 -0
  94. package/vendor/ars/academic-paper/agents/structure_architect_agent.md +401 -0
  95. package/vendor/ars/academic-paper/agents/visualization_agent.md +441 -0
  96. package/vendor/ars/academic-paper/examples/chinese_paper_example.md +278 -0
  97. package/vendor/ars/academic-paper/examples/clinical_citation_verification_checklist.md +95 -0
  98. package/vendor/ars/academic-paper/examples/clinical_epistemic_status_example.md +100 -0
  99. package/vendor/ars/academic-paper/examples/commitment_ledger_example.md +147 -0
  100. package/vendor/ars/academic-paper/examples/imrad_hei_example.md +234 -0
  101. package/vendor/ars/academic-paper/examples/literature_review_example.md +260 -0
  102. package/vendor/ars/academic-paper/examples/plan_mode_guided_writing.md +600 -0
  103. package/vendor/ars/academic-paper/examples/revision_mode_example.md +344 -0
  104. package/vendor/ars/academic-paper/examples/revision_recovery_example.md +506 -0
  105. package/vendor/ars/academic-paper/examples/version_family_reconciliation_example.md +89 -0
  106. package/vendor/ars/academic-paper/references/abstract_writing_guide.md +169 -0
  107. package/vendor/ars/academic-paper/references/academic_writing_style.md +188 -0
  108. package/vendor/ars/academic-paper/references/anti_leakage_protocol.md +83 -0
  109. package/vendor/ars/academic-paper/references/apa7_chinese_citation_guide.md +364 -0
  110. package/vendor/ars/academic-paper/references/apa7_extended_guide.md +198 -0
  111. package/vendor/ars/academic-paper/references/changelog.md +11 -0
  112. package/vendor/ars/academic-paper/references/citation_format_switcher.md +228 -0
  113. package/vendor/ars/academic-paper/references/committee_correspondence_protocol.md +158 -0
  114. package/vendor/ars/academic-paper/references/credit_authorship_guide.md +308 -0
  115. package/vendor/ars/academic-paper/references/disclosure_mode_protocol.md +478 -0
  116. package/vendor/ars/academic-paper/references/domain_evidence_profiles.md +38 -0
  117. package/vendor/ars/academic-paper/references/failure_paths.md +349 -0
  118. package/vendor/ars/academic-paper/references/funding_statement_guide.md +319 -0
  119. package/vendor/ars/academic-paper/references/hei_domain_glossary.md +169 -0
  120. package/vendor/ars/academic-paper/references/intro_title_rhetoric_guide.md +114 -0
  121. package/vendor/ars/academic-paper/references/journal_submission_guide.md +249 -0
  122. package/vendor/ars/academic-paper/references/latex_template_reference.md +378 -0
  123. package/vendor/ars/academic-paper/references/mode_selection_guide.md +378 -0
  124. package/vendor/ars/academic-paper/references/paper_structure_patterns.md +330 -0
  125. package/vendor/ars/academic-paper/references/plan_mode_protocol.md +112 -0
  126. package/vendor/ars/academic-paper/references/policy_anchor_disclosure_protocol.md +200 -0
  127. package/vendor/ars/academic-paper/references/policy_anchor_table.md +157 -0
  128. package/vendor/ars/academic-paper/references/revision_patch_protocol.md +173 -0
  129. package/vendor/ars/academic-paper/references/statistical_visualization_standards.md +750 -0
  130. package/vendor/ars/academic-paper/references/venue_disclosure_policies.md +259 -0
  131. package/vendor/ars/academic-paper/references/vlm_figure_verification.md +126 -0
  132. package/vendor/ars/academic-paper/references/workflow_phase_details.md +135 -0
  133. package/vendor/ars/academic-paper/references/writing_judgment_framework.md +59 -0
  134. package/vendor/ars/academic-paper/references/writing_quality_check.md +173 -0
  135. package/vendor/ars/academic-paper/templates/bilingual_abstract_template.md +78 -0
  136. package/vendor/ars/academic-paper/templates/case_study_template.md +129 -0
  137. package/vendor/ars/academic-paper/templates/conference_paper_template.md +108 -0
  138. package/vendor/ars/academic-paper/templates/credit_statement_template.md +132 -0
  139. package/vendor/ars/academic-paper/templates/funding_statement_template.md +290 -0
  140. package/vendor/ars/academic-paper/templates/imrad_template.md +183 -0
  141. package/vendor/ars/academic-paper/templates/latex_article_template.tex +199 -0
  142. package/vendor/ars/academic-paper/templates/literature_review_template.md +135 -0
  143. package/vendor/ars/academic-paper/templates/policy_brief_template.md +139 -0
  144. package/vendor/ars/academic-paper/templates/revision_tracking_template.md +199 -0
  145. package/vendor/ars/academic-paper/templates/theoretical_paper_template.md +119 -0
  146. package/vendor/ars/academic-paper-reviewer/SKILL.md +491 -0
  147. package/vendor/ars/academic-paper-reviewer/agents/devils_advocate_reviewer_agent.md +443 -0
  148. package/vendor/ars/academic-paper-reviewer/agents/domain_reviewer_agent.md +412 -0
  149. package/vendor/ars/academic-paper-reviewer/agents/editorial_synthesizer_agent.md +478 -0
  150. package/vendor/ars/academic-paper-reviewer/agents/eic_agent.md +339 -0
  151. package/vendor/ars/academic-paper-reviewer/agents/field_analyst_agent.md +221 -0
  152. package/vendor/ars/academic-paper-reviewer/agents/methodology_reviewer_agent.md +449 -0
  153. package/vendor/ars/academic-paper-reviewer/agents/perspective_reviewer_agent.md +427 -0
  154. package/vendor/ars/academic-paper-reviewer/examples/hei_paper_review_example.md +391 -0
  155. package/vendor/ars/academic-paper-reviewer/examples/interdisciplinary_review_example.md +299 -0
  156. package/vendor/ars/academic-paper-reviewer/examples/subclaim_decomposition_example.md +80 -0
  157. package/vendor/ars/academic-paper-reviewer/references/calibration_mode_protocol.md +256 -0
  158. package/vendor/ars/academic-paper-reviewer/references/changelog.md +10 -0
  159. package/vendor/ars/academic-paper-reviewer/references/editorial_decision_standards.md +236 -0
  160. package/vendor/ars/academic-paper-reviewer/references/guided_mode_protocol.md +34 -0
  161. package/vendor/ars/academic-paper-reviewer/references/integration_guide.md +15 -0
  162. package/vendor/ars/academic-paper-reviewer/references/quality_rubrics.md +84 -0
  163. package/vendor/ars/academic-paper-reviewer/references/re_review_mode_protocol.md +340 -0
  164. package/vendor/ars/academic-paper-reviewer/references/review_criteria_framework.md +98 -0
  165. package/vendor/ars/academic-paper-reviewer/references/review_panel_provenance_protocol.md +197 -0
  166. package/vendor/ars/academic-paper-reviewer/references/review_quality_thinking.md +58 -0
  167. package/vendor/ars/academic-paper-reviewer/references/reviewer_sprint_prompt_source.md +324 -0
  168. package/vendor/ars/academic-paper-reviewer/references/sprint_contract_protocol.md +296 -0
  169. package/vendor/ars/academic-paper-reviewer/references/statistical_reporting_standards.md +505 -0
  170. package/vendor/ars/academic-paper-reviewer/references/top_journals_by_field.md +206 -0
  171. package/vendor/ars/academic-paper-reviewer/templates/editorial_decision_template.md +235 -0
  172. package/vendor/ars/academic-paper-reviewer/templates/peer_review_report_template.md +305 -0
  173. package/vendor/ars/academic-paper-reviewer/templates/revision_response_template.md +248 -0
  174. package/vendor/ars/academic-pipeline/SKILL.md +736 -0
  175. package/vendor/ars/academic-pipeline/agents/claim_ref_alignment_audit_agent.md +382 -0
  176. package/vendor/ars/academic-pipeline/agents/collaboration_depth_agent.md +164 -0
  177. package/vendor/ars/academic-pipeline/agents/integrity_verification_agent.md +870 -0
  178. package/vendor/ars/academic-pipeline/agents/pipeline_orchestrator_agent.md +1379 -0
  179. package/vendor/ars/academic-pipeline/agents/state_tracker_agent.md +622 -0
  180. package/vendor/ars/academic-pipeline/examples/full_pipeline_example.md +482 -0
  181. package/vendor/ars/academic-pipeline/examples/integrity_failure_recovery.md +389 -0
  182. package/vendor/ars/academic-pipeline/examples/mid_entry_example.md +414 -0
  183. package/vendor/ars/academic-pipeline/references/adapters/.gitkeep +0 -0
  184. package/vendor/ars/academic-pipeline/references/adapters/overview.md +153 -0
  185. package/vendor/ars/academic-pipeline/references/ai_research_failure_modes.md +185 -0
  186. package/vendor/ars/academic-pipeline/references/changelog.md +14 -0
  187. package/vendor/ars/academic-pipeline/references/claim_audit_calibration_protocol.md +175 -0
  188. package/vendor/ars/academic-pipeline/references/claim_verification_protocol.md +282 -0
  189. package/vendor/ars/academic-pipeline/references/external_review_protocol.md +131 -0
  190. package/vendor/ars/academic-pipeline/references/integrity_review_protocol.md +110 -0
  191. package/vendor/ars/academic-pipeline/references/literature_corpus_consumers.md +193 -0
  192. package/vendor/ars/academic-pipeline/references/mode_advisor.md +135 -0
  193. package/vendor/ars/academic-pipeline/references/passport_as_reset_boundary.md +132 -0
  194. package/vendor/ars/academic-pipeline/references/pipeline_state_machine.md +405 -0
  195. package/vendor/ars/academic-pipeline/references/plagiarism_detection_protocol.md +239 -0
  196. package/vendor/ars/academic-pipeline/references/process_summary_protocol.md +209 -0
  197. package/vendor/ars/academic-pipeline/references/progress_dashboard_template.md +38 -0
  198. package/vendor/ars/academic-pipeline/references/reinforcement_content.md +15 -0
  199. package/vendor/ars/academic-pipeline/references/reproducibility_audit.md +55 -0
  200. package/vendor/ars/academic-pipeline/references/score_trajectory_protocol.md +78 -0
  201. package/vendor/ars/academic-pipeline/references/team_collaboration_protocol.md +261 -0
  202. package/vendor/ars/academic-pipeline/references/two_stage_review_protocol.md +27 -0
  203. package/vendor/ars/academic-pipeline/templates/pipeline_status_template.md +146 -0
  204. package/vendor/ars/agents/report_compiler_agent.md +341 -0
  205. package/vendor/ars/agents/research_architect_agent.md +298 -0
  206. package/vendor/ars/agents/synthesis_agent.md +356 -0
  207. package/vendor/ars/commands/ars-3w.md +10 -0
  208. package/vendor/ars/commands/ars-abstract.md +10 -0
  209. package/vendor/ars/commands/ars-cache-invalidate.md +20 -0
  210. package/vendor/ars/commands/ars-citation-check.md +10 -0
  211. package/vendor/ars/commands/ars-disclosure.md +10 -0
  212. package/vendor/ars/commands/ars-format-convert.md +10 -0
  213. package/vendor/ars/commands/ars-full.md +9 -0
  214. package/vendor/ars/commands/ars-lit-review.md +12 -0
  215. package/vendor/ars/commands/ars-mark-read.md +18 -0
  216. package/vendor/ars/commands/ars-outline.md +10 -0
  217. package/vendor/ars/commands/ars-plan.md +10 -0
  218. package/vendor/ars/commands/ars-rebuttal-audit.md +12 -0
  219. package/vendor/ars/commands/ars-reviewer.md +9 -0
  220. package/vendor/ars/commands/ars-revision-coach.md +9 -0
  221. package/vendor/ars/commands/ars-revision.md +10 -0
  222. package/vendor/ars/commands/ars-unmark-read.md +16 -0
  223. package/vendor/ars/deep-research/SKILL.md +600 -0
  224. package/vendor/ars/deep-research/agents/bibliography_agent.md +473 -0
  225. package/vendor/ars/deep-research/agents/devils_advocate_agent.md +192 -0
  226. package/vendor/ars/deep-research/agents/editor_in_chief_agent.md +167 -0
  227. package/vendor/ars/deep-research/agents/ethics_review_agent.md +267 -0
  228. package/vendor/ars/deep-research/agents/meta_analysis_agent.md +325 -0
  229. package/vendor/ars/deep-research/agents/monitoring_agent.md +209 -0
  230. package/vendor/ars/deep-research/agents/report_compiler_agent.md +341 -0
  231. package/vendor/ars/deep-research/agents/research_architect_agent.md +298 -0
  232. package/vendor/ars/deep-research/agents/research_question_agent.md +216 -0
  233. package/vendor/ars/deep-research/agents/risk_of_bias_agent.md +231 -0
  234. package/vendor/ars/deep-research/agents/socratic_mentor_agent.md +764 -0
  235. package/vendor/ars/deep-research/agents/source_verification_agent.md +219 -0
  236. package/vendor/ars/deep-research/agents/synthesis_agent.md +356 -0
  237. package/vendor/ars/deep-research/agents/timeline_extraction_agent.md +99 -0
  238. package/vendor/ars/deep-research/examples/exploratory_research.md +157 -0
  239. package/vendor/ars/deep-research/examples/fact_check_mode.md +173 -0
  240. package/vendor/ars/deep-research/examples/handoff_to_paper.md +318 -0
  241. package/vendor/ars/deep-research/examples/idea_diversity_coverage_gap_advisory.md +64 -0
  242. package/vendor/ars/deep-research/examples/policy_analysis.md +161 -0
  243. package/vendor/ars/deep-research/examples/review_mode.md +253 -0
  244. package/vendor/ars/deep-research/examples/socratic_guided_research.md +331 -0
  245. package/vendor/ars/deep-research/examples/systematic_review.md +133 -0
  246. package/vendor/ars/deep-research/references/apa7_style_guide.md +162 -0
  247. package/vendor/ars/deep-research/references/argumentation_reasoning_framework.md +68 -0
  248. package/vendor/ars/deep-research/references/arxiv_api_protocol.md +76 -0
  249. package/vendor/ars/deep-research/references/changelog.md +22 -0
  250. package/vendor/ars/deep-research/references/chinese_literature_api_protocol.md +317 -0
  251. package/vendor/ars/deep-research/references/cross_agent_quality_definitions.md +14 -0
  252. package/vendor/ars/deep-research/references/crossref_api_protocol.md +84 -0
  253. package/vendor/ars/deep-research/references/equator_reporting_guidelines.md +482 -0
  254. package/vendor/ars/deep-research/references/ethics_checklist.md +282 -0
  255. package/vendor/ars/deep-research/references/failure_paths.md +355 -0
  256. package/vendor/ars/deep-research/references/interdisciplinary_bridges.md +292 -0
  257. package/vendor/ars/deep-research/references/irb_decision_tree.md +315 -0
  258. package/vendor/ars/deep-research/references/literature_monitoring_strategies.md +263 -0
  259. package/vendor/ars/deep-research/references/logical_fallacies.md +192 -0
  260. package/vendor/ars/deep-research/references/methodology_patterns.md +462 -0
  261. package/vendor/ars/deep-research/references/mode_selection_guide.md +331 -0
  262. package/vendor/ars/deep-research/references/openalex_api_protocol.md +82 -0
  263. package/vendor/ars/deep-research/references/preregistration_guide.md +324 -0
  264. package/vendor/ars/deep-research/references/semantic_scholar_api_protocol.md +107 -0
  265. package/vendor/ars/deep-research/references/socratic_mode_protocol.md +99 -0
  266. package/vendor/ars/deep-research/references/socratic_questioning_framework.md +232 -0
  267. package/vendor/ars/deep-research/references/source_quality_hierarchy.md +188 -0
  268. package/vendor/ars/deep-research/references/systematic_review_protocol.md +95 -0
  269. package/vendor/ars/deep-research/references/systematic_review_toolkit.md +353 -0
  270. package/vendor/ars/deep-research/templates/evidence_assessment_template.md +127 -0
  271. package/vendor/ars/deep-research/templates/literature_matrix_template.md +85 -0
  272. package/vendor/ars/deep-research/templates/preregistration_template.md +318 -0
  273. package/vendor/ars/deep-research/templates/prisma_protocol_template.md +248 -0
  274. package/vendor/ars/deep-research/templates/prisma_report_template.md +415 -0
  275. package/vendor/ars/deep-research/templates/research_brief_template.md +93 -0
  276. package/vendor/ars/package.json +24 -0
  277. package/vendor/ars/pi/README.md +161 -0
  278. package/vendor/ars/pi/package.json +26 -0
  279. package/vendor/ars/pi/wrapper.js +193 -0
  280. package/vendor/ars/pi/wrapper.test.mjs +201 -0
  281. package/vendor/ars/pyproject.toml +2 -0
  282. package/vendor/ars/requirements-pdf-content-classifier.txt +5 -0
  283. package/vendor/ars/scripts/_block_parser.py +396 -0
  284. package/vendor/ars/scripts/_ci_pytest_manifest.toml +661 -0
  285. package/vendor/ars/scripts/_claim_audit_constants.py +268 -0
  286. package/vendor/ars/scripts/_e4_evidence.py +110 -0
  287. package/vendor/ars/scripts/_eval_threshold_gate.py +73 -0
  288. package/vendor/ars/scripts/_markdown_lint_util.py +224 -0
  289. package/vendor/ars/scripts/_next_verified_at_ms.py +176 -0
  290. package/vendor/ars/scripts/_passport_yaml.py +53 -0
  291. package/vendor/ars/scripts/_skill_lint.py +254 -0
  292. package/vendor/ars/scripts/_text_similarity.py +141 -0
  293. package/vendor/ars/scripts/adapters/README.md +89 -0
  294. package/vendor/ars/scripts/adapters/_common.py +209 -0
  295. package/vendor/ars/scripts/adapters/examples/folder_scan/expected_passport.yaml +25 -0
  296. package/vendor/ars/scripts/adapters/examples/folder_scan/expected_rejection_log.yaml +18 -0
  297. package/vendor/ars/scripts/adapters/examples/folder_scan/input_fixture/Chen2024_AIAssessment.pdf +0 -0
  298. package/vendor/ars/scripts/adapters/examples/folder_scan/input_fixture/Wang_2023_formative_feedback.pdf +0 -0
  299. package/vendor/ars/scripts/adapters/examples/folder_scan/input_fixture/paper1.pdf +0 -0
  300. package/vendor/ars/scripts/adapters/examples/folder_scan/input_fixture//344/270/255/346/226/207/346/252/224/345/220/215_2024.pdf +0 -0
  301. package/vendor/ars/scripts/adapters/examples/obsidian/expected_passport.yaml +40 -0
  302. package/vendor/ars/scripts/adapters/examples/obsidian/expected_rejection_log.yaml +13 -0
  303. package/vendor/ars/scripts/adapters/examples/obsidian/input_fixture/vault/.gitkeep +0 -0
  304. package/vendor/ars/scripts/adapters/examples/obsidian/input_fixture/vault/.obsidian/app.json +1 -0
  305. package/vendor/ars/scripts/adapters/examples/obsidian/input_fixture/vault/_templates/tmpl.md +7 -0
  306. package/vendor/ars/scripts/adapters/examples/obsidian/input_fixture/vault/chen2024ai.md +13 -0
  307. package/vendor/ars/scripts/adapters/examples/obsidian/input_fixture/vault/invalid.md +1 -0
  308. package/vendor/ars/scripts/adapters/examples/obsidian/input_fixture/vault/wang2023formative.md +10 -0
  309. package/vendor/ars/scripts/adapters/examples/zotero/expected_passport.yaml +34 -0
  310. package/vendor/ars/scripts/adapters/examples/zotero/expected_rejection_log.yaml +34 -0
  311. package/vendor/ars/scripts/adapters/examples/zotero/input_fixture/.gitkeep +0 -0
  312. package/vendor/ars/scripts/adapters/examples/zotero/input_fixture/export.json +43 -0
  313. package/vendor/ars/scripts/adapters/folder_scan.py +214 -0
  314. package/vendor/ars/scripts/adapters/obsidian.py +336 -0
  315. package/vendor/ars/scripts/adapters/tests/.gitkeep +0 -0
  316. package/vendor/ars/scripts/adapters/tests/conftest.py +77 -0
  317. package/vendor/ars/scripts/adapters/tests/test_check_corpus_consumer_protocol.py +632 -0
  318. package/vendor/ars/scripts/adapters/tests/test_check_literature_corpus_schema.py +631 -0
  319. package/vendor/ars/scripts/adapters/tests/test_common.py +365 -0
  320. package/vendor/ars/scripts/adapters/tests/test_conftest.py +96 -0
  321. package/vendor/ars/scripts/adapters/tests/test_folder_scan.py +260 -0
  322. package/vendor/ars/scripts/adapters/tests/test_literature_corpus_entry_schema.py +745 -0
  323. package/vendor/ars/scripts/adapters/tests/test_obsidian.py +357 -0
  324. package/vendor/ars/scripts/adapters/tests/test_rejection_log_schema.py +271 -0
  325. package/vendor/ars/scripts/adapters/tests/test_sync_adapter_docs.py +88 -0
  326. package/vendor/ars/scripts/adapters/tests/test_zotero.py +454 -0
  327. package/vendor/ars/scripts/adapters/zotero.py +318 -0
  328. package/vendor/ars/scripts/adjudication_activity.py +1592 -0
  329. package/vendor/ars/scripts/announce-ars-loaded.sh +144 -0
  330. package/vendor/ars/scripts/ars_anchorize_draft.py +170 -0
  331. package/vendor/ars/scripts/ars_apply_revision_patch.py +912 -0
  332. package/vendor/ars/scripts/ars_cache_invalidate.py +40 -0
  333. package/vendor/ars/scripts/ars_mark_read.py +521 -0
  334. package/vendor/ars/scripts/ars_phase_scope_manifest.json +33 -0
  335. package/vendor/ars/scripts/ars_update_check.sh +215 -0
  336. package/vendor/ars/scripts/ars_write_scope_guard.py +506 -0
  337. package/vendor/ars/scripts/arxiv_client.py +222 -0
  338. package/vendor/ars/scripts/audit_snapshot.py +572 -0
  339. package/vendor/ars/scripts/bibliographic_integrity_signals.py +800 -0
  340. package/vendor/ars/scripts/bootstrap_timeline_yaml.py +146 -0
  341. package/vendor/ars/scripts/build_claim_standing_candidate_ledger.py +1238 -0
  342. package/vendor/ars/scripts/build_claim_standing_query_plan.py +643 -0
  343. package/vendor/ars/scripts/build_content_coverage_advisory.py +1205 -0
  344. package/vendor/ars/scripts/build_cross_document_consistency_advisory.py +2332 -0
  345. package/vendor/ars/scripts/build_review_pathway_rule_trace.py +830 -0
  346. package/vendor/ars/scripts/build_submission_packet_manifest.py +2310 -0
  347. package/vendor/ars/scripts/check_215_field_norm.py +173 -0
  348. package/vendor/ars/scripts/check_216_surface_form.py +250 -0
  349. package/vendor/ars/scripts/check_268_nested_commitment_ledger.py +180 -0
  350. package/vendor/ars/scripts/check_390_revision_patch_discipline.py +296 -0
  351. package/vendor/ars/scripts/check_392_citation_verification_intake.py +126 -0
  352. package/vendor/ars/scripts/check_394_submission_policy.py +178 -0
  353. package/vendor/ars/scripts/check_439_format_profile.py +307 -0
  354. package/vendor/ars/scripts/check_619_disclosure_closeout.py +237 -0
  355. package/vendor/ars/scripts/check_630_codex_subscription_transport.py +456 -0
  356. package/vendor/ars/scripts/check_669_review_pathway_rule_trace.py +662 -0
  357. package/vendor/ars/scripts/check_670_revision_roadmap_integration.py +518 -0
  358. package/vendor/ars/scripts/check_673_adjudication_activity.py +684 -0
  359. package/vendor/ars/scripts/check_684_review_criteria_binding.py +557 -0
  360. package/vendor/ars/scripts/check_agents_mirror_sync.py +115 -0
  361. package/vendor/ars/scripts/check_audit_artifact_consistency.py +2313 -0
  362. package/vendor/ars/scripts/check_benchmark_report.py +79 -0
  363. package/vendor/ars/scripts/check_bibliographic_integrity_signals.py +831 -0
  364. package/vendor/ars/scripts/check_calibration_tiers.py +235 -0
  365. package/vendor/ars/scripts/check_changelog_covers_merges.py +289 -0
  366. package/vendor/ars/scripts/check_ci_pytest_manifest.py +204 -0
  367. package/vendor/ars/scripts/check_claim_audit_consistency.py +1664 -0
  368. package/vendor/ars/scripts/check_claim_standing_candidate_ledger_integration.py +500 -0
  369. package/vendor/ars/scripts/check_claim_standing_freshness.py +253 -0
  370. package/vendor/ars/scripts/check_claim_standing_transmissions.py +449 -0
  371. package/vendor/ars/scripts/check_collaboration_depth_rubric.py +180 -0
  372. package/vendor/ars/scripts/check_command_frontmatter_name.py +116 -0
  373. package/vendor/ars/scripts/check_committee_correspondence.py +333 -0
  374. package/vendor/ars/scripts/check_compliance_report.py +108 -0
  375. package/vendor/ars/scripts/check_content_coverage_advisory_integration.py +796 -0
  376. package/vendor/ars/scripts/check_control_availability.py +172 -0
  377. package/vendor/ars/scripts/check_corpus_consumer_protocol.py +404 -0
  378. package/vendor/ars/scripts/check_cross_document_consistency_advisory_integration.py +1191 -0
  379. package/vendor/ars/scripts/check_cross_model_handoff_contract.py +234 -0
  380. package/vendor/ars/scripts/check_cross_model_verification_sync.py +261 -0
  381. package/vendor/ars/scripts/check_data_access_level.py +131 -0
  382. package/vendor/ars/scripts/check_data_flows.py +252 -0
  383. package/vendor/ars/scripts/check_decision_contract.py +464 -0
  384. package/vendor/ars/scripts/check_degradation_registry.py +326 -0
  385. package/vendor/ars/scripts/check_distribution_surface_claims.py +226 -0
  386. package/vendor/ars/scripts/check_domain_evidence_profile.py +538 -0
  387. package/vendor/ars/scripts/check_e4_promotion.py +195 -0
  388. package/vendor/ars/scripts/check_evals_gold_set.py +279 -0
  389. package/vendor/ars/scripts/check_evidence_row_integration.py +396 -0
  390. package/vendor/ars/scripts/check_experiment_provenance.py +117 -0
  391. package/vendor/ars/scripts/check_field_norm_severity.py +144 -0
  392. package/vendor/ars/scripts/check_firm_rules_sync.py +375 -0
  393. package/vendor/ars/scripts/check_heldout_measurement_report.py +1179 -0
  394. package/vendor/ars/scripts/check_human_subjects_output_contract.py +139 -0
  395. package/vendor/ars/scripts/check_human_subjects_reference_migration.py +844 -0
  396. package/vendor/ars/scripts/check_indirect_prompt_injection_no_call.py +328 -0
  397. package/vendor/ars/scripts/check_instruction_data_boundary.py +236 -0
  398. package/vendor/ars/scripts/check_judge_prompt_version.py +125 -0
  399. package/vendor/ars/scripts/check_literature_corpus_schema.py +402 -0
  400. package/vendor/ars/scripts/check_model_tiering.py +223 -0
  401. package/vendor/ars/scripts/check_panel_synthesis.py +1331 -0
  402. package/vendor/ars/scripts/check_passport_reset_contract.py +214 -0
  403. package/vendor/ars/scripts/check_pattern_eval_manifest.py +422 -0
  404. package/vendor/ars/scripts/check_persuasion_invariance_fixtures.py +637 -0
  405. package/vendor/ars/scripts/check_phase_conformance.py +2180 -0
  406. package/vendor/ars/scripts/check_pipeline_boundary_semantics.py +600 -0
  407. package/vendor/ars/scripts/check_pipeline_integrity.py +340 -0
  408. package/vendor/ars/scripts/check_policy_anchor_protocol.py +159 -0
  409. package/vendor/ars/scripts/check_policy_anchor_table.py +286 -0
  410. package/vendor/ars/scripts/check_preprint_venues_consistency.py +123 -0
  411. package/vendor/ars/scripts/check_prisma_trAIce_freshness.py +84 -0
  412. package/vendor/ars/scripts/check_promotion_bakeoff_preregistration.py +1303 -0
  413. package/vendor/ars/scripts/check_ranking_lift.py +323 -0
  414. package/vendor/ars/scripts/check_re_review_synthesis.py +2719 -0
  415. package/vendor/ars/scripts/check_receipt_enum_sync.py +203 -0
  416. package/vendor/ars/scripts/check_repro_lock.py +85 -0
  417. package/vendor/ars/scripts/check_review_pathway_output.py +276 -0
  418. package/vendor/ars/scripts/check_reviewer_data_fences.py +224 -0
  419. package/vendor/ars/scripts/check_reviewer_finding_contract.py +783 -0
  420. package/vendor/ars/scripts/check_reviewer_role_label.py +447 -0
  421. package/vendor/ars/scripts/check_reviewer_scoring_honesty.py +292 -0
  422. package/vendor/ars/scripts/check_reviewer_sprint_prompt_sync.py +409 -0
  423. package/vendor/ars/scripts/check_revision_claim_drift_suite_v2.py +1622 -0
  424. package/vendor/ars/scripts/check_revision_token_conservation.py +263 -0
  425. package/vendor/ars/scripts/check_risk_register.py +280 -0
  426. package/vendor/ars/scripts/check_role_scoped_contract.py +702 -0
  427. package/vendor/ars/scripts/check_rq_framing_patterns.py +184 -0
  428. package/vendor/ars/scripts/check_rubric_weight_consistency.py +32 -0
  429. package/vendor/ars/scripts/check_seeded_defect_fixtures.py +425 -0
  430. package/vendor/ars/scripts/check_setup_cross_model_parity.py +139 -0
  431. package/vendor/ars/scripts/check_spec_consistency.py +1249 -0
  432. package/vendor/ars/scripts/check_sprint_contract.py +371 -0
  433. package/vendor/ars/scripts/check_stage_capability_matrix.py +784 -0
  434. package/vendor/ars/scripts/check_submission_packet_manifest_integration.py +358 -0
  435. package/vendor/ars/scripts/check_surface_form_parity.py +445 -0
  436. package/vendor/ars/scripts/check_task_type.py +22 -0
  437. package/vendor/ars/scripts/check_tools_allowlist.py +538 -0
  438. package/vendor/ars/scripts/check_tortured_phrase_screening_integration.py +1974 -0
  439. package/vendor/ars/scripts/check_v3_10_134_write_scope.py +286 -0
  440. package/vendor/ars/scripts/check_v3_10_policy.py +656 -0
  441. package/vendor/ars/scripts/check_v3_6_6_ab_manifest.py +364 -0
  442. package/vendor/ars/scripts/check_v3_6_7_pattern_protection.py +1366 -0
  443. package/vendor/ars/scripts/check_v3_6_8_audit_scope_block.py +464 -0
  444. package/vendor/ars/scripts/check_v3_6_8_cite_provenance_pipeline.py +231 -0
  445. package/vendor/ars/scripts/check_v3_6_8_frontmatter_trust_schema.py +248 -0
  446. package/vendor/ars/scripts/check_v3_6_8_mark_read_commands.py +79 -0
  447. package/vendor/ars/scripts/check_v3_6_8_pattern_protection.py +941 -0
  448. package/vendor/ars/scripts/check_v3_7_3_three_layer_citation.py +318 -0
  449. package/vendor/ars/scripts/check_v3_8_annotation_literal_sync.py +228 -0
  450. package/vendor/ars/scripts/check_v3_9_0_triangulation.py +366 -0
  451. package/vendor/ars/scripts/check_v3_9_2_phase_boundary.py +270 -0
  452. package/vendor/ars/scripts/check_v3_9_4_temporal_verification.py +139 -0
  453. package/vendor/ars/scripts/check_venue_disclosure_policies.py +63 -0
  454. package/vendor/ars/scripts/check_version_consistency.py +826 -0
  455. package/vendor/ars/scripts/check_workflow_classification.py +223 -0
  456. package/vendor/ars/scripts/chinese_literature_client.py +1938 -0
  457. package/vendor/ars/scripts/citation_verification_summary.py +85 -0
  458. package/vendor/ars/scripts/claim_audit_calibration.py +517 -0
  459. package/vendor/ars/scripts/claim_audit_finalizer.py +456 -0
  460. package/vendor/ars/scripts/claim_audit_pipeline.py +1594 -0
  461. package/vendor/ars/scripts/claim_registry_coverage.py +493 -0
  462. package/vendor/ars/scripts/claim_standing_discovery.py +784 -0
  463. package/vendor/ars/scripts/claim_standing_stance_runner.py +758 -0
  464. package/vendor/ars/scripts/claim_standing_stance_scorer.py +239 -0
  465. package/vendor/ars/scripts/claim_strength_drift_disposition.py +666 -0
  466. package/vendor/ars/scripts/contamination_signals.py +689 -0
  467. package/vendor/ars/scripts/corpus_consumer_manifest.json +19 -0
  468. package/vendor/ars/scripts/cross_model_codex_transport.py +1374 -0
  469. package/vendor/ars/scripts/cross_model_codex_verify.sh +6 -0
  470. package/vendor/ars/scripts/cross_model_handoff.py +359 -0
  471. package/vendor/ars/scripts/cross_model_smoke_test.sh +183 -0
  472. package/vendor/ars/scripts/cross_model_smoke_test_codex.sh +35 -0
  473. package/vendor/ars/scripts/cross_model_verification/gemini_is_grounded.jq +45 -0
  474. package/vendor/ars/scripts/cross_model_verification/gemini_sources.jq +45 -0
  475. package/vendor/ars/scripts/cross_model_verification/normalize_compat_verdict.py +57 -0
  476. package/vendor/ars/scripts/cross_model_verification/openai_has_completed_web_search.jq +15 -0
  477. package/vendor/ars/scripts/cross_model_verification/openai_sources.jq +17 -0
  478. package/vendor/ars/scripts/cross_model_verification/openai_text.jq +11 -0
  479. package/vendor/ars/scripts/crossref_client.py +225 -0
  480. package/vendor/ars/scripts/dispatch_e4_panel.py +2731 -0
  481. package/vendor/ars/scripts/evidence_rows.py +2043 -0
  482. package/vendor/ars/scripts/fixtures/adjudication_activity/author_stage3.json +32 -0
  483. package/vendor/ars/scripts/fixtures/adjudication_activity/author_stage3_input.json +27 -0
  484. package/vendor/ars/scripts/fixtures/adjudication_activity/author_stage3_prime.json +32 -0
  485. package/vendor/ars/scripts/fixtures/adjudication_activity/author_stage3_prime_input.json +27 -0
  486. package/vendor/ars/scripts/fixtures/adjudication_activity/compliance_override.json +50 -0
  487. package/vendor/ars/scripts/fixtures/adjudication_activity/compliance_override_action.json +14 -0
  488. package/vendor/ars/scripts/fixtures/adjudication_activity/compliance_pass.json +44 -0
  489. package/vendor/ars/scripts/fixtures/adjudication_activity/explicit_user_request_log.json +26 -0
  490. package/vendor/ars/scripts/fixtures/adjudication_activity/mandatory_checkpoint_log.json +116 -0
  491. package/vendor/ars/scripts/fixtures/audit_artifact_consistency/README.md +56 -0
  492. package/vendor/ars/scripts/fixtures/audit_artifact_consistency/negative/a1_pass_with_p1/2026-04-30T15-22-04Z-d8f3.audit_artifact_entry.json +24 -0
  493. package/vendor/ars/scripts/fixtures/audit_artifact_consistency/negative/a1_pass_with_p1/2026-04-30T15-22-04Z-d8f3.jsonl +4 -0
  494. package/vendor/ars/scripts/fixtures/audit_artifact_consistency/negative/a1_pass_with_p1/2026-04-30T15-22-04Z-d8f3.meta.json +43 -0
  495. package/vendor/ars/scripts/fixtures/audit_artifact_consistency/negative/a1_pass_with_p1/2026-04-30T15-22-04Z-d8f3.verdict.yaml +19 -0
  496. package/vendor/ars/scripts/fixtures/audit_artifact_consistency/negative/a7_orphan_completion/2026-04-30T15-22-04Z-d8f3.jsonl +3 -0
  497. package/vendor/ars/scripts/fixtures/audit_artifact_consistency/positive/persisted_minor/2026-04-30T15-22-04Z-d8f3.audit_artifact_entry.json +26 -0
  498. package/vendor/ars/scripts/fixtures/audit_artifact_consistency/positive/persisted_minor/2026-04-30T15-22-04Z-d8f3.jsonl +4 -0
  499. package/vendor/ars/scripts/fixtures/audit_artifact_consistency/positive/persisted_minor/2026-04-30T15-22-04Z-d8f3.meta.json +43 -0
  500. package/vendor/ars/scripts/fixtures/audit_artifact_consistency/positive/persisted_minor/2026-04-30T15-22-04Z-d8f3.verdict.yaml +19 -0
  501. package/vendor/ars/scripts/fixtures/audit_artifact_consistency/positive/proposal_pass/2026-04-30T15-22-04Z-d8f3.audit_artifact_entry.json +24 -0
  502. package/vendor/ars/scripts/fixtures/audit_artifact_consistency/positive/proposal_pass/2026-04-30T15-22-04Z-d8f3.jsonl +4 -0
  503. package/vendor/ars/scripts/fixtures/audit_artifact_consistency/positive/proposal_pass/2026-04-30T15-22-04Z-d8f3.meta.json +43 -0
  504. package/vendor/ars/scripts/fixtures/audit_artifact_consistency/positive/proposal_pass/2026-04-30T15-22-04Z-d8f3.verdict.yaml +12 -0
  505. package/vendor/ars/scripts/fixtures/bibliographic_integrity_signals/retraction.json +46 -0
  506. package/vendor/ars/scripts/fixtures/bibliographic_integrity_signals/retraction_check_attestation.json +44 -0
  507. package/vendor/ars/scripts/fixtures/bibliographic_integrity_signals/tortured_phrase.json +44 -0
  508. package/vendor/ars/scripts/fixtures/bibliographic_integrity_signals/tortured_phrase_v1_2_abstract_missing.json +107 -0
  509. package/vendor/ars/scripts/fixtures/bibliographic_integrity_signals/tortured_phrase_v1_2_detected.json +124 -0
  510. package/vendor/ars/scripts/fixtures/check_evals_gold_set/clean/expected_outcomes.json +77 -0
  511. package/vendor/ars/scripts/fixtures/check_evals_gold_set/clean/manifest.yaml +37 -0
  512. package/vendor/ars/scripts/fixtures/check_evals_gold_set/clean/tuples/001-valid-doi-test.json +20 -0
  513. package/vendor/ars/scripts/fixtures/check_evals_gold_set/clean/tuples/002-valid-arxiv-test.json +19 -0
  514. package/vendor/ars/scripts/fixtures/check_evals_gold_set/clean/tuples/003-fabricated-test.json +20 -0
  515. package/vendor/ars/scripts/fixtures/claim_audit_calibration/gold_set.json +344 -0
  516. package/vendor/ars/scripts/fixtures/claim_standing_candidate_ledger/query_plan.json +108 -0
  517. package/vendor/ars/scripts/fixtures/claim_standing_candidate_ledger/retrieval_input.json +179 -0
  518. package/vendor/ars/scripts/fixtures/committee_correspondence/16fd83f6aec7/concern_tracker.json +129 -0
  519. package/vendor/ars/scripts/fixtures/committee_correspondence/16fd83f6aec7/response_skeleton.md +19 -0
  520. package/vendor/ars/scripts/fixtures/committee_correspondence/16fd83f6aec7/source_letter.txt +9 -0
  521. package/vendor/ars/scripts/fixtures/content_coverage_advisory/base_draft.json +48 -0
  522. package/vendor/ars/scripts/fixtures/content_coverage_advisory/base_inventory.json +38 -0
  523. package/vendor/ars/scripts/fixtures/content_coverage_advisory/packet/consent.txt +1 -0
  524. package/vendor/ars/scripts/fixtures/content_coverage_advisory/session_sources.json +3 -0
  525. package/vendor/ars/scripts/fixtures/cross_document_consistency/README.md +6 -0
  526. package/vendor/ars/scripts/fixtures/cross_document_consistency/accepted_draft.md +35 -0
  527. package/vendor/ars/scripts/fixtures/cross_document_consistency/cases.json +75 -0
  528. package/vendor/ars/scripts/fixtures/cross_document_consistency/preregistration.md +5 -0
  529. package/vendor/ars/scripts/fixtures/cross_model_codex_transport/forbidden_event.jsonl +4 -0
  530. package/vendor/ars/scripts/fixtures/cross_model_codex_transport/grounded_verified.jsonl +3 -0
  531. package/vendor/ars/scripts/fixtures/cross_model_codex_transport/malformed.jsonl +3 -0
  532. package/vendor/ars/scripts/fixtures/cross_model_codex_transport/missing_search.jsonl +2 -0
  533. package/vendor/ars/scripts/fixtures/cross_model_codex_transport/multiple_finals.jsonl +4 -0
  534. package/vendor/ars/scripts/fixtures/cross_model_codex_transport/not_found.jsonl +3 -0
  535. package/vendor/ars/scripts/fixtures/cross_model_codex_transport/unbound_source.jsonl +3 -0
  536. package/vendor/ars/scripts/fixtures/cross_model_codex_transport/wrong_search_shape.jsonl +3 -0
  537. package/vendor/ars/scripts/fixtures/evidence_rows/phase_e_inputs.json +114 -0
  538. package/vendor/ars/scripts/fixtures/evidence_rows/session_sources.json +5 -0
  539. package/vendor/ars/scripts/fixtures/human_subjects_authority/cross-border-us-tw-gdpr.json +71 -0
  540. package/vendor/ars/scripts/fixtures/human_subjects_authority/gdpr-member-state-unresolved.json +62 -0
  541. package/vendor/ars/scripts/fixtures/human_subjects_authority/missing-data-axis.json +45 -0
  542. package/vendor/ars/scripts/fixtures/human_subjects_authority/no-profile.json +33 -0
  543. package/vendor/ars/scripts/fixtures/human_subjects_authority/tw-gdpr-two-axis.json +74 -0
  544. package/vendor/ars/scripts/fixtures/human_subjects_authority/us-gdpr-two-axis.json +74 -0
  545. package/vendor/ars/scripts/fixtures/review_pathway_rule_trace/lint-near-misses.json +72 -0
  546. package/vendor/ars/scripts/fixtures/review_pathway_rule_trace/no-profile-request.json +18 -0
  547. package/vendor/ars/scripts/fixtures/review_pathway_rule_trace/tw-candidates-request.json +63 -0
  548. package/vendor/ars/scripts/fixtures/review_pathway_rule_trace/us-candidates-request.json +77 -0
  549. package/vendor/ars/scripts/fixtures/review_target_context/exact-declaration.json +24 -0
  550. package/vendor/ars/scripts/fixtures/review_target_context/field-general-declaration.json +24 -0
  551. package/vendor/ars/scripts/fixtures/review_target_context/msr-2027-technical-full-declaration.json +24 -0
  552. package/vendor/ars/scripts/fixtures/review_target_context/synthetic-registry.json +92 -0
  553. package/vendor/ars/scripts/fixtures/revision_claim_drift_v2/README.md +21 -0
  554. package/vendor/ars/scripts/fixtures/revision_claim_drift_v2/subject_context_attested_only.json +55 -0
  555. package/vendor/ars/scripts/fixtures/revision_claim_drift_v2/subject_context_machine_supported.json +49 -0
  556. package/vendor/ars/scripts/fixtures/revision_claim_drift_v2/subject_context_not_isolated.json +56 -0
  557. package/vendor/ars/scripts/fixtures/revision_claim_drift_v2/subject_context_unknown.json +49 -0
  558. package/vendor/ars/scripts/fixtures/submission_package/clean/paper.md +16 -0
  559. package/vendor/ars/scripts/fixtures/submission_package/clean/references.bib +13 -0
  560. package/vendor/ars/scripts/fixtures/submission_package/fallback_authoryear/paper.md +11 -0
  561. package/vendor/ars/scripts/fixtures/submission_package/fallback_authoryear/references.bib +13 -0
  562. package/vendor/ars/scripts/fixtures/submission_package/fallback_latex/paper.tex +9 -0
  563. package/vendor/ars/scripts/fixtures/submission_package/fallback_latex/references.bib +13 -0
  564. package/vendor/ars/scripts/fixtures/submission_package/marker_no_join/paper.md +7 -0
  565. package/vendor/ars/scripts/fixtures/submission_package/orphan_intext/paper.md +8 -0
  566. package/vendor/ars/scripts/fixtures/submission_package/orphan_intext/references.bib +6 -0
  567. package/vendor/ars/scripts/fixtures/submission_package/passports/corpus_only.yaml +9 -0
  568. package/vendor/ars/scripts/fixtures/submission_package/passports/summary_join.yaml +16 -0
  569. package/vendor/ars/scripts/fixtures/submission_package/profiles/full.yaml +15 -0
  570. package/vendor/ars/scripts/fixtures/submission_package/profiles/tight.yaml +15 -0
  571. package/vendor/ars/scripts/fixtures/submission_package/summary_join/paper.md +7 -0
  572. package/vendor/ars/scripts/fixtures/submission_package/uncited_reference/paper.md +9 -0
  573. package/vendor/ars/scripts/fixtures/submission_package/uncited_reference/references.bib +13 -0
  574. package/vendor/ars/scripts/fixtures/submission_package/venue_clean/paper.md +26 -0
  575. package/vendor/ars/scripts/fixtures/submission_package/venue_clean/references.bib +13 -0
  576. package/vendor/ars/scripts/fixtures/submission_package/venue_violations/paper.md +20 -0
  577. package/vendor/ars/scripts/fixtures/submission_package/venue_violations/references.bib +13 -0
  578. package/vendor/ars/scripts/fixtures/submission_packet_manifest/base_inventory.json +101 -0
  579. package/vendor/ars/scripts/fixtures/submission_packet_manifest/packet/consent-materials.txt +3 -0
  580. package/vendor/ars/scripts/fixtures/submission_packet_manifest/packet/training-certificate.txt +2 -0
  581. package/vendor/ars/scripts/fixtures/submission_packet_manifest/packet/tw-consent-materials.txt +3 -0
  582. package/vendor/ars/scripts/fixtures/tortured_phrase_screening/corpus_input.yaml +30 -0
  583. package/vendor/ars/scripts/fixtures/tortured_phrase_screening/own_draft.md +36 -0
  584. package/vendor/ars/scripts/fixtures/tortured_phrase_screening/own_draft.tex +21 -0
  585. package/vendor/ars/scripts/fixtures/tortured_phrase_screening/seed_expectations.json +218 -0
  586. package/vendor/ars/scripts/fixtures/tortured_phrase_screening/snapshot.json +164 -0
  587. package/vendor/ars/scripts/fixtures/tortured_phrase_screening/snapshot_manifest.json +29 -0
  588. package/vendor/ars/scripts/fixtures/transport_bodies/README.md +55 -0
  589. package/vendor/ars/scripts/fixtures/transport_bodies/arxiv/empty_feed.xml +10 -0
  590. package/vendor/ars/scripts/fixtures/transport_bodies/arxiv/error_5xx.html +7 -0
  591. package/vendor/ars/scripts/fixtures/transport_bodies/arxiv/id_hit.xml +26 -0
  592. package/vendor/ars/scripts/fixtures/transport_bodies/chinese_literature/README.md +69 -0
  593. package/vendor/ars/scripts/fixtures/transport_bodies/chinese_literature/cnki_landing_page.html +13 -0
  594. package/vendor/ars/scripts/fixtures/transport_bodies/chinese_literature/error_5xx.html +2 -0
  595. package/vendor/ars/scripts/fixtures/transport_bodies/chinese_literature/esearch_coordinate_ambiguous.json +16 -0
  596. package/vendor/ars/scripts/fixtures/transport_bodies/chinese_literature/esearch_coordinate_hit.json +16 -0
  597. package/vendor/ars/scripts/fixtures/transport_bodies/chinese_literature/esearch_coordinate_zero.json +14 -0
  598. package/vendor/ars/scripts/fixtures/transport_bodies/chinese_literature/esearch_coverage_hit.json +15 -0
  599. package/vendor/ars/scripts/fixtures/transport_bodies/chinese_literature/esearch_coverage_zero.json +13 -0
  600. package/vendor/ars/scripts/fixtures/transport_bodies/chinese_literature/esummary_hit.json +43 -0
  601. package/vendor/ars/scripts/fixtures/transport_bodies/chinese_literature/esummary_issn_mismatch.json +31 -0
  602. package/vendor/ars/scripts/fixtures/transport_bodies/chinese_literature/esummary_no_doi.json +31 -0
  603. package/vendor/ars/scripts/fixtures/transport_bodies/chinese_literature/esummary_unknown_ra.json +34 -0
  604. package/vendor/ars/scripts/fixtures/transport_bodies/chinese_literature/esummary_year_mismatch.json +31 -0
  605. package/vendor/ars/scripts/fixtures/transport_bodies/chinese_literature/handle_absent.json +4 -0
  606. package/vendor/ars/scripts/fixtures/transport_bodies/chinese_literature/handle_exists.json +16 -0
  607. package/vendor/ars/scripts/fixtures/transport_bodies/chinese_literature/handle_internal_error.json +4 -0
  608. package/vendor/ars/scripts/fixtures/transport_bodies/chinese_literature/istic_csl_hit.json +25 -0
  609. package/vendor/ars/scripts/fixtures/transport_bodies/chinese_literature/istic_csl_other_title.json +18 -0
  610. package/vendor/ars/scripts/fixtures/transport_bodies/chinese_literature/ra_cnki.json +6 -0
  611. package/vendor/ars/scripts/fixtures/transport_bodies/chinese_literature/ra_crossref.json +6 -0
  612. package/vendor/ars/scripts/fixtures/transport_bodies/chinese_literature/ra_istic.json +6 -0
  613. package/vendor/ars/scripts/fixtures/transport_bodies/chinese_literature/ra_unknown_prefix.json +6 -0
  614. package/vendor/ars/scripts/fixtures/transport_bodies/crossref/doi_hit.json +24 -0
  615. package/vendor/ars/scripts/fixtures/transport_bodies/crossref/error_5xx.html +7 -0
  616. package/vendor/ars/scripts/fixtures/transport_bodies/crossref/title_search_miss.json +15 -0
  617. package/vendor/ars/scripts/fixtures/transport_bodies/openalex/doi_hit.json +29 -0
  618. package/vendor/ars/scripts/fixtures/transport_bodies/openalex/error_5xx.json +4 -0
  619. package/vendor/ars/scripts/fixtures/transport_bodies/openalex/title_search_miss.json +11 -0
  620. package/vendor/ars/scripts/fixtures/transport_bodies/semantic_scholar/doi_hit.json +14 -0
  621. package/vendor/ars/scripts/fixtures/transport_bodies/semantic_scholar/error_5xx.json +3 -0
  622. package/vendor/ars/scripts/fixtures/transport_bodies/semantic_scholar/title_search_miss.json +5 -0
  623. package/vendor/ars/scripts/human_read_attestation_resolver.py +467 -0
  624. package/vendor/ars/scripts/ideation_diversity_assignment_gate.py +430 -0
  625. package/vendor/ars/scripts/inquiry_branch_ledger.py +2540 -0
  626. package/vendor/ars/scripts/legacy/ars_apply_revision_patch_v1_0.py +715 -0
  627. package/vendor/ars/scripts/legacy/check_re_review_synthesis_v1_0.py +2215 -0
  628. package/vendor/ars/scripts/migrate_literature_corpus_to_v3_10.py +223 -0
  629. package/vendor/ars/scripts/migrate_literature_corpus_to_v3_7_3.py +277 -0
  630. package/vendor/ars/scripts/migrate_literature_corpus_to_v3_9_0.py +304 -0
  631. package/vendor/ars/scripts/model_tiering_manifest.json +46 -0
  632. package/vendor/ars/scripts/openalex_client.py +232 -0
  633. package/vendor/ars/scripts/parse_audit_verdict.py +802 -0
  634. package/vendor/ars/scripts/pdf_content_classifier_worker.py +176 -0
  635. package/vendor/ars/scripts/pdf_read_preflight.py +1455 -0
  636. package/vendor/ars/scripts/policy_anchor_disclosure_referee.py +354 -0
  637. package/vendor/ars/scripts/recompute_receipts.py +1414 -0
  638. package/vendor/ars/scripts/render_claim_standing_view.py +374 -0
  639. package/vendor/ars/scripts/render_eval_comment.py +130 -0
  640. package/vendor/ars/scripts/render_harness_retirement_issue.py +167 -0
  641. package/vendor/ars/scripts/repro_lock_validation.py +90 -0
  642. package/vendor/ars/scripts/research_workflow_profile.py +1079 -0
  643. package/vendor/ars/scripts/resolve_human_subjects_authority.py +1158 -0
  644. package/vendor/ars/scripts/resolve_review_target_context.py +683 -0
  645. package/vendor/ars/scripts/resume_e4_record.py +509 -0
  646. package/vendor/ars/scripts/retraction_status.py +484 -0
  647. package/vendor/ars/scripts/review_criteria_binding.py +889 -0
  648. package/vendor/ars/scripts/review_panel_provenance.py +744 -0
  649. package/vendor/ars/scripts/revision_roadmap.py +1967 -0
  650. package/vendor/ars/scripts/run_ci_pytest_manifest.py +116 -0
  651. package/vendor/ars/scripts/run_codex_audit.sh +1191 -0
  652. package/vendor/ars/scripts/run_evals.py +513 -0
  653. package/vendor/ars/scripts/run_ideation_diversity_no_call.py +3505 -0
  654. package/vendor/ars/scripts/run_indirect_prompt_injection_no_call.py +3330 -0
  655. package/vendor/ars/scripts/run_indirect_prompt_injection_probe.py +399 -0
  656. package/vendor/ars/scripts/run_review_criteria_constructive_value.py +1895 -0
  657. package/vendor/ars/scripts/run_role_topology_utility_dry_run.py +606 -0
  658. package/vendor/ars/scripts/score_review_criteria_constructive_value.py +617 -0
  659. package/vendor/ars/scripts/semantic_scholar_client.py +291 -0
  660. package/vendor/ars/scripts/slr_lineage.py +59 -0
  661. package/vendor/ars/scripts/sync_adapter_docs.py +118 -0
  662. package/vendor/ars/scripts/temporal_integrity_audit.py +840 -0
  663. package/vendor/ars/scripts/test_431_exact_or_bust.py +253 -0
  664. package/vendor/ars/scripts/test__eval_threshold_gate.py +125 -0
  665. package/vendor/ars/scripts/test__markdown_lint_util.py +129 -0
  666. package/vendor/ars/scripts/test__next_verified_at_ms.py +256 -0
  667. package/vendor/ars/scripts/test_adjacent_framing_probe_lint.py +171 -0
  668. package/vendor/ars/scripts/test_adjudication_activity.py +1515 -0
  669. package/vendor/ars/scripts/test_ars_anchorize_draft.py +178 -0
  670. package/vendor/ars/scripts/test_ars_apply_revision_patch.py +1335 -0
  671. package/vendor/ars/scripts/test_ars_cache_invalidate.py +51 -0
  672. package/vendor/ars/scripts/test_ars_mark_read.py +910 -0
  673. package/vendor/ars/scripts/test_ars_update_check.py +816 -0
  674. package/vendor/ars/scripts/test_ars_write_scope_guard.py +790 -0
  675. package/vendor/ars/scripts/test_arxiv_client.py +374 -0
  676. package/vendor/ars/scripts/test_audit_schemas.py +560 -0
  677. package/vendor/ars/scripts/test_audit_snapshot_render_section_0.py +105 -0
  678. package/vendor/ars/scripts/test_block_parser.py +259 -0
  679. package/vendor/ars/scripts/test_bootstrap_timeline_yaml.py +148 -0
  680. package/vendor/ars/scripts/test_build_claim_standing_candidate_ledger.py +1203 -0
  681. package/vendor/ars/scripts/test_build_claim_standing_query_plan.py +791 -0
  682. package/vendor/ars/scripts/test_build_submission_packet_manifest.py +2644 -0
  683. package/vendor/ars/scripts/test_check_215_field_norm.py +238 -0
  684. package/vendor/ars/scripts/test_check_216_surface_form.py +341 -0
  685. package/vendor/ars/scripts/test_check_268_nested_commitment_ledger.py +194 -0
  686. package/vendor/ars/scripts/test_check_390_revision_patch_discipline.py +279 -0
  687. package/vendor/ars/scripts/test_check_392_citation_verification_intake.py +144 -0
  688. package/vendor/ars/scripts/test_check_394_submission_policy.py +200 -0
  689. package/vendor/ars/scripts/test_check_439_format_profile.py +252 -0
  690. package/vendor/ars/scripts/test_check_619_disclosure_closeout.py +158 -0
  691. package/vendor/ars/scripts/test_check_630_codex_subscription_transport.py +245 -0
  692. package/vendor/ars/scripts/test_check_669_review_pathway_rule_trace.py +304 -0
  693. package/vendor/ars/scripts/test_check_670_revision_roadmap_integration.py +260 -0
  694. package/vendor/ars/scripts/test_check_673_adjudication_activity.py +367 -0
  695. package/vendor/ars/scripts/test_check_684_review_criteria_binding.py +274 -0
  696. package/vendor/ars/scripts/test_check_agents_mirror_sync.py +137 -0
  697. package/vendor/ars/scripts/test_check_audit_artifact_consistency.py +2133 -0
  698. package/vendor/ars/scripts/test_check_benchmark_report.py +117 -0
  699. package/vendor/ars/scripts/test_check_bibliographic_integrity_signals.py +609 -0
  700. package/vendor/ars/scripts/test_check_calibration_tiers.py +376 -0
  701. package/vendor/ars/scripts/test_check_changelog_covers_merges.py +509 -0
  702. package/vendor/ars/scripts/test_check_ci_pytest_manifest.py +425 -0
  703. package/vendor/ars/scripts/test_check_claim_standing_candidate_ledger_integration.py +256 -0
  704. package/vendor/ars/scripts/test_check_claim_standing_freshness.py +277 -0
  705. package/vendor/ars/scripts/test_check_collaboration_depth_rubric.py +239 -0
  706. package/vendor/ars/scripts/test_check_command_frontmatter_name.py +178 -0
  707. package/vendor/ars/scripts/test_check_committee_correspondence.py +298 -0
  708. package/vendor/ars/scripts/test_check_compliance_report.py +381 -0
  709. package/vendor/ars/scripts/test_check_content_coverage_advisory_integration.py +308 -0
  710. package/vendor/ars/scripts/test_check_control_availability.py +361 -0
  711. package/vendor/ars/scripts/test_check_cross_document_consistency_advisory_integration.py +698 -0
  712. package/vendor/ars/scripts/test_check_cross_model_handoff_contract.py +301 -0
  713. package/vendor/ars/scripts/test_check_cross_model_verification_sync.py +203 -0
  714. package/vendor/ars/scripts/test_check_data_access_level.py +227 -0
  715. package/vendor/ars/scripts/test_check_data_flows.py +382 -0
  716. package/vendor/ars/scripts/test_check_decision_contract.py +387 -0
  717. package/vendor/ars/scripts/test_check_degradation_registry.py +270 -0
  718. package/vendor/ars/scripts/test_check_distribution_surface_claims.py +225 -0
  719. package/vendor/ars/scripts/test_check_domain_evidence_profile.py +439 -0
  720. package/vendor/ars/scripts/test_check_e4_promotion.py +163 -0
  721. package/vendor/ars/scripts/test_check_evals_gold_set.py +312 -0
  722. package/vendor/ars/scripts/test_check_evidence_row_integration.py +187 -0
  723. package/vendor/ars/scripts/test_check_field_norm_severity.py +173 -0
  724. package/vendor/ars/scripts/test_check_firm_rules_sync.py +342 -0
  725. package/vendor/ars/scripts/test_check_heldout_measurement_report.py +1508 -0
  726. package/vendor/ars/scripts/test_check_human_subjects_output_contract.py +129 -0
  727. package/vendor/ars/scripts/test_check_human_subjects_reference_migration.py +756 -0
  728. package/vendor/ars/scripts/test_check_instruction_data_boundary.py +204 -0
  729. package/vendor/ars/scripts/test_check_judge_prompt_version.py +90 -0
  730. package/vendor/ars/scripts/test_check_model_tiering.py +236 -0
  731. package/vendor/ars/scripts/test_check_panel_synthesis.py +1658 -0
  732. package/vendor/ars/scripts/test_check_passport_reset_contract.py +249 -0
  733. package/vendor/ars/scripts/test_check_pattern_eval_manifest.py +381 -0
  734. package/vendor/ars/scripts/test_check_persuasion_invariance_fixtures.py +591 -0
  735. package/vendor/ars/scripts/test_check_phase_conformance.py +4366 -0
  736. package/vendor/ars/scripts/test_check_pipeline_boundary_semantics.py +931 -0
  737. package/vendor/ars/scripts/test_check_pipeline_integrity.py +243 -0
  738. package/vendor/ars/scripts/test_check_policy_anchor_protocol.py +236 -0
  739. package/vendor/ars/scripts/test_check_policy_anchor_table.py +295 -0
  740. package/vendor/ars/scripts/test_check_prisma_trAIce_freshness.py +68 -0
  741. package/vendor/ars/scripts/test_check_promotion_bakeoff_preregistration.py +799 -0
  742. package/vendor/ars/scripts/test_check_ranking_lift.py +377 -0
  743. package/vendor/ars/scripts/test_check_re_review_synthesis.py +3398 -0
  744. package/vendor/ars/scripts/test_check_receipt_enum_sync.py +176 -0
  745. package/vendor/ars/scripts/test_check_repro_lock.py +107 -0
  746. package/vendor/ars/scripts/test_check_reviewer_data_fences.py +334 -0
  747. package/vendor/ars/scripts/test_check_reviewer_finding_contract.py +1107 -0
  748. package/vendor/ars/scripts/test_check_reviewer_role_label.py +491 -0
  749. package/vendor/ars/scripts/test_check_reviewer_scoring_honesty.py +222 -0
  750. package/vendor/ars/scripts/test_check_reviewer_sprint_prompt_sync.py +373 -0
  751. package/vendor/ars/scripts/test_check_revision_claim_drift_suite_v2.py +1925 -0
  752. package/vendor/ars/scripts/test_check_revision_token_conservation.py +398 -0
  753. package/vendor/ars/scripts/test_check_risk_register.py +336 -0
  754. package/vendor/ars/scripts/test_check_role_scoped_contract.py +1104 -0
  755. package/vendor/ars/scripts/test_check_rq_framing_patterns.py +110 -0
  756. package/vendor/ars/scripts/test_check_rubric_weight_consistency.py +32 -0
  757. package/vendor/ars/scripts/test_check_seeded_defect_fixtures.py +392 -0
  758. package/vendor/ars/scripts/test_check_setup_cross_model_parity.py +121 -0
  759. package/vendor/ars/scripts/test_check_spec_consistency.py +1081 -0
  760. package/vendor/ars/scripts/test_check_sprint_contract.py +458 -0
  761. package/vendor/ars/scripts/test_check_stage_capability_matrix.py +698 -0
  762. package/vendor/ars/scripts/test_check_submission_packet_manifest_integration.py +177 -0
  763. package/vendor/ars/scripts/test_check_surface_form_parity.py +417 -0
  764. package/vendor/ars/scripts/test_check_task_type.py +116 -0
  765. package/vendor/ars/scripts/test_check_tools_allowlist.py +835 -0
  766. package/vendor/ars/scripts/test_check_tortured_phrase_screening_integration.py +1306 -0
  767. package/vendor/ars/scripts/test_check_v3_10_134_write_scope.py +251 -0
  768. package/vendor/ars/scripts/test_check_v3_10_policy.py +547 -0
  769. package/vendor/ars/scripts/test_check_v3_6_7_pattern_protection.py +960 -0
  770. package/vendor/ars/scripts/test_check_v3_6_8_audit_scope_block.py +1000 -0
  771. package/vendor/ars/scripts/test_check_v3_6_8_cite_provenance_pipeline.py +454 -0
  772. package/vendor/ars/scripts/test_check_v3_6_8_frontmatter_trust_schema.py +581 -0
  773. package/vendor/ars/scripts/test_check_v3_6_8_mark_read_commands.py +120 -0
  774. package/vendor/ars/scripts/test_check_v3_6_8_pattern_protection.py +1138 -0
  775. package/vendor/ars/scripts/test_check_v3_7_3_three_layer_citation.py +566 -0
  776. package/vendor/ars/scripts/test_check_v3_8_annotation_literal_sync.py +262 -0
  777. package/vendor/ars/scripts/test_check_v3_9_0_triangulation.py +321 -0
  778. package/vendor/ars/scripts/test_check_v3_9_2_phase_boundary.py +190 -0
  779. package/vendor/ars/scripts/test_check_v3_9_4_temporal_verification.py +471 -0
  780. package/vendor/ars/scripts/test_check_version_consistency.py +1462 -0
  781. package/vendor/ars/scripts/test_check_workflow_classification.py +225 -0
  782. package/vendor/ars/scripts/test_chinese_literature_client.py +1889 -0
  783. package/vendor/ars/scripts/test_citation_existence_policy.py +480 -0
  784. package/vendor/ars/scripts/test_citation_verification_summary.py +342 -0
  785. package/vendor/ars/scripts/test_claim_audit_calibration.py +882 -0
  786. package/vendor/ars/scripts/test_claim_audit_finalizer.py +979 -0
  787. package/vendor/ars/scripts/test_claim_audit_pipeline.py +2398 -0
  788. package/vendor/ars/scripts/test_claim_audit_schema.py +1778 -0
  789. package/vendor/ars/scripts/test_claim_intent_manifest.py +666 -0
  790. package/vendor/ars/scripts/test_claim_registry_coverage.py +246 -0
  791. package/vendor/ars/scripts/test_claim_standing_discovery.py +579 -0
  792. package/vendor/ars/scripts/test_claim_standing_pipeline_wiring.py +290 -0
  793. package/vendor/ars/scripts/test_claim_standing_stance_assets.py +399 -0
  794. package/vendor/ars/scripts/test_claim_standing_stance_contracts.py +383 -0
  795. package/vendor/ars/scripts/test_claim_standing_stance_runner.py +349 -0
  796. package/vendor/ars/scripts/test_claim_standing_transmissions.py +605 -0
  797. package/vendor/ars/scripts/test_claim_strength_drift_disposition.py +517 -0
  798. package/vendor/ars/scripts/test_claim_verification_coverage_contract.py +104 -0
  799. package/vendor/ars/scripts/test_contamination_signals.py +1086 -0
  800. package/vendor/ars/scripts/test_content_coverage_advisory.py +1767 -0
  801. package/vendor/ars/scripts/test_cross_document_consistency_advisory.py +1270 -0
  802. package/vendor/ars/scripts/test_cross_model_codex_transport.py +1152 -0
  803. package/vendor/ars/scripts/test_cross_model_handoff.py +571 -0
  804. package/vendor/ars/scripts/test_cross_model_verification_guards.py +792 -0
  805. package/vendor/ars/scripts/test_crossref_client.py +393 -0
  806. package/vendor/ars/scripts/test_dispatch_e4_panel.py +4235 -0
  807. package/vendor/ars/scripts/test_e2e_claim_audit.py +540 -0
  808. package/vendor/ars/scripts/test_eval_harness_workflow.py +140 -0
  809. package/vendor/ars/scripts/test_evals_citation_extraction.py +150 -0
  810. package/vendor/ars/scripts/test_evals_lift_report_schema.py +108 -0
  811. package/vendor/ars/scripts/test_evidence_rows.py +2593 -0
  812. package/vendor/ars/scripts/test_experiment_provenance.py +915 -0
  813. package/vendor/ars/scripts/test_human_read_attestation_resolver.py +477 -0
  814. package/vendor/ars/scripts/test_ideation_diversity_assignment_gate.py +615 -0
  815. package/vendor/ars/scripts/test_indirect_prompt_injection_behavior_probe.py +250 -0
  816. package/vendor/ars/scripts/test_inquiry_branch_ledger.py +2296 -0
  817. package/vendor/ars/scripts/test_migrate_literature_corpus_to_v3_10.py +248 -0
  818. package/vendor/ars/scripts/test_migrate_literature_corpus_to_v3_7_3.py +545 -0
  819. package/vendor/ars/scripts/test_migrate_literature_corpus_to_v3_9_0.py +497 -0
  820. package/vendor/ars/scripts/test_normalize_compat_verdict.py +149 -0
  821. package/vendor/ars/scripts/test_openalex_client.py +490 -0
  822. package/vendor/ars/scripts/test_passport_yaml.py +104 -0
  823. package/vendor/ars/scripts/test_pattern_eval_runtime.py +1295 -0
  824. package/vendor/ars/scripts/test_pdf_read_preflight.py +1943 -0
  825. package/vendor/ars/scripts/test_policy_anchor_disclosure.py +666 -0
  826. package/vendor/ars/scripts/test_reading_probe_lint.py +218 -0
  827. package/vendor/ars/scripts/test_recompute_receipts.py +778 -0
  828. package/vendor/ars/scripts/test_render_claim_standing_view.py +192 -0
  829. package/vendor/ars/scripts/test_render_eval_comment.py +162 -0
  830. package/vendor/ars/scripts/test_render_harness_retirement_issue.py +110 -0
  831. package/vendor/ars/scripts/test_repro_lock_validation_drift.py +100 -0
  832. package/vendor/ars/scripts/test_research_workflow_profile.py +734 -0
  833. package/vendor/ars/scripts/test_resolve_human_subjects_authority.py +1219 -0
  834. package/vendor/ars/scripts/test_resolve_review_target_context.py +703 -0
  835. package/vendor/ars/scripts/test_resume_e4_record.py +315 -0
  836. package/vendor/ars/scripts/test_retraction_status.py +456 -0
  837. package/vendor/ars/scripts/test_review_criteria_binding.py +629 -0
  838. package/vendor/ars/scripts/test_review_panel_provenance.py +565 -0
  839. package/vendor/ars/scripts/test_review_pathway_rule_trace.py +821 -0
  840. package/vendor/ars/scripts/test_revision_roadmap.py +1255 -0
  841. package/vendor/ars/scripts/test_run_ci_pytest_manifest.py +186 -0
  842. package/vendor/ars/scripts/test_run_codex_audit_e2e.py +369 -0
  843. package/vendor/ars/scripts/test_run_evals.py +430 -0
  844. package/vendor/ars/scripts/test_run_guard_launcher.py +500 -0
  845. package/vendor/ars/scripts/test_run_ideation_diversity_no_call.py +1833 -0
  846. package/vendor/ars/scripts/test_run_indirect_prompt_injection_no_call.py +1889 -0
  847. package/vendor/ars/scripts/test_run_review_criteria_constructive_value.py +586 -0
  848. package/vendor/ars/scripts/test_run_role_topology_utility_dry_run.py +428 -0
  849. package/vendor/ars/scripts/test_score_review_criteria_constructive_value.py +340 -0
  850. package/vendor/ars/scripts/test_semantic_scholar_client.py +554 -0
  851. package/vendor/ars/scripts/test_slr_lineage_emission.py +230 -0
  852. package/vendor/ars/scripts/test_socratic_rq_non_generation_contract.py +173 -0
  853. package/vendor/ars/scripts/test_temporal_integrity_audit.py +438 -0
  854. package/vendor/ars/scripts/test_text_similarity.py +95 -0
  855. package/vendor/ars/scripts/test_title_fuzzy_false_positive.py +111 -0
  856. package/vendor/ars/scripts/test_tortured_phrase_screening.py +2959 -0
  857. package/vendor/ars/scripts/test_transport_fixture_citation_gate.py +338 -0
  858. package/vendor/ars/scripts/test_uncited_assertion.py +558 -0
  859. package/vendor/ars/scripts/test_v3_6_7_phase_6_6.py +1279 -0
  860. package/vendor/ars/scripts/test_validate_compliance_fixtures.py +36 -0
  861. package/vendor/ars/scripts/test_validate_ideation_diversity_assets.py +230 -0
  862. package/vendor/ars/scripts/test_venue_disclosure_contract.py +755 -0
  863. package/vendor/ars/scripts/test_verification_cache.py +280 -0
  864. package/vendor/ars/scripts/test_verification_gate.py +461 -0
  865. package/vendor/ars/scripts/test_verify_passport_cli.py +123 -0
  866. package/vendor/ars/scripts/test_verify_submission_package.py +1407 -0
  867. package/vendor/ars/scripts/test_version_records_schema.py +211 -0
  868. package/vendor/ars/scripts/tortured_phrase_screening.py +3502 -0
  869. package/vendor/ars/scripts/uncited_assertion_detector.py +254 -0
  870. package/vendor/ars/scripts/v3_6_7_inversion_manifest.json +9 -0
  871. package/vendor/ars/scripts/v3_6_8_inversion_manifest.json +10 -0
  872. package/vendor/ars/scripts/validate_claim_standing_stance_assets.py +249 -0
  873. package/vendor/ars/scripts/validate_compliance_fixtures.py +56 -0
  874. package/vendor/ars/scripts/validate_ideation_diversity_assets.py +303 -0
  875. package/vendor/ars/scripts/venue_disclosure_contract_harness.py +837 -0
  876. package/vendor/ars/scripts/verification_cache.py +276 -0
  877. package/vendor/ars/scripts/verification_gate/__init__.py +345 -0
  878. package/vendor/ars/scripts/verify_passport.py +133 -0
  879. package/vendor/ars/scripts/verify_submission_package.py +1657 -0
  880. package/vendor/ars/shared/agents/compliance_agent.md +136 -0
  881. package/vendor/ars/shared/artifact_reproducibility_pattern.md +173 -0
  882. package/vendor/ars/shared/benchmark_report.schema.json +81 -0
  883. package/vendor/ars/shared/benchmark_report_pattern.md +180 -0
  884. package/vendor/ars/shared/bibliographic_integrity_signals.md +142 -0
  885. package/vendor/ars/shared/collaboration_depth_rubric.md +154 -0
  886. package/vendor/ars/shared/compliance_checkpoint_protocol.md +162 -0
  887. package/vendor/ars/shared/compliance_report.schema.json +187 -0
  888. package/vendor/ars/shared/contracts/README.md +938 -0
  889. package/vendor/ars/shared/contracts/activity/adjudication_activity_input.schema.json +555 -0
  890. package/vendor/ars/shared/contracts/activity/adjudication_activity_store.schema.json +560 -0
  891. package/vendor/ars/shared/contracts/audit/audit_jsonl.schema.json +128 -0
  892. package/vendor/ars/shared/contracts/audit/audit_sidecar.schema.json +169 -0
  893. package/vendor/ars/shared/contracts/audit/audit_verdict.schema.json +133 -0
  894. package/vendor/ars/shared/contracts/audit/cross_document_consistency_advisory.schema.json +480 -0
  895. package/vendor/ars/shared/contracts/audit/cross_document_consistency_advisory_draft.schema.json +564 -0
  896. package/vendor/ars/shared/contracts/audit/cross_document_source_manifest.schema.json +202 -0
  897. package/vendor/ars/shared/contracts/audit/tortured_phrase_advisory.schema.json +1362 -0
  898. package/vendor/ars/shared/contracts/audit/tortured_phrase_snapshot.schema.json +208 -0
  899. package/vendor/ars/shared/contracts/audit/tortured_phrase_snapshot_manifest.schema.json +335 -0
  900. package/vendor/ars/shared/contracts/capability/stage_capability_matrix.json +434 -0
  901. package/vendor/ars/shared/contracts/claim_standing/candidate_ledger.schema.json +705 -0
  902. package/vendor/ars/shared/contracts/claim_standing/query_plan.schema.json +389 -0
  903. package/vendor/ars/shared/contracts/claim_standing/query_plan_v1_1.schema.json +782 -0
  904. package/vendor/ars/shared/contracts/claim_standing/retrieval_input.schema.json +440 -0
  905. package/vendor/ars/shared/contracts/claim_standing/stance_record.schema.json +460 -0
  906. package/vendor/ars/shared/contracts/claim_standing/transmission_ledger.schema.json +282 -0
  907. package/vendor/ars/shared/contracts/cross_model/codex_citation_receipt.schema.json +157 -0
  908. package/vendor/ars/shared/contracts/cross_model/codex_citation_request.schema.json +23 -0
  909. package/vendor/ars/shared/contracts/cross_model/promotion_bakeoff_sealed_commitment.schema.json +55 -0
  910. package/vendor/ars/shared/contracts/cross_model/promotion_bakeoff_sealed_reveal.schema.json +50 -0
  911. package/vendor/ars/shared/contracts/degradation_registry.json +428 -0
  912. package/vendor/ars/shared/contracts/evaluator/full.json +126 -0
  913. package/vendor/ars/shared/contracts/evidence/claim_registry.schema.json +50 -0
  914. package/vendor/ars/shared/contracts/evidence/claim_registry_coverage_report.schema.json +79 -0
  915. package/vendor/ars/shared/contracts/evidence/evidence_row.schema.json +504 -0
  916. package/vendor/ars/shared/contracts/evidence/evidence_row_v1_1.schema.json +364 -0
  917. package/vendor/ars/shared/contracts/evidence/evidence_row_v1_2.schema.json +714 -0
  918. package/vendor/ars/shared/contracts/evidence/evidence_row_v1_3.schema.json +524 -0
  919. package/vendor/ars/shared/contracts/human_subjects/authority_profile_registry.schema.json +497 -0
  920. package/vendor/ars/shared/contracts/human_subjects/committee_correspondence.schema.json +253 -0
  921. package/vendor/ars/shared/contracts/human_subjects/content_coverage_advisory.schema.json +620 -0
  922. package/vendor/ars/shared/contracts/human_subjects/irb_context_record.schema.json +329 -0
  923. package/vendor/ars/shared/contracts/human_subjects/resolved_authority_context.schema.json +347 -0
  924. package/vendor/ars/shared/contracts/human_subjects/review_pathway_rule_trace.schema.json +265 -0
  925. package/vendor/ars/shared/contracts/human_subjects/review_pathway_trace_request.schema.json +127 -0
  926. package/vendor/ars/shared/contracts/human_subjects/submission_packet_inventory.schema.json +240 -0
  927. package/vendor/ars/shared/contracts/human_subjects/submission_packet_manifest.schema.json +999 -0
  928. package/vendor/ars/shared/contracts/passport/audit_artifact_entry.schema.json +266 -0
  929. package/vendor/ars/shared/contracts/passport/bibliographic_integrity_signal.schema.json +1676 -0
  930. package/vendor/ars/shared/contracts/passport/citation_provenance.schema.json +107 -0
  931. package/vendor/ars/shared/contracts/passport/citation_verification_summary.schema.json +164 -0
  932. package/vendor/ars/shared/contracts/passport/claim_audit_result.schema.json +124 -0
  933. package/vendor/ars/shared/contracts/passport/claim_drift.schema.json +58 -0
  934. package/vendor/ars/shared/contracts/passport/claim_intent_manifest.schema.json +107 -0
  935. package/vendor/ars/shared/contracts/passport/constraint_violation.schema.json +65 -0
  936. package/vendor/ars/shared/contracts/passport/experiment_alignment_result.schema.json +69 -0
  937. package/vendor/ars/shared/contracts/passport/experiment_provenance_entry.schema.json +169 -0
  938. package/vendor/ars/shared/contracts/passport/human_read_log.schema.json +86 -0
  939. package/vendor/ars/shared/contracts/passport/inquiry_ledger_ref.schema.json +22 -0
  940. package/vendor/ars/shared/contracts/passport/literature_corpus_entry.schema.json +650 -0
  941. package/vendor/ars/shared/contracts/passport/preregistration_artifact.schema.json +132 -0
  942. package/vendor/ars/shared/contracts/passport/rejection_log.schema.json +89 -0
  943. package/vendor/ars/shared/contracts/passport/reset_ledger_entry.schema.json +158 -0
  944. package/vendor/ars/shared/contracts/passport/temporal_audit_results.schema.json +208 -0
  945. package/vendor/ars/shared/contracts/passport/terminal_policies.schema.json +50 -0
  946. package/vendor/ars/shared/contracts/passport/timeline.schema.json +102 -0
  947. package/vendor/ars/shared/contracts/passport/uncited_assertion.schema.json +56 -0
  948. package/vendor/ars/shared/contracts/passport/uncited_audit_failure.schema.json +72 -0
  949. package/vendor/ars/shared/contracts/passport/user_attested_read_resolution.schema.json +87 -0
  950. package/vendor/ars/shared/contracts/passport/version_records.schema.json +138 -0
  951. package/vendor/ars/shared/contracts/patch/block_manifest.schema.json +45 -0
  952. package/vendor/ars/shared/contracts/patch/legacy/v1_0/revision_patch.schema.json +110 -0
  953. package/vendor/ars/shared/contracts/patch/revision_patch.schema.json +250 -0
  954. package/vendor/ars/shared/contracts/pdf/pdf_content_classifier_diagnostic.schema.json +39 -0
  955. package/vendor/ars/shared/contracts/pdf/pdf_content_classifier_worker.schema.json +88 -0
  956. package/vendor/ars/shared/contracts/pdf/pdf_read_preflight.schema.json +227 -0
  957. package/vendor/ars/shared/contracts/re_review/input_manifest.schema.json +161 -0
  958. package/vendor/ars/shared/contracts/re_review/legacy/v1_0/input_manifest.schema.json +134 -0
  959. package/vendor/ars/shared/contracts/re_review/legacy/v1_0/precommitment.schema.json +193 -0
  960. package/vendor/ars/shared/contracts/re_review/legacy/v1_0/traceability.schema.json +841 -0
  961. package/vendor/ars/shared/contracts/re_review/legacy/v1_0/verdict_record.schema.json +244 -0
  962. package/vendor/ars/shared/contracts/re_review/precommitment.schema.json +193 -0
  963. package/vendor/ars/shared/contracts/re_review/traceability.schema.json +916 -0
  964. package/vendor/ars/shared/contracts/re_review/verdict_record.schema.json +245 -0
  965. package/vendor/ars/shared/contracts/research_workflow/inquiry_branch_ledger.schema.json +449 -0
  966. package/vendor/ars/shared/contracts/research_workflow/research_workflow_profile.schema.json +222 -0
  967. package/vendor/ars/shared/contracts/research_workflow/research_workflow_profile_selection_receipt.schema.json +111 -0
  968. package/vendor/ars/shared/contracts/review_target/constructive_review_findings.schema.json +172 -0
  969. package/vendor/ars/shared/contracts/review_target/criteria_registry.schema.json +97 -0
  970. package/vendor/ars/shared/contracts/review_target/review_criteria_binding_manifest.schema.json +235 -0
  971. package/vendor/ars/shared/contracts/review_target/review_criteria_source_receipt.schema.json +158 -0
  972. package/vendor/ars/shared/contracts/review_target/review_target_context.schema.json +106 -0
  973. package/vendor/ars/shared/contracts/review_target/review_target_declaration.schema.json +118 -0
  974. package/vendor/ars/shared/contracts/reviewer/full.json +114 -0
  975. package/vendor/ars/shared/contracts/reviewer/methodology_focus.json +75 -0
  976. package/vendor/ars/shared/contracts/reviewer/review_panel_provenance.schema.json +263 -0
  977. package/vendor/ars/shared/contracts/reviewer/review_panel_provenance_carrier.schema.json +122 -0
  978. package/vendor/ars/shared/contracts/reviewer/review_panel_provenance_input.schema.json +120 -0
  979. package/vendor/ars/shared/contracts/revision/author_adjudication.schema.json +251 -0
  980. package/vendor/ars/shared/contracts/revision/author_adjudication_input.schema.json +25 -0
  981. package/vendor/ars/shared/contracts/revision/claim_strength_drift_disposition.schema.json +97 -0
  982. package/vendor/ars/shared/contracts/revision/claim_strength_drift_disposition_input.schema.json +80 -0
  983. package/vendor/ars/shared/contracts/revision/claim_strength_drift_findings.schema.json +139 -0
  984. package/vendor/ars/shared/contracts/revision/claim_surface_manifest.schema.json +99 -0
  985. package/vendor/ars/shared/contracts/revision/integrity_correction_authorization.schema.json +140 -0
  986. package/vendor/ars/shared/contracts/revision/integrity_correction_authorization_input.schema.json +28 -0
  987. package/vendor/ars/shared/contracts/revision/integrity_correction_list.schema.json +48 -0
  988. package/vendor/ars/shared/contracts/revision/integrity_pass_receipt.schema.json +16 -0
  989. package/vendor/ars/shared/contracts/revision/revision_evidence_bundle.schema.json +134 -0
  990. package/vendor/ars/shared/contracts/revision/revision_roadmap.schema.json +334 -0
  991. package/vendor/ars/shared/contracts/submission/format_profile.example.yaml +33 -0
  992. package/vendor/ars/shared/contracts/submission/format_profile.schema.json +102 -0
  993. package/vendor/ars/shared/contracts/submission/submission_verification_report.schema.json +233 -0
  994. package/vendor/ars/shared/contracts/submission/venue_profile.schema.json +114 -0
  995. package/vendor/ars/shared/contracts/writer/full.json +87 -0
  996. package/vendor/ars/shared/cross_model_verification.md +714 -0
  997. package/vendor/ars/shared/evals_lift_report.schema.json +141 -0
  998. package/vendor/ars/shared/ground_truth_isolation_pattern.md +275 -0
  999. package/vendor/ars/shared/handoff_schemas.md +1209 -0
  1000. package/vendor/ars/shared/human_subjects_authority_registry.json +1278 -0
  1001. package/vendor/ars/shared/mode_spectrum.md +57 -0
  1002. package/vendor/ars/shared/model_tiering.md +83 -0
  1003. package/vendor/ars/shared/policy_data/nature_policy.md +56 -0
  1004. package/vendor/ars/shared/prisma_trAIce_protocol.md +157 -0
  1005. package/vendor/ars/shared/raise_framework.md +129 -0
  1006. package/vendor/ars/shared/references/authority_content_coverage_advisory_protocol.md +275 -0
  1007. package/vendor/ars/shared/references/claim_standing_candidate_ledger_protocol.md +66 -0
  1008. package/vendor/ars/shared/references/claim_strength_ladder.md +93 -0
  1009. package/vendor/ars/shared/references/cross_document_consistency_advisory_protocol.md +263 -0
  1010. package/vendor/ars/shared/references/evidence_row_protocol.md +260 -0
  1011. package/vendor/ars/shared/references/firm_rules.md +90 -0
  1012. package/vendor/ars/shared/references/human_subjects_authority_protocol.md +274 -0
  1013. package/vendor/ars/shared/references/intent_clarification_protocol.md +168 -0
  1014. package/vendor/ars/shared/references/irb_terminology_glossary.md +229 -0
  1015. package/vendor/ars/shared/references/protected_hedging_phrases.md +118 -0
  1016. package/vendor/ars/shared/references/psychometric_terminology_glossary.md +109 -0
  1017. package/vendor/ars/shared/references/review_criteria_consumer_protocol.md +238 -0
  1018. package/vendor/ars/shared/references/review_pathway_rule_trace_protocol.md +166 -0
  1019. package/vendor/ars/shared/references/submission_packet_manifest_protocol.md +292 -0
  1020. package/vendor/ars/shared/references/word_count_conventions.md +124 -0
  1021. package/vendor/ars/shared/research_workflow_profiles/field_general.json +1 -0
  1022. package/vendor/ars/shared/review_criteria_registry.json +207 -0
  1023. package/vendor/ars/shared/review_criteria_sources/msr-2027-technical-papers.2026-08-24.json +46 -0
  1024. package/vendor/ars/shared/review_criteria_sources/sigsoft-empirical-standards.2026-08-24.json +31 -0
  1025. package/vendor/ars/shared/sprint_contract.schema.json +482 -0
  1026. package/vendor/ars/shared/style_calibration_protocol.md +151 -0
  1027. package/vendor/ars/shared/templates/codex_audit_multifile_template.md +263 -0
  1028. package/vendor/ars/tools/release-discipline/.toolkit-version +1 -0
  1029. package/vendor/ars/tools/release-discipline/README.md +4 -0
  1030. package/vendor/ars/tools/release-discipline/scripts/_release_doc_alignment_schema.py +1011 -0
  1031. package/vendor/ars/tools/release-discipline/scripts/check_command_invariants.py +497 -0
  1032. package/vendor/ars/tools/release-discipline/scripts/check_release_doc_alignment.py +263 -0
  1033. package/vendor/ars/tools/release-discipline/scripts/sync-toolkit.sh +147 -0
  1034. package/vendor/windows/NOTICE.md +12 -0
  1035. package/vendor/windows/arm64/fd.exe +0 -0
  1036. package/vendor/windows/arm64/licenses/fd/LICENSE-APACHE +201 -0
  1037. package/vendor/windows/arm64/licenses/fd/LICENSE-MIT +21 -0
  1038. package/vendor/windows/arm64/licenses/ripgrep/COPYING +3 -0
  1039. package/vendor/windows/arm64/licenses/ripgrep/LICENSE-MIT +21 -0
  1040. package/vendor/windows/arm64/licenses/ripgrep/UNLICENSE +24 -0
  1041. package/vendor/windows/arm64/rg.exe +0 -0
  1042. package/vendor/windows/x64/fd.exe +0 -0
  1043. package/vendor/windows/x64/licenses/fd/LICENSE-APACHE +201 -0
  1044. package/vendor/windows/x64/licenses/fd/LICENSE-MIT +21 -0
  1045. package/vendor/windows/x64/licenses/ripgrep/COPYING +3 -0
  1046. package/vendor/windows/x64/licenses/ripgrep/LICENSE-MIT +21 -0
  1047. package/vendor/windows/x64/licenses/ripgrep/UNLICENSE +24 -0
  1048. package/vendor/windows/x64/rg.exe +0 -0
@@ -0,0 +1,2332 @@
1
+ #!/usr/bin/env python3
2
+ """Build, replay-validate, and render the hermetic #672 advisory.
3
+
4
+ The semantic observations are explicit untrusted inputs. This module performs
5
+ only closed-contract validation, exact-byte hashing/replay, deterministic
6
+ serialization, and bounded rendering. It never calls a model, network, clock,
7
+ subprocess, cache, or directory discovery surface.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import argparse
13
+ import copy
14
+ import datetime as dt
15
+ import hashlib
16
+ import json
17
+ import os
18
+ import re
19
+ import stat
20
+ import sys
21
+ import tempfile
22
+ import unicodedata
23
+ from collections.abc import Mapping, Sequence
24
+ from pathlib import Path
25
+ from typing import Any, NoReturn
26
+ from urllib.parse import unquote
27
+
28
+
29
+ SIDECAR_SCHEMA_VERSION = "preregistration-artifact/1.0"
30
+ MANIFEST_SCHEMA_VERSION = "cross-document-source-manifest/1.0"
31
+ DRAFT_SCHEMA_VERSION = "cross-document-consistency-advisory-draft/1.0"
32
+ REPORT_SCHEMA_VERSION = "cross-document-consistency-advisory/1.0"
33
+ EVIDENCE_SCHEMA_VERSION = "evidence-row/1.2"
34
+ SURFACE = "cross_document_consistency"
35
+ LAYER = "LLM-ADVISORY"
36
+ EVALUATION_STATUS = "UNMEASURED"
37
+
38
+ MAX_DRAFT_BYTES = 16 * 1024 * 1024
39
+ MAX_MANIFEST_BYTES = 1 * 1024 * 1024
40
+ MAX_SIDECAR_BYTES = 1 * 1024 * 1024
41
+ MAX_FINAL_BYTES = 32 * 1024 * 1024
42
+ MAX_ACCEPTED_DRAFT_BYTES = 8 * 1024 * 1024
43
+ MAX_PREREGISTRATION_BYTES = 64 * 1024 * 1024
44
+ MAX_TOTAL_SOURCE_BYTES = 72 * 1024 * 1024
45
+ MAX_OBSERVATIONS = 4096
46
+ MAX_JSON_DEPTH = 100
47
+ MAX_JSON_NODES = 1_000_000
48
+ MAX_PAGE_SIZE = 25
49
+ MAX_IDENTIFIER = 200
50
+ MAX_PATH_CODEPOINTS = 1024
51
+ MAX_EXTERNAL_CODEPOINTS = 1000
52
+ MAX_EXTERNAL_WORDS = 25
53
+ MAX_ENCODED_ANCHOR = 12000
54
+
55
+ TEMPLATE_SHA256 = "40054e26c527ff3dd237a5eef3fee60b821cf8549e210d48a057005333c8e0d2"
56
+ LOCATOR_PROVENANCE = "agent_supplied_not_independently_authenticated"
57
+ SCOPE_COMPLETENESS = (
58
+ "caller_declared_complete_named_scope_not_independently_authenticated"
59
+ )
60
+ SEMANTIC_PROVENANCE = "caller_supplied_not_deterministically_verified"
61
+
62
+ PAIR_ORDER = (
63
+ "abstract_results",
64
+ "discussion_results",
65
+ "methods_reported_analyses",
66
+ "manuscript_preregistration",
67
+ )
68
+ PAIR_ROLES = {
69
+ "abstract_results": ("abstract", "results"),
70
+ "discussion_results": ("discussion", "results"),
71
+ "methods_reported_analyses": ("methods", "reported_analyses"),
72
+ "manuscript_preregistration": (
73
+ "manuscript_report",
74
+ "preregistration",
75
+ "disclosure_scope",
76
+ ),
77
+ }
78
+ FINDING_TYPES = {
79
+ "abstract_results": frozenset(
80
+ {
81
+ "numeric_mismatch",
82
+ "direction_mismatch",
83
+ "significance_mismatch",
84
+ "claim_strength_rung_mismatch",
85
+ }
86
+ ),
87
+ "discussion_results": frozenset(
88
+ {
89
+ "direction_mismatch",
90
+ "claim_strength_rung_mismatch",
91
+ "scope_or_population_overreach",
92
+ }
93
+ ),
94
+ "methods_reported_analyses": frozenset(
95
+ {
96
+ "declared_analysis_no_reported_counterpart",
97
+ "reported_analysis_no_declared_counterpart",
98
+ "analysis_specification_conflict",
99
+ }
100
+ ),
101
+ "manuscript_preregistration": frozenset({"undisclosed_preregistration_deviation"}),
102
+ }
103
+ NEGATIVE_BASES = frozenset(
104
+ {
105
+ "legitimate_compression",
106
+ "same_rung_rewording",
107
+ "disclosed_deviation",
108
+ "other_no_listed_observation",
109
+ }
110
+ )
111
+ DEVIATION_DOMAINS = frozenset(
112
+ {
113
+ "hypothesis",
114
+ "primary_outcome",
115
+ "sample_size_or_stopping",
116
+ "analysis_model",
117
+ "transformation",
118
+ "exclusion",
119
+ "inference_criterion",
120
+ "confirmatory_exploratory_designation",
121
+ }
122
+ )
123
+ EVIDENCE_STATES = frozenset(
124
+ {
125
+ "agent_extracted",
126
+ "checked_no_match",
127
+ "not_checked",
128
+ "source_missing",
129
+ "access_failed",
130
+ "retrieval_failed",
131
+ }
132
+ )
133
+ FAILURE_STATES = frozenset(
134
+ {"not_checked", "source_missing", "access_failed", "retrieval_failed"}
135
+ )
136
+ MANIFEST_STATES = frozenset(
137
+ {"present", "source_missing", "access_failed", "retrieval_failed"}
138
+ )
139
+ SIDECAR_STATES = frozenset(
140
+ {"provided", "not_provided", "access_failed", "retrieval_failed"}
141
+ )
142
+ NOT_CHECKED_REASONS = frozenset(
143
+ {
144
+ "PAIR_CHECK_NOT_PERFORMED",
145
+ "COUNTERPART_DOCUMENT_MISSING",
146
+ "COUNTERPART_SCOPE_NOT_PROVIDED",
147
+ "SOURCE_ACCESS_FAILED",
148
+ "SOURCE_RETRIEVAL_FAILED",
149
+ }
150
+ )
151
+ OUTCOMES = frozenset(
152
+ {"POTENTIAL_INCONSISTENCY_LOCATED", "NO_LISTED_INCONSISTENCY_LOCATED"}
153
+ )
154
+ DIAGNOSTIC_CODES = frozenset(
155
+ {
156
+ "NAMED_INPUT_UNREADABLE",
157
+ "DRAFT_CONTRACT_INVALID",
158
+ "SOURCE_MANIFEST_INVALID",
159
+ "SOURCE_BINDING_INVALID",
160
+ "EVIDENCE_REPLAY_INVALID",
161
+ "FINAL_ARTIFACT_INVALID",
162
+ "RESOURCE_LIMIT",
163
+ }
164
+ )
165
+ BOUNDARY = {
166
+ "semantic_observation_not_recomputed": True,
167
+ "stage_4_5_verdict_unchanged": True,
168
+ "stage_5_routing_unchanged": True,
169
+ "integrity_issue_counts_unchanged": True,
170
+ "formatter_gate_unchanged": True,
171
+ "terminal_policy_unchanged": True,
172
+ "score_not_produced": True,
173
+ "automatic_rewrite_not_performed": True,
174
+ "agreement_not_certified": True,
175
+ }
176
+
177
+ _RFC3339_RE = re.compile(
178
+ r"^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt]"
179
+ r"(?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]"
180
+ r"(?:\.[0-9]+)?(?:[Zz]|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])$"
181
+ )
182
+ _HEX = frozenset("0123456789abcdefABCDEF")
183
+
184
+
185
+ class AdvisoryError(ValueError):
186
+ """A closed #672 contract or replay invariant failed."""
187
+
188
+ def __init__(self, code: str, message: str) -> None:
189
+ if code not in DIAGNOSTIC_CODES:
190
+ raise ValueError(f"unknown diagnostic code: {code}")
191
+ super().__init__(message)
192
+ self.code = code
193
+
194
+
195
+ class _ClosedArgumentParser(argparse.ArgumentParser):
196
+ """Convert malformed CLI syntax into the same bounded diagnostic channel."""
197
+
198
+ def error(self, message: str) -> NoReturn:
199
+ del message
200
+ raise AdvisoryError(
201
+ "FINAL_ARTIFACT_INVALID",
202
+ "command line: arguments do not match the closed CLI",
203
+ )
204
+
205
+
206
+ def _fail(code: str, path: str, message: str) -> NoReturn:
207
+ raise AdvisoryError(code, f"{path}: {message}")
208
+
209
+
210
+ def _sha256(value: bytes) -> str:
211
+ return hashlib.sha256(value).hexdigest()
212
+
213
+
214
+ def _canonical_bytes(value: Any) -> bytes:
215
+ try:
216
+ return json.dumps(
217
+ value,
218
+ ensure_ascii=False,
219
+ sort_keys=True,
220
+ separators=(",", ":"),
221
+ allow_nan=False,
222
+ ).encode("utf-8", errors="strict")
223
+ except (TypeError, ValueError, UnicodeError, RecursionError) as exc:
224
+ _fail("FINAL_ARTIFACT_INVALID", "value", f"cannot serialize canonically: {exc}")
225
+
226
+
227
+ def _digest_without(value: Mapping[str, Any], field: str) -> str:
228
+ payload = {key: copy.deepcopy(item) for key, item in value.items() if key != field}
229
+ return _sha256(_canonical_bytes(payload))
230
+
231
+
232
+ def _closed(
233
+ value: Any,
234
+ path: str,
235
+ fields: set[str] | frozenset[str],
236
+ *,
237
+ code: str,
238
+ ) -> dict[str, Any]:
239
+ if not isinstance(value, dict):
240
+ _fail(code, path, "must be an object")
241
+ missing = fields - set(value)
242
+ extra = set(value) - fields
243
+ if missing:
244
+ _fail(code, path, f"missing field(s): {', '.join(sorted(missing))}")
245
+ if extra:
246
+ _fail(code, path, f"undeclared field(s): {', '.join(sorted(extra))}")
247
+ return value
248
+
249
+
250
+ def _array(
251
+ value: Any,
252
+ path: str,
253
+ *,
254
+ code: str,
255
+ minimum: int = 0,
256
+ maximum: int = MAX_OBSERVATIONS,
257
+ ) -> list[Any]:
258
+ if not isinstance(value, list):
259
+ _fail(code, path, "must be an array")
260
+ if len(value) < minimum or len(value) > maximum:
261
+ _fail(code, path, f"must contain {minimum}..{maximum} items")
262
+ return value
263
+
264
+
265
+ def _safe_text(
266
+ value: Any,
267
+ path: str,
268
+ *,
269
+ code: str,
270
+ minimum: int = 1,
271
+ maximum: int = 1000,
272
+ ) -> str:
273
+ if not isinstance(value, str):
274
+ _fail(code, path, "must be a string")
275
+ if len(value) < minimum or len(value) > maximum:
276
+ _fail(code, path, f"must contain {minimum}..{maximum} code points")
277
+ for character in value:
278
+ number = ord(character)
279
+ category = unicodedata.category(character)
280
+ if (
281
+ number == 127
282
+ or (number < 32 and character not in {"\t", "\n", "\r"})
283
+ or 0xD800 <= number <= 0xDFFF
284
+ or category in {"Cf", "Zl", "Zp"}
285
+ ):
286
+ _fail(code, path, f"contains forbidden character U+{number:04X}")
287
+ return value
288
+
289
+
290
+ def _identifier(value: Any, path: str, *, code: str) -> str:
291
+ text = _safe_text(value, path, code=code, maximum=MAX_IDENTIFIER)
292
+ if re.fullmatch(r"[a-z0-9][a-z0-9._-]{0,199}", text) is None:
293
+ _fail(code, path, "must be a lowercase ASCII identifier")
294
+ return text
295
+
296
+
297
+ def _sha(value: Any, path: str, *, code: str) -> str:
298
+ if not isinstance(value, str) or re.fullmatch(r"[0-9a-f]{64}", value) is None:
299
+ _fail(code, path, "must be a lowercase SHA-256 hex digest")
300
+ return value
301
+
302
+
303
+ def _integer(
304
+ value: Any,
305
+ path: str,
306
+ *,
307
+ code: str,
308
+ minimum: int = 0,
309
+ maximum: int,
310
+ ) -> int:
311
+ if isinstance(value, bool) or not isinstance(value, int):
312
+ _fail(code, path, "must be an integer")
313
+ if value < minimum or value > maximum:
314
+ _fail(code, path, f"must be within {minimum}..{maximum}")
315
+ return value
316
+
317
+
318
+ def _enum(value: Any, path: str, choices: frozenset[str], *, code: str) -> str:
319
+ if not isinstance(value, str) or value not in choices:
320
+ _fail(code, path, f"must be one of {sorted(choices)}")
321
+ return value
322
+
323
+
324
+ def _timestamp(value: Any, path: str, *, code: str) -> str:
325
+ text = _safe_text(value, path, code=code, maximum=100)
326
+ if _RFC3339_RE.fullmatch(text) is None:
327
+ _fail(code, path, "must be an RFC 3339 timestamp with an offset")
328
+ normalized = text[:-1] + "+00:00" if text[-1] in {"Z", "z"} else text
329
+ try:
330
+ dt.datetime.fromisoformat(normalized)
331
+ except ValueError as exc:
332
+ _fail(code, path, f"is not a real RFC 3339 timestamp: {exc}")
333
+ return text
334
+
335
+
336
+ def _relative_path(value: Any, path: str, *, code: str) -> str:
337
+ text = _safe_text(value, path, code=code, maximum=MAX_PATH_CODEPOINTS)
338
+ if (
339
+ text.startswith("/")
340
+ or "\\" in text
341
+ or any(
342
+ unicodedata.category(character) in {"Cc", "Cf", "Zl", "Zp"}
343
+ for character in text
344
+ )
345
+ ):
346
+ _fail(code, path, "must be a normalized relative POSIX path")
347
+ components = text.split("/")
348
+ if any(component in {"", ".", ".."} for component in components):
349
+ _fail(code, path, "contains an empty, dot, or parent component")
350
+ return text
351
+
352
+
353
+ def _span(value: Any, path: str, *, code: str) -> dict[str, int]:
354
+ block = _closed(value, path, {"start", "end"}, code=code)
355
+ start = _integer(
356
+ block["start"], f"{path}.start", code=code, maximum=MAX_TOTAL_SOURCE_BYTES
357
+ )
358
+ end = _integer(
359
+ block["end"],
360
+ f"{path}.end",
361
+ code=code,
362
+ minimum=1,
363
+ maximum=MAX_TOTAL_SOURCE_BYTES,
364
+ )
365
+ if end <= start:
366
+ _fail(code, path, "must be a non-empty half-open UTF-8 span")
367
+ return {"start": start, "end": end}
368
+
369
+
370
+ def strict_percent_decode(value: str) -> str:
371
+ """Decode RFC 3986 percent escapes once; a plus remains a literal plus."""
372
+
373
+ _safe_text(
374
+ value,
375
+ "anchor_value_encoded",
376
+ code="EVIDENCE_REPLAY_INVALID",
377
+ maximum=MAX_ENCODED_ANCHOR,
378
+ )
379
+ index = 0
380
+ while index < len(value):
381
+ if value[index] == "%":
382
+ if (
383
+ index + 2 >= len(value)
384
+ or value[index + 1] not in _HEX
385
+ or value[index + 2] not in _HEX
386
+ ):
387
+ _fail(
388
+ "EVIDENCE_REPLAY_INVALID",
389
+ "anchor_value_encoded",
390
+ f"malformed percent escape at character {index}",
391
+ )
392
+ index += 3
393
+ else:
394
+ index += 1
395
+ try:
396
+ return unquote(value, encoding="utf-8", errors="strict")
397
+ except UnicodeError as exc:
398
+ _fail(
399
+ "EVIDENCE_REPLAY_INVALID",
400
+ "anchor_value_encoded",
401
+ f"percent escapes are not strict UTF-8: {exc}",
402
+ )
403
+
404
+
405
+ def _precheck_depth(text: str, *, code: str, path: str) -> None:
406
+ depth = 0
407
+ in_string = False
408
+ escaped = False
409
+ for character in text:
410
+ if in_string:
411
+ if escaped:
412
+ escaped = False
413
+ elif character == "\\":
414
+ escaped = True
415
+ elif character == '"':
416
+ in_string = False
417
+ continue
418
+ if character == '"':
419
+ in_string = True
420
+ elif character in "[{":
421
+ depth += 1
422
+ if depth > MAX_JSON_DEPTH:
423
+ _fail(code, path, f"JSON nesting exceeds {MAX_JSON_DEPTH}")
424
+ elif character in "]}":
425
+ depth -= 1
426
+
427
+
428
+ def _count_nodes(value: Any, *, code: str, path: str) -> None:
429
+ count = 0
430
+ stack = [value]
431
+ while stack:
432
+ current = stack.pop()
433
+ count += 1
434
+ if count > MAX_JSON_NODES:
435
+ _fail(code, path, f"JSON aggregate nodes exceed {MAX_JSON_NODES}")
436
+ if isinstance(current, dict):
437
+ stack.extend(current.values())
438
+ elif isinstance(current, list):
439
+ stack.extend(current)
440
+
441
+
442
+ def _reject_unsafe_json_strings(value: Any, *, code: str, path: str) -> None:
443
+ stack: list[tuple[str, Any]] = [(path, value)]
444
+ while stack:
445
+ current_path, current = stack.pop()
446
+ if isinstance(current, dict):
447
+ for key, item in current.items():
448
+ _safe_text(
449
+ key, f"{current_path} key", code=code, minimum=0, maximum=1024
450
+ )
451
+ stack.append((f"{current_path}.{key}", item))
452
+ elif isinstance(current, list):
453
+ for index, item in enumerate(current):
454
+ stack.append((f"{current_path}[{index}]", item))
455
+ elif isinstance(current, str):
456
+ _safe_text(
457
+ current,
458
+ current_path,
459
+ code=code,
460
+ minimum=0,
461
+ maximum=max(len(current), 1),
462
+ )
463
+
464
+
465
+ def _read_named_bytes(
466
+ path: Path,
467
+ maximum: int,
468
+ *,
469
+ label: str,
470
+ unreadable_code: str = "NAMED_INPUT_UNREADABLE",
471
+ ) -> bytes:
472
+ flags = os.O_RDONLY
473
+ if hasattr(os, "O_NOFOLLOW"):
474
+ flags |= os.O_NOFOLLOW
475
+ # A read-only open of a FIFO can otherwise wait forever before fstat has a
476
+ # chance to reject it. O_NONBLOCK is inert for ordinary regular files.
477
+ if hasattr(os, "O_NONBLOCK"):
478
+ flags |= os.O_NONBLOCK
479
+ try:
480
+ descriptor = os.open(path, flags)
481
+ try:
482
+ metadata = os.fstat(descriptor)
483
+ if not stat.S_ISREG(metadata.st_mode):
484
+ _fail(unreadable_code, label, "must be a regular file")
485
+ chunks: list[bytes] = []
486
+ remaining = maximum + 1
487
+ while remaining:
488
+ chunk = os.read(descriptor, min(1024 * 1024, remaining))
489
+ if not chunk:
490
+ break
491
+ chunks.append(chunk)
492
+ remaining -= len(chunk)
493
+ payload = b"".join(chunks)
494
+ finally:
495
+ os.close(descriptor)
496
+ except AdvisoryError:
497
+ raise
498
+ except (OSError, ValueError) as exc:
499
+ _fail(
500
+ unreadable_code,
501
+ label,
502
+ f"could not be read: {exc.__class__.__name__}",
503
+ )
504
+ if len(payload) > maximum:
505
+ _fail("RESOURCE_LIMIT", label, f"exceeds {maximum} bytes")
506
+ return payload
507
+
508
+
509
+ def _strict_json_bytes(
510
+ raw: bytes,
511
+ *,
512
+ code: str,
513
+ path: str,
514
+ ) -> Any:
515
+ if raw.startswith(b"\xef\xbb\xbf"):
516
+ _fail(code, path, "must not contain a UTF-8 BOM")
517
+ try:
518
+ text = raw.decode("utf-8", errors="strict")
519
+ except UnicodeError as exc:
520
+ _fail(code, path, f"is not strict UTF-8: {exc}")
521
+ _precheck_depth(text, code=code, path=path)
522
+
523
+ def object_pairs(pairs: list[tuple[str, Any]]) -> dict[str, Any]:
524
+ result: dict[str, Any] = {}
525
+ for key, item in pairs:
526
+ if key in result:
527
+ _fail(code, path, f"contains duplicate decoded key {key!r}")
528
+ result[key] = item
529
+ return result
530
+
531
+ def reject_constant(value: str) -> NoReturn:
532
+ _fail(code, path, f"contains non-finite number {value}")
533
+
534
+ def reject_float(value: str) -> NoReturn:
535
+ _fail(code, path, f"contains unsupported non-integer number {value}")
536
+
537
+ try:
538
+ value = json.loads(
539
+ text,
540
+ object_pairs_hook=object_pairs,
541
+ parse_constant=reject_constant,
542
+ parse_float=reject_float,
543
+ )
544
+ except AdvisoryError:
545
+ raise
546
+ except (json.JSONDecodeError, RecursionError, ValueError) as exc:
547
+ _fail(code, path, f"is not strict JSON: {exc}")
548
+ _count_nodes(value, code=code, path=path)
549
+ _reject_unsafe_json_strings(value, code=code, path=path)
550
+ return value
551
+
552
+
553
+ def _load_json(
554
+ path: Path,
555
+ maximum: int,
556
+ *,
557
+ code: str,
558
+ label: str,
559
+ ) -> tuple[Any, bytes]:
560
+ raw = _read_named_bytes(path, maximum, label=label)
561
+ return _strict_json_bytes(raw, code=code, path=label), raw
562
+
563
+
564
+ def _binding_bytes(
565
+ value: Any,
566
+ raw: bytes | None,
567
+ maximum: int,
568
+ *,
569
+ code: str,
570
+ path: str,
571
+ ) -> bytes:
572
+ """Bind a parsed carrier to the exact raw bytes named by its caller."""
573
+
574
+ if raw is None:
575
+ candidate = _canonical_bytes(value)
576
+ elif isinstance(raw, bytes):
577
+ candidate = raw
578
+ else:
579
+ _fail(code, path, "raw binding must be bytes")
580
+ if len(candidate) > maximum:
581
+ _fail("RESOURCE_LIMIT", path, f"exceeds {maximum} bytes")
582
+ parsed = _strict_json_bytes(candidate, code=code, path=path)
583
+ if _canonical_bytes(parsed) != _canonical_bytes(value):
584
+ _fail(code, path, "raw bytes decode to a different object")
585
+ return candidate
586
+
587
+
588
+ def _strict_source(raw: bytes, *, label: str, maximum: int) -> str:
589
+ if not isinstance(raw, bytes):
590
+ _fail("SOURCE_BINDING_INVALID", label, "must be bytes")
591
+ if len(raw) > maximum:
592
+ _fail("RESOURCE_LIMIT", label, f"exceeds {maximum} bytes")
593
+ if raw.startswith(b"\xef\xbb\xbf"):
594
+ _fail("SOURCE_BINDING_INVALID", label, "must not contain a UTF-8 BOM")
595
+ try:
596
+ text = raw.decode("utf-8", errors="strict")
597
+ if text.encode("utf-8", errors="strict") != raw:
598
+ _fail(
599
+ "SOURCE_BINDING_INVALID", label, "does not round-trip as strict UTF-8"
600
+ )
601
+ except UnicodeError as exc:
602
+ _fail("SOURCE_BINDING_INVALID", label, f"is not strict UTF-8: {exc}")
603
+ return text
604
+
605
+
606
+ def _strict_accepted_draft(raw: bytes) -> str:
607
+ text = _strict_source(
608
+ raw,
609
+ label="accepted draft",
610
+ maximum=MAX_ACCEPTED_DRAFT_BYTES,
611
+ )
612
+ if not text.strip():
613
+ _fail("SOURCE_BINDING_INVALID", "accepted draft", "must not be blank")
614
+ return text
615
+
616
+
617
+ def _atomic_write(path: Path, payload: bytes) -> None:
618
+ try:
619
+ path.parent.mkdir(parents=True, exist_ok=True)
620
+ descriptor, temporary = tempfile.mkstemp(
621
+ dir=path.parent,
622
+ prefix=f".{path.name}.",
623
+ suffix=".tmp",
624
+ )
625
+ try:
626
+ with os.fdopen(descriptor, "wb") as handle:
627
+ handle.write(payload)
628
+ handle.flush()
629
+ os.fsync(handle.fileno())
630
+ os.replace(temporary, path)
631
+ except BaseException:
632
+ try:
633
+ os.unlink(temporary)
634
+ except FileNotFoundError:
635
+ pass
636
+ raise
637
+ except AdvisoryError:
638
+ raise
639
+ except OSError as exc:
640
+ _fail(
641
+ "NAMED_INPUT_UNREADABLE",
642
+ "output",
643
+ f"atomic write failed: {exc.__class__.__name__}",
644
+ )
645
+
646
+
647
+ def _reject_output_alias(output: Path, inputs: Sequence[Path | None]) -> None:
648
+ output_absolute = os.path.abspath(output)
649
+ for candidate in inputs:
650
+ if candidate is None:
651
+ continue
652
+ if output_absolute == os.path.abspath(candidate):
653
+ _fail("NAMED_INPUT_UNREADABLE", "output", "must not alias a named input")
654
+ try:
655
+ if (
656
+ output.exists()
657
+ and candidate.exists()
658
+ and os.path.samefile(output, candidate)
659
+ ):
660
+ _fail(
661
+ "NAMED_INPUT_UNREADABLE", "output", "must not alias a named input"
662
+ )
663
+ except OSError:
664
+ continue
665
+
666
+
667
+ def build_preregistration_artifact(
668
+ *,
669
+ status: str,
670
+ artifact_id: str,
671
+ declared_at: str,
672
+ companion_bytes: bytes | None = None,
673
+ relative_path: str | None = None,
674
+ artifact_provenance: str | None = None,
675
+ ) -> dict[str, Any]:
676
+ """Derive one canonical, hash-bound preregistration handoff sidecar."""
677
+
678
+ state = _enum(status, "status", SIDECAR_STATES, code="SOURCE_BINDING_INVALID")
679
+ identity = _identifier(artifact_id, "artifact_id", code="SOURCE_BINDING_INVALID")
680
+ timestamp = _timestamp(declared_at, "declared_at", code="SOURCE_BINDING_INVALID")
681
+ if state == "provided":
682
+ if companion_bytes is None:
683
+ _fail(
684
+ "SOURCE_BINDING_INVALID", "companion", "is required for provided status"
685
+ )
686
+ text = _strict_source(
687
+ companion_bytes,
688
+ label="preregistration companion",
689
+ maximum=MAX_PREREGISTRATION_BYTES,
690
+ )
691
+ if not text.strip():
692
+ _fail("SOURCE_BINDING_INVALID", "companion", "must not be blank")
693
+ digest = _sha256(companion_bytes)
694
+ if digest == TEMPLATE_SHA256:
695
+ _fail(
696
+ "SOURCE_BINDING_INVALID",
697
+ "companion",
698
+ "blank guidance template is not evidence",
699
+ )
700
+ if relative_path is None:
701
+ _fail(
702
+ "SOURCE_BINDING_INVALID",
703
+ "relative_path",
704
+ "is required for provided status",
705
+ )
706
+ normalized_path = _relative_path(
707
+ relative_path,
708
+ "relative_path",
709
+ code="SOURCE_BINDING_INVALID",
710
+ )
711
+ provenance = artifact_provenance or "author_provided_completed_preregistration"
712
+ if not isinstance(provenance, str) or provenance not in {
713
+ "author_provided_completed_preregistration",
714
+ "synthetic_fixture",
715
+ }:
716
+ _fail(
717
+ "SOURCE_BINDING_INVALID",
718
+ "artifact_provenance",
719
+ "is invalid for provided status",
720
+ )
721
+ size = len(companion_bytes)
722
+ record: dict[str, Any] = {
723
+ "schema_version": SIDECAR_SCHEMA_VERSION,
724
+ "status": state,
725
+ "artifact_id": identity,
726
+ "relative_path": normalized_path,
727
+ "artifact_provenance": provenance,
728
+ "source_artifact_sha256": digest,
729
+ "source_artifact_size_bytes": size,
730
+ "source_content_sha256": digest,
731
+ "source_content_utf8_bytes": size,
732
+ "declared_at": timestamp,
733
+ "record_digest": "",
734
+ }
735
+ else:
736
+ if companion_bytes is not None or relative_path is not None:
737
+ _fail(
738
+ "SOURCE_BINDING_INVALID",
739
+ "sidecar",
740
+ "unavailable status forbids companion/path",
741
+ )
742
+ if artifact_provenance is not None and artifact_provenance != "not_provided":
743
+ _fail(
744
+ "SOURCE_BINDING_INVALID", "artifact_provenance", "must be not_provided"
745
+ )
746
+ record = {
747
+ "schema_version": SIDECAR_SCHEMA_VERSION,
748
+ "status": state,
749
+ "artifact_id": identity,
750
+ "relative_path": None,
751
+ "artifact_provenance": "not_provided",
752
+ "source_artifact_sha256": None,
753
+ "source_artifact_size_bytes": None,
754
+ "source_content_sha256": None,
755
+ "source_content_utf8_bytes": None,
756
+ "declared_at": timestamp,
757
+ "record_digest": "",
758
+ }
759
+ record["record_digest"] = _digest_without(record, "record_digest")
760
+ if len(_canonical_bytes(record)) > MAX_SIDECAR_BYTES:
761
+ _fail("RESOURCE_LIMIT", "sidecar", "canonical output exceeds 1 MiB")
762
+ return record
763
+
764
+
765
+ def validate_preregistration_artifact(
766
+ value: Any,
767
+ *,
768
+ companion_bytes: bytes | None,
769
+ ) -> dict[str, Any]:
770
+ fields = {
771
+ "schema_version",
772
+ "status",
773
+ "artifact_id",
774
+ "relative_path",
775
+ "artifact_provenance",
776
+ "source_artifact_sha256",
777
+ "source_artifact_size_bytes",
778
+ "source_content_sha256",
779
+ "source_content_utf8_bytes",
780
+ "declared_at",
781
+ "record_digest",
782
+ }
783
+ record = _closed(value, "sidecar", fields, code="SOURCE_BINDING_INVALID")
784
+ if record["schema_version"] != SIDECAR_SCHEMA_VERSION:
785
+ _fail(
786
+ "SOURCE_BINDING_INVALID", "sidecar.schema_version", "has the wrong version"
787
+ )
788
+ _sha(
789
+ record["record_digest"], "sidecar.record_digest", code="SOURCE_BINDING_INVALID"
790
+ )
791
+ expected = build_preregistration_artifact(
792
+ status=record["status"],
793
+ artifact_id=record["artifact_id"],
794
+ declared_at=record["declared_at"],
795
+ companion_bytes=companion_bytes,
796
+ relative_path=record["relative_path"],
797
+ artifact_provenance=record["artifact_provenance"],
798
+ )
799
+ if _canonical_bytes(record) != _canonical_bytes(expected):
800
+ _fail(
801
+ "SOURCE_BINDING_INVALID", "sidecar", "does not match deterministic replay"
802
+ )
803
+ return copy.deepcopy(record)
804
+
805
+
806
+ def _manifest_artifact(value: Any, path: str) -> dict[str, Any]:
807
+ fields = {
808
+ "artifact_id",
809
+ "document_kind",
810
+ "relative_path",
811
+ "artifact_state",
812
+ "artifact_provenance",
813
+ "source_artifact_sha256",
814
+ "source_artifact_size_bytes",
815
+ "source_content_sha256",
816
+ "source_content_utf8_bytes",
817
+ }
818
+ artifact = _closed(value, path, fields, code="SOURCE_MANIFEST_INVALID")
819
+ _identifier(
820
+ artifact["artifact_id"], f"{path}.artifact_id", code="SOURCE_MANIFEST_INVALID"
821
+ )
822
+ if not isinstance(artifact["document_kind"], str) or artifact[
823
+ "document_kind"
824
+ ] not in {
825
+ "manuscript",
826
+ "preregistration",
827
+ }:
828
+ _fail("SOURCE_MANIFEST_INVALID", f"{path}.document_kind", "is invalid")
829
+ state = _enum(
830
+ artifact["artifact_state"],
831
+ f"{path}.artifact_state",
832
+ MANIFEST_STATES,
833
+ code="SOURCE_MANIFEST_INVALID",
834
+ )
835
+ if state == "present":
836
+ _relative_path(
837
+ artifact["relative_path"],
838
+ f"{path}.relative_path",
839
+ code="SOURCE_MANIFEST_INVALID",
840
+ )
841
+ raw_sha = _sha(
842
+ artifact["source_artifact_sha256"],
843
+ f"{path}.source_artifact_sha256",
844
+ code="SOURCE_MANIFEST_INVALID",
845
+ )
846
+ content_sha = _sha(
847
+ artifact["source_content_sha256"],
848
+ f"{path}.source_content_sha256",
849
+ code="SOURCE_MANIFEST_INVALID",
850
+ )
851
+ maximum_size = (
852
+ MAX_ACCEPTED_DRAFT_BYTES
853
+ if artifact["document_kind"] == "manuscript"
854
+ else MAX_PREREGISTRATION_BYTES
855
+ )
856
+ raw_size = _integer(
857
+ artifact["source_artifact_size_bytes"],
858
+ f"{path}.source_artifact_size_bytes",
859
+ code="SOURCE_MANIFEST_INVALID",
860
+ minimum=1,
861
+ maximum=maximum_size,
862
+ )
863
+ content_size = _integer(
864
+ artifact["source_content_utf8_bytes"],
865
+ f"{path}.source_content_utf8_bytes",
866
+ code="SOURCE_MANIFEST_INVALID",
867
+ minimum=1,
868
+ maximum=maximum_size,
869
+ )
870
+ if raw_sha != content_sha or raw_size != content_size:
871
+ _fail(
872
+ "SOURCE_MANIFEST_INVALID", path, "UTF-8 V1 raw/content bindings differ"
873
+ )
874
+ allowed_provenance = (
875
+ {"author_provided_manuscript", "synthetic_fixture"}
876
+ if artifact["document_kind"] == "manuscript"
877
+ else {"author_provided_completed_preregistration", "synthetic_fixture"}
878
+ )
879
+ if (
880
+ not isinstance(artifact["artifact_provenance"], str)
881
+ or artifact["artifact_provenance"] not in allowed_provenance
882
+ ):
883
+ _fail(
884
+ "SOURCE_MANIFEST_INVALID", f"{path}.artifact_provenance", "is invalid"
885
+ )
886
+ else:
887
+ if artifact["document_kind"] != "preregistration":
888
+ _fail(
889
+ "SOURCE_MANIFEST_INVALID", path, "accepted manuscript must be present"
890
+ )
891
+ if artifact["relative_path"] is not None:
892
+ _fail("SOURCE_MANIFEST_INVALID", f"{path}.relative_path", "must be null")
893
+ for field in (
894
+ "source_artifact_sha256",
895
+ "source_artifact_size_bytes",
896
+ "source_content_sha256",
897
+ "source_content_utf8_bytes",
898
+ ):
899
+ if artifact[field] is not None:
900
+ _fail("SOURCE_MANIFEST_INVALID", f"{path}.{field}", "must be null")
901
+ if artifact["artifact_provenance"] != "not_provided":
902
+ _fail(
903
+ "SOURCE_MANIFEST_INVALID",
904
+ f"{path}.artifact_provenance",
905
+ "must be not_provided",
906
+ )
907
+ return artifact
908
+
909
+
910
+ def _project_sidecar(record: Mapping[str, Any]) -> dict[str, Any]:
911
+ state = {
912
+ "provided": "present",
913
+ "not_provided": "source_missing",
914
+ "access_failed": "access_failed",
915
+ "retrieval_failed": "retrieval_failed",
916
+ }[record["status"]]
917
+ return {
918
+ "artifact_id": record["artifact_id"],
919
+ "document_kind": "preregistration",
920
+ "relative_path": record["relative_path"],
921
+ "artifact_state": state,
922
+ "artifact_provenance": record["artifact_provenance"],
923
+ "source_artifact_sha256": record["source_artifact_sha256"],
924
+ "source_artifact_size_bytes": record["source_artifact_size_bytes"],
925
+ "source_content_sha256": record["source_content_sha256"],
926
+ "source_content_utf8_bytes": record["source_content_utf8_bytes"],
927
+ }
928
+
929
+
930
+ def validate_source_manifest(
931
+ value: Any,
932
+ *,
933
+ sidecar: Mapping[str, Any],
934
+ accepted_draft_bytes: bytes,
935
+ ) -> tuple[dict[str, Any], dict[str, dict[str, Any]]]:
936
+ fields = {
937
+ "schema_version",
938
+ "manifest_id",
939
+ "accepted_draft_artifact_id",
940
+ "accepted_draft_sha256",
941
+ "artifacts",
942
+ "manifest_digest",
943
+ }
944
+ manifest = _closed(value, "manifest", fields, code="SOURCE_MANIFEST_INVALID")
945
+ if manifest["schema_version"] != MANIFEST_SCHEMA_VERSION:
946
+ _fail(
947
+ "SOURCE_MANIFEST_INVALID",
948
+ "manifest.schema_version",
949
+ "has the wrong version",
950
+ )
951
+ _identifier(
952
+ manifest["manifest_id"], "manifest.manifest_id", code="SOURCE_MANIFEST_INVALID"
953
+ )
954
+ accepted_id = _identifier(
955
+ manifest["accepted_draft_artifact_id"],
956
+ "manifest.accepted_draft_artifact_id",
957
+ code="SOURCE_MANIFEST_INVALID",
958
+ )
959
+ accepted_sha = _sha(
960
+ manifest["accepted_draft_sha256"],
961
+ "manifest.accepted_draft_sha256",
962
+ code="SOURCE_MANIFEST_INVALID",
963
+ )
964
+ _sha(
965
+ manifest["manifest_digest"],
966
+ "manifest.manifest_digest",
967
+ code="SOURCE_MANIFEST_INVALID",
968
+ )
969
+ artifacts = _array(
970
+ manifest["artifacts"],
971
+ "manifest.artifacts",
972
+ code="SOURCE_MANIFEST_INVALID",
973
+ minimum=2,
974
+ maximum=2,
975
+ )
976
+ parsed = [
977
+ _manifest_artifact(item, f"manifest.artifacts[{index}]")
978
+ for index, item in enumerate(artifacts)
979
+ ]
980
+ ids = [item["artifact_id"] for item in parsed]
981
+ if ids != sorted(ids) or len(set(ids)) != 2:
982
+ _fail(
983
+ "SOURCE_MANIFEST_INVALID",
984
+ "manifest.artifacts",
985
+ "must have unique ASCII-sorted IDs",
986
+ )
987
+ by_id = {item["artifact_id"]: item for item in parsed}
988
+ if accepted_id not in by_id:
989
+ _fail(
990
+ "SOURCE_MANIFEST_INVALID",
991
+ "manifest.accepted_draft_artifact_id",
992
+ "does not resolve",
993
+ )
994
+ accepted = by_id[accepted_id]
995
+ if (
996
+ accepted["document_kind"] != "manuscript"
997
+ or accepted["artifact_state"] != "present"
998
+ ):
999
+ _fail(
1000
+ "SOURCE_MANIFEST_INVALID",
1001
+ "manifest",
1002
+ "designated accepted draft is not present manuscript",
1003
+ )
1004
+ if sidecar["artifact_id"] == accepted_id:
1005
+ _fail(
1006
+ "SOURCE_MANIFEST_INVALID",
1007
+ "manifest",
1008
+ "preregistration/manuscript IDs must differ",
1009
+ )
1010
+ if set(by_id) != {accepted_id, sidecar["artifact_id"]}:
1011
+ _fail(
1012
+ "SOURCE_MANIFEST_INVALID",
1013
+ "manifest.artifacts",
1014
+ "must contain exactly accepted draft and sidecar projection",
1015
+ )
1016
+ if by_id[sidecar["artifact_id"]] != _project_sidecar(sidecar):
1017
+ _fail(
1018
+ "SOURCE_MANIFEST_INVALID",
1019
+ "manifest",
1020
+ "preregistration projection differs from sidecar",
1021
+ )
1022
+ actual_sha = _sha256(accepted_draft_bytes)
1023
+ actual_size = len(accepted_draft_bytes)
1024
+ if accepted_sha != actual_sha:
1025
+ _fail(
1026
+ "SOURCE_BINDING_INVALID",
1027
+ "accepted draft",
1028
+ "manifest SHA does not match named bytes",
1029
+ )
1030
+ for field in ("source_artifact_sha256", "source_content_sha256"):
1031
+ if accepted[field] != actual_sha:
1032
+ _fail(
1033
+ "SOURCE_BINDING_INVALID",
1034
+ f"accepted draft {field}",
1035
+ "does not match named bytes",
1036
+ )
1037
+ for field in ("source_artifact_size_bytes", "source_content_utf8_bytes"):
1038
+ if accepted[field] != actual_size:
1039
+ _fail(
1040
+ "SOURCE_BINDING_INVALID",
1041
+ f"accepted draft {field}",
1042
+ "does not match named bytes",
1043
+ )
1044
+ if _digest_without(manifest, "manifest_digest") != manifest["manifest_digest"]:
1045
+ _fail("SOURCE_MANIFEST_INVALID", "manifest.manifest_digest", "does not replay")
1046
+ return copy.deepcopy(manifest), copy.deepcopy(by_id)
1047
+
1048
+
1049
+ def _locator(value: Any, path: str) -> dict[str, str]:
1050
+ locator = _closed(
1051
+ value,
1052
+ path,
1053
+ {"kind", "value", "provenance"},
1054
+ code="DRAFT_CONTRACT_INVALID",
1055
+ )
1056
+ if not isinstance(locator["kind"], str) or locator["kind"] not in {
1057
+ "document",
1058
+ "page",
1059
+ "section",
1060
+ "paragraph",
1061
+ "other",
1062
+ }:
1063
+ _fail("DRAFT_CONTRACT_INVALID", f"{path}.kind", "is invalid")
1064
+ _safe_text(
1065
+ locator["value"],
1066
+ f"{path}.value",
1067
+ code="DRAFT_CONTRACT_INVALID",
1068
+ maximum=500,
1069
+ )
1070
+ if any(
1071
+ unicodedata.category(character) in {"Cc", "Cf", "Zl", "Zp"}
1072
+ for character in locator["value"]
1073
+ ):
1074
+ _fail(
1075
+ "DRAFT_CONTRACT_INVALID",
1076
+ f"{path}.value",
1077
+ "must be a control-free single line",
1078
+ )
1079
+ if locator["provenance"] != LOCATOR_PROVENANCE:
1080
+ _fail("DRAFT_CONTRACT_INVALID", f"{path}.provenance", "is invalid")
1081
+ return copy.deepcopy(locator)
1082
+
1083
+
1084
+ def _rights_pair(sharing_scope: Any, rights_basis: Any, path: str) -> tuple[str, str]:
1085
+ if not isinstance(sharing_scope, str) or not isinstance(rights_basis, str):
1086
+ _fail(
1087
+ "DRAFT_CONTRACT_INVALID",
1088
+ path,
1089
+ "sharing_scope/rights_basis must both be strings",
1090
+ )
1091
+ pair = (sharing_scope, rights_basis)
1092
+ allowed = {
1093
+ ("session_only", "not_assessed"),
1094
+ ("user_confirmed_shareable", "user_declared_authorized"),
1095
+ }
1096
+ if pair not in allowed:
1097
+ _fail(
1098
+ "DRAFT_CONTRACT_INVALID",
1099
+ path,
1100
+ "sharing_scope/rights_basis pairing is invalid",
1101
+ )
1102
+ return pair # type: ignore[return-value]
1103
+
1104
+
1105
+ def _draft_slot(
1106
+ value: Any,
1107
+ path: str,
1108
+ *,
1109
+ expected_role: str,
1110
+ accepted_id: str,
1111
+ preregistration_id: str,
1112
+ ) -> dict[str, Any]:
1113
+ fields = {
1114
+ "logical_role",
1115
+ "artifact_id",
1116
+ "document_locator",
1117
+ "evidence_state",
1118
+ "anchor_value_encoded",
1119
+ "quote_source_span_utf8",
1120
+ "checked_scope_input",
1121
+ "captured_at",
1122
+ "sharing_scope",
1123
+ "rights_basis",
1124
+ }
1125
+ slot = _closed(value, path, fields, code="DRAFT_CONTRACT_INVALID")
1126
+ if slot["logical_role"] != expected_role:
1127
+ _fail(
1128
+ "DRAFT_CONTRACT_INVALID",
1129
+ f"{path}.logical_role",
1130
+ f"must equal {expected_role}",
1131
+ )
1132
+ expected_id = (
1133
+ preregistration_id if expected_role == "preregistration" else accepted_id
1134
+ )
1135
+ artifact_id = _identifier(
1136
+ slot["artifact_id"], f"{path}.artifact_id", code="DRAFT_CONTRACT_INVALID"
1137
+ )
1138
+ if artifact_id != expected_id:
1139
+ _fail(
1140
+ "DRAFT_CONTRACT_INVALID",
1141
+ f"{path}.artifact_id",
1142
+ "does not bind the required artifact",
1143
+ )
1144
+ _locator(slot["document_locator"], f"{path}.document_locator")
1145
+ state = _enum(
1146
+ slot["evidence_state"],
1147
+ f"{path}.evidence_state",
1148
+ EVIDENCE_STATES,
1149
+ code="DRAFT_CONTRACT_INVALID",
1150
+ )
1151
+ encoded = slot["anchor_value_encoded"]
1152
+ span = slot["quote_source_span_utf8"]
1153
+ scope = slot["checked_scope_input"]
1154
+ captured = slot["captured_at"]
1155
+ if state == "agent_extracted":
1156
+ _safe_text(
1157
+ encoded,
1158
+ f"{path}.anchor_value_encoded",
1159
+ code="DRAFT_CONTRACT_INVALID",
1160
+ maximum=MAX_ENCODED_ANCHOR,
1161
+ )
1162
+ _span(span, f"{path}.quote_source_span_utf8", code="DRAFT_CONTRACT_INVALID")
1163
+ _timestamp(captured, f"{path}.captured_at", code="DRAFT_CONTRACT_INVALID")
1164
+ if scope is not None:
1165
+ _fail(
1166
+ "DRAFT_CONTRACT_INVALID", f"{path}.checked_scope_input", "must be null"
1167
+ )
1168
+ elif state == "checked_no_match":
1169
+ if encoded is not None or span is not None or captured is not None:
1170
+ _fail(
1171
+ "DRAFT_CONTRACT_INVALID",
1172
+ path,
1173
+ "checked_no_match carries no quote payload",
1174
+ )
1175
+ block = _closed(
1176
+ scope,
1177
+ f"{path}.checked_scope_input",
1178
+ {"source_span_utf8", "checked_at", "scope_completeness"},
1179
+ code="DRAFT_CONTRACT_INVALID",
1180
+ )
1181
+ _span(
1182
+ block["source_span_utf8"],
1183
+ f"{path}.checked_scope_input.source_span_utf8",
1184
+ code="DRAFT_CONTRACT_INVALID",
1185
+ )
1186
+ _timestamp(
1187
+ block["checked_at"],
1188
+ f"{path}.checked_scope_input.checked_at",
1189
+ code="DRAFT_CONTRACT_INVALID",
1190
+ )
1191
+ if block["scope_completeness"] != SCOPE_COMPLETENESS:
1192
+ _fail(
1193
+ "DRAFT_CONTRACT_INVALID",
1194
+ f"{path}.checked_scope_input.scope_completeness",
1195
+ "is invalid",
1196
+ )
1197
+ else:
1198
+ if (
1199
+ encoded is not None
1200
+ or span is not None
1201
+ or scope is not None
1202
+ or captured is not None
1203
+ ):
1204
+ _fail(
1205
+ "DRAFT_CONTRACT_INVALID",
1206
+ path,
1207
+ "failure state carries quote/scope payload",
1208
+ )
1209
+ sharing, rights = _rights_pair(slot["sharing_scope"], slot["rights_basis"], path)
1210
+ if state != "agent_extracted" and (sharing, rights) != (
1211
+ "session_only",
1212
+ "not_assessed",
1213
+ ):
1214
+ _fail(
1215
+ "DRAFT_CONTRACT_INVALID",
1216
+ path,
1217
+ "non-quote state must use session_only/not_assessed",
1218
+ )
1219
+ return copy.deepcopy(slot)
1220
+
1221
+
1222
+ def _expected_not_checked_reason(pair_kind: str, slots: list[dict[str, Any]]) -> str:
1223
+ states = [slot["evidence_state"] for slot in slots]
1224
+ if "source_missing" in states:
1225
+ return "COUNTERPART_DOCUMENT_MISSING"
1226
+ if "access_failed" in states:
1227
+ return "SOURCE_ACCESS_FAILED"
1228
+ if "retrieval_failed" in states:
1229
+ return "SOURCE_RETRIEVAL_FAILED"
1230
+ if pair_kind == "methods_reported_analyses" and sorted(states) == [
1231
+ "agent_extracted",
1232
+ "not_checked",
1233
+ ]:
1234
+ return "COUNTERPART_SCOPE_NOT_PROVIDED"
1235
+ if pair_kind == "manuscript_preregistration" and states == [
1236
+ "agent_extracted",
1237
+ "agent_extracted",
1238
+ "not_checked",
1239
+ ]:
1240
+ return "COUNTERPART_SCOPE_NOT_PROVIDED"
1241
+ return "PAIR_CHECK_NOT_PERFORMED"
1242
+
1243
+
1244
+ def _performed_combination(
1245
+ observation: Mapping[str, Any], states: tuple[str, ...], path: str
1246
+ ) -> None:
1247
+ pair = observation["pair_kind"]
1248
+ outcome = observation["outcome"]
1249
+ finding = observation["finding_type"]
1250
+ negative = observation["negative_basis"]
1251
+ expected: tuple[str, ...]
1252
+ if outcome == "POTENTIAL_INCONSISTENCY_LOCATED":
1253
+ if pair in {"abstract_results", "discussion_results"}:
1254
+ expected = ("agent_extracted", "agent_extracted")
1255
+ elif pair == "methods_reported_analyses":
1256
+ expected = {
1257
+ "declared_analysis_no_reported_counterpart": (
1258
+ "agent_extracted",
1259
+ "checked_no_match",
1260
+ ),
1261
+ "reported_analysis_no_declared_counterpart": (
1262
+ "checked_no_match",
1263
+ "agent_extracted",
1264
+ ),
1265
+ "analysis_specification_conflict": (
1266
+ "agent_extracted",
1267
+ "agent_extracted",
1268
+ ),
1269
+ }[finding]
1270
+ else:
1271
+ expected = (
1272
+ "agent_extracted",
1273
+ "agent_extracted",
1274
+ "checked_no_match",
1275
+ )
1276
+ elif negative == "disclosed_deviation":
1277
+ expected = ("agent_extracted", "agent_extracted", "agent_extracted")
1278
+ else:
1279
+ expected = ("agent_extracted", "agent_extracted")
1280
+ if states != expected:
1281
+ _fail(
1282
+ "DRAFT_CONTRACT_INVALID",
1283
+ f"{path}.evidence_slots",
1284
+ f"must use states {expected}",
1285
+ )
1286
+
1287
+
1288
+ def _preflight_draft_role_matrix(
1289
+ observations: Sequence[Any],
1290
+ *,
1291
+ manifest: Mapping[str, Any],
1292
+ artifacts: Mapping[str, Mapping[str, Any]],
1293
+ sidecar: Mapping[str, Any],
1294
+ fields: set[str],
1295
+ ) -> None:
1296
+ """Validate every identity/role/source slot before reading any outcome."""
1297
+
1298
+ keys: set[str] = set()
1299
+ pair_counts = {pair: 0 for pair in PAIR_ORDER}
1300
+ accepted_id = manifest["accepted_draft_artifact_id"]
1301
+ for index, item in enumerate(observations):
1302
+ path = f"draft.observations[{index}]"
1303
+ observation = _closed(item, path, fields, code="DRAFT_CONTRACT_INVALID")
1304
+ key = _identifier(
1305
+ observation["observation_key"],
1306
+ f"{path}.observation_key",
1307
+ code="DRAFT_CONTRACT_INVALID",
1308
+ )
1309
+ if key in keys:
1310
+ _fail(
1311
+ "DRAFT_CONTRACT_INVALID",
1312
+ f"{path}.observation_key",
1313
+ "duplicates an earlier key",
1314
+ )
1315
+ keys.add(key)
1316
+ pair = _enum(
1317
+ observation["pair_kind"],
1318
+ f"{path}.pair_kind",
1319
+ frozenset(PAIR_ORDER),
1320
+ code="DRAFT_CONTRACT_INVALID",
1321
+ )
1322
+ pair_counts[pair] += 1
1323
+ roles = PAIR_ROLES[pair]
1324
+ raw_slots = _array(
1325
+ observation["evidence_slots"],
1326
+ f"{path}.evidence_slots",
1327
+ code="DRAFT_CONTRACT_INVALID",
1328
+ minimum=len(roles),
1329
+ maximum=len(roles),
1330
+ )
1331
+ slots = [
1332
+ _draft_slot(
1333
+ slot,
1334
+ f"{path}.evidence_slots[{slot_index}]",
1335
+ expected_role=role,
1336
+ accepted_id=accepted_id,
1337
+ preregistration_id=sidecar["artifact_id"],
1338
+ )
1339
+ for slot_index, (slot, role) in enumerate(
1340
+ zip(raw_slots, roles, strict=True)
1341
+ )
1342
+ ]
1343
+ for slot_index, slot in enumerate(slots):
1344
+ artifact = artifacts[slot["artifact_id"]]
1345
+ state = slot["evidence_state"]
1346
+ if state in {"agent_extracted", "checked_no_match", "not_checked"}:
1347
+ if artifact["artifact_state"] != "present":
1348
+ _fail(
1349
+ "DRAFT_CONTRACT_INVALID",
1350
+ f"{path}.evidence_slots[{slot_index}]",
1351
+ "requires a present artifact",
1352
+ )
1353
+ elif artifact["artifact_state"] != state:
1354
+ _fail(
1355
+ "DRAFT_CONTRACT_INVALID",
1356
+ f"{path}.evidence_slots[{slot_index}]",
1357
+ "state differs from manifest",
1358
+ )
1359
+ if any(count == 0 for count in pair_counts.values()):
1360
+ _fail(
1361
+ "DRAFT_CONTRACT_INVALID",
1362
+ "draft.observations",
1363
+ "must contain all four pair kinds",
1364
+ )
1365
+
1366
+
1367
+ def validate_draft(
1368
+ value: Any,
1369
+ *,
1370
+ manifest: Mapping[str, Any],
1371
+ artifacts: Mapping[str, Mapping[str, Any]],
1372
+ sidecar: Mapping[str, Any],
1373
+ ) -> list[dict[str, Any]]:
1374
+ root = _closed(
1375
+ value,
1376
+ "draft",
1377
+ {"schema_version", "layer", "recorded_at", "observations"},
1378
+ code="DRAFT_CONTRACT_INVALID",
1379
+ )
1380
+ if root["schema_version"] != DRAFT_SCHEMA_VERSION or root["layer"] != LAYER:
1381
+ _fail("DRAFT_CONTRACT_INVALID", "draft", "has wrong schema version or layer")
1382
+ _timestamp(root["recorded_at"], "draft.recorded_at", code="DRAFT_CONTRACT_INVALID")
1383
+ observations = _array(
1384
+ root["observations"],
1385
+ "draft.observations",
1386
+ code="DRAFT_CONTRACT_INVALID",
1387
+ minimum=4,
1388
+ maximum=MAX_OBSERVATIONS,
1389
+ )
1390
+ fields = {
1391
+ "observation_key",
1392
+ "pair_kind",
1393
+ "check_state",
1394
+ "outcome",
1395
+ "finding_type",
1396
+ "negative_basis",
1397
+ "not_checked_reason",
1398
+ "deviation_id",
1399
+ "deviation_domain",
1400
+ "evidence_slots",
1401
+ }
1402
+ _preflight_draft_role_matrix(
1403
+ observations,
1404
+ manifest=manifest,
1405
+ artifacts=artifacts,
1406
+ sidecar=sidecar,
1407
+ fields=fields,
1408
+ )
1409
+ result: list[dict[str, Any]] = []
1410
+ keys: set[str] = set()
1411
+ deviation_ids: set[str] = set()
1412
+ pair_counts = {pair: 0 for pair in PAIR_ORDER}
1413
+ accepted_id = manifest["accepted_draft_artifact_id"]
1414
+ for index, item in enumerate(observations):
1415
+ path = f"draft.observations[{index}]"
1416
+ observation = _closed(item, path, fields, code="DRAFT_CONTRACT_INVALID")
1417
+ key = _identifier(
1418
+ observation["observation_key"],
1419
+ f"{path}.observation_key",
1420
+ code="DRAFT_CONTRACT_INVALID",
1421
+ )
1422
+ if key in keys:
1423
+ _fail(
1424
+ "DRAFT_CONTRACT_INVALID",
1425
+ f"{path}.observation_key",
1426
+ "duplicates an earlier key",
1427
+ )
1428
+ keys.add(key)
1429
+ pair = _enum(
1430
+ observation["pair_kind"],
1431
+ f"{path}.pair_kind",
1432
+ frozenset(PAIR_ORDER),
1433
+ code="DRAFT_CONTRACT_INVALID",
1434
+ )
1435
+ pair_counts[pair] += 1
1436
+ roles = PAIR_ROLES[pair]
1437
+ raw_slots = _array(
1438
+ observation["evidence_slots"],
1439
+ f"{path}.evidence_slots",
1440
+ code="DRAFT_CONTRACT_INVALID",
1441
+ minimum=len(roles),
1442
+ maximum=len(roles),
1443
+ )
1444
+ slots = [
1445
+ _draft_slot(
1446
+ slot,
1447
+ f"{path}.evidence_slots[{slot_index}]",
1448
+ expected_role=role,
1449
+ accepted_id=accepted_id,
1450
+ preregistration_id=sidecar["artifact_id"],
1451
+ )
1452
+ for slot_index, (slot, role) in enumerate(
1453
+ zip(raw_slots, roles, strict=True)
1454
+ )
1455
+ ]
1456
+ for slot_index, slot in enumerate(slots):
1457
+ artifact = artifacts[slot["artifact_id"]]
1458
+ state = slot["evidence_state"]
1459
+ if state in {"agent_extracted", "checked_no_match", "not_checked"}:
1460
+ if artifact["artifact_state"] != "present":
1461
+ _fail(
1462
+ "DRAFT_CONTRACT_INVALID",
1463
+ f"{path}.evidence_slots[{slot_index}]",
1464
+ "requires a present artifact",
1465
+ )
1466
+ elif artifact["artifact_state"] != state:
1467
+ _fail(
1468
+ "DRAFT_CONTRACT_INVALID",
1469
+ f"{path}.evidence_slots[{slot_index}]",
1470
+ "state differs from manifest",
1471
+ )
1472
+ check_state = observation["check_state"]
1473
+ if not isinstance(check_state, str) or check_state not in {
1474
+ "performed",
1475
+ "not_checked",
1476
+ }:
1477
+ _fail("DRAFT_CONTRACT_INVALID", f"{path}.check_state", "is invalid")
1478
+ states = tuple(slot["evidence_state"] for slot in slots)
1479
+ if check_state == "performed":
1480
+ if (
1481
+ not isinstance(observation["outcome"], str)
1482
+ or observation["outcome"] not in OUTCOMES
1483
+ ):
1484
+ _fail("DRAFT_CONTRACT_INVALID", f"{path}.outcome", "is invalid")
1485
+ if observation["not_checked_reason"] is not None:
1486
+ _fail(
1487
+ "DRAFT_CONTRACT_INVALID",
1488
+ f"{path}.not_checked_reason",
1489
+ "must be null",
1490
+ )
1491
+ if observation["outcome"] == "POTENTIAL_INCONSISTENCY_LOCATED":
1492
+ if (
1493
+ not isinstance(observation["finding_type"], str)
1494
+ or observation["finding_type"] not in FINDING_TYPES[pair]
1495
+ or observation["negative_basis"] is not None
1496
+ ):
1497
+ _fail(
1498
+ "DRAFT_CONTRACT_INVALID",
1499
+ path,
1500
+ "positive outcome fields are invalid",
1501
+ )
1502
+ else:
1503
+ if (
1504
+ observation["finding_type"] is not None
1505
+ or not isinstance(observation["negative_basis"], str)
1506
+ or observation["negative_basis"] not in NEGATIVE_BASES
1507
+ ):
1508
+ _fail(
1509
+ "DRAFT_CONTRACT_INVALID",
1510
+ path,
1511
+ "no-listed outcome fields are invalid",
1512
+ )
1513
+ negative = observation["negative_basis"]
1514
+ allowed = (
1515
+ (
1516
+ negative == "legitimate_compression"
1517
+ and pair == "abstract_results"
1518
+ )
1519
+ or (
1520
+ negative == "same_rung_rewording"
1521
+ and pair in {"abstract_results", "discussion_results"}
1522
+ )
1523
+ or (
1524
+ negative == "disclosed_deviation"
1525
+ and pair == "manuscript_preregistration"
1526
+ )
1527
+ or (
1528
+ negative == "other_no_listed_observation"
1529
+ and pair != "manuscript_preregistration"
1530
+ )
1531
+ )
1532
+ if not allowed:
1533
+ _fail(
1534
+ "DRAFT_CONTRACT_INVALID",
1535
+ f"{path}.negative_basis",
1536
+ "is invalid for pair",
1537
+ )
1538
+ _performed_combination(observation, states, path)
1539
+ else:
1540
+ if any(
1541
+ observation[field] is not None
1542
+ for field in ("outcome", "finding_type", "negative_basis")
1543
+ ):
1544
+ _fail(
1545
+ "DRAFT_CONTRACT_INVALID",
1546
+ path,
1547
+ "not_checked carries no semantic outcome",
1548
+ )
1549
+ reason = _enum(
1550
+ observation["not_checked_reason"],
1551
+ f"{path}.not_checked_reason",
1552
+ NOT_CHECKED_REASONS,
1553
+ code="DRAFT_CONTRACT_INVALID",
1554
+ )
1555
+ if not any(state in FAILURE_STATES for state in states):
1556
+ _fail(
1557
+ "DRAFT_CONTRACT_INVALID",
1558
+ path,
1559
+ "not_checked requires a failure slot",
1560
+ )
1561
+ if reason != _expected_not_checked_reason(pair, slots):
1562
+ _fail(
1563
+ "DRAFT_CONTRACT_INVALID",
1564
+ f"{path}.not_checked_reason",
1565
+ "contradicts slot-state precedence",
1566
+ )
1567
+ if pair == "manuscript_preregistration" and check_state == "performed":
1568
+ deviation_id = _identifier(
1569
+ observation["deviation_id"],
1570
+ f"{path}.deviation_id",
1571
+ code="DRAFT_CONTRACT_INVALID",
1572
+ )
1573
+ if deviation_id in deviation_ids:
1574
+ _fail(
1575
+ "DRAFT_CONTRACT_INVALID",
1576
+ f"{path}.deviation_id",
1577
+ "must be globally unique",
1578
+ )
1579
+ deviation_ids.add(deviation_id)
1580
+ _enum(
1581
+ observation["deviation_domain"],
1582
+ f"{path}.deviation_domain",
1583
+ DEVIATION_DOMAINS,
1584
+ code="DRAFT_CONTRACT_INVALID",
1585
+ )
1586
+ elif (
1587
+ observation["deviation_id"] is not None
1588
+ or observation["deviation_domain"] is not None
1589
+ ):
1590
+ _fail("DRAFT_CONTRACT_INVALID", path, "deviation fields must be null")
1591
+ normalized = copy.deepcopy(observation)
1592
+ normalized["evidence_slots"] = slots
1593
+ result.append(normalized)
1594
+ if any(count == 0 for count in pair_counts.values()):
1595
+ _fail(
1596
+ "DRAFT_CONTRACT_INVALID",
1597
+ "draft.observations",
1598
+ "must contain all four pair kinds",
1599
+ )
1600
+ return result
1601
+
1602
+
1603
+ def _source_block(artifact: Mapping[str, Any]) -> dict[str, Any]:
1604
+ return {
1605
+ "artifact_id": artifact["artifact_id"],
1606
+ "document_kind": artifact["document_kind"],
1607
+ "relative_path": artifact["relative_path"],
1608
+ "source_artifact_sha256": artifact["source_artifact_sha256"],
1609
+ "source_artifact_size_bytes": artifact["source_artifact_size_bytes"],
1610
+ "source_content_sha256": artifact["source_content_sha256"],
1611
+ "source_content_utf8_bytes": artifact["source_content_utf8_bytes"],
1612
+ }
1613
+
1614
+
1615
+ def _slice_utf8(raw: bytes, span: Mapping[str, int], path: str) -> tuple[bytes, str]:
1616
+ start = span["start"]
1617
+ end = span["end"]
1618
+ if end > len(raw):
1619
+ _fail("EVIDENCE_REPLAY_INVALID", path, "extends beyond bound source bytes")
1620
+ payload = raw[start:end]
1621
+ try:
1622
+ text = payload.decode("utf-8", errors="strict")
1623
+ except UnicodeError as exc:
1624
+ _fail("EVIDENCE_REPLAY_INVALID", path, f"splits a UTF-8 sequence: {exc}")
1625
+ return payload, text
1626
+
1627
+
1628
+ def _derive_slot(
1629
+ slot: Mapping[str, Any],
1630
+ *,
1631
+ artifact: Mapping[str, Any],
1632
+ source_bytes: bytes | None,
1633
+ path: str,
1634
+ ) -> dict[str, Any]:
1635
+ state = slot["evidence_state"]
1636
+ anchor: dict[str, Any]
1637
+ excerpt: dict[str, Any]
1638
+ checked_scope: dict[str, Any] | None = None
1639
+ if state == "agent_extracted":
1640
+ if source_bytes is None:
1641
+ _fail("EVIDENCE_REPLAY_INVALID", path, "quote source is unavailable")
1642
+ span = _span(
1643
+ slot["quote_source_span_utf8"],
1644
+ f"{path}.quote_source_span_utf8",
1645
+ code="EVIDENCE_REPLAY_INVALID",
1646
+ )
1647
+ payload, replayed = _slice_utf8(
1648
+ source_bytes, span, f"{path}.quote_source_span_utf8"
1649
+ )
1650
+ decoded = strict_percent_decode(slot["anchor_value_encoded"])
1651
+ _safe_text(
1652
+ decoded,
1653
+ f"{path}.anchor_value_encoded decoded",
1654
+ code="EVIDENCE_REPLAY_INVALID",
1655
+ maximum=MAX_EXTERNAL_CODEPOINTS,
1656
+ )
1657
+ word_count = len(decoded.split())
1658
+ if word_count > MAX_EXTERNAL_WORDS:
1659
+ _fail(
1660
+ "EVIDENCE_REPLAY_INVALID",
1661
+ f"{path}.anchor_value_encoded",
1662
+ f"exceeds {MAX_EXTERNAL_WORDS} words by whitespace split",
1663
+ )
1664
+ if decoded != replayed:
1665
+ _fail(
1666
+ "EVIDENCE_REPLAY_INVALID",
1667
+ path,
1668
+ "decoded quote does not equal exact source span",
1669
+ )
1670
+ anchor = {
1671
+ "kind": "quote",
1672
+ "value_encoded": slot["anchor_value_encoded"],
1673
+ "value_decoded": decoded,
1674
+ }
1675
+ excerpt = {
1676
+ "text": decoded,
1677
+ "excerpt_sha256": _sha256(payload),
1678
+ "source_span_utf8": span,
1679
+ "captured_at": slot["captured_at"],
1680
+ }
1681
+ else:
1682
+ anchor = {"kind": "none", "value_encoded": "", "value_decoded": ""}
1683
+ excerpt = {
1684
+ "text": None,
1685
+ "excerpt_sha256": None,
1686
+ "source_span_utf8": None,
1687
+ "captured_at": None,
1688
+ }
1689
+ if state == "checked_no_match":
1690
+ if source_bytes is None:
1691
+ _fail(
1692
+ "EVIDENCE_REPLAY_INVALID",
1693
+ path,
1694
+ "checked scope source is unavailable",
1695
+ )
1696
+ block = slot["checked_scope_input"]
1697
+ span = _span(
1698
+ block["source_span_utf8"],
1699
+ f"{path}.checked_scope_input.source_span_utf8",
1700
+ code="EVIDENCE_REPLAY_INVALID",
1701
+ )
1702
+ payload, scope_text = _slice_utf8(
1703
+ source_bytes,
1704
+ span,
1705
+ f"{path}.checked_scope_input.source_span_utf8",
1706
+ )
1707
+ if not scope_text.strip():
1708
+ _fail(
1709
+ "EVIDENCE_REPLAY_INVALID", path, "checked scope must not be blank"
1710
+ )
1711
+ checked_scope = {
1712
+ "source_span_utf8": span,
1713
+ "scope_sha256": _sha256(payload),
1714
+ "scope_utf8_bytes": len(payload),
1715
+ "checked_at": block["checked_at"],
1716
+ "completeness_provenance": block["scope_completeness"],
1717
+ }
1718
+ sharing_scope, rights_basis = _rights_pair(
1719
+ slot["sharing_scope"],
1720
+ slot["rights_basis"],
1721
+ path,
1722
+ )
1723
+ return {
1724
+ "logical_role": slot["logical_role"],
1725
+ "source": _source_block(artifact),
1726
+ "document_locator": copy.deepcopy(slot["document_locator"]),
1727
+ "evidence_state": state,
1728
+ "anchor": anchor,
1729
+ "excerpt": excerpt,
1730
+ "checked_scope": checked_scope,
1731
+ "cache": {"status": "not_used", "key_sha256": None},
1732
+ "content_handling": {
1733
+ "contains_external_text": state == "agent_extracted",
1734
+ "sharing_scope": sharing_scope,
1735
+ "rights_basis": rights_basis,
1736
+ },
1737
+ }
1738
+
1739
+
1740
+ def _derive_evidence_row(
1741
+ observation: Mapping[str, Any],
1742
+ *,
1743
+ row_id: str,
1744
+ artifacts: Mapping[str, Mapping[str, Any]],
1745
+ sources: Mapping[str, bytes],
1746
+ ) -> dict[str, Any]:
1747
+ evidence_slots = [
1748
+ _derive_slot(
1749
+ slot,
1750
+ artifact=artifacts[slot["artifact_id"]],
1751
+ source_bytes=sources.get(slot["artifact_id"]),
1752
+ path=f"observation.{observation['observation_key']}.evidence_slots[{index}]",
1753
+ )
1754
+ for index, slot in enumerate(observation["evidence_slots"])
1755
+ ]
1756
+ row: dict[str, Any] = {
1757
+ "schema_version": EVIDENCE_SCHEMA_VERSION,
1758
+ "surface": SURFACE,
1759
+ "row_id": row_id,
1760
+ "pair_kind": observation["pair_kind"],
1761
+ "observation_key": observation["observation_key"],
1762
+ "deviation_id": observation["deviation_id"],
1763
+ "deviation_domain": observation["deviation_domain"],
1764
+ "evidence_slots": evidence_slots,
1765
+ "row_sha256": "",
1766
+ }
1767
+ row["row_sha256"] = _digest_without(row, "row_sha256")
1768
+ return row
1769
+
1770
+
1771
+ def _source_bundle_digest(
1772
+ *,
1773
+ manifest_sha256: str,
1774
+ sidecar_sha256: str,
1775
+ sidecar: Mapping[str, Any],
1776
+ manifest: Mapping[str, Any],
1777
+ ) -> str:
1778
+ framing = {
1779
+ "source_manifest_sha256": manifest_sha256,
1780
+ "preregistration_record_sha256": sidecar_sha256,
1781
+ "preregistration_record_digest": sidecar["record_digest"],
1782
+ "accepted_draft_artifact_id": manifest["accepted_draft_artifact_id"],
1783
+ "accepted_draft_sha256": manifest["accepted_draft_sha256"],
1784
+ "artifacts": [copy.deepcopy(item) for item in manifest["artifacts"]],
1785
+ }
1786
+ return _sha256(_canonical_bytes(framing))
1787
+
1788
+
1789
+ def _prepare_inputs(
1790
+ draft: Any,
1791
+ manifest: Any,
1792
+ sidecar: Any,
1793
+ *,
1794
+ accepted_draft_bytes: bytes,
1795
+ preregistration_bytes: bytes | None,
1796
+ ) -> tuple[
1797
+ list[dict[str, Any]],
1798
+ dict[str, Any],
1799
+ dict[str, Any],
1800
+ dict[str, dict[str, Any]],
1801
+ dict[str, bytes],
1802
+ ]:
1803
+ accepted_text = _strict_accepted_draft(accepted_draft_bytes)
1804
+ del accepted_text
1805
+ if preregistration_bytes is not None:
1806
+ _strict_source(
1807
+ preregistration_bytes,
1808
+ label="preregistration companion",
1809
+ maximum=MAX_PREREGISTRATION_BYTES,
1810
+ )
1811
+ total = len(accepted_draft_bytes) + len(preregistration_bytes or b"")
1812
+ if total > MAX_TOTAL_SOURCE_BYTES:
1813
+ _fail("RESOURCE_LIMIT", "sources", "exceed 72 MiB aggregate")
1814
+ normalized_sidecar = validate_preregistration_artifact(
1815
+ sidecar,
1816
+ companion_bytes=preregistration_bytes,
1817
+ )
1818
+ normalized_manifest, artifacts = validate_source_manifest(
1819
+ manifest,
1820
+ sidecar=normalized_sidecar,
1821
+ accepted_draft_bytes=accepted_draft_bytes,
1822
+ )
1823
+ observations = validate_draft(
1824
+ draft,
1825
+ manifest=normalized_manifest,
1826
+ artifacts=artifacts,
1827
+ sidecar=normalized_sidecar,
1828
+ )
1829
+ sources = {normalized_manifest["accepted_draft_artifact_id"]: accepted_draft_bytes}
1830
+ if preregistration_bytes is not None:
1831
+ sources[normalized_sidecar["artifact_id"]] = preregistration_bytes
1832
+ return observations, normalized_manifest, normalized_sidecar, artifacts, sources
1833
+
1834
+
1835
+ def finalize_advisory(
1836
+ draft: Any,
1837
+ manifest: Any,
1838
+ sidecar: Any,
1839
+ *,
1840
+ accepted_draft_bytes: bytes,
1841
+ preregistration_bytes: bytes | None,
1842
+ draft_raw: bytes | None = None,
1843
+ manifest_raw: bytes | None = None,
1844
+ sidecar_raw: bytes | None = None,
1845
+ ) -> dict[str, Any]:
1846
+ """Build the canonical final carrier from all exact named inputs."""
1847
+
1848
+ draft_bytes = _binding_bytes(
1849
+ draft,
1850
+ draft_raw,
1851
+ MAX_DRAFT_BYTES,
1852
+ code="DRAFT_CONTRACT_INVALID",
1853
+ path="advisory draft",
1854
+ )
1855
+ manifest_bytes = _binding_bytes(
1856
+ manifest,
1857
+ manifest_raw,
1858
+ MAX_MANIFEST_BYTES,
1859
+ code="SOURCE_MANIFEST_INVALID",
1860
+ path="source manifest",
1861
+ )
1862
+ sidecar_bytes = _binding_bytes(
1863
+ sidecar,
1864
+ sidecar_raw,
1865
+ MAX_SIDECAR_BYTES,
1866
+ code="SOURCE_BINDING_INVALID",
1867
+ path="preregistration record",
1868
+ )
1869
+ observations, normalized_manifest, normalized_sidecar, artifacts, sources = (
1870
+ _prepare_inputs(
1871
+ draft,
1872
+ manifest,
1873
+ sidecar,
1874
+ accepted_draft_bytes=accepted_draft_bytes,
1875
+ preregistration_bytes=preregistration_bytes,
1876
+ )
1877
+ )
1878
+ draft_sha = _sha256(draft_bytes)
1879
+ manifest_sha = _sha256(manifest_bytes)
1880
+ sidecar_sha = _sha256(sidecar_bytes)
1881
+ source_bundle_sha = _source_bundle_digest(
1882
+ manifest_sha256=manifest_sha,
1883
+ sidecar_sha256=sidecar_sha,
1884
+ sidecar=normalized_sidecar,
1885
+ manifest=normalized_manifest,
1886
+ )
1887
+ report_identity_payload = {
1888
+ "draft_sha256": draft_sha,
1889
+ "source_manifest_sha256": manifest_sha,
1890
+ "preregistration_record_sha256": sidecar_sha,
1891
+ "preregistration_record_digest": normalized_sidecar["record_digest"],
1892
+ "accepted_draft_artifact_id": normalized_manifest["accepted_draft_artifact_id"],
1893
+ "accepted_draft_sha256": normalized_manifest["accepted_draft_sha256"],
1894
+ "source_bundle_sha256": source_bundle_sha,
1895
+ }
1896
+ report_id = "XDOC-" + _sha256(_canonical_bytes(report_identity_payload))[:24]
1897
+ ordered = sorted(
1898
+ observations,
1899
+ key=lambda item: (PAIR_ORDER.index(item["pair_kind"]), item["observation_key"]),
1900
+ )
1901
+ grouped: dict[str, list[dict[str, Any]]] = {pair: [] for pair in PAIR_ORDER}
1902
+ for ordinal, observation in enumerate(ordered, start=1):
1903
+ advisory_id = f"ADV-XDOC-{ordinal:06d}"
1904
+ row_id = f"EVR-XDOC-{ordinal:06d}"
1905
+ row = _derive_evidence_row(
1906
+ observation,
1907
+ row_id=row_id,
1908
+ artifacts=artifacts,
1909
+ sources=sources,
1910
+ )
1911
+ grouped[observation["pair_kind"]].append(
1912
+ {
1913
+ "advisory_id": advisory_id,
1914
+ "observation_key": observation["observation_key"],
1915
+ "pair_kind": observation["pair_kind"],
1916
+ "check_state": observation["check_state"],
1917
+ "outcome": observation["outcome"],
1918
+ "finding_type": observation["finding_type"],
1919
+ "negative_basis": observation["negative_basis"],
1920
+ "not_checked_reason": observation["not_checked_reason"],
1921
+ "deviation_id": observation["deviation_id"],
1922
+ "deviation_domain": observation["deviation_domain"],
1923
+ "semantic_provenance": SEMANTIC_PROVENANCE,
1924
+ "evidence_row": row,
1925
+ }
1926
+ )
1927
+ report: dict[str, Any] = {
1928
+ "schema_version": REPORT_SCHEMA_VERSION,
1929
+ "layer": LAYER,
1930
+ "evaluation_status": EVALUATION_STATUS,
1931
+ "report_id": report_id,
1932
+ "input_binding": {
1933
+ "draft_schema_version": DRAFT_SCHEMA_VERSION,
1934
+ "draft_sha256": draft_sha,
1935
+ "source_manifest_schema_version": MANIFEST_SCHEMA_VERSION,
1936
+ "source_manifest_sha256": manifest_sha,
1937
+ "preregistration_record_schema_version": SIDECAR_SCHEMA_VERSION,
1938
+ "preregistration_record_sha256": sidecar_sha,
1939
+ "preregistration_record_digest": normalized_sidecar["record_digest"],
1940
+ "accepted_draft_artifact_id": normalized_manifest[
1941
+ "accepted_draft_artifact_id"
1942
+ ],
1943
+ "accepted_draft_sha256": normalized_manifest["accepted_draft_sha256"],
1944
+ "source_bundle_sha256": source_bundle_sha,
1945
+ },
1946
+ "pair_results": [
1947
+ {"pair_kind": pair, "observations": grouped[pair]} for pair in PAIR_ORDER
1948
+ ],
1949
+ "boundary": copy.deepcopy(BOUNDARY),
1950
+ "report_digest": "",
1951
+ }
1952
+ report["report_digest"] = _digest_without(report, "report_digest")
1953
+ if len(_canonical_bytes(report)) > MAX_FINAL_BYTES:
1954
+ _fail("RESOURCE_LIMIT", "final advisory", "canonical output exceeds 32 MiB")
1955
+ return report
1956
+
1957
+
1958
+ def validate_advisory(
1959
+ advisory: Any,
1960
+ draft: Any,
1961
+ manifest: Any,
1962
+ sidecar: Any,
1963
+ *,
1964
+ advisory_raw: bytes,
1965
+ accepted_draft_bytes: bytes,
1966
+ preregistration_bytes: bytes | None,
1967
+ draft_raw: bytes | None = None,
1968
+ manifest_raw: bytes | None = None,
1969
+ sidecar_raw: bytes | None = None,
1970
+ ) -> None:
1971
+ expected = finalize_advisory(
1972
+ draft,
1973
+ manifest,
1974
+ sidecar,
1975
+ accepted_draft_bytes=accepted_draft_bytes,
1976
+ preregistration_bytes=preregistration_bytes,
1977
+ draft_raw=draft_raw,
1978
+ manifest_raw=manifest_raw,
1979
+ sidecar_raw=sidecar_raw,
1980
+ )
1981
+ _require_exact_final(advisory, advisory_raw, expected)
1982
+
1983
+
1984
+ def _require_exact_final(advisory: Any, advisory_raw: bytes, expected: Any) -> None:
1985
+ if not isinstance(advisory_raw, bytes):
1986
+ _fail("FINAL_ARTIFACT_INVALID", "advisory", "raw binding must be bytes")
1987
+ if len(advisory_raw) > MAX_FINAL_BYTES:
1988
+ _fail("RESOURCE_LIMIT", "final advisory", "exceeds 32 MiB")
1989
+ parsed = _strict_json_bytes(
1990
+ advisory_raw,
1991
+ code="FINAL_ARTIFACT_INVALID",
1992
+ path="final advisory",
1993
+ )
1994
+ expected_bytes = _canonical_bytes(expected)
1995
+ if (
1996
+ advisory_raw != expected_bytes
1997
+ or _canonical_bytes(parsed) != expected_bytes
1998
+ or _canonical_bytes(advisory) != expected_bytes
1999
+ ):
2000
+ _fail(
2001
+ "FINAL_ARTIFACT_INVALID",
2002
+ "advisory",
2003
+ "is not the exact canonical deterministic replay",
2004
+ )
2005
+
2006
+
2007
+ def _markdown_inert(value: Any) -> str:
2008
+ if value is None:
2009
+ return "NOT CHECKED"
2010
+ result: list[str] = []
2011
+ for character in str(value):
2012
+ if character.isascii() and (character.isalnum() or character == " "):
2013
+ result.append(character)
2014
+ else:
2015
+ result.append(f"&#{ord(character)};")
2016
+ return "".join(result)
2017
+
2018
+
2019
+ def paginate(
2020
+ items: Sequence[Any], *, page: int, page_size: int
2021
+ ) -> tuple[list[Any], int]:
2022
+ if isinstance(page, bool) or not isinstance(page, int) or page < 1:
2023
+ _fail("FINAL_ARTIFACT_INVALID", "page", "must be a positive integer")
2024
+ if (
2025
+ isinstance(page_size, bool)
2026
+ or not isinstance(page_size, int)
2027
+ or page_size < 1
2028
+ or page_size > MAX_PAGE_SIZE
2029
+ ):
2030
+ _fail("FINAL_ARTIFACT_INVALID", "page_size", "must be within 1..25")
2031
+ total_pages = max(1, (len(items) + page_size - 1) // page_size)
2032
+ if page > total_pages:
2033
+ _fail("FINAL_ARTIFACT_INVALID", "page", f"must not exceed {total_pages}")
2034
+ start = (page - 1) * page_size
2035
+ return list(items[start : start + page_size]), total_pages
2036
+
2037
+
2038
+ def render_advisory(
2039
+ advisory: Mapping[str, Any], *, page: int = 1, page_size: int = 25
2040
+ ) -> str:
2041
+ observations = [
2042
+ observation
2043
+ for pair_result in advisory["pair_results"]
2044
+ for observation in pair_result["observations"]
2045
+ ]
2046
+ visible, total_pages = paginate(observations, page=page, page_size=page_size)
2047
+ report_sha = _sha256(_canonical_bytes(advisory))
2048
+ lines = [
2049
+ f"# Cross-document consistency advisory — Page {page}/{total_pages}",
2050
+ "",
2051
+ "Layer: LLM-ADVISORY",
2052
+ "Evaluation status: UNMEASURED",
2053
+ f"Report ID: {_markdown_inert(advisory['report_id'])}",
2054
+ f"Report SHA-256: {report_sha}",
2055
+ f"Rows: {len(observations)} total; {len(visible)} on this page",
2056
+ "",
2057
+ "NO LISTED INCONSISTENCY LOCATED — not proof of agreement, completeness, or a clean document.",
2058
+ "",
2059
+ "| Advisory | Pair | State | Observation | Left | Right | Disclosure | Result | Evidence |",
2060
+ "|---|---|---|---|---|---|---|---|---|",
2061
+ ]
2062
+ for observation in visible:
2063
+ row = observation["evidence_row"]
2064
+ slots = row["evidence_slots"]
2065
+ display_slots: list[str] = []
2066
+ for slot in slots:
2067
+ locator = slot["document_locator"]
2068
+ if slot["evidence_state"] == "agent_extracted":
2069
+ evidence = slot["anchor"]["value_decoded"]
2070
+ elif slot["evidence_state"] == "checked_no_match":
2071
+ evidence = "CHECKED NO MATCH"
2072
+ else:
2073
+ evidence = "NOT CHECKED"
2074
+ display_slots.append(
2075
+ f"{slot['logical_role']} @ {locator['kind']}: {locator['value']} — "
2076
+ f"{slot['evidence_state']} — {evidence}"
2077
+ )
2078
+ while len(display_slots) < 3:
2079
+ display_slots.append("not applicable")
2080
+ if observation["outcome"] == "NO_LISTED_INCONSISTENCY_LOCATED":
2081
+ result = f"{observation['outcome']} — {observation['negative_basis']}"
2082
+ else:
2083
+ result = (
2084
+ observation["finding_type"]
2085
+ or observation["not_checked_reason"]
2086
+ or observation["outcome"]
2087
+ )
2088
+ evidence_ref = f"{row['row_id']} / {row['row_sha256']}"
2089
+ values = (
2090
+ observation["advisory_id"],
2091
+ observation["pair_kind"],
2092
+ observation["check_state"],
2093
+ observation["observation_key"],
2094
+ display_slots[0],
2095
+ display_slots[1],
2096
+ display_slots[2],
2097
+ result,
2098
+ evidence_ref,
2099
+ )
2100
+ lines.append(
2101
+ "| " + " | ".join(_markdown_inert(value) for value in values) + " |"
2102
+ )
2103
+ lines.append("")
2104
+ if page > 1:
2105
+ lines.append(f"Previous: `--page {page - 1} --page-size {page_size}`")
2106
+ if page < total_pages:
2107
+ lines.append(f"Next: `--page {page + 1} --page-size {page_size}`")
2108
+ lines.append("")
2109
+ return "\n".join(lines)
2110
+
2111
+
2112
+ def _load_runtime_inputs(args: argparse.Namespace) -> dict[str, Any]:
2113
+ sidecar, sidecar_raw = _load_json(
2114
+ args.preregistration_record,
2115
+ MAX_SIDECAR_BYTES,
2116
+ code="SOURCE_BINDING_INVALID",
2117
+ label="preregistration record",
2118
+ )
2119
+ companion_bytes = (
2120
+ _read_named_bytes(
2121
+ args.preregistration_companion,
2122
+ MAX_PREREGISTRATION_BYTES,
2123
+ label="preregistration companion",
2124
+ unreadable_code="SOURCE_BINDING_INVALID",
2125
+ )
2126
+ if args.preregistration_companion is not None
2127
+ else None
2128
+ )
2129
+ accepted_bytes = _read_named_bytes(
2130
+ args.accepted_draft,
2131
+ MAX_ACCEPTED_DRAFT_BYTES,
2132
+ label="accepted draft",
2133
+ )
2134
+ manifest, manifest_raw = _load_json(
2135
+ args.manifest,
2136
+ MAX_MANIFEST_BYTES,
2137
+ code="SOURCE_MANIFEST_INVALID",
2138
+ label="source manifest",
2139
+ )
2140
+ # Establish all source/sidecar/manifest bindings before parsing semantic outcomes.
2141
+ _strict_accepted_draft(accepted_bytes)
2142
+ if companion_bytes is not None:
2143
+ _strict_source(
2144
+ companion_bytes,
2145
+ label="preregistration companion",
2146
+ maximum=MAX_PREREGISTRATION_BYTES,
2147
+ )
2148
+ if len(accepted_bytes) + len(companion_bytes or b"") > MAX_TOTAL_SOURCE_BYTES:
2149
+ _fail("RESOURCE_LIMIT", "sources", "exceed 72 MiB aggregate")
2150
+ normalized_sidecar = validate_preregistration_artifact(
2151
+ sidecar,
2152
+ companion_bytes=companion_bytes,
2153
+ )
2154
+ validate_source_manifest(
2155
+ manifest,
2156
+ sidecar=normalized_sidecar,
2157
+ accepted_draft_bytes=accepted_bytes,
2158
+ )
2159
+ draft, draft_raw = _load_json(
2160
+ args.draft,
2161
+ MAX_DRAFT_BYTES,
2162
+ code="DRAFT_CONTRACT_INVALID",
2163
+ label="advisory draft",
2164
+ )
2165
+ return {
2166
+ "sidecar": sidecar,
2167
+ "sidecar_raw": sidecar_raw,
2168
+ "companion_bytes": companion_bytes,
2169
+ "accepted_bytes": accepted_bytes,
2170
+ "manifest": manifest,
2171
+ "manifest_raw": manifest_raw,
2172
+ "draft": draft,
2173
+ "draft_raw": draft_raw,
2174
+ }
2175
+
2176
+
2177
+ def _expected_from_loaded(loaded: Mapping[str, Any]) -> dict[str, Any]:
2178
+ return finalize_advisory(
2179
+ loaded["draft"],
2180
+ loaded["manifest"],
2181
+ loaded["sidecar"],
2182
+ accepted_draft_bytes=loaded["accepted_bytes"],
2183
+ preregistration_bytes=loaded["companion_bytes"],
2184
+ draft_raw=loaded["draft_raw"],
2185
+ manifest_raw=loaded["manifest_raw"],
2186
+ sidecar_raw=loaded["sidecar_raw"],
2187
+ )
2188
+
2189
+
2190
+ def _parser() -> argparse.ArgumentParser:
2191
+ parser = _ClosedArgumentParser(description=__doc__, allow_abbrev=False)
2192
+ commands = parser.add_subparsers(dest="command", required=True)
2193
+
2194
+ sidecar = commands.add_parser("build-preregistration-artifact", allow_abbrev=False)
2195
+ sidecar.add_argument("--status", required=True, choices=sorted(SIDECAR_STATES))
2196
+ sidecar.add_argument("--artifact-id", required=True)
2197
+ sidecar.add_argument("--declared-at", required=True)
2198
+ sidecar.add_argument("--relative-path")
2199
+ sidecar.add_argument("--artifact-provenance")
2200
+ sidecar.add_argument("--companion", type=Path)
2201
+ sidecar.add_argument("--output", type=Path, required=True)
2202
+
2203
+ for name in ("finalize", "validate", "render"):
2204
+ command = commands.add_parser(name, allow_abbrev=False)
2205
+ command.add_argument("--draft", type=Path, required=True)
2206
+ command.add_argument("--manifest", type=Path, required=True)
2207
+ command.add_argument("--preregistration-record", type=Path, required=True)
2208
+ command.add_argument("--preregistration-companion", type=Path)
2209
+ command.add_argument("--accepted-draft", type=Path, required=True)
2210
+ if name in {"validate", "render"}:
2211
+ command.add_argument("--advisory", type=Path, required=True)
2212
+ if name in {"finalize", "render"}:
2213
+ command.add_argument("--output", type=Path)
2214
+ if name == "render":
2215
+ command.add_argument("--page", type=int, default=1)
2216
+ command.add_argument("--page-size", type=int, default=25)
2217
+ return parser
2218
+
2219
+
2220
+ def main(argv: Sequence[str] | None = None) -> int:
2221
+ try:
2222
+ args = _parser().parse_args(argv)
2223
+ if args.command == "build-preregistration-artifact":
2224
+ companion = (
2225
+ _read_named_bytes(
2226
+ args.companion,
2227
+ MAX_PREREGISTRATION_BYTES,
2228
+ label="preregistration companion",
2229
+ )
2230
+ if args.companion is not None
2231
+ else None
2232
+ )
2233
+ _reject_output_alias(args.output, (args.companion,))
2234
+ record = build_preregistration_artifact(
2235
+ status=args.status,
2236
+ artifact_id=args.artifact_id,
2237
+ declared_at=args.declared_at,
2238
+ companion_bytes=companion,
2239
+ relative_path=args.relative_path,
2240
+ artifact_provenance=args.artifact_provenance,
2241
+ )
2242
+ _atomic_write(args.output, _canonical_bytes(record))
2243
+ return 0
2244
+
2245
+ loaded = _load_runtime_inputs(args)
2246
+ expected = _expected_from_loaded(loaded)
2247
+ if args.command == "finalize":
2248
+ payload = _canonical_bytes(expected)
2249
+ if args.output is None:
2250
+ sys.stdout.buffer.write(payload)
2251
+ else:
2252
+ _reject_output_alias(
2253
+ args.output,
2254
+ (
2255
+ args.draft,
2256
+ args.manifest,
2257
+ args.preregistration_record,
2258
+ args.preregistration_companion,
2259
+ args.accepted_draft,
2260
+ ),
2261
+ )
2262
+ _atomic_write(args.output, payload)
2263
+ return 0
2264
+
2265
+ advisory, advisory_raw = _load_json(
2266
+ args.advisory,
2267
+ MAX_FINAL_BYTES,
2268
+ code="FINAL_ARTIFACT_INVALID",
2269
+ label="final advisory",
2270
+ )
2271
+ _require_exact_final(advisory, advisory_raw, expected)
2272
+ if args.command == "validate":
2273
+ print("Cross-document consistency advisory validation passed (#672).")
2274
+ return 0
2275
+ rendered = render_advisory(expected, page=args.page, page_size=args.page_size)
2276
+ if args.output is None:
2277
+ sys.stdout.write(rendered)
2278
+ else:
2279
+ _reject_output_alias(
2280
+ args.output,
2281
+ (
2282
+ args.draft,
2283
+ args.manifest,
2284
+ args.preregistration_record,
2285
+ args.preregistration_companion,
2286
+ args.accepted_draft,
2287
+ args.advisory,
2288
+ ),
2289
+ )
2290
+ _atomic_write(args.output, rendered.encode("utf-8"))
2291
+ return 0
2292
+ except AdvisoryError as exc:
2293
+ print(f"ADVISORY_UNAVAILABLE:{exc.code}", file=sys.stderr)
2294
+ return 2
2295
+ except (
2296
+ IndexError,
2297
+ KeyError,
2298
+ OSError,
2299
+ RecursionError,
2300
+ TypeError,
2301
+ UnicodeError,
2302
+ ValueError,
2303
+ ):
2304
+ print("ADVISORY_UNAVAILABLE:FINAL_ARTIFACT_INVALID", file=sys.stderr)
2305
+ return 2
2306
+
2307
+
2308
+ __all__ = [
2309
+ "AdvisoryError",
2310
+ "DRAFT_SCHEMA_VERSION",
2311
+ "EVIDENCE_SCHEMA_VERSION",
2312
+ "EVALUATION_STATUS",
2313
+ "LAYER",
2314
+ "MANIFEST_SCHEMA_VERSION",
2315
+ "MAX_PAGE_SIZE",
2316
+ "REPORT_SCHEMA_VERSION",
2317
+ "SIDECAR_SCHEMA_VERSION",
2318
+ "SURFACE",
2319
+ "build_preregistration_artifact",
2320
+ "finalize_advisory",
2321
+ "main",
2322
+ "paginate",
2323
+ "render_advisory",
2324
+ "strict_percent_decode",
2325
+ "validate_advisory",
2326
+ "validate_preregistration_artifact",
2327
+ "validate_source_manifest",
2328
+ ]
2329
+
2330
+
2331
+ if __name__ == "__main__":
2332
+ raise SystemExit(main())