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,767 @@
1
+ from __future__ import annotations
2
+
3
+ # ruff: noqa: F403,F405
4
+
5
+ from agentic_project_kit.cli_commands.transfer_shared import *
6
+
7
+
8
+ def _normalize_agentic_command_for_reference(command: str) -> str:
9
+ parts = shlex.split(command)
10
+ if not parts:
11
+ return ""
12
+ if parts[0].endswith("agentic-kit"):
13
+ parts[0] = "agentic-kit"
14
+ elif parts[:2] == ["./.venv/bin/python", "-m"] and len(parts) >= 3 and parts[2] == "agentic_project_kit":
15
+ parts = ["agentic-kit", *parts[3:]]
16
+ else:
17
+ return " ".join(parts)
18
+ return " ".join(parts)
19
+
20
+ def _load_command_reference_names(root: Path) -> set[str]:
21
+ reference_path = root / "docs/reference/agentic-kit-commands.json"
22
+ payload = json.loads(reference_path.read_text(encoding="utf-8"))
23
+ commands = payload.get("commands", [])
24
+ names: set[str] = set()
25
+ for item in commands:
26
+ if isinstance(item, dict) and isinstance(item.get("qualified_name"), str):
27
+ names.add(str(item["qualified_name"]))
28
+ return names
29
+
30
+ def _detect_avoidable_low_level_meta_command_sequences(sequence_commands: list[str] | None) -> list[dict[str, object]]:
31
+ if not sequence_commands:
32
+ return []
33
+
34
+ meta_command_sequences = {
35
+ "pr-closeout-complete": {
36
+ "meta_command": "agentic-kit transfer pr-closeout-complete",
37
+ "low_level_markers": {
38
+ "agentic-kit transfer pr-wait-ci",
39
+ "agentic-kit transfer pr-merge-safe",
40
+ "agentic-kit transfer post-merge-check",
41
+ "agentic-kit transfer post-merge-complete",
42
+ "agentic-kit transfer repo-status",
43
+ },
44
+ },
45
+ "work-start": {
46
+ "meta_command": "agentic-kit work start",
47
+ "low_level_markers": {
48
+ "agentic-kit transfer sync-main",
49
+ "agentic-kit rules acknowledge",
50
+ "agentic-kit transfer post-merge-check",
51
+ "agentic-kit transfer repo-status",
52
+ },
53
+ },
54
+ "work-check": {
55
+ "meta_command": "agentic-kit work check",
56
+ "low_level_markers": {
57
+ "agentic-kit transfer command-reference-check",
58
+ "agentic-kit docs-audit",
59
+ "agentic-kit audit-doc-currency",
60
+ },
61
+ },
62
+ "work-finish": {
63
+ "meta_command": "agentic-kit work finish",
64
+ "low_level_markers": {
65
+ "agentic-kit transfer protected-diff-plan",
66
+ "agentic-kit transfer commit",
67
+ "agentic-kit transfer push-current",
68
+ "agentic-kit transfer pr-create-complete",
69
+ },
70
+ },
71
+ "work-recover": {
72
+ "meta_command": "agentic-kit work recover",
73
+ "low_level_markers": {
74
+ "agentic-kit transfer restore-known-volatile",
75
+ "agentic-kit transfer normalize-session",
76
+ "agentic-kit transfer conflict-status",
77
+ "agentic-kit transfer patch-cycle-status",
78
+ },
79
+ },
80
+ "release-ready": {
81
+ "meta_command": "agentic-kit release ready",
82
+ "low_level_markers": {
83
+ "agentic-kit transfer standard-error-scan",
84
+ "agentic-kit release-status",
85
+ },
86
+ },
87
+ "release-prepare": {
88
+ "meta_command": "agentic-kit release prepare",
89
+ "low_level_markers": {
90
+ "agentic-kit release-notes-generate",
91
+ "agentic-kit release-prep",
92
+ },
93
+ },
94
+ }
95
+
96
+ normalized_sequence = [" ".join(command.split()) for command in sequence_commands]
97
+ sequence_blob = "\n".join(normalized_sequence)
98
+ avoidable: list[dict[str, object]] = []
99
+ for sequence_name, rule in meta_command_sequences.items():
100
+ meta_command = str(rule["meta_command"])
101
+ markers = set(rule["low_level_markers"])
102
+ matched_markers = sorted(marker for marker in markers if marker in sequence_blob)
103
+ if len(matched_markers) >= 2 and meta_command not in sequence_blob:
104
+ avoidable.append(
105
+ {
106
+ "sequence": sequence_name,
107
+ "preferred_meta_command": meta_command,
108
+ "matched_low_level_markers": matched_markers,
109
+ }
110
+ )
111
+ return avoidable
112
+
113
+ @transfer_app.command("command-composition-check")
114
+ def command_composition_check_command(
115
+ test_paths: list[Path] | None = typer.Option(
116
+ None,
117
+ "--test-path",
118
+ help="Repository-relative test path that must exist before composing a pytest command. Repeatable.",
119
+ ),
120
+ commands: list[str] | None = typer.Option(
121
+ None,
122
+ "--command",
123
+ help="agentic-kit command prefix that must exist in docs/reference/agentic-kit-commands.json. Repeatable.",
124
+ ),
125
+ sequence_commands: list[str] | None = typer.Option(
126
+ None,
127
+ "--sequence-command",
128
+ help="Command sequence entry to check for avoidable low-level workflow chains. Repeatable.",
129
+ ),
130
+ root: Path = typer.Option(Path("."), "--root", help="Project root."),
131
+ json_output: bool = typer.Option(False, "--json", help="Print machine-readable JSON only."),
132
+ ) -> None:
133
+ """Block common copied-command mistakes before running patch, transfer, or release gates."""
134
+ project_root = root.resolve()
135
+ avoidable_low_level_sequences = _detect_avoidable_low_level_meta_command_sequences(sequence_commands)
136
+ missing_test_paths: list[str] = []
137
+ existing_test_paths: list[str] = []
138
+ for raw_path in test_paths or []:
139
+ candidate = raw_path if raw_path.is_absolute() else project_root / raw_path
140
+ rel = str(raw_path)
141
+ if candidate.exists():
142
+ existing_test_paths.append(rel)
143
+ else:
144
+ missing_test_paths.append(rel)
145
+
146
+ reference_missing = False
147
+ valid_commands: list[str] = []
148
+ invalid_commands: list[str] = []
149
+ try:
150
+ reference_names = _load_command_reference_names(project_root)
151
+ except (OSError, json.JSONDecodeError, ValueError):
152
+ reference_names = set()
153
+ reference_missing = bool(commands)
154
+
155
+ for command in commands or []:
156
+ normalized = _normalize_agentic_command_for_reference(command)
157
+ if normalized and normalized in reference_names:
158
+ valid_commands.append(command)
159
+ else:
160
+ invalid_commands.append(command)
161
+
162
+ blockers: list[str] = []
163
+ if missing_test_paths:
164
+ blockers.append("missing_test_paths")
165
+ if reference_missing:
166
+ blockers.append("command_reference_unavailable")
167
+ if invalid_commands:
168
+ blockers.append("invalid_agentic_kit_commands")
169
+ if avoidable_low_level_sequences:
170
+ blockers.append("avoidable_low_level_sequences")
171
+
172
+ result_status = "PASS" if not blockers else "BLOCKED"
173
+ next_action = (
174
+ "Command composition inputs are valid."
175
+ if result_status == "PASS"
176
+ else "Fix missing test paths or invalid agentic-kit command names before running the composed block."
177
+ )
178
+ payload = {
179
+ "schema_version": 1,
180
+ "kind": "transfer_command_composition_check_result",
181
+ "action": "command-composition-check",
182
+ "result_status": result_status,
183
+ "returncode": 0 if result_status == "PASS" else 2,
184
+ "blockers": blockers,
185
+ "test_paths": {
186
+ "existing": existing_test_paths,
187
+ "missing": missing_test_paths,
188
+ },
189
+ "commands": {
190
+ "valid": valid_commands,
191
+ "invalid": invalid_commands,
192
+ },
193
+ "avoidable_low_level_sequences": avoidable_low_level_sequences,
194
+ "next_action": next_action,
195
+ }
196
+
197
+ if json_output:
198
+ typer.echo(json.dumps(payload, indent=2, sort_keys=True))
199
+ else:
200
+ _echo_transfer_payload_summary(
201
+ title="TRANSFER_COMMAND_COMPOSITION_CHECK",
202
+ result_status=result_status,
203
+ final_signal="d" if result_status == "PASS" else "f",
204
+ next_action=next_action,
205
+ fields={
206
+ "MISSING_TEST_PATHS": len(missing_test_paths),
207
+ "INVALID_COMMANDS": len(invalid_commands),
208
+ "AVOIDABLE_LOW_LEVEL_SEQUENCES": len(avoidable_low_level_sequences),
209
+ },
210
+ )
211
+
212
+ if result_status != "PASS":
213
+ raise typer.Exit(code=2)
214
+
215
+ def _load_yaml_mapping(path: Path) -> dict[str, object]:
216
+ if not path.exists():
217
+ return {}
218
+ try:
219
+ loaded = yaml.safe_load(path.read_text(encoding="utf-8"))
220
+ except Exception:
221
+ return {}
222
+ return loaded if isinstance(loaded, dict) else {}
223
+
224
+ def _meta_command_preference_source_paths(root: Path) -> set[Path]:
225
+ """Return the explicit YAML rule sources for active meta-command policy."""
226
+ return {
227
+ root / ".agentic" / "transfer_safety_rules.yaml",
228
+ root / ".agentic" / "transfer" / "one_command_transfer_protocol.yaml",
229
+ }
230
+
231
+ def _load_transfer_meta_command_preference(root: Path) -> dict[str, object]:
232
+ """Load local-to-LLM meta-command preference dynamically from rule sources."""
233
+ safety = _load_yaml_mapping(root / ".agentic" / "transfer_safety_rules.yaml")
234
+ protocol = _load_yaml_mapping(root / ".agentic" / "transfer" / "one_command_transfer_protocol.yaml")
235
+
236
+ safety_pref = safety.get("meta_command_preference")
237
+ protocol_pref = protocol.get("meta_command_preference")
238
+
239
+ preferred_commands: list[str] = []
240
+ if isinstance(safety_pref, dict):
241
+ raw = safety_pref.get("preferred_commands")
242
+ if isinstance(raw, dict):
243
+ preferred_commands.extend(str(value) for value in raw.values())
244
+ elif isinstance(raw, list):
245
+ preferred_commands.extend(str(value) for value in raw)
246
+ if isinstance(protocol_pref, dict):
247
+ raw = protocol_pref.get("preferred_entrypoints")
248
+ if isinstance(raw, list):
249
+ preferred_commands.extend(str(value) for value in raw)
250
+
251
+ unique_commands: list[str] = []
252
+ seen: set[str] = set()
253
+ for command in preferred_commands:
254
+ if command and command not in seen:
255
+ seen.add(command)
256
+ unique_commands.append(command)
257
+
258
+ fallback_rule = ""
259
+ priority = ""
260
+ if isinstance(safety_pref, dict):
261
+ fallback_rule = str(safety_pref.get("fallback_rule") or "")
262
+ priority = str(safety_pref.get("priority") or "")
263
+ if not fallback_rule and isinstance(protocol_pref, dict):
264
+ fallback_rule = str(protocol_pref.get("rule") or "")
265
+
266
+ return {
267
+ "status": "active" if unique_commands else "missing",
268
+ "priority": priority or "primary_path",
269
+ "preferred_commands": unique_commands,
270
+ "fallback_rule": fallback_rule,
271
+ "sources": sorted(str(path) for path in _meta_command_preference_source_paths(root)),
272
+ }
273
+
274
+ def _render_transfer_meta_command_preference_header(root: Path) -> str:
275
+ preference = _load_transfer_meta_command_preference(root)
276
+ if preference["status"] != "active":
277
+ return ""
278
+ lines = [
279
+ "META_COMMAND_PREFERENCE:",
280
+ f" status: {preference['status']}",
281
+ f" priority: {preference['priority']}",
282
+ " source: dynamic-from-rule-files",
283
+ " preferred_commands:",
284
+ ]
285
+ for command in preference["preferred_commands"]:
286
+ lines.append(f" - {command}")
287
+ fallback = str(preference.get("fallback_rule") or "").strip()
288
+ if fallback:
289
+ lines.append(f" fallback_rule: {fallback}")
290
+ lines.append(" low_level_fallback_requires_reason: true")
291
+ return "\n".join(lines)
292
+
293
+ def _render_local_to_llm_transfer_header(root: Path) -> str:
294
+ """Render the local-to-LLM transfer header from current rule sources."""
295
+ sections: list[str] = []
296
+ meta_header = _render_transfer_meta_command_preference_header(root).strip()
297
+ if meta_header:
298
+ sections.append(meta_header)
299
+ return "\n\n".join(sections).strip()
300
+
301
+ def _prefix_local_to_llm_transfer_header(content: str, *, root: Path | None = None) -> str:
302
+ """Prefix local-to-LLM transfer content with a dynamically rendered header."""
303
+ effective_root = root or Path(".")
304
+ header = _render_local_to_llm_transfer_header(effective_root).strip()
305
+ if not header:
306
+ return content
307
+ if content.startswith("META_COMMAND_PREFERENCE:"):
308
+ return content
309
+ return f"{header}\n\n{content}"
310
+
311
+ def _json_contains_static_meta_preference_policy(content: str) -> bool:
312
+ try:
313
+ parsed = json.loads(content)
314
+ except json.JSONDecodeError:
315
+ return False
316
+
317
+ def walk(value: object) -> bool:
318
+ if isinstance(value, dict):
319
+ for key, nested in value.items():
320
+ if key in {"meta_command_preference", "META_COMMAND_PREFERENCE"}:
321
+ return True
322
+ if walk(nested):
323
+ return True
324
+ elif isinstance(value, list):
325
+ return any(walk(item) for item in value)
326
+ return False
327
+
328
+ return walk(parsed)
329
+
330
+ def _scan_static_meta_preference_projection_drift(root: Path) -> dict[str, object]:
331
+ """Block static active meta-command policy outside explicit YAML rule sources.
332
+
333
+ This scans projections and generated/compiled carriers. It deliberately does
334
+ not scan implementation source code, because renderer code necessarily
335
+ contains marker strings such as META_COMMAND_PREFERENCE.
336
+ """
337
+ allowed_sources = {path.resolve() for path in _meta_command_preference_source_paths(root)}
338
+ scanned_roots = [
339
+ root / ".agentic",
340
+ root / "docs",
341
+ ]
342
+ forbidden_markers = [
343
+ "meta_command_preference:",
344
+ '"meta_command_preference"',
345
+ "META_COMMAND_PREFERENCE:",
346
+ '"META_COMMAND_PREFERENCE"',
347
+ ]
348
+ matches: list[dict[str, object]] = []
349
+
350
+ for scan_root in scanned_roots:
351
+ if not scan_root.exists():
352
+ continue
353
+ for candidate in scan_root.rglob("*"):
354
+ if not candidate.is_file():
355
+ continue
356
+ relative_parts = candidate.relative_to(scan_root).parts
357
+ if any(part in {".git", ".venv", "tmp", "__pycache__"} for part in relative_parts):
358
+ continue
359
+ if candidate.suffix not in {"", ".md", ".txt", ".yaml", ".yml", ".json"}:
360
+ continue
361
+ if candidate.resolve() in allowed_sources:
362
+ continue
363
+ try:
364
+ content = candidate.read_text(encoding="utf-8")
365
+ except UnicodeDecodeError:
366
+ continue
367
+ json_policy_match = candidate.suffix == ".json" and _json_contains_static_meta_preference_policy(content)
368
+ if json_policy_match:
369
+ line_numbers = [
370
+ index
371
+ for index, line in enumerate(content.splitlines(), start=1)
372
+ if "meta_command_preference" in line or "META_COMMAND_PREFERENCE" in line
373
+ ] or [1]
374
+ matches.append(
375
+ {
376
+ "path": str(candidate.relative_to(root)),
377
+ "marker": "json:meta_command_preference",
378
+ "line_numbers": line_numbers,
379
+ }
380
+ )
381
+ continue
382
+
383
+ for marker in forbidden_markers:
384
+ marker_matches = [marker]
385
+ if marker == "meta_command_preference:":
386
+ marker_matches.extend([
387
+ '"meta_command_preference"',
388
+ "'meta_command_preference'",
389
+ ])
390
+ if marker == "META_COMMAND_PREFERENCE:":
391
+ marker_matches.extend([
392
+ '"META_COMMAND_PREFERENCE"',
393
+ "'META_COMMAND_PREFERENCE'",
394
+ ])
395
+ if not any(marker_match in content for marker_match in marker_matches):
396
+ continue
397
+ line_numbers = [
398
+ index
399
+ for index, line in enumerate(content.splitlines(), start=1)
400
+ if any(marker_match in line for marker_match in marker_matches)
401
+ ]
402
+ matches.append(
403
+ {
404
+ "path": str(candidate.relative_to(root)),
405
+ "marker": marker,
406
+ "line_numbers": line_numbers,
407
+ }
408
+ )
409
+ return {
410
+ "status": "PASS" if not matches else "BLOCKED",
411
+ "allowed_static_sources": sorted(str(path.relative_to(root)) for path in _meta_command_preference_source_paths(root)),
412
+ "matches": matches,
413
+ }
414
+
415
+ def _latest_release_tag() -> str:
416
+ completed = subprocess.run(
417
+ ["git", "tag", "--sort=-creatordate"],
418
+ text=True,
419
+ capture_output=True,
420
+ )
421
+ if completed.returncode != 0:
422
+ return ""
423
+ for line in completed.stdout.splitlines():
424
+ tag = line.strip()
425
+ if tag.startswith("v"):
426
+ return tag
427
+ return ""
428
+
429
+ def _run_standard_error_scan_step(
430
+ name: str,
431
+ argv: list[str],
432
+ *,
433
+ allowed_returncodes: set[int] | None = None,
434
+ ) -> dict[str, object]:
435
+ allowed = allowed_returncodes or {0}
436
+ completed = subprocess.run(argv, text=True, capture_output=True)
437
+ ok = completed.returncode in allowed
438
+ return {
439
+ "name": name,
440
+ "argv": argv,
441
+ "returncode": completed.returncode,
442
+ "ok": ok,
443
+ "stdout": completed.stdout,
444
+ "stderr": completed.stderr,
445
+ "allowed_returncodes": sorted(allowed),
446
+ }
447
+
448
+ def _known_bad_pattern_scan(root: Path) -> dict[str, object]:
449
+ # Build these from fragments so repository audits do not flag the scanner's own
450
+ # negative examples as active workflow instructions.
451
+ patterns = [
452
+ "tests/" + "test_release_status.py",
453
+ "agentic-kit " + "command-reference-refresh",
454
+ "_copy_" + "project_fixture",
455
+ "<" + "pr-number>",
456
+ "./" + "ns protected-diff-check",
457
+ "./" + "ns merge-if-green",
458
+ "./" + "ns next-safe-step",
459
+ ]
460
+ # Scan only active workflow surfaces. Historical planning/test-gate docs may
461
+ # legitimately mention old commands as examples or archived failure modes.
462
+ search_roots = [
463
+ root / "src",
464
+ root / "tests",
465
+ root / "docs/reference",
466
+ root / "docs/handoff",
467
+ root / ".agentic",
468
+ ]
469
+ matches: list[dict[str, object]] = []
470
+ for base in search_roots:
471
+ if not base.exists():
472
+ continue
473
+ for file_path in base.rglob("*"):
474
+ if not file_path.is_file():
475
+ continue
476
+ if any(part in {".git", ".venv", "tmp", "__pycache__"} for part in file_path.parts):
477
+ continue
478
+ try:
479
+ content = file_path.read_text(encoding="utf-8")
480
+ except UnicodeDecodeError:
481
+ continue
482
+ for line_number, line in enumerate(content.splitlines(), start=1):
483
+ for pattern in patterns:
484
+ if pattern in line:
485
+ matches.append(
486
+ {
487
+ "path": str(file_path.relative_to(root)),
488
+ "line": line_number,
489
+ "pattern": pattern,
490
+ "text": line.strip()[:240],
491
+ }
492
+ )
493
+ return {"patterns": patterns, "matches": matches}
494
+
495
+ def _scan_llm_work_order_contract(root: Path) -> dict[str, object]:
496
+ """Verify that LLM work orders are contractually Python scripts."""
497
+ try:
498
+ header = build_transfer_safety_header(root)
499
+ except Exception as exc:
500
+ return {
501
+ "status": "BLOCKED",
502
+ "error": str(exc),
503
+ "required_format": None,
504
+ "canonical_inbox": None,
505
+ "shell_commands_allowed": None,
506
+ }
507
+
508
+ contract = header.get("llm_work_order_contract")
509
+ if not isinstance(contract, dict):
510
+ return {
511
+ "status": "BLOCKED",
512
+ "error": "llm_work_order_contract_missing",
513
+ "required_format": None,
514
+ "canonical_inbox": None,
515
+ "shell_commands_allowed": None,
516
+ }
517
+
518
+ transfer_file = contract.get("transfer_file")
519
+ if not isinstance(transfer_file, dict):
520
+ transfer_file = {}
521
+
522
+ required_format = contract.get("required_format")
523
+ canonical_inbox = transfer_file.get("canonical_inbox")
524
+ shell_commands_allowed = transfer_file.get("shell_commands_allowed")
525
+
526
+ failures: list[str] = []
527
+ if required_format != "python_script":
528
+ failures.append("required_format_not_python_script")
529
+ if not str(canonical_inbox or "").endswith(".py.txt"):
530
+ failures.append("canonical_inbox_not_python_script_file")
531
+ if shell_commands_allowed is not False:
532
+ failures.append("transfer_file_allows_shell_commands")
533
+
534
+ return {
535
+ "status": "PASS" if not failures else "BLOCKED",
536
+ "failures": failures,
537
+ "required_format": required_format,
538
+ "canonical_inbox": canonical_inbox,
539
+ "shell_commands_allowed": shell_commands_allowed,
540
+ }
541
+
542
+ @transfer_app.command("standard-error-scan")
543
+ def standard_error_scan_command(
544
+ before_release: bool = typer.Option(
545
+ False,
546
+ "--before-release",
547
+ help="Run the release-oriented standard-error scan bundle.",
548
+ ),
549
+ version: str = typer.Option("", "--version", help="Release version for before-release checks. Required with --before-release."),
550
+ from_tag: str = typer.Option("", "--from-tag", help="Previous release tag for release notes checks. Defaults to the latest local v* git tag."),
551
+ to_ref: str = typer.Option("main", "--to-ref", help="Target ref for release notes checks."),
552
+ date: str = typer.Option("", "--date", help="Release date for release-prep dry-run. Defaults to today."),
553
+ root: Path = typer.Option(Path("."), "--root", help="Project root."),
554
+ json_output: bool = typer.Option(False, "--json", help="Print machine-readable JSON only."),
555
+ ) -> None:
556
+ """Run a bounded scan for known workflow standard errors before patch/transfer/release work."""
557
+ project_root = root.resolve()
558
+ release_date = date or date_cls.today().isoformat()
559
+ effective_from_tag = from_tag or _latest_release_tag()
560
+ steps: list[dict[str, object]] = []
561
+
562
+ def step(name: str, argv: list[str], *, allowed_returncodes: set[int] | None = None) -> None:
563
+ steps.append(_run_standard_error_scan_step(name, argv, allowed_returncodes=allowed_returncodes))
564
+
565
+ if before_release:
566
+ step("post-merge-check", ["./.venv/bin/agentic-kit", "transfer", "post-merge-check"])
567
+ step("repo-status", ["./.venv/bin/agentic-kit", "transfer", "repo-status"])
568
+
569
+ release_tests = [
570
+ "tests/test_release_prepare_command.py",
571
+ "tests/test_release_notes.py",
572
+ "tests/test_release_state.py",
573
+ "tests/test_agentic_kit_command_reference_is_current.py",
574
+ ]
575
+ command_check = [
576
+ "./.venv/bin/agentic-kit",
577
+ "transfer",
578
+ "command-composition-check",
579
+ "--json",
580
+ ]
581
+ for test_path in release_tests:
582
+ command_check.extend(["--test-path", test_path])
583
+ for command in [
584
+ "agentic-kit transfer command-reference-check",
585
+ "agentic-kit transfer command-composition-check",
586
+ "agentic-kit transfer patch-cycle-status",
587
+ "agentic-kit release-status",
588
+ "agentic-kit release-notes-generate",
589
+ "agentic-kit release-prep",
590
+ ]:
591
+ command_check.extend(["--command", command])
592
+ step("command-composition-check", command_check)
593
+ step("command-reference-check", ["./.venv/bin/agentic-kit", "transfer", "command-reference-check", "--json"])
594
+ step("patch-cycle-status", ["./.venv/bin/agentic-kit", "transfer", "patch-cycle-status", "--include-ci", "--json"], allowed_returncodes={0, 2})
595
+
596
+ if before_release:
597
+ if not version:
598
+ steps.append(
599
+ {
600
+ "name": "release-version",
601
+ "argv": [],
602
+ "returncode": 2,
603
+ "ok": False,
604
+ "allowed_returncodes": [0],
605
+ "stdout": "",
606
+ "stderr": "--version is required with --before-release.",
607
+ }
608
+ )
609
+ if not effective_from_tag:
610
+ steps.append(
611
+ {
612
+ "name": "release-from-tag",
613
+ "argv": [],
614
+ "returncode": 2,
615
+ "ok": False,
616
+ "allowed_returncodes": [0],
617
+ "stdout": "",
618
+ "stderr": "--from-tag was not provided and no local v* git tag could be derived.",
619
+ }
620
+ )
621
+ summary_lines_path = project_root / "tmp" / f"release-{version.replace('.', '')}-summary-lines.json"
622
+ step("release-status", ["./.venv/bin/agentic-kit", "release-status", "--include-remote", "--json"], allowed_returncodes={0, 2})
623
+ step(
624
+ "release-notes-generate",
625
+ [
626
+ "./.venv/bin/agentic-kit",
627
+ "release-notes-generate",
628
+ "--version",
629
+ version,
630
+ "--from-tag",
631
+ effective_from_tag,
632
+ "--to-ref",
633
+ to_ref,
634
+ "--include-github-metadata",
635
+ "--summary-lines-json",
636
+ str(summary_lines_path),
637
+ "--json",
638
+ ],
639
+ )
640
+ step(
641
+ "release-prep-dry-run",
642
+ [
643
+ "./.venv/bin/agentic-kit",
644
+ "release-prep",
645
+ "--version",
646
+ version,
647
+ "--date",
648
+ release_date,
649
+ "--summary-lines-from",
650
+ str(summary_lines_path),
651
+ "--dry-run",
652
+ "--json",
653
+ ],
654
+ )
655
+
656
+ step(
657
+ "fresh-context-strict",
658
+ ["./.venv/bin/agentic-kit", "transfer", "require-fresh-llm-context", "--json"],
659
+ allowed_returncodes={0, 2},
660
+ )
661
+ step(
662
+ "fresh-context-clean-post-merge-allowance",
663
+ [
664
+ "./.venv/bin/agentic-kit",
665
+ "transfer",
666
+ "require-fresh-llm-context",
667
+ "--allow-clean-post-merge-carrier-staleness",
668
+ "--json",
669
+ ],
670
+ allowed_returncodes={0} if before_release else {0, 2},
671
+ )
672
+ step("docs-audit", ["./.venv/bin/agentic-kit", "docs-audit"])
673
+ step("audit-doc-currency", ["./.venv/bin/agentic-kit", "audit-doc-currency"])
674
+ step("audit-planning-docs-consolidation", ["./.venv/bin/agentic-kit", "audit-planning-docs-consolidation"])
675
+ step("audit-ns-legacy-references", ["./.venv/bin/agentic-kit", "audit-ns-legacy-references"])
676
+ step("audit-program-redundancy", ["./.venv/bin/agentic-kit", "audit-program-redundancy"])
677
+ step("standard-gates-audit-suite", ["./.venv/bin/agentic-kit", "standard-gates-audit-suite"])
678
+
679
+ pattern_scan = _known_bad_pattern_scan(project_root)
680
+ llm_work_order_contract_scan = _scan_llm_work_order_contract(project_root)
681
+ local_to_llm_log_header = render_local_to_llm_log_header(project_root)
682
+ local_to_llm_log_header_contains_meta_preference = (
683
+ "META_COMMAND_PREFERENCE" in local_to_llm_log_header
684
+ or "meta_command_preference" in local_to_llm_log_header
685
+ )
686
+ local_to_llm_log_header_scan = {
687
+ "status": "PASS"
688
+ if local_to_llm_log_header_contains_meta_preference and "dynamic-from-rule-files" in local_to_llm_log_header
689
+ else "BLOCKED",
690
+ "contains_meta_command_preference": local_to_llm_log_header_contains_meta_preference,
691
+ "contains_dynamic_source_marker": "dynamic-from-rule-files" in local_to_llm_log_header,
692
+ }
693
+ static_meta_preference_projection_scan = _scan_static_meta_preference_projection_drift(project_root)
694
+ blockers: list[str] = []
695
+ warnings: list[str] = []
696
+
697
+ for item in steps:
698
+ if not item["ok"]:
699
+ blockers.append(str(item["name"]))
700
+
701
+ if pattern_scan["matches"]:
702
+ warnings.append("known_bad_patterns_found")
703
+ if llm_work_order_contract_scan["status"] != "PASS":
704
+ blockers.append("llm_work_order_contract_not_python_script")
705
+ if local_to_llm_log_header_scan["status"] != "PASS":
706
+ blockers.append("local_to_llm_log_header_missing_dynamic_meta_preference")
707
+ if static_meta_preference_projection_scan["matches"]:
708
+ blockers.append("static_meta_preference_projection_drift")
709
+
710
+ strict_step = next((item for item in steps if item["name"] == "fresh-context-strict"), None)
711
+ allowance_step = next((item for item in steps if item["name"] == "fresh-context-clean-post-merge-allowance"), None)
712
+ if strict_step and strict_step["returncode"] == 2 and allowance_step:
713
+ if allowance_step["returncode"] == 0:
714
+ warnings.append("strict_fresh_context_blocked_but_clean_post_merge_allowance_passed")
715
+ elif not before_release and allowance_step["returncode"] == 2:
716
+ warnings.append("fresh_context_stale_in_feature_branch_diagnostic")
717
+
718
+ result_status = "BLOCKED" if blockers else "WARN" if warnings else "PASS"
719
+ next_action = (
720
+ "Fix blocking standard-error scan steps before continuing."
721
+ if blockers
722
+ else "Review warnings, then continue release readiness."
723
+ if warnings
724
+ else "No known standard-error blockers detected."
725
+ )
726
+
727
+ payload = {
728
+ "schema_version": 1,
729
+ "kind": "transfer_standard_error_scan_result",
730
+ "action": "standard-error-scan",
731
+ "result_status": result_status,
732
+ "returncode": 2 if blockers else 0,
733
+ "before_release": before_release,
734
+ "version": version,
735
+ "from_tag": effective_from_tag,
736
+ "to_ref": to_ref,
737
+ "date": release_date,
738
+ "blockers": blockers,
739
+ "warnings": warnings,
740
+ "steps": steps,
741
+ "known_bad_pattern_scan": pattern_scan,
742
+ "llm_work_order_contract_scan": llm_work_order_contract_scan,
743
+ "local_to_llm_log_header_scan": local_to_llm_log_header_scan,
744
+ "static_meta_preference_projection_scan": static_meta_preference_projection_scan,
745
+ "next_action": next_action,
746
+ }
747
+
748
+ if json_output:
749
+ typer.echo(json.dumps(payload, indent=2, sort_keys=True))
750
+ else:
751
+ _echo_transfer_payload_summary(
752
+ title="TRANSFER_STANDARD_ERROR_SCAN",
753
+ result_status=result_status,
754
+ final_signal="f" if blockers else "d",
755
+ next_action=next_action,
756
+ fields={
757
+ "BLOCKERS": len(blockers),
758
+ "WARNINGS": len(warnings),
759
+ "PATTERN_MATCHES": len(pattern_scan["matches"]),
760
+ },
761
+ )
762
+
763
+ if blockers:
764
+ raise typer.Exit(code=2)
765
+
766
+
767
+ __all__ = [name for name in globals() if not name.startswith("__")]