agentic-project-kit 1.0.1__py3-none-any.whl

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 (310) hide show
  1. agentic_project_kit/__init__.py +1 -0
  2. agentic_project_kit/absolute_path_portability_audit.py +241 -0
  3. agentic_project_kit/access_level_policy.py +14 -0
  4. agentic_project_kit/access_levels.py +22 -0
  5. agentic_project_kit/action_registry.py +195 -0
  6. agentic_project_kit/action_specs.py +286 -0
  7. agentic_project_kit/agent_command_runner.py +516 -0
  8. agentic_project_kit/audit_test_matrix.py +36 -0
  9. agentic_project_kit/audit_test_matrix_cli.py +43 -0
  10. agentic_project_kit/chat_bootloader.py +257 -0
  11. agentic_project_kit/chat_entrypoint_contract.py +297 -0
  12. agentic_project_kit/checks.py +511 -0
  13. agentic_project_kit/ci_readiness.py +211 -0
  14. agentic_project_kit/cli.py +147 -0
  15. agentic_project_kit/cli_commands/__init__.py +1 -0
  16. agentic_project_kit/cli_commands/absolute_path_audit.py +25 -0
  17. agentic_project_kit/cli_commands/actions.py +21 -0
  18. agentic_project_kit/cli_commands/artifact_gc.py +240 -0
  19. agentic_project_kit/cli_commands/boot.py +55 -0
  20. agentic_project_kit/cli_commands/chat.py +34 -0
  21. agentic_project_kit/cli_commands/checks.py +305 -0
  22. agentic_project_kit/cli_commands/cockpit.py +103 -0
  23. agentic_project_kit/cli_commands/command_taxonomy.py +25 -0
  24. agentic_project_kit/cli_commands/commands.py +129 -0
  25. agentic_project_kit/cli_commands/dev.py +23 -0
  26. agentic_project_kit/cli_commands/direction.py +92 -0
  27. agentic_project_kit/cli_commands/doc_currency_audit.py +25 -0
  28. agentic_project_kit/cli_commands/doc_registry.py +126 -0
  29. agentic_project_kit/cli_commands/docs.py +223 -0
  30. agentic_project_kit/cli_commands/dpa.py +1338 -0
  31. agentic_project_kit/cli_commands/evidence.py +251 -0
  32. agentic_project_kit/cli_commands/github.py +34 -0
  33. agentic_project_kit/cli_commands/governance.py +14 -0
  34. agentic_project_kit/cli_commands/gui.py +23 -0
  35. agentic_project_kit/cli_commands/gui_readiness_gate.py +27 -0
  36. agentic_project_kit/cli_commands/handoff.py +183 -0
  37. agentic_project_kit/cli_commands/human_workflows.py +430 -0
  38. agentic_project_kit/cli_commands/init.py +132 -0
  39. agentic_project_kit/cli_commands/instruction.py +75 -0
  40. agentic_project_kit/cli_commands/mutation_lock_audit.py +24 -0
  41. agentic_project_kit/cli_commands/ns_legacy_audit.py +25 -0
  42. agentic_project_kit/cli_commands/pass_already_done.py +66 -0
  43. agentic_project_kit/cli_commands/patch_failure_discipline_audit.py +26 -0
  44. agentic_project_kit/cli_commands/patch_preflight.py +37 -0
  45. agentic_project_kit/cli_commands/path_literal_audit.py +39 -0
  46. agentic_project_kit/cli_commands/patterns.py +40 -0
  47. agentic_project_kit/cli_commands/planning_docs_audit.py +25 -0
  48. agentic_project_kit/cli_commands/pr.py +133 -0
  49. agentic_project_kit/cli_commands/pr_hygiene.py +27 -0
  50. agentic_project_kit/cli_commands/profiles.py +26 -0
  51. agentic_project_kit/cli_commands/program_redundancy_audit.py +25 -0
  52. agentic_project_kit/cli_commands/project_direction.py +25 -0
  53. agentic_project_kit/cli_commands/release.py +392 -0
  54. agentic_project_kit/cli_commands/release_publish_orchestration.py +36 -0
  55. agentic_project_kit/cli_commands/remote_branch_hygiene.py +152 -0
  56. agentic_project_kit/cli_commands/remote_next.py +57 -0
  57. agentic_project_kit/cli_commands/removed_ns_commands.py +65 -0
  58. agentic_project_kit/cli_commands/rule_registry.py +129 -0
  59. agentic_project_kit/cli_commands/rules.py +222 -0
  60. agentic_project_kit/cli_commands/scaffold.py +46 -0
  61. agentic_project_kit/cli_commands/slice.py +21 -0
  62. agentic_project_kit/cli_commands/standard_gates_audit_suite.py +27 -0
  63. agentic_project_kit/cli_commands/state.py +51 -0
  64. agentic_project_kit/cli_commands/status_current_state_audit.py +30 -0
  65. agentic_project_kit/cli_commands/todo.py +53 -0
  66. agentic_project_kit/cli_commands/transfer.py +19 -0
  67. agentic_project_kit/cli_commands/transfer_context_flow.py +398 -0
  68. agentic_project_kit/cli_commands/transfer_context_helpers.py +398 -0
  69. agentic_project_kit/cli_commands/transfer_diagnostics.py +767 -0
  70. agentic_project_kit/cli_commands/transfer_evidence_flow.py +368 -0
  71. agentic_project_kit/cli_commands/transfer_handoff_flow.py +594 -0
  72. agentic_project_kit/cli_commands/transfer_order_contract.py +74 -0
  73. agentic_project_kit/cli_commands/transfer_post_merge_complete.py +442 -0
  74. agentic_project_kit/cli_commands/transfer_post_merge_settle.py +171 -0
  75. agentic_project_kit/cli_commands/transfer_pr_closeout_complete.py +124 -0
  76. agentic_project_kit/cli_commands/transfer_pr_create_flow.py +743 -0
  77. agentic_project_kit/cli_commands/transfer_pr_merge_flow.py +547 -0
  78. agentic_project_kit/cli_commands/transfer_repo_after_pr.py +160 -0
  79. agentic_project_kit/cli_commands/transfer_repo_pre_pr.py +664 -0
  80. agentic_project_kit/cli_commands/transfer_runner_flow.py +131 -0
  81. agentic_project_kit/cli_commands/transfer_runtime_initial.py +194 -0
  82. agentic_project_kit/cli_commands/transfer_shared.py +274 -0
  83. agentic_project_kit/cli_commands/validation.py +200 -0
  84. agentic_project_kit/cli_commands/version.py +27 -0
  85. agentic_project_kit/cli_commands/work_orders.py +219 -0
  86. agentic_project_kit/cli_commands/workflow.py +471 -0
  87. agentic_project_kit/cli_commands/workflow_guard.py +26 -0
  88. agentic_project_kit/cli_commands/workspace.py +252 -0
  89. agentic_project_kit/cockpit.py +608 -0
  90. agentic_project_kit/cockpit_readiness.py +67 -0
  91. agentic_project_kit/command_authority_audit.py +192 -0
  92. agentic_project_kit/command_inbox_check.py +103 -0
  93. agentic_project_kit/command_manifest.py +591 -0
  94. agentic_project_kit/command_queue_contract.py +161 -0
  95. agentic_project_kit/command_selector.py +245 -0
  96. agentic_project_kit/command_taxonomy.py +264 -0
  97. agentic_project_kit/commit_guard.py +67 -0
  98. agentic_project_kit/communication_artifact_gc.py +495 -0
  99. agentic_project_kit/communication_rule_context.py +437 -0
  100. agentic_project_kit/communication_state.py +115 -0
  101. agentic_project_kit/composed_wrapper_invariants.py +97 -0
  102. agentic_project_kit/composite_short_circuit.py +140 -0
  103. agentic_project_kit/contract.py +251 -0
  104. agentic_project_kit/control_state.py +83 -0
  105. agentic_project_kit/doc_currency_audit.py +536 -0
  106. agentic_project_kit/doc_lifecycle.py +1179 -0
  107. agentic_project_kit/doc_lifecycle_signals.py +446 -0
  108. agentic_project_kit/doc_lifecycle_sweep.py +639 -0
  109. agentic_project_kit/doc_mesh.py +491 -0
  110. agentic_project_kit/doctor.py +379 -0
  111. agentic_project_kit/documentation_registry.py +1122 -0
  112. agentic_project_kit/documentation_system_audit.py +310 -0
  113. agentic_project_kit/dpa_current_handoff_lifecycle.py +549 -0
  114. agentic_project_kit/dpa_dp2_decision_readiness.py +362 -0
  115. agentic_project_kit/dpa_dp3_dp4_adjudication.py +604 -0
  116. agentic_project_kit/dpa_dp5_block_new_gate.py +294 -0
  117. agentic_project_kit/dpa_dp5_stage_adoption.py +615 -0
  118. agentic_project_kit/dpa_dp5_strict_gate.py +187 -0
  119. agentic_project_kit/dpa_final_closeout.py +627 -0
  120. agentic_project_kit/dpa_fixture_evidence.py +680 -0
  121. agentic_project_kit/dpa_maintainer_record_check.py +711 -0
  122. agentic_project_kit/dpa_post_dp2_scope_assessment.py +734 -0
  123. agentic_project_kit/dpa_probe_002_readiness.py +509 -0
  124. agentic_project_kit/dpa_probe_003_readiness.py +417 -0
  125. agentic_project_kit/dpa_probe_004_readiness.py +437 -0
  126. agentic_project_kit/dpa_readiness.py +505 -0
  127. agentic_project_kit/dpa_readonly_probe_execution.py +500 -0
  128. agentic_project_kit/dpa_registry_contracts.py +312 -0
  129. agentic_project_kit/dpa_renderer_readiness.py +407 -0
  130. agentic_project_kit/dpa_repo_adoption_assessment.py +574 -0
  131. agentic_project_kit/dpa_stable_readiness.py +743 -0
  132. agentic_project_kit/dpa_successor_projection.py +168 -0
  133. agentic_project_kit/dpa_workspace_init_projection.py +93 -0
  134. agentic_project_kit/dpa_wrt_ch001_evidence.py +327 -0
  135. agentic_project_kit/entrypoint_slice_runner.py +153 -0
  136. agentic_project_kit/evidence_clean.py +152 -0
  137. agentic_project_kit/evidence_commit_paths.py +214 -0
  138. agentic_project_kit/evidence_finalize_log.py +204 -0
  139. agentic_project_kit/evidence_guard.py +114 -0
  140. agentic_project_kit/evidence_inspector.py +507 -0
  141. agentic_project_kit/evidence_state_contract.py +99 -0
  142. agentic_project_kit/execution_mode_state.py +148 -0
  143. agentic_project_kit/final_summary_contract.py +85 -0
  144. agentic_project_kit/finalize_guard.py +139 -0
  145. agentic_project_kit/gatekeeper_core.py +232 -0
  146. agentic_project_kit/github.py +25 -0
  147. agentic_project_kit/governance.py +59 -0
  148. agentic_project_kit/gui_action_execution.py +105 -0
  149. agentic_project_kit/gui_action_renderer.py +81 -0
  150. agentic_project_kit/gui_action_run_intent.py +98 -0
  151. agentic_project_kit/gui_action_views.py +195 -0
  152. agentic_project_kit/gui_activity_log.py +76 -0
  153. agentic_project_kit/gui_button_catalog.py +605 -0
  154. agentic_project_kit/gui_cockpit.py +365 -0
  155. agentic_project_kit/gui_cockpit_actions.py +695 -0
  156. agentic_project_kit/gui_cockpit_common.py +172 -0
  157. agentic_project_kit/gui_cockpit_header.py +501 -0
  158. agentic_project_kit/gui_cockpit_sidebar.py +387 -0
  159. agentic_project_kit/gui_cockpit_task.py +748 -0
  160. agentic_project_kit/gui_command_projection.py +355 -0
  161. agentic_project_kit/gui_communication_modes.py +130 -0
  162. agentic_project_kit/gui_dry_run.py +219 -0
  163. agentic_project_kit/gui_gatekeeper_status.py +259 -0
  164. agentic_project_kit/gui_layout_plan.py +148 -0
  165. agentic_project_kit/gui_open_folder.py +18 -0
  166. agentic_project_kit/gui_output_status_panel.py +61 -0
  167. agentic_project_kit/gui_panel_state.py +47 -0
  168. agentic_project_kit/gui_presenter.py +62 -0
  169. agentic_project_kit/gui_readiness_gate.py +206 -0
  170. agentic_project_kit/gui_release_flow.py +59 -0
  171. agentic_project_kit/gui_task_editor.py +1077 -0
  172. agentic_project_kit/gui_tk_widgets.py +177 -0
  173. agentic_project_kit/gui_tkinter_renderer.py +87 -0
  174. agentic_project_kit/gui_tkinter_shell.py +1176 -0
  175. agentic_project_kit/gui_transfer_contract.py +28 -0
  176. agentic_project_kit/gui_viewmodel.py +698 -0
  177. agentic_project_kit/gui_window_guard.py +46 -0
  178. agentic_project_kit/handoff_freshness.py +390 -0
  179. agentic_project_kit/handoff_prompt.py +180 -0
  180. agentic_project_kit/handoff_state.py +254 -0
  181. agentic_project_kit/instruction_lint.py +455 -0
  182. agentic_project_kit/llm_context_carriers.py +66 -0
  183. agentic_project_kit/llm_execution_context.py +285 -0
  184. agentic_project_kit/local_command_stack.py +133 -0
  185. agentic_project_kit/local_feature_gate.py +82 -0
  186. agentic_project_kit/local_garbage_collector.py +269 -0
  187. agentic_project_kit/models.py +18 -0
  188. agentic_project_kit/mutation_lock_audit.py +421 -0
  189. agentic_project_kit/next_turn_evidence.py +253 -0
  190. agentic_project_kit/next_turn_merge_if_green.py +459 -0
  191. agentic_project_kit/next_turn_pr_status.py +255 -0
  192. agentic_project_kit/next_turn_result.py +183 -0
  193. agentic_project_kit/next_turn_runner.py +159 -0
  194. agentic_project_kit/next_turn_slot.py +107 -0
  195. agentic_project_kit/next_turn_status.py +274 -0
  196. agentic_project_kit/ns_legacy_reference_audit.py +258 -0
  197. agentic_project_kit/ns_slice_runner.py +16 -0
  198. agentic_project_kit/operational_handoff_projection.py +124 -0
  199. agentic_project_kit/output_contract.py +80 -0
  200. agentic_project_kit/output_repair.py +61 -0
  201. agentic_project_kit/pass_already_done.py +216 -0
  202. agentic_project_kit/patch_artifact_preflight.py +147 -0
  203. agentic_project_kit/patch_cycle_workflow.py +440 -0
  204. agentic_project_kit/patch_failure_discipline_audit.py +223 -0
  205. agentic_project_kit/patch_preflight.py +215 -0
  206. agentic_project_kit/path_literal_audit.py +612 -0
  207. agentic_project_kit/patterns.py +99 -0
  208. agentic_project_kit/planning_docs_consolidation_audit.py +313 -0
  209. agentic_project_kit/portability_shell_gate.py +40 -0
  210. agentic_project_kit/post_merge_handoff_refresh.py +56 -0
  211. agentic_project_kit/post_release.py +252 -0
  212. agentic_project_kit/post_release_closeout.py +616 -0
  213. agentic_project_kit/pr_cleanup.py +172 -0
  214. agentic_project_kit/pr_closeout.py +50 -0
  215. agentic_project_kit/pr_closeout_complete.py +344 -0
  216. agentic_project_kit/pr_create_or_skip.py +71 -0
  217. agentic_project_kit/pr_hygiene.py +210 -0
  218. agentic_project_kit/program_redundancy_audit.py +251 -0
  219. agentic_project_kit/project_direction.py +840 -0
  220. agentic_project_kit/protected_change_planner.py +194 -0
  221. agentic_project_kit/release.py +401 -0
  222. agentic_project_kit/release_doi_safety.py +24 -0
  223. agentic_project_kit/release_gate_core.py +174 -0
  224. agentic_project_kit/release_metadata_authority_gate.py +328 -0
  225. agentic_project_kit/release_metadata_prep.py +43 -0
  226. agentic_project_kit/release_notes.py +823 -0
  227. agentic_project_kit/release_prep_core.py +204 -0
  228. agentic_project_kit/release_prepare.py +369 -0
  229. agentic_project_kit/release_process_guardrails.py +247 -0
  230. agentic_project_kit/release_publish_core.py +114 -0
  231. agentic_project_kit/release_publish_orchestration.py +469 -0
  232. agentic_project_kit/release_state.py +552 -0
  233. agentic_project_kit/release_verify_core.py +175 -0
  234. agentic_project_kit/remote_branch_hygiene.py +223 -0
  235. agentic_project_kit/remote_next.py +89 -0
  236. agentic_project_kit/remote_next_closeout.py +101 -0
  237. agentic_project_kit/remote_next_order_contract.py +391 -0
  238. agentic_project_kit/removed_ns_commands.py +458 -0
  239. agentic_project_kit/removed_source_audit.py +225 -0
  240. agentic_project_kit/rendering.py +13 -0
  241. agentic_project_kit/repair_report.py +79 -0
  242. agentic_project_kit/repo_identity.py +59 -0
  243. agentic_project_kit/result_report_classifier.py +57 -0
  244. agentic_project_kit/rule_ack.py +105 -0
  245. agentic_project_kit/rule_preservation.py +58 -0
  246. agentic_project_kit/rule_refresh.py +174 -0
  247. agentic_project_kit/rule_registry_registration.py +322 -0
  248. agentic_project_kit/rule_registry_report.py +206 -0
  249. agentic_project_kit/rule_registry_validator.py +704 -0
  250. agentic_project_kit/rule_snapshot.py +98 -0
  251. agentic_project_kit/rule_source_validator.py +133 -0
  252. agentic_project_kit/run_summary.py +68 -0
  253. agentic_project_kit/run_summary_renderer.py +238 -0
  254. agentic_project_kit/runtime_validator.py +68 -0
  255. agentic_project_kit/safe_file_replace.py +35 -0
  256. agentic_project_kit/safe_patch.py +47 -0
  257. agentic_project_kit/safe_push.py +218 -0
  258. agentic_project_kit/safe_remove_diagnostic.py +51 -0
  259. agentic_project_kit/scaffold.py +69 -0
  260. agentic_project_kit/site_claims.py +444 -0
  261. agentic_project_kit/site_generator.py +1140 -0
  262. agentic_project_kit/slice_gate.py +225 -0
  263. agentic_project_kit/slice_runner.py +75 -0
  264. agentic_project_kit/standard_gates_audit_suite.py +167 -0
  265. agentic_project_kit/state_freshness.py +135 -0
  266. agentic_project_kit/status_current_state_audit.py +762 -0
  267. agentic_project_kit/successor_handoff_package.py +1763 -0
  268. agentic_project_kit/templates.py +292 -0
  269. agentic_project_kit/terminal_block_guard.py +166 -0
  270. agentic_project_kit/terminal_logging.py +275 -0
  271. agentic_project_kit/todo.py +97 -0
  272. agentic_project_kit/transfer_closeout.py +136 -0
  273. agentic_project_kit/transfer_continue.py +215 -0
  274. agentic_project_kit/transfer_local_runner.py +101 -0
  275. agentic_project_kit/transfer_operation_monitor.py +236 -0
  276. agentic_project_kit/transfer_post_merge_lifecycle.py +356 -0
  277. agentic_project_kit/transfer_post_merge_settle.py +383 -0
  278. agentic_project_kit/transfer_pr_actions.py +164 -0
  279. agentic_project_kit/transfer_remote_next.py +959 -0
  280. agentic_project_kit/transfer_repo_actions.py +2253 -0
  281. agentic_project_kit/transfer_runner.py +347 -0
  282. agentic_project_kit/transfer_safety_context.py +291 -0
  283. agentic_project_kit/transfer_state.py +483 -0
  284. agentic_project_kit/transfer_uplink.py +471 -0
  285. agentic_project_kit/transfer_workflow_next.py +148 -0
  286. agentic_project_kit/typed_work_order_evidence.py +58 -0
  287. agentic_project_kit/typed_work_order_queue.py +166 -0
  288. agentic_project_kit/typed_work_order_runner.py +168 -0
  289. agentic_project_kit/work_cycle.py +317 -0
  290. agentic_project_kit/work_discard_changes.py +129 -0
  291. agentic_project_kit/work_order_patch.py +199 -0
  292. agentic_project_kit/work_order_runner.py +120 -0
  293. agentic_project_kit/work_order_uploader.py +220 -0
  294. agentic_project_kit/work_order_validator.py +185 -0
  295. agentic_project_kit/work_orders.py +246 -0
  296. agentic_project_kit/workflow_guard.py +262 -0
  297. agentic_project_kit/workflow_summary_runner.py +124 -0
  298. agentic_project_kit/workspace.py +665 -0
  299. agentic_project_kit/workspace_adopt.py +471 -0
  300. agentic_project_kit/workspace_dpa_intake.py +406 -0
  301. agentic_project_kit/workspace_init.py +487 -0
  302. agentic_project_kit/workspace_lock.py +129 -0
  303. agentic_project_kit/workspace_remove.py +381 -0
  304. agentic_project_kit/workspace_upgrade.py +324 -0
  305. agentic_project_kit/wrapper_live_status.py +104 -0
  306. agentic_project_kit-1.0.1.dist-info/METADATA +724 -0
  307. agentic_project_kit-1.0.1.dist-info/RECORD +310 -0
  308. agentic_project_kit-1.0.1.dist-info/WHEEL +4 -0
  309. agentic_project_kit-1.0.1.dist-info/entry_points.txt +3 -0
  310. agentic_project_kit-1.0.1.dist-info/licenses/LICENSE +10 -0
@@ -0,0 +1,734 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ import json
5
+ from pathlib import Path
6
+ import subprocess
7
+ from typing import Any
8
+
9
+ from agentic_project_kit.dpa_dp3_dp4_adjudication import (
10
+ DEFAULT_DP3_DP4_ADJUDICATION_RECORD_PATH,
11
+ Dp3Dp4AdjudicationResult,
12
+ evaluate_dp3_dp4_adjudication_record,
13
+ )
14
+ from agentic_project_kit.dpa_dp5_stage_adoption import (
15
+ DEFAULT_DP5_STAGE_RECORD_PATH,
16
+ Dp5StageAdoptionResult,
17
+ evaluate_dp5_stage_record,
18
+ )
19
+ from agentic_project_kit.dpa_readiness import (
20
+ DEFAULT_READINESS_PATH,
21
+ evaluate_dpa_readiness,
22
+ )
23
+ from agentic_project_kit.dpa_successor_projection import (
24
+ DPA_SUCCESSOR_PROJECTION_CONTRACT_ID,
25
+ DPA_SUCCESSOR_PROJECTION_SOURCE_PATHS,
26
+ DPA_SUCCESSOR_PROJECTION_TARGET_SCOPE,
27
+ DPA_SUCCESSOR_PROJECTION_WRITER_ID,
28
+ )
29
+ from agentic_project_kit.dpa_workspace_init_projection import (
30
+ DPA_WORKSPACE_INIT_CONTRACT_ID,
31
+ DPA_WORKSPACE_INIT_MANIFEST_PATH,
32
+ DPA_WORKSPACE_INIT_SOURCE_PATHS,
33
+ DPA_WORKSPACE_INIT_TARGET_SCOPE,
34
+ DPA_WORKSPACE_INIT_WRITER_ID,
35
+ )
36
+ from agentic_project_kit.workspace import load_workspace
37
+
38
+ ASSESSMENT_MODEL = "dpa-post-dp2-scope-assessment-v1"
39
+ RESULT_STATUS = "POST_DP2_SCOPE_ASSESSMENT_RECORDED"
40
+ KIT_WIDE_DPA_STATUS = "DP3_DP5_NOT_COMPLETE"
41
+ KIT_WIDE_DPA_STATUS_DP5_ONLY = "DP5_NOT_COMPLETE"
42
+ KIT_WIDE_DPA_STATUS_DP5_OBSERVE = "DP5_OBSERVE_ADOPTED_STRICT_NOT_COMPLETE"
43
+ KIT_WIDE_DPA_STATUS_DP5_WARN = "DP5_WARN_ACTIVE_STRICT_NOT_COMPLETE"
44
+ KIT_WIDE_DPA_STATUS_DP5_BLOCK_NEW = "DP5_BLOCK_NEW_ACTIVE_STRICT_NOT_COMPLETE"
45
+ EVIDENCE_OUTPUT_ROOT_PARTS = ("evidence", "dpa", "assessment")
46
+ DP5_STAGE_SEQUENCE = ("observe", "warn", "block-new", "strict")
47
+ DP5_ADOPTED_STAGE_STATUS = {
48
+ "observe": "ADOPTED_OBSERVE",
49
+ "warn": "ADOPTED_WARN",
50
+ "block-new": "ADOPTED_BLOCK_NEW",
51
+ "strict": "ADOPTED_STRICT",
52
+ }
53
+
54
+
55
+ @dataclass(frozen=True)
56
+ class ScopeAssessmentFinding:
57
+ code: str
58
+ message: str
59
+ path: str
60
+
61
+ def as_dict(self) -> dict[str, str]:
62
+ return {"code": self.code, "message": self.message, "path": self.path}
63
+
64
+
65
+ @dataclass(frozen=True)
66
+ class RolloutCandidate:
67
+ writer_id: str
68
+ target_identity: str
69
+ target_path: str
70
+ source_authority: str
71
+ source_paths: tuple[str, ...]
72
+ document_form: str
73
+ readiness_record_status: str
74
+ implementation_result_ref: str
75
+ implementation_ref_verified: bool | None
76
+ dpa_600_evidence: dict[str, Any]
77
+ dpa_700_evidence: dict[str, Any]
78
+ rollback: str
79
+ adjudication_record: str
80
+ adjudication_status: str
81
+ entry_blockers: tuple[str, ...]
82
+ completion_blockers: tuple[str, ...]
83
+
84
+ @property
85
+ def entry_ready(self) -> bool:
86
+ return not self.entry_blockers
87
+
88
+ @property
89
+ def status(self) -> str:
90
+ if self.entry_blockers:
91
+ return "BLOCKED_FOR_DP3_ENTRY"
92
+ if not self.completion_blockers:
93
+ return "ADJUDICATED_FOR_BOUNDED_DP3_ROLLOUT"
94
+ return "READY_FOR_BOUNDED_DP3_ADJUDICATION"
95
+
96
+ def as_dict(self) -> dict[str, Any]:
97
+ return {
98
+ "writer_id": self.writer_id,
99
+ "target_identity": self.target_identity,
100
+ "target_path": self.target_path,
101
+ "source_authority": self.source_authority,
102
+ "source_paths": list(self.source_paths),
103
+ "document_form": self.document_form,
104
+ "readiness_record_status": self.readiness_record_status,
105
+ "implementation_result_ref": self.implementation_result_ref,
106
+ "implementation_ref_verified": self.implementation_ref_verified,
107
+ "dpa_600_evidence": self.dpa_600_evidence,
108
+ "dpa_700_evidence": self.dpa_700_evidence,
109
+ "rollback": self.rollback,
110
+ "adjudication_record": self.adjudication_record,
111
+ "adjudication_status": self.adjudication_status,
112
+ "status": self.status,
113
+ "entry_ready": self.entry_ready,
114
+ "entry_blockers": list(self.entry_blockers),
115
+ "completion_blockers": list(self.completion_blockers),
116
+ "claims": _false_claims(),
117
+ }
118
+
119
+
120
+ @dataclass(frozen=True)
121
+ class StatusAuthorityCandidate:
122
+ id: str
123
+ path: str
124
+ document_form: str
125
+ source_authority: str
126
+ target_identity: str
127
+ generated_or_command_updated: bool
128
+ decision: str
129
+ adjudication_record: str
130
+ adjudication_status: str
131
+ blockers: tuple[str, ...]
132
+ evidence: tuple[str, ...]
133
+
134
+ @property
135
+ def status(self) -> str:
136
+ if self.blockers:
137
+ return "BLOCKED_FOR_DP4_EXIT"
138
+ return "ADJUDICATED_FOR_BOUNDED_DP4_EXIT"
139
+
140
+ def as_dict(self) -> dict[str, Any]:
141
+ return {
142
+ "id": self.id,
143
+ "path": self.path,
144
+ "document_form": self.document_form,
145
+ "source_authority": self.source_authority,
146
+ "target_identity": self.target_identity,
147
+ "generated_or_command_updated": self.generated_or_command_updated,
148
+ "decision": self.decision,
149
+ "adjudication_record": self.adjudication_record,
150
+ "adjudication_status": self.adjudication_status,
151
+ "status": self.status,
152
+ "blockers": list(self.blockers),
153
+ "evidence": list(self.evidence),
154
+ }
155
+
156
+
157
+ @dataclass(frozen=True)
158
+ class StrictLifecycleStage:
159
+ stage: str
160
+ status: str
161
+ blockers: tuple[str, ...]
162
+
163
+ def as_dict(self) -> dict[str, Any]:
164
+ return {"stage": self.stage, "status": self.status, "blockers": list(self.blockers)}
165
+
166
+
167
+ @dataclass(frozen=True)
168
+ class PostDp2ScopeAssessmentResult:
169
+ root: str
170
+ validation_ref: str
171
+ readiness_record: str
172
+ dp2_status: str
173
+ dp2_implementation_percent: int
174
+ dp2_scope: str
175
+ adjudication_record: Dp3Dp4AdjudicationResult
176
+ dp5_stage_record: Dp5StageAdoptionResult
177
+ rollout_candidates: tuple[RolloutCandidate, ...]
178
+ status_authority_candidates: tuple[StatusAuthorityCandidate, ...]
179
+ strict_lifecycle_stages: tuple[StrictLifecycleStage, ...]
180
+ findings: tuple[ScopeAssessmentFinding, ...]
181
+
182
+ @property
183
+ def structural_ok(self) -> bool:
184
+ return not self.findings
185
+
186
+ @property
187
+ def dp3_blockers(self) -> tuple[str, ...]:
188
+ blockers: list[str] = []
189
+ for candidate in self.rollout_candidates:
190
+ blockers.extend(f"{candidate.writer_id}:{blocker}" for blocker in candidate.entry_blockers)
191
+ blockers.extend(f"{candidate.writer_id}:{blocker}" for blocker in candidate.completion_blockers)
192
+ return tuple(blockers)
193
+
194
+ @property
195
+ def dp4_blockers(self) -> tuple[str, ...]:
196
+ blockers: list[str] = []
197
+ for candidate in self.status_authority_candidates:
198
+ blockers.extend(f"{candidate.id}:{blocker}" for blocker in candidate.blockers)
199
+ return tuple(blockers)
200
+
201
+ @property
202
+ def dp5_blockers(self) -> tuple[str, ...]:
203
+ blockers: list[str] = []
204
+ for stage in self.strict_lifecycle_stages:
205
+ blockers.extend(f"{stage.stage}:{blocker}" for blocker in stage.blockers)
206
+ return tuple(dict.fromkeys(blockers))
207
+
208
+ @property
209
+ def blocker_count(self) -> int:
210
+ return len(self.dp3_blockers) + len(self.dp4_blockers) + len(self.dp5_blockers)
211
+
212
+ @property
213
+ def final_closeout_ready(self) -> bool:
214
+ return self.structural_ok and self.blocker_count == 0
215
+
216
+ @property
217
+ def kit_wide_dpa_status(self) -> str:
218
+ if self.final_closeout_ready:
219
+ return "READY_FOR_FINAL_CLOSEOUT_RECORD"
220
+ if self.dp5_stage_record.stage_accepted("block-new") and self.dp5_blockers:
221
+ return KIT_WIDE_DPA_STATUS_DP5_BLOCK_NEW
222
+ if self.dp5_stage_record.stage_accepted("warn") and self.dp5_blockers:
223
+ return KIT_WIDE_DPA_STATUS_DP5_WARN
224
+ if self.dp5_stage_record.stage_accepted("observe") and self.dp5_blockers:
225
+ return KIT_WIDE_DPA_STATUS_DP5_OBSERVE
226
+ if not self.dp3_blockers and not self.dp4_blockers and self.dp5_blockers:
227
+ return KIT_WIDE_DPA_STATUS_DP5_ONLY
228
+ return KIT_WIDE_DPA_STATUS
229
+
230
+ @property
231
+ def dp5_warnings(self) -> tuple[str, ...]:
232
+ if self.dp5_stage_record.stage_accepted("warn") and self.dp5_blockers:
233
+ return tuple(f"DP5_WARN:{blocker}" for blocker in self.dp5_blockers)
234
+ return ()
235
+
236
+ @property
237
+ def result_status(self) -> str:
238
+ if not self.structural_ok:
239
+ return "STRUCTURAL_BLOCK"
240
+ if self.dp2_status != "DP2_AUTHORIZED":
241
+ return "DP2_NOT_AUTHORIZED"
242
+ return RESULT_STATUS
243
+
244
+ def as_dict(self) -> dict[str, Any]:
245
+ dp3_bounded_slice_adjudicated = not self.dp3_blockers
246
+ dp4_bounded_slice_adjudicated = not self.dp4_blockers
247
+ return {
248
+ "schema_version": 1,
249
+ "kind": "dpa_post_dp2_scope_assessment",
250
+ "assessment_model": ASSESSMENT_MODEL,
251
+ "result_status": self.result_status,
252
+ "validation_ref": self.validation_ref,
253
+ "readiness_record": self.readiness_record,
254
+ "dp2_status": self.dp2_status,
255
+ "dp2_implementation_percent": self.dp2_implementation_percent,
256
+ "dp2_scope": self.dp2_scope,
257
+ "kit_wide_dpa_status": self.kit_wide_dpa_status,
258
+ "kit_wide_dpa_conformance_claimed": False,
259
+ "final_closeout_ready": self.final_closeout_ready,
260
+ "dp3_dp4_adjudication": self.adjudication_record.as_dict(),
261
+ "dp5_stage_adoption": self.dp5_stage_record.as_dict(),
262
+ "finding_count": len(self.findings),
263
+ "blocker_count": self.blocker_count,
264
+ "findings": [finding.as_dict() for finding in self.findings],
265
+ "dp3": {
266
+ "status": (
267
+ "ADJUDICATED_FOR_BOUNDED_SLICE"
268
+ if dp3_bounded_slice_adjudicated
269
+ else "NOT_COMPLETE"
270
+ ),
271
+ "bounded_slice_adjudicated": dp3_bounded_slice_adjudicated,
272
+ "blockers": list(self.dp3_blockers),
273
+ "rollout_candidates": [candidate.as_dict() for candidate in self.rollout_candidates],
274
+ },
275
+ "dp4": {
276
+ "status": (
277
+ "ADJUDICATED_FOR_BOUNDED_STATUS_AUTHORITY_SLICE"
278
+ if dp4_bounded_slice_adjudicated
279
+ else "NOT_COMPLETE"
280
+ ),
281
+ "bounded_slice_adjudicated": dp4_bounded_slice_adjudicated,
282
+ "blockers": list(self.dp4_blockers),
283
+ "status_authority_candidates": [
284
+ candidate.as_dict() for candidate in self.status_authority_candidates
285
+ ],
286
+ },
287
+ "dp5": {
288
+ "status": self._dp5_status(),
289
+ "blockers": list(self.dp5_blockers),
290
+ "warning_count": len(self.dp5_warnings),
291
+ "warnings": list(self.dp5_warnings),
292
+ "strict_lifecycle_stages": [stage.as_dict() for stage in self.strict_lifecycle_stages],
293
+ },
294
+ "claims": _false_claims(),
295
+ }
296
+
297
+ def _dp5_status(self) -> str:
298
+ if self.dp5_stage_record.stage_accepted("strict"):
299
+ return "STRICT_ACTIVE_READY_FOR_FINAL_CLOSEOUT"
300
+ if self.dp5_stage_record.stage_accepted("block-new"):
301
+ return "BLOCK_NEW_ACTIVE_STRICT_LIFECYCLE_NOT_COMPLETE"
302
+ if self.dp5_stage_record.stage_accepted("warn"):
303
+ return "WARN_ACTIVE_STRICT_LIFECYCLE_NOT_COMPLETE"
304
+ if self.dp5_stage_record.stage_accepted("observe"):
305
+ return "OBSERVE_ADOPTED_STRICT_LIFECYCLE_NOT_COMPLETE"
306
+ return "BLOCKED_BEFORE_STAGE_TRANSITION"
307
+
308
+
309
+ def evaluate_post_dp2_scope_assessment(
310
+ root: Path | str = ".",
311
+ *,
312
+ readiness_path: Path | str = DEFAULT_READINESS_PATH,
313
+ adjudication_record_path: Path | str = DEFAULT_DP3_DP4_ADJUDICATION_RECORD_PATH,
314
+ dp5_stage_record_path: Path | str = DEFAULT_DP5_STAGE_RECORD_PATH,
315
+ validation_ref: str | None = None,
316
+ ) -> PostDp2ScopeAssessmentResult:
317
+ base = Path(root).resolve()
318
+ readiness = evaluate_dpa_readiness(base, readiness_path=readiness_path)
319
+ record_path = _resolve_under_root(base, readiness_path)
320
+ findings = [
321
+ ScopeAssessmentFinding(
322
+ code=f"dp2-readiness-{finding.code}",
323
+ message=finding.message,
324
+ path=finding.path,
325
+ )
326
+ for finding in readiness.findings
327
+ ]
328
+ selected_writer_status = _mapping(readiness.data.get("selected_writer_status"))
329
+ resolved_validation_ref = validation_ref or _git_head(base)
330
+ adjudication = evaluate_dp3_dp4_adjudication_record(
331
+ base,
332
+ record_path=adjudication_record_path,
333
+ validation_ref=resolved_validation_ref,
334
+ )
335
+ dp5_stage_record = evaluate_dp5_stage_record(
336
+ base,
337
+ record_path=dp5_stage_record_path,
338
+ validation_ref=resolved_validation_ref,
339
+ )
340
+
341
+ rollout_candidates = _rollout_candidates(base, selected_writer_status, adjudication)
342
+ status_authority_candidates = _status_authority_candidates(base, adjudication)
343
+ strict_lifecycle_stages = _strict_lifecycle_stages(adjudication, dp5_stage_record)
344
+ dp2_scope = str(
345
+ _mapping(readiness.data.get("dp2_entry_status")).get(
346
+ "first_dp2_target_scope",
347
+ "UNKNOWN",
348
+ )
349
+ )
350
+ return PostDp2ScopeAssessmentResult(
351
+ root=base.as_posix(),
352
+ validation_ref=resolved_validation_ref,
353
+ readiness_record=_display_path(record_path, base),
354
+ dp2_status=readiness.status,
355
+ dp2_implementation_percent=readiness.implementation_percent,
356
+ dp2_scope=dp2_scope,
357
+ adjudication_record=adjudication,
358
+ dp5_stage_record=dp5_stage_record,
359
+ rollout_candidates=rollout_candidates,
360
+ status_authority_candidates=status_authority_candidates,
361
+ strict_lifecycle_stages=strict_lifecycle_stages,
362
+ findings=tuple(findings),
363
+ )
364
+
365
+
366
+ def render_post_dp2_scope_assessment(result: PostDp2ScopeAssessmentResult) -> str:
367
+ payload = result.as_dict()
368
+ lines = [
369
+ "DPA_POST_DP2_SCOPE_ASSESSMENT",
370
+ f"STATUS={payload['result_status']}",
371
+ f"VALIDATION_REF={payload['validation_ref']}",
372
+ f"DP2_STATUS={payload['dp2_status']}",
373
+ f"DP2_IMPLEMENTATION_PERCENT={payload['dp2_implementation_percent']}",
374
+ f"DP2_SCOPE={payload['dp2_scope']}",
375
+ f"KIT_WIDE_DPA_STATUS={payload['kit_wide_dpa_status']}",
376
+ "KIT_WIDE_DPA_CONFORMANCE_CLAIMED=false",
377
+ f"FINAL_CLOSEOUT_READY={str(payload['final_closeout_ready']).lower()}",
378
+ f"FINDINGS={payload['finding_count']}",
379
+ f"BLOCKERS={payload['blocker_count']}",
380
+ f"WARNINGS={payload['dp5']['warning_count']}",
381
+ ]
382
+ for candidate in payload["dp3"]["rollout_candidates"]:
383
+ lines.append(
384
+ "DP3_TARGET="
385
+ f"{candidate['writer_id']}|status={candidate['status']}|target={candidate['target_identity']}"
386
+ )
387
+ for candidate in payload["dp4"]["status_authority_candidates"]:
388
+ lines.append(
389
+ "DP4_CANDIDATE="
390
+ f"{candidate['id']}|status={candidate['status']}|decision={candidate['decision']}"
391
+ )
392
+ for stage in payload["dp5"]["strict_lifecycle_stages"]:
393
+ lines.append(f"DP5_STAGE={stage['stage']}|status={stage['status']}")
394
+ for blocker in (*payload["dp3"]["blockers"], *payload["dp4"]["blockers"], *payload["dp5"]["blockers"]):
395
+ lines.append(f"BLOCKER={blocker}")
396
+ for warning in payload["dp5"]["warnings"]:
397
+ lines.append(f"WARNING={warning}")
398
+ for finding in payload["findings"]:
399
+ lines.append(f"FINDING={finding['code']}|path={finding['path']}|{finding['message']}")
400
+ return "\n".join(lines) + "\n"
401
+
402
+
403
+ def write_post_dp2_scope_assessment_json(
404
+ result: PostDp2ScopeAssessmentResult,
405
+ root: Path | str,
406
+ output: Path | str,
407
+ *,
408
+ execute: bool,
409
+ ) -> dict[str, Any]:
410
+ base = Path(root).resolve()
411
+ output_path = _resolve_under_root(base, output)
412
+ relative = output_path.relative_to(base)
413
+ evidence_root = _evidence_output_root(base)
414
+ if evidence_root not in (output_path, *output_path.parents):
415
+ return {
416
+ "result_status": "BLOCK",
417
+ "reason": "output_outside_dpa_assessment_evidence_root",
418
+ "output_path": relative.as_posix(),
419
+ "written": False,
420
+ }
421
+ rendered = json.dumps(result.as_dict(), indent=2, sort_keys=True) + "\n"
422
+ changed = True
423
+ if output_path.exists():
424
+ changed = output_path.read_text(encoding="utf-8") != rendered
425
+ if execute:
426
+ output_path.parent.mkdir(parents=True, exist_ok=True)
427
+ output_path.write_text(rendered, encoding="utf-8")
428
+ return {
429
+ "result_status": "PASS",
430
+ "output_path": relative.as_posix(),
431
+ "changed": changed,
432
+ "written": bool(execute),
433
+ }
434
+
435
+
436
+ def _rollout_candidates(
437
+ root: Path,
438
+ selected_writer_status: dict[str, Any],
439
+ adjudication: Dp3Dp4AdjudicationResult,
440
+ ) -> tuple[RolloutCandidate, ...]:
441
+ return (
442
+ _candidate(
443
+ root,
444
+ writer_id=DPA_WORKSPACE_INIT_WRITER_ID,
445
+ target_identity=DPA_WORKSPACE_INIT_TARGET_SCOPE,
446
+ target_path=DPA_WORKSPACE_INIT_MANIFEST_PATH,
447
+ source_authority=DPA_WORKSPACE_INIT_CONTRACT_ID,
448
+ source_paths=DPA_WORKSPACE_INIT_SOURCE_PATHS,
449
+ document_form="external-generated-initialization-manifest",
450
+ readiness_record_status=str(selected_writer_status.get(DPA_WORKSPACE_INIT_WRITER_ID, "MISSING")),
451
+ expected_readiness_status="EXTERNAL_HABITABILITY_ONLY",
452
+ implementation_result_ref="f653bbbb",
453
+ evidence_path="docs/architecture/evidence/dpa/probes/fixture-evidence-0b985a22-wrt-ch005-20260729/results.json",
454
+ rollback="no production migration; fixture cleanup covers disposable generated target roots",
455
+ adjudication=adjudication,
456
+ completion_blocker="dp3-adjudicated-rollout-result-missing",
457
+ ),
458
+ _candidate(
459
+ root,
460
+ writer_id=DPA_SUCCESSOR_PROJECTION_WRITER_ID,
461
+ target_identity=DPA_SUCCESSOR_PROJECTION_TARGET_SCOPE,
462
+ target_path="docs/reports/handoff-packages/latest/",
463
+ source_authority=DPA_SUCCESSOR_PROJECTION_CONTRACT_ID,
464
+ source_paths=DPA_SUCCESSOR_PROJECTION_SOURCE_PATHS,
465
+ document_form="command-generated-successor-handoff-projection",
466
+ readiness_record_status=str(selected_writer_status.get(DPA_SUCCESSOR_PROJECTION_WRITER_ID, "MISSING")),
467
+ expected_readiness_status="GENERATED_OUTPUT_CONTRACT_ONLY",
468
+ implementation_result_ref="644f470a",
469
+ evidence_path="docs/architecture/evidence/dpa/probes/fixture-evidence-9cd4a7fc-wrt-ch006-20260729/results.json",
470
+ rollback="source command contract and exact-byte rollback classification; no durable manual patches",
471
+ adjudication=adjudication,
472
+ completion_blocker="dp3-or-dp4-generated-output-adjudication-record-missing",
473
+ ),
474
+ )
475
+
476
+
477
+ def _candidate(
478
+ root: Path,
479
+ *,
480
+ writer_id: str,
481
+ target_identity: str,
482
+ target_path: str,
483
+ source_authority: str,
484
+ source_paths: tuple[str, ...],
485
+ document_form: str,
486
+ readiness_record_status: str,
487
+ expected_readiness_status: str,
488
+ implementation_result_ref: str,
489
+ evidence_path: str,
490
+ rollback: str,
491
+ adjudication: Dp3Dp4AdjudicationResult,
492
+ completion_blocker: str,
493
+ ) -> RolloutCandidate:
494
+ entry_blockers: list[str] = []
495
+ for source_path in source_paths:
496
+ if not (root / source_path).exists():
497
+ entry_blockers.append(f"source-missing:{source_path}")
498
+ if readiness_record_status != expected_readiness_status:
499
+ entry_blockers.append(
500
+ f"readiness-record-status-mismatch:{readiness_record_status}:expected:{expected_readiness_status}"
501
+ )
502
+ evidence = _evidence_summary(root, evidence_path)
503
+ if not evidence["present"]:
504
+ entry_blockers.append(f"evidence-missing:{evidence_path}")
505
+ elif evidence.get("result_status") != "FULL_FIXTURE_EVIDENCE_RECORDED":
506
+ entry_blockers.append(f"fixture-evidence-not-full:{evidence.get('result_status')}")
507
+ if _mapping(evidence.get("full_evidence_by_family")).get("PROBE-003") is not True:
508
+ entry_blockers.append("dpa-600-probe-003-evidence-missing")
509
+ if _mapping(evidence.get("full_evidence_by_family")).get("PROBE-004") is not True:
510
+ entry_blockers.append("dpa-700-probe-004-evidence-missing")
511
+ if evidence.get("rollback_cleanup_proven") is not True:
512
+ entry_blockers.append("rollback-cleanup-not-proven")
513
+ completion_blockers: tuple[str, ...]
514
+ if adjudication.dp3_target_accepted(writer_id):
515
+ completion_blockers = ()
516
+ else:
517
+ completion_blockers = (completion_blocker,)
518
+ return RolloutCandidate(
519
+ writer_id=writer_id,
520
+ target_identity=target_identity,
521
+ target_path=target_path,
522
+ source_authority=source_authority,
523
+ source_paths=source_paths,
524
+ document_form=document_form,
525
+ readiness_record_status=readiness_record_status,
526
+ implementation_result_ref=implementation_result_ref,
527
+ implementation_ref_verified=_git_ref_exists(root, implementation_result_ref),
528
+ dpa_600_evidence={
529
+ "probe_family": "PROBE-003",
530
+ "evidence_path": evidence_path,
531
+ "satisfied": _mapping(evidence.get("full_evidence_by_family")).get("PROBE-003") is True,
532
+ },
533
+ dpa_700_evidence={
534
+ "probe_family": "PROBE-004",
535
+ "evidence_path": evidence_path,
536
+ "satisfied": _mapping(evidence.get("full_evidence_by_family")).get("PROBE-004") is True,
537
+ "rollback_cleanup_proven": evidence.get("rollback_cleanup_proven") is True,
538
+ },
539
+ rollback=rollback,
540
+ adjudication_record=adjudication.record_path,
541
+ adjudication_status=adjudication.dp3_target_status.get(writer_id, adjudication.result_status),
542
+ entry_blockers=tuple(entry_blockers),
543
+ completion_blockers=completion_blockers,
544
+ )
545
+
546
+
547
+ def _status_authority_candidates(
548
+ root: Path,
549
+ adjudication: Dp3Dp4AdjudicationResult,
550
+ ) -> tuple[StatusAuthorityCandidate, ...]:
551
+ successor_evidence = "docs/architecture/evidence/dpa/probes/fixture-evidence-9cd4a7fc-wrt-ch006-20260729/results.json"
552
+ candidates = [
553
+ StatusAuthorityCandidate(
554
+ id="DP4-CURRENT-HANDOFF",
555
+ path="docs/handoff/CURRENT_HANDOFF.md",
556
+ document_form="hybrid-current-state-document",
557
+ source_authority=".agentic/operational_handoff_state.yaml plus curated manual regions",
558
+ target_identity="CURRENT_HANDOFF_SELF_HOSTING_TARGET",
559
+ generated_or_command_updated=True,
560
+ decision="manual-preservation-required-for-non-lifecycle-owned-bytes",
561
+ adjudication_record=adjudication.record_path,
562
+ adjudication_status=adjudication.dp4_candidate_status.get("DP4-CURRENT-HANDOFF", adjudication.result_status),
563
+ blockers=_dp4_blockers(adjudication, "DP4-CURRENT-HANDOFF", "dp4-adjudication-record-missing"),
564
+ evidence=("docs/architecture/evidence/dpa/assessment/DP2_MAINTAINER_ASSESSMENT_RECORD_20260728.json",),
565
+ ),
566
+ StatusAuthorityCandidate(
567
+ id="DP4-STATUS",
568
+ path="docs/STATUS.md",
569
+ document_form="manual-current-state-dashboard",
570
+ source_authority="manual-maintainer-current-state-update",
571
+ target_identity="PROJECT_STATUS_CURRENT_STATE",
572
+ generated_or_command_updated=False,
573
+ decision="no-migration-until-reader-writer-inventory-is-recorded",
574
+ adjudication_record=adjudication.record_path,
575
+ adjudication_status=adjudication.dp4_candidate_status.get("DP4-STATUS", adjudication.result_status),
576
+ blockers=_dp4_blockers(adjudication, "DP4-STATUS", "reader-writer-generator-command-update-inventory-missing"),
577
+ evidence=(),
578
+ ),
579
+ StatusAuthorityCandidate(
580
+ id="DP4-SUCCESSOR-PROJECTIONS",
581
+ path="docs/reports/handoff-packages/latest/ and docs/handoff/NEXT_CHAT_BOOTSTRAP.md",
582
+ document_form="command-generated-successor-handoff-projection-family",
583
+ source_authority=DPA_SUCCESSOR_PROJECTION_CONTRACT_ID,
584
+ target_identity=DPA_SUCCESSOR_PROJECTION_TARGET_SCOPE,
585
+ generated_or_command_updated=True,
586
+ decision="no-migration-generated-output-command-contract-boundary",
587
+ adjudication_record=adjudication.record_path,
588
+ adjudication_status=adjudication.dp4_candidate_status.get(
589
+ "DP4-SUCCESSOR-PROJECTIONS",
590
+ adjudication.result_status,
591
+ ),
592
+ blockers=_dp4_blockers(adjudication, "DP4-SUCCESSOR-PROJECTIONS", "dp4-no-migration-adjudication-record-missing"),
593
+ evidence=(successor_evidence,),
594
+ ),
595
+ ]
596
+ return tuple(_with_missing_path_blockers(root, candidate) for candidate in candidates)
597
+
598
+
599
+ def _with_missing_path_blockers(root: Path, candidate: StatusAuthorityCandidate) -> StatusAuthorityCandidate:
600
+ path = candidate.path.split(" and ", 1)[0].rstrip("/")
601
+ if path.endswith("latest"):
602
+ path = "docs/reports/handoff-packages/latest"
603
+ blockers = list(candidate.blockers)
604
+ if not (root / path).exists():
605
+ blockers.append(f"candidate-path-missing:{candidate.path}")
606
+ for evidence in candidate.evidence:
607
+ if not (root / evidence).exists():
608
+ blockers.append(f"evidence-missing:{evidence}")
609
+ return StatusAuthorityCandidate(
610
+ id=candidate.id,
611
+ path=candidate.path,
612
+ document_form=candidate.document_form,
613
+ source_authority=candidate.source_authority,
614
+ target_identity=candidate.target_identity,
615
+ generated_or_command_updated=candidate.generated_or_command_updated,
616
+ decision=candidate.decision,
617
+ adjudication_record=candidate.adjudication_record,
618
+ adjudication_status=candidate.adjudication_status,
619
+ blockers=tuple(blockers),
620
+ evidence=candidate.evidence,
621
+ )
622
+
623
+
624
+ def _dp4_blockers(adjudication: Dp3Dp4AdjudicationResult, candidate_id: str, fallback: str) -> tuple[str, ...]:
625
+ if adjudication.dp4_candidate_accepted(candidate_id):
626
+ return ()
627
+ return (fallback,)
628
+
629
+
630
+ def _strict_lifecycle_stages(
631
+ adjudication: Dp3Dp4AdjudicationResult,
632
+ dp5_stage: Dp5StageAdoptionResult,
633
+ ) -> tuple[StrictLifecycleStage, ...]:
634
+ shared_blockers = []
635
+ if not adjudication.ok:
636
+ shared_blockers.append("accepted-dp3-and-dp4-results-missing")
637
+ transition_blockers = (
638
+ "exact-stage-authorization-record-missing",
639
+ "rollback-to-less-strict-stage-evidence-missing",
640
+ )
641
+ stages: list[StrictLifecycleStage] = []
642
+ for stage in DP5_STAGE_SEQUENCE:
643
+ if adjudication.ok and dp5_stage.stage_accepted(stage) and stage in DP5_ADOPTED_STAGE_STATUS:
644
+ stages.append(StrictLifecycleStage(stage, DP5_ADOPTED_STAGE_STATUS[stage], ()))
645
+ continue
646
+ blockers = list(shared_blockers)
647
+ if not dp5_stage.stage_accepted(stage):
648
+ blockers.extend(transition_blockers)
649
+ stages.append(StrictLifecycleStage(stage, "BLOCKED_BEFORE_STAGE_TRANSITION", tuple(blockers)))
650
+ return tuple(stages)
651
+
652
+
653
+ def _evidence_summary(root: Path, evidence_path: str) -> dict[str, Any]:
654
+ path = root / evidence_path
655
+ if not path.exists():
656
+ return {"path": evidence_path, "present": False}
657
+ try:
658
+ data = json.loads(path.read_text(encoding="utf-8"))
659
+ except json.JSONDecodeError as exc:
660
+ return {"path": evidence_path, "present": True, "json_error": str(exc)}
661
+ if not isinstance(data, dict):
662
+ return {"path": evidence_path, "present": True, "json_error": "evidence root must be object"}
663
+ return {
664
+ "path": evidence_path,
665
+ "present": True,
666
+ "kind": data.get("kind"),
667
+ "validation_ref": data.get("validation_ref"),
668
+ "result_status": data.get("result_status"),
669
+ "full_evidence_by_family": data.get("full_evidence_by_family", {}),
670
+ "rollback_cleanup_proven": data.get("rollback_cleanup_proven"),
671
+ }
672
+
673
+
674
+ def _false_claims() -> dict[str, bool]:
675
+ return {
676
+ "dp3_complete": False,
677
+ "dp4_complete": False,
678
+ "dp5_strict_enforced": False,
679
+ "kit_wide_dpa_conformance_claimed": False,
680
+ "production_mutation_performed": False,
681
+ "generated_outputs_manually_patched": False,
682
+ }
683
+
684
+
685
+ def _mapping(value: Any) -> dict[str, Any]:
686
+ return value if isinstance(value, dict) else {}
687
+
688
+
689
+ def _resolve_under_root(root: Path, path: Path | str) -> Path:
690
+ candidate = Path(path)
691
+ if candidate.is_absolute():
692
+ return candidate
693
+ return root / candidate
694
+
695
+
696
+ def _display_path(path: Path, root: Path) -> str:
697
+ try:
698
+ return path.relative_to(root).as_posix()
699
+ except ValueError:
700
+ return path.as_posix()
701
+
702
+
703
+ def _evidence_output_root(root: Path) -> Path:
704
+ ws = load_workspace(root, suppress_legacy_profile_warning=True)
705
+ return ws.architecture_file(Path(*EVIDENCE_OUTPUT_ROOT_PARTS)).resolve()
706
+
707
+
708
+ def _git_head(root: Path) -> str:
709
+ try:
710
+ completed = subprocess.run(
711
+ ["git", "rev-parse", "HEAD"],
712
+ cwd=root,
713
+ check=True,
714
+ text=True,
715
+ stdout=subprocess.PIPE,
716
+ stderr=subprocess.PIPE,
717
+ )
718
+ except (OSError, subprocess.CalledProcessError):
719
+ return "UNKNOWN"
720
+ return completed.stdout.strip() or "UNKNOWN"
721
+
722
+
723
+ def _git_ref_exists(root: Path, ref: str) -> bool | None:
724
+ if not (root / ".git").exists():
725
+ return None
726
+ completed = subprocess.run(
727
+ ["git", "rev-parse", "--verify", f"{ref}^{{commit}}"],
728
+ cwd=root,
729
+ check=False,
730
+ text=True,
731
+ stdout=subprocess.PIPE,
732
+ stderr=subprocess.PIPE,
733
+ )
734
+ return completed.returncode == 0