@hunter-harness/workflow-harness 0.2.15 → 0.2.17
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.
- package/harness/bundles/general/claude-code/.harness-build.json +1 -1
- package/harness/bundles/general/claude-code/CONTEXT.md +14 -1
- package/harness/bundles/general/claude-code/README.md +1 -1
- package/harness/bundles/general/claude-code/harness-archive/SKILL.md +7 -4
- package/harness/bundles/general/claude-code/harness-archive/reference.md +1 -1
- package/harness/bundles/general/claude-code/harness-codebase-map/SKILL.md +4 -2
- package/harness/bundles/general/claude-code/harness-knowledge-ingest/SKILL.md +4 -2
- package/harness/bundles/general/claude-code/harness-knowledge-ingest/scripts/harness_knowledge.py +16 -1
- package/harness/bundles/general/claude-code/harness-knowledge-query/SKILL.md +4 -2
- package/harness/bundles/general/claude-code/harness-plan/SKILL.md +8 -4
- package/harness/bundles/general/claude-code/harness-plan/checklist.md +5 -5
- package/harness/bundles/general/claude-code/harness-review/SKILL.md +5 -2
- package/harness/bundles/general/claude-code/harness-review/reference.md +13 -0
- package/harness/bundles/general/claude-code/harness-run/SKILL.md +7 -3
- package/harness/bundles/general/claude-code/harness-run/checklist.md +4 -4
- package/harness/bundles/general/claude-code/harness-submit/SKILL.md +6 -3
- package/harness/bundles/general/claude-code/harness-submit/checklist.md +5 -5
- package/harness/bundles/general/claude-code/harness-submit/reference.md +3 -3
- package/harness/bundles/general/claude-code/harness-sync/SKILL.md +4 -2
- package/harness/bundles/general/claude-code/harness-sync/reference.md +1 -1
- package/harness/bundles/general/claude-code/harness-test/SKILL.md +7 -4
- package/harness/bundles/general/claude-code/harness-test/checklist.md +8 -5
- package/harness/bundles/general/claude-code/harness-test/pitfalls.md +1 -1
- package/harness/bundles/general/claude-code/harness-test/reference.md +28 -13
- package/harness/bundles/general/claude-code/protocols/submit-protocol.md +1 -1
- package/harness/bundles/general/claude-code/scripts/harness_deploy.py +7 -0
- package/harness/bundles/general/claude-code/scripts/harness_gate.py +75 -0
- package/harness/bundles/general/claude-code/scripts/harness_integration.py +64 -2
- package/harness/bundles/general/claude-code/scripts/harness_ledger.py +70 -3
- package/harness/bundles/general/claude-code/scripts/harness_paths.py +17 -0
- package/harness/bundles/general/claude-code/scripts/harness_plan_finalize.py +306 -7
- package/harness/bundles/general/claude-code/scripts/harness_profile.py +58 -7
- package/harness/bundles/general/claude-code/scripts/harness_review.py +107 -0
- package/harness/bundles/general/claude-code/scripts/harness_test_cleanup.py +175 -0
- package/harness/bundles/general/codebuddy/.harness-build.json +1 -1
- package/harness/bundles/general/codebuddy/CONTEXT.md +14 -1
- package/harness/bundles/general/codebuddy/README.md +1 -1
- package/harness/bundles/general/codebuddy/harness-archive/SKILL.md +7 -4
- package/harness/bundles/general/codebuddy/harness-archive/reference.md +1 -1
- package/harness/bundles/general/codebuddy/harness-codebase-map/SKILL.md +4 -2
- package/harness/bundles/general/codebuddy/harness-knowledge-ingest/SKILL.md +4 -2
- package/harness/bundles/general/codebuddy/harness-knowledge-ingest/scripts/harness_knowledge.py +16 -1
- package/harness/bundles/general/codebuddy/harness-knowledge-query/SKILL.md +4 -2
- package/harness/bundles/general/codebuddy/harness-plan/SKILL.md +8 -4
- package/harness/bundles/general/codebuddy/harness-plan/checklist.md +5 -5
- package/harness/bundles/general/codebuddy/harness-review/SKILL.md +5 -2
- package/harness/bundles/general/codebuddy/harness-review/reference.md +13 -0
- package/harness/bundles/general/codebuddy/harness-run/SKILL.md +7 -3
- package/harness/bundles/general/codebuddy/harness-run/checklist.md +4 -4
- package/harness/bundles/general/codebuddy/harness-submit/SKILL.md +6 -3
- package/harness/bundles/general/codebuddy/harness-submit/checklist.md +5 -5
- package/harness/bundles/general/codebuddy/harness-submit/reference.md +3 -3
- package/harness/bundles/general/codebuddy/harness-sync/SKILL.md +4 -2
- package/harness/bundles/general/codebuddy/harness-sync/reference.md +1 -1
- package/harness/bundles/general/codebuddy/harness-test/SKILL.md +7 -4
- package/harness/bundles/general/codebuddy/harness-test/checklist.md +8 -5
- package/harness/bundles/general/codebuddy/harness-test/pitfalls.md +1 -1
- package/harness/bundles/general/codebuddy/harness-test/reference.md +28 -13
- package/harness/bundles/general/codebuddy/protocols/submit-protocol.md +1 -1
- package/harness/bundles/general/codebuddy/scripts/harness_deploy.py +7 -0
- package/harness/bundles/general/codebuddy/scripts/harness_gate.py +75 -0
- package/harness/bundles/general/codebuddy/scripts/harness_integration.py +64 -2
- package/harness/bundles/general/codebuddy/scripts/harness_ledger.py +70 -3
- package/harness/bundles/general/codebuddy/scripts/harness_paths.py +17 -0
- package/harness/bundles/general/codebuddy/scripts/harness_plan_finalize.py +306 -7
- package/harness/bundles/general/codebuddy/scripts/harness_profile.py +58 -7
- package/harness/bundles/general/codebuddy/scripts/harness_review.py +107 -0
- package/harness/bundles/general/codebuddy/scripts/harness_test_cleanup.py +175 -0
- package/harness/bundles/general/codex/.harness-build.json +1 -1
- package/harness/bundles/general/codex/CONTEXT.md +14 -1
- package/harness/bundles/general/codex/README.md +1 -1
- package/harness/bundles/general/codex/harness-archive/SKILL.md +7 -4
- package/harness/bundles/general/codex/harness-archive/reference.md +1 -1
- package/harness/bundles/general/codex/harness-codebase-map/SKILL.md +4 -2
- package/harness/bundles/general/codex/harness-knowledge-ingest/SKILL.md +4 -2
- package/harness/bundles/general/codex/harness-knowledge-ingest/scripts/harness_knowledge.py +16 -1
- package/harness/bundles/general/codex/harness-knowledge-query/SKILL.md +4 -2
- package/harness/bundles/general/codex/harness-plan/SKILL.md +8 -4
- package/harness/bundles/general/codex/harness-plan/checklist.md +5 -5
- package/harness/bundles/general/codex/harness-review/SKILL.md +5 -2
- package/harness/bundles/general/codex/harness-review/reference.md +13 -0
- package/harness/bundles/general/codex/harness-run/SKILL.md +7 -3
- package/harness/bundles/general/codex/harness-run/checklist.md +4 -4
- package/harness/bundles/general/codex/harness-submit/SKILL.md +6 -3
- package/harness/bundles/general/codex/harness-submit/checklist.md +5 -5
- package/harness/bundles/general/codex/harness-submit/reference.md +3 -3
- package/harness/bundles/general/codex/harness-sync/SKILL.md +4 -2
- package/harness/bundles/general/codex/harness-sync/reference.md +1 -1
- package/harness/bundles/general/codex/harness-test/SKILL.md +7 -4
- package/harness/bundles/general/codex/harness-test/checklist.md +8 -5
- package/harness/bundles/general/codex/harness-test/pitfalls.md +1 -1
- package/harness/bundles/general/codex/harness-test/reference.md +28 -13
- package/harness/bundles/general/codex/protocols/submit-protocol.md +1 -1
- package/harness/bundles/general/codex/scripts/harness_deploy.py +7 -0
- package/harness/bundles/general/codex/scripts/harness_gate.py +75 -0
- package/harness/bundles/general/codex/scripts/harness_integration.py +64 -2
- package/harness/bundles/general/codex/scripts/harness_ledger.py +70 -3
- package/harness/bundles/general/codex/scripts/harness_paths.py +17 -0
- package/harness/bundles/general/codex/scripts/harness_plan_finalize.py +306 -7
- package/harness/bundles/general/codex/scripts/harness_profile.py +58 -7
- package/harness/bundles/general/codex/scripts/harness_review.py +107 -0
- package/harness/bundles/general/codex/scripts/harness_test_cleanup.py +175 -0
- package/harness/bundles/general/cursor/.harness-build.json +1 -1
- package/harness/bundles/general/cursor/CONTEXT.md +14 -1
- package/harness/bundles/general/cursor/README.md +1 -1
- package/harness/bundles/general/cursor/harness-archive/SKILL.md +7 -4
- package/harness/bundles/general/cursor/harness-archive/reference.md +1 -1
- package/harness/bundles/general/cursor/harness-codebase-map/SKILL.md +4 -2
- package/harness/bundles/general/cursor/harness-knowledge-ingest/SKILL.md +4 -2
- package/harness/bundles/general/cursor/harness-knowledge-ingest/scripts/harness_knowledge.py +16 -1
- package/harness/bundles/general/cursor/harness-knowledge-query/SKILL.md +4 -2
- package/harness/bundles/general/cursor/harness-plan/SKILL.md +8 -4
- package/harness/bundles/general/cursor/harness-plan/checklist.md +5 -5
- package/harness/bundles/general/cursor/harness-review/SKILL.md +5 -2
- package/harness/bundles/general/cursor/harness-review/reference.md +13 -0
- package/harness/bundles/general/cursor/harness-run/SKILL.md +7 -3
- package/harness/bundles/general/cursor/harness-run/checklist.md +4 -4
- package/harness/bundles/general/cursor/harness-submit/SKILL.md +6 -3
- package/harness/bundles/general/cursor/harness-submit/checklist.md +5 -5
- package/harness/bundles/general/cursor/harness-submit/reference.md +3 -3
- package/harness/bundles/general/cursor/harness-sync/SKILL.md +4 -2
- package/harness/bundles/general/cursor/harness-sync/reference.md +1 -1
- package/harness/bundles/general/cursor/harness-test/SKILL.md +7 -4
- package/harness/bundles/general/cursor/harness-test/checklist.md +8 -5
- package/harness/bundles/general/cursor/harness-test/pitfalls.md +1 -1
- package/harness/bundles/general/cursor/harness-test/reference.md +28 -13
- package/harness/bundles/general/cursor/protocols/submit-protocol.md +1 -1
- package/harness/bundles/general/cursor/scripts/harness_deploy.py +7 -0
- package/harness/bundles/general/cursor/scripts/harness_gate.py +75 -0
- package/harness/bundles/general/cursor/scripts/harness_integration.py +64 -2
- package/harness/bundles/general/cursor/scripts/harness_ledger.py +70 -3
- package/harness/bundles/general/cursor/scripts/harness_paths.py +17 -0
- package/harness/bundles/general/cursor/scripts/harness_plan_finalize.py +306 -7
- package/harness/bundles/general/cursor/scripts/harness_profile.py +58 -7
- package/harness/bundles/general/cursor/scripts/harness_review.py +107 -0
- package/harness/bundles/general/cursor/scripts/harness_test_cleanup.py +175 -0
- package/harness/bundles/java/claude-code/.harness-build.json +1 -1
- package/harness/bundles/java/claude-code/CONTEXT.md +14 -1
- package/harness/bundles/java/claude-code/README.md +1 -1
- package/harness/bundles/java/claude-code/harness-apidoc/SKILL.md +5 -2
- package/harness/bundles/java/claude-code/harness-archive/SKILL.md +7 -4
- package/harness/bundles/java/claude-code/harness-archive/reference.md +1 -1
- package/harness/bundles/java/claude-code/harness-codebase-map/SKILL.md +4 -2
- package/harness/bundles/java/claude-code/harness-knowledge-ingest/SKILL.md +4 -2
- package/harness/bundles/java/claude-code/harness-knowledge-ingest/scripts/harness_knowledge.py +16 -1
- package/harness/bundles/java/claude-code/harness-knowledge-query/SKILL.md +4 -2
- package/harness/bundles/java/claude-code/harness-package/SKILL.md +5 -2
- package/harness/bundles/java/claude-code/harness-package/checklist.md +4 -4
- package/harness/bundles/java/claude-code/harness-plan/SKILL.md +8 -4
- package/harness/bundles/java/claude-code/harness-plan/checklist.md +5 -5
- package/harness/bundles/java/claude-code/harness-review/SKILL.md +5 -2
- package/harness/bundles/java/claude-code/harness-review/reference.md +13 -0
- package/harness/bundles/java/claude-code/harness-run/SKILL.md +7 -3
- package/harness/bundles/java/claude-code/harness-run/checklist.md +4 -4
- package/harness/bundles/java/claude-code/harness-submit/SKILL.md +6 -3
- package/harness/bundles/java/claude-code/harness-submit/checklist.md +5 -5
- package/harness/bundles/java/claude-code/harness-submit/reference.md +3 -3
- package/harness/bundles/java/claude-code/harness-sync/SKILL.md +4 -2
- package/harness/bundles/java/claude-code/harness-sync/reference.md +1 -1
- package/harness/bundles/java/claude-code/harness-test/SKILL.md +8 -5
- package/harness/bundles/java/claude-code/harness-test/pitfalls.md +1 -1
- package/harness/bundles/java/claude-code/harness-test/reference.md +1 -1
- package/harness/bundles/java/claude-code/protocols/submit-protocol.md +1 -1
- package/harness/bundles/java/claude-code/scripts/harness_deploy.py +7 -0
- package/harness/bundles/java/claude-code/scripts/harness_gate.py +75 -0
- package/harness/bundles/java/claude-code/scripts/harness_integration.py +64 -2
- package/harness/bundles/java/claude-code/scripts/harness_ledger.py +70 -3
- package/harness/bundles/java/claude-code/scripts/harness_paths.py +17 -0
- package/harness/bundles/java/claude-code/scripts/harness_plan_finalize.py +306 -7
- package/harness/bundles/java/claude-code/scripts/harness_profile.py +58 -7
- package/harness/bundles/java/claude-code/scripts/harness_review.py +107 -0
- package/harness/bundles/java/claude-code/scripts/harness_test_cleanup.py +175 -0
- package/harness/bundles/java/codebuddy/.harness-build.json +1 -1
- package/harness/bundles/java/codebuddy/CONTEXT.md +14 -1
- package/harness/bundles/java/codebuddy/README.md +1 -1
- package/harness/bundles/java/codebuddy/harness-apidoc/SKILL.md +5 -2
- package/harness/bundles/java/codebuddy/harness-archive/SKILL.md +7 -4
- package/harness/bundles/java/codebuddy/harness-archive/reference.md +1 -1
- package/harness/bundles/java/codebuddy/harness-codebase-map/SKILL.md +4 -2
- package/harness/bundles/java/codebuddy/harness-knowledge-ingest/SKILL.md +4 -2
- package/harness/bundles/java/codebuddy/harness-knowledge-ingest/scripts/harness_knowledge.py +16 -1
- package/harness/bundles/java/codebuddy/harness-knowledge-query/SKILL.md +4 -2
- package/harness/bundles/java/codebuddy/harness-package/SKILL.md +5 -2
- package/harness/bundles/java/codebuddy/harness-package/checklist.md +4 -4
- package/harness/bundles/java/codebuddy/harness-plan/SKILL.md +8 -4
- package/harness/bundles/java/codebuddy/harness-plan/checklist.md +5 -5
- package/harness/bundles/java/codebuddy/harness-review/SKILL.md +5 -2
- package/harness/bundles/java/codebuddy/harness-review/reference.md +13 -0
- package/harness/bundles/java/codebuddy/harness-run/SKILL.md +7 -3
- package/harness/bundles/java/codebuddy/harness-run/checklist.md +4 -4
- package/harness/bundles/java/codebuddy/harness-submit/SKILL.md +6 -3
- package/harness/bundles/java/codebuddy/harness-submit/checklist.md +5 -5
- package/harness/bundles/java/codebuddy/harness-submit/reference.md +3 -3
- package/harness/bundles/java/codebuddy/harness-sync/SKILL.md +4 -2
- package/harness/bundles/java/codebuddy/harness-sync/reference.md +1 -1
- package/harness/bundles/java/codebuddy/harness-test/SKILL.md +8 -5
- package/harness/bundles/java/codebuddy/harness-test/pitfalls.md +1 -1
- package/harness/bundles/java/codebuddy/harness-test/reference.md +1 -1
- package/harness/bundles/java/codebuddy/protocols/submit-protocol.md +1 -1
- package/harness/bundles/java/codebuddy/scripts/harness_deploy.py +7 -0
- package/harness/bundles/java/codebuddy/scripts/harness_gate.py +75 -0
- package/harness/bundles/java/codebuddy/scripts/harness_integration.py +64 -2
- package/harness/bundles/java/codebuddy/scripts/harness_ledger.py +70 -3
- package/harness/bundles/java/codebuddy/scripts/harness_paths.py +17 -0
- package/harness/bundles/java/codebuddy/scripts/harness_plan_finalize.py +306 -7
- package/harness/bundles/java/codebuddy/scripts/harness_profile.py +58 -7
- package/harness/bundles/java/codebuddy/scripts/harness_review.py +107 -0
- package/harness/bundles/java/codebuddy/scripts/harness_test_cleanup.py +175 -0
- package/harness/bundles/java/codex/.harness-build.json +1 -1
- package/harness/bundles/java/codex/CONTEXT.md +14 -1
- package/harness/bundles/java/codex/README.md +1 -1
- package/harness/bundles/java/codex/harness-apidoc/SKILL.md +5 -2
- package/harness/bundles/java/codex/harness-archive/SKILL.md +7 -4
- package/harness/bundles/java/codex/harness-archive/reference.md +1 -1
- package/harness/bundles/java/codex/harness-codebase-map/SKILL.md +4 -2
- package/harness/bundles/java/codex/harness-knowledge-ingest/SKILL.md +4 -2
- package/harness/bundles/java/codex/harness-knowledge-ingest/scripts/harness_knowledge.py +16 -1
- package/harness/bundles/java/codex/harness-knowledge-query/SKILL.md +4 -2
- package/harness/bundles/java/codex/harness-package/SKILL.md +5 -2
- package/harness/bundles/java/codex/harness-package/checklist.md +4 -4
- package/harness/bundles/java/codex/harness-plan/SKILL.md +8 -4
- package/harness/bundles/java/codex/harness-plan/checklist.md +5 -5
- package/harness/bundles/java/codex/harness-review/SKILL.md +5 -2
- package/harness/bundles/java/codex/harness-review/reference.md +13 -0
- package/harness/bundles/java/codex/harness-run/SKILL.md +7 -3
- package/harness/bundles/java/codex/harness-run/checklist.md +4 -4
- package/harness/bundles/java/codex/harness-submit/SKILL.md +6 -3
- package/harness/bundles/java/codex/harness-submit/checklist.md +5 -5
- package/harness/bundles/java/codex/harness-submit/reference.md +3 -3
- package/harness/bundles/java/codex/harness-sync/SKILL.md +4 -2
- package/harness/bundles/java/codex/harness-sync/reference.md +1 -1
- package/harness/bundles/java/codex/harness-test/SKILL.md +8 -5
- package/harness/bundles/java/codex/harness-test/pitfalls.md +1 -1
- package/harness/bundles/java/codex/harness-test/reference.md +1 -1
- package/harness/bundles/java/codex/protocols/submit-protocol.md +1 -1
- package/harness/bundles/java/codex/scripts/harness_deploy.py +7 -0
- package/harness/bundles/java/codex/scripts/harness_gate.py +75 -0
- package/harness/bundles/java/codex/scripts/harness_integration.py +64 -2
- package/harness/bundles/java/codex/scripts/harness_ledger.py +70 -3
- package/harness/bundles/java/codex/scripts/harness_paths.py +17 -0
- package/harness/bundles/java/codex/scripts/harness_plan_finalize.py +306 -7
- package/harness/bundles/java/codex/scripts/harness_profile.py +58 -7
- package/harness/bundles/java/codex/scripts/harness_review.py +107 -0
- package/harness/bundles/java/codex/scripts/harness_test_cleanup.py +175 -0
- package/harness/bundles/java/cursor/.harness-build.json +1 -1
- package/harness/bundles/java/cursor/CONTEXT.md +14 -1
- package/harness/bundles/java/cursor/README.md +1 -1
- package/harness/bundles/java/cursor/harness-apidoc/SKILL.md +5 -2
- package/harness/bundles/java/cursor/harness-archive/SKILL.md +7 -4
- package/harness/bundles/java/cursor/harness-archive/reference.md +1 -1
- package/harness/bundles/java/cursor/harness-codebase-map/SKILL.md +4 -2
- package/harness/bundles/java/cursor/harness-knowledge-ingest/SKILL.md +4 -2
- package/harness/bundles/java/cursor/harness-knowledge-ingest/scripts/harness_knowledge.py +16 -1
- package/harness/bundles/java/cursor/harness-knowledge-query/SKILL.md +4 -2
- package/harness/bundles/java/cursor/harness-package/SKILL.md +5 -2
- package/harness/bundles/java/cursor/harness-package/checklist.md +4 -4
- package/harness/bundles/java/cursor/harness-plan/SKILL.md +8 -4
- package/harness/bundles/java/cursor/harness-plan/checklist.md +5 -5
- package/harness/bundles/java/cursor/harness-review/SKILL.md +5 -2
- package/harness/bundles/java/cursor/harness-review/reference.md +13 -0
- package/harness/bundles/java/cursor/harness-run/SKILL.md +7 -3
- package/harness/bundles/java/cursor/harness-run/checklist.md +4 -4
- package/harness/bundles/java/cursor/harness-submit/SKILL.md +6 -3
- package/harness/bundles/java/cursor/harness-submit/checklist.md +5 -5
- package/harness/bundles/java/cursor/harness-submit/reference.md +3 -3
- package/harness/bundles/java/cursor/harness-sync/SKILL.md +4 -2
- package/harness/bundles/java/cursor/harness-sync/reference.md +1 -1
- package/harness/bundles/java/cursor/harness-test/SKILL.md +8 -5
- package/harness/bundles/java/cursor/harness-test/pitfalls.md +1 -1
- package/harness/bundles/java/cursor/harness-test/reference.md +1 -1
- package/harness/bundles/java/cursor/protocols/submit-protocol.md +1 -1
- package/harness/bundles/java/cursor/scripts/harness_deploy.py +7 -0
- package/harness/bundles/java/cursor/scripts/harness_gate.py +75 -0
- package/harness/bundles/java/cursor/scripts/harness_integration.py +64 -2
- package/harness/bundles/java/cursor/scripts/harness_ledger.py +70 -3
- package/harness/bundles/java/cursor/scripts/harness_paths.py +17 -0
- package/harness/bundles/java/cursor/scripts/harness_plan_finalize.py +306 -7
- package/harness/bundles/java/cursor/scripts/harness_profile.py +58 -7
- package/harness/bundles/java/cursor/scripts/harness_review.py +107 -0
- package/harness/bundles/java/cursor/scripts/harness_test_cleanup.py +175 -0
- package/harness/manifests/general/claude-code.json +38 -34
- package/harness/manifests/general/codebuddy.json +38 -34
- package/harness/manifests/general/codex.json +38 -34
- package/harness/manifests/general/cursor.json +38 -34
- package/harness/manifests/java/claude-code.json +40 -36
- package/harness/manifests/java/codebuddy.json +40 -36
- package/harness/manifests/java/codex.json +40 -36
- package/harness/manifests/java/cursor.json +40 -36
- package/hunter-workflow-family.json +2 -2
- package/package.json +1 -1
|
@@ -1049,10 +1049,11 @@ class IntegrationTransaction:
|
|
|
1049
1049
|
heavy_removed.append(name)
|
|
1050
1050
|
except OSError as exc:
|
|
1051
1051
|
heavy_failures.append({"path": name, "error": str(exc)})
|
|
1052
|
-
self.runner.run(
|
|
1052
|
+
remove_result = self.runner.run(
|
|
1053
1053
|
self.project_root, "worktree", "remove", "--force", str(resolved),
|
|
1054
1054
|
check=False,
|
|
1055
1055
|
)
|
|
1056
|
+
remove_returncode = getattr(remove_result, "returncode", 0)
|
|
1056
1057
|
listed = self.runner.text(self.project_root, "worktree", "list", "--porcelain")
|
|
1057
1058
|
registered_after = {
|
|
1058
1059
|
str(Path(line.removeprefix("worktree ")).resolve())
|
|
@@ -1061,7 +1062,8 @@ class IntegrationTransaction:
|
|
|
1061
1062
|
}
|
|
1062
1063
|
still_registered = str(resolved) in registered_after
|
|
1063
1064
|
residual_paths: list[str] = []
|
|
1064
|
-
|
|
1065
|
+
disk_path_present = resolved.exists()
|
|
1066
|
+
if disk_path_present:
|
|
1065
1067
|
if resolved.is_file():
|
|
1066
1068
|
residual_paths.append(resolved.name)
|
|
1067
1069
|
else:
|
|
@@ -1075,6 +1077,27 @@ class IntegrationTransaction:
|
|
|
1075
1077
|
break
|
|
1076
1078
|
if len(residual_paths) >= 200:
|
|
1077
1079
|
break
|
|
1080
|
+
# §5.30: Windows half-success — git worktree remove returned non-zero
|
|
1081
|
+
# but registration is already deleted and disk path remains. Return a
|
|
1082
|
+
# structured status distinct from generic CLEANUP_RESIDUAL so callers
|
|
1083
|
+
# can apply the allowlisted residual cleaner.
|
|
1084
|
+
if (
|
|
1085
|
+
remove_returncode != 0
|
|
1086
|
+
and not still_registered
|
|
1087
|
+
and disk_path_present
|
|
1088
|
+
and residual_paths
|
|
1089
|
+
and not heavy_failures
|
|
1090
|
+
):
|
|
1091
|
+
return {
|
|
1092
|
+
"ok": False,
|
|
1093
|
+
"code": "REGISTRATION_REMOVED_RESIDUAL_PRESENT",
|
|
1094
|
+
"target": str(resolved),
|
|
1095
|
+
"heavyRootsRemoved": heavy_removed,
|
|
1096
|
+
"heavyRootFailures": heavy_failures,
|
|
1097
|
+
"worktreeRegistered": False,
|
|
1098
|
+
"diskPathPresent": True,
|
|
1099
|
+
"residualPaths": residual_paths,
|
|
1100
|
+
}
|
|
1078
1101
|
ok = not heavy_failures and not still_registered and not residual_paths
|
|
1079
1102
|
return {
|
|
1080
1103
|
"ok": ok,
|
|
@@ -1083,6 +1106,7 @@ class IntegrationTransaction:
|
|
|
1083
1106
|
"heavyRootsRemoved": heavy_removed,
|
|
1084
1107
|
"heavyRootFailures": heavy_failures,
|
|
1085
1108
|
"worktreeRegistered": still_registered,
|
|
1109
|
+
"diskPathPresent": disk_path_present,
|
|
1086
1110
|
"residualPaths": residual_paths,
|
|
1087
1111
|
}
|
|
1088
1112
|
|
|
@@ -1266,6 +1290,31 @@ def cmd_status(args: argparse.Namespace) -> int:
|
|
|
1266
1290
|
return _emit(_txn_from_args(args).status())
|
|
1267
1291
|
|
|
1268
1292
|
|
|
1293
|
+
def cmd_journal(args: argparse.Namespace) -> int:
|
|
1294
|
+
"""C5: journal 子命令 — 默认 compact (transactionId/currentStep/status),--verbose 全量。"""
|
|
1295
|
+
txn = _txn_from_args(args)
|
|
1296
|
+
full = txn.status()
|
|
1297
|
+
if getattr(args, "verbose", False):
|
|
1298
|
+
return _emit(full)
|
|
1299
|
+
# Derive currentStep: first non-DONE step, or last step name if all DONE.
|
|
1300
|
+
current_step = None
|
|
1301
|
+
for step in full.get("steps", []):
|
|
1302
|
+
if step.get("status") != "DONE":
|
|
1303
|
+
current_step = step.get("name")
|
|
1304
|
+
break
|
|
1305
|
+
if current_step is None and full.get("steps"):
|
|
1306
|
+
current_step = full["steps"][-1].get("name")
|
|
1307
|
+
overall_status = "DONE" if all(
|
|
1308
|
+
step.get("status") == "DONE" for step in full.get("steps", [])
|
|
1309
|
+
) else "IN_PROGRESS"
|
|
1310
|
+
compact = {
|
|
1311
|
+
"transactionId": full.get("transactionId"),
|
|
1312
|
+
"currentStep": current_step,
|
|
1313
|
+
"status": overall_status,
|
|
1314
|
+
}
|
|
1315
|
+
return _emit(compact)
|
|
1316
|
+
|
|
1317
|
+
|
|
1269
1318
|
def build_parser() -> argparse.ArgumentParser:
|
|
1270
1319
|
parser = argparse.ArgumentParser(prog="harness_integration.py")
|
|
1271
1320
|
sub = parser.add_subparsers(dest="command_name", required=True)
|
|
@@ -1287,6 +1336,19 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
1287
1336
|
add("recover", cmd_recover)
|
|
1288
1337
|
add("status", cmd_status)
|
|
1289
1338
|
|
|
1339
|
+
p_journal = sub.add_parser("journal")
|
|
1340
|
+
p_journal.add_argument("--change", required=True)
|
|
1341
|
+
p_journal.add_argument("--run-id", required=True)
|
|
1342
|
+
p_journal.add_argument("--target-branch", default="main")
|
|
1343
|
+
p_journal.add_argument("--feature-branch", required=True)
|
|
1344
|
+
p_journal.add_argument("--temp-root", required=True)
|
|
1345
|
+
p_journal.add_argument(
|
|
1346
|
+
"--verbose",
|
|
1347
|
+
action="store_true",
|
|
1348
|
+
help="emit full journal payload (default: compact transactionId/currentStep/status)",
|
|
1349
|
+
)
|
|
1350
|
+
p_journal.set_defaults(func=cmd_journal)
|
|
1351
|
+
|
|
1290
1352
|
p_verify = sub.add_parser("verify")
|
|
1291
1353
|
p_verify.add_argument("--change", required=True)
|
|
1292
1354
|
p_verify.add_argument("--run-id", required=True)
|
|
@@ -100,6 +100,37 @@ def emit_json(payload: dict[str, Any], *, as_json: bool) -> None:
|
|
|
100
100
|
sys.stdout.write(("ok" if ok else "error") + "\n")
|
|
101
101
|
|
|
102
102
|
|
|
103
|
+
def _compact_record_payload(payload: dict[str, Any]) -> dict[str, Any]:
|
|
104
|
+
"""C5: record compact — ok/action/verification/status only."""
|
|
105
|
+
return {
|
|
106
|
+
"ok": payload.get("ok", True),
|
|
107
|
+
"action": payload.get("action"),
|
|
108
|
+
"verification": payload.get("verification"),
|
|
109
|
+
"status": payload.get("status"),
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def _compact_can_reuse_payload(payload: dict[str, Any]) -> dict[str, Any]:
|
|
114
|
+
"""C5: can-reuse compact — ok/reuse/code only."""
|
|
115
|
+
return {
|
|
116
|
+
"ok": payload.get("ok", True),
|
|
117
|
+
"reuse": payload.get("reuse"),
|
|
118
|
+
"code": payload.get("code"),
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def emit_compact_or_verbose(
|
|
123
|
+
payload: dict[str, Any],
|
|
124
|
+
*,
|
|
125
|
+
as_json: bool,
|
|
126
|
+
verbose: bool,
|
|
127
|
+
compact_fn,
|
|
128
|
+
) -> None:
|
|
129
|
+
"""Emit compact payload by default; full payload when --verbose."""
|
|
130
|
+
out = payload if verbose else compact_fn(payload)
|
|
131
|
+
emit_json(out, as_json=as_json)
|
|
132
|
+
|
|
133
|
+
|
|
103
134
|
def emit_error(message: str, *, as_json: bool, code: int = 1) -> int:
|
|
104
135
|
payload = {"ok": False, "error": message}
|
|
105
136
|
if as_json:
|
|
@@ -1227,6 +1258,7 @@ def cmd_hash(args: argparse.Namespace) -> int:
|
|
|
1227
1258
|
|
|
1228
1259
|
def cmd_can_reuse(args: argparse.Namespace) -> int:
|
|
1229
1260
|
as_json = bool(args.json)
|
|
1261
|
+
verbose = bool(getattr(args, "verbose", False))
|
|
1230
1262
|
verification = args.verification
|
|
1231
1263
|
if verification not in VERIFICATIONS:
|
|
1232
1264
|
return emit_error(
|
|
@@ -1253,7 +1285,10 @@ def cmd_can_reuse(args: argparse.Namespace) -> int:
|
|
|
1253
1285
|
"verification": verification,
|
|
1254
1286
|
"detail": err,
|
|
1255
1287
|
}
|
|
1256
|
-
|
|
1288
|
+
emit_compact_or_verbose(
|
|
1289
|
+
payload, as_json=as_json, verbose=verbose,
|
|
1290
|
+
compact_fn=_compact_can_reuse_payload,
|
|
1291
|
+
)
|
|
1257
1292
|
return 0
|
|
1258
1293
|
files = resolve_input_files(resolved_files, project_root)
|
|
1259
1294
|
if not files:
|
|
@@ -1275,12 +1310,16 @@ def cmd_can_reuse(args: argparse.Namespace) -> int:
|
|
|
1275
1310
|
except (OSError, ValueError, json.JSONDecodeError) as exc:
|
|
1276
1311
|
return emit_error(f"can-reuse failed: {exc}", as_json=as_json)
|
|
1277
1312
|
|
|
1278
|
-
|
|
1313
|
+
emit_compact_or_verbose(
|
|
1314
|
+
payload, as_json=as_json, verbose=verbose,
|
|
1315
|
+
compact_fn=_compact_can_reuse_payload,
|
|
1316
|
+
)
|
|
1279
1317
|
return 0
|
|
1280
1318
|
|
|
1281
1319
|
|
|
1282
1320
|
def cmd_record(args: argparse.Namespace) -> int:
|
|
1283
1321
|
as_json = bool(args.json)
|
|
1322
|
+
verbose = bool(getattr(args, "verbose", False))
|
|
1284
1323
|
change_dir = resolve_path(args.change_dir)
|
|
1285
1324
|
verification = args.verification
|
|
1286
1325
|
if verification not in VERIFICATIONS:
|
|
@@ -1421,6 +1460,16 @@ def cmd_record(args: argparse.Namespace) -> int:
|
|
|
1421
1460
|
if _nonempty_str(getattr(args, "tests_reused_from", None)):
|
|
1422
1461
|
entry["testsReusedFrom"] = str(args.tests_reused_from).strip()
|
|
1423
1462
|
|
|
1463
|
+
# C9: bind scenario IDs from --scenario-ids to this ledger entry.
|
|
1464
|
+
scenario_ids_raw = getattr(args, "scenario_ids", None)
|
|
1465
|
+
if _nonempty_str(scenario_ids_raw):
|
|
1466
|
+
ids = [s.strip() for s in str(scenario_ids_raw).split(",") if s.strip()]
|
|
1467
|
+
if ids:
|
|
1468
|
+
entry["scenarioIds"] = ids
|
|
1469
|
+
elif "scenarioIds" in entry:
|
|
1470
|
+
# Fresh record without scenario-ids must not keep stale ids from prev.
|
|
1471
|
+
entry.pop("scenarioIds", None)
|
|
1472
|
+
|
|
1424
1473
|
ledger["validations"][verification] = entry
|
|
1425
1474
|
if "changeName" not in ledger:
|
|
1426
1475
|
ledger["changeName"] = change_dir.name
|
|
@@ -1487,7 +1536,10 @@ def cmd_record(args: argparse.Namespace) -> int:
|
|
|
1487
1536
|
"diffHash": ledger.get("diffHash"),
|
|
1488
1537
|
"resolvedProjectRoot": str(project_root) if project_root else None,
|
|
1489
1538
|
}
|
|
1490
|
-
|
|
1539
|
+
emit_compact_or_verbose(
|
|
1540
|
+
payload, as_json=as_json, verbose=verbose,
|
|
1541
|
+
compact_fn=_compact_record_payload,
|
|
1542
|
+
)
|
|
1491
1543
|
return 0
|
|
1492
1544
|
|
|
1493
1545
|
|
|
@@ -1589,6 +1641,11 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
1589
1641
|
default=None,
|
|
1590
1642
|
help="optional environment hash to compare against ledger entry (UT-017)",
|
|
1591
1643
|
)
|
|
1644
|
+
p_reuse.add_argument(
|
|
1645
|
+
"--verbose",
|
|
1646
|
+
action="store_true",
|
|
1647
|
+
help="emit full payload (default: compact ok/reuse/code)",
|
|
1648
|
+
)
|
|
1592
1649
|
p_reuse.set_defaults(func=cmd_can_reuse)
|
|
1593
1650
|
|
|
1594
1651
|
p_record = sub.add_parser("record", parents=[shared_json], help="write validation result into ledger")
|
|
@@ -1669,6 +1726,16 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
1669
1726
|
default=None,
|
|
1670
1727
|
help="ledger v3: scope reason (required when --applicability NOT_APPLICABLE)",
|
|
1671
1728
|
)
|
|
1729
|
+
p_record.add_argument(
|
|
1730
|
+
"--scenario-ids",
|
|
1731
|
+
default=None,
|
|
1732
|
+
help="comma-separated scenario IDs from scenario-manifest.json to bind to this entry",
|
|
1733
|
+
)
|
|
1734
|
+
p_record.add_argument(
|
|
1735
|
+
"--verbose",
|
|
1736
|
+
action="store_true",
|
|
1737
|
+
help="emit full payload (default: compact ok/action/verification/status)",
|
|
1738
|
+
)
|
|
1672
1739
|
p_record.set_defaults(func=cmd_record)
|
|
1673
1740
|
|
|
1674
1741
|
p_diff = sub.add_parser(
|
|
@@ -83,6 +83,23 @@ def _git_common_dir(cwd: Path) -> Path | None:
|
|
|
83
83
|
return common
|
|
84
84
|
|
|
85
85
|
|
|
86
|
+
def common_root(project_root: Path) -> Path:
|
|
87
|
+
"""Resolve the shared "common" root for a project.
|
|
88
|
+
|
|
89
|
+
For a linked worktree, ``git rev-parse --git-common-dir`` points at the
|
|
90
|
+
main repository's ``.git`` directory; its parent is the main project root.
|
|
91
|
+
For the main worktree, the common dir is ``<root>/.git`` so the parent is
|
|
92
|
+
the project root itself. Falls back to the resolved input when not in a
|
|
93
|
+
git repo (e.g. exploratory scratch dirs).
|
|
94
|
+
"""
|
|
95
|
+
cwd = Path(project_root).resolve()
|
|
96
|
+
common = _git_common_dir(cwd)
|
|
97
|
+
if common is None:
|
|
98
|
+
return cwd
|
|
99
|
+
# common dir is <root>/.git — its parent is the main project root.
|
|
100
|
+
return common.parent.resolve()
|
|
101
|
+
|
|
102
|
+
|
|
86
103
|
def _root_commit(cwd: Path) -> str | None:
|
|
87
104
|
raw = _git_text(cwd, "rev-list", "--max-parents=0", "HEAD")
|
|
88
105
|
if not raw:
|
|
@@ -30,11 +30,117 @@ if hasattr(sys.stderr, "reconfigure"):
|
|
|
30
30
|
SCHEMA_VERSION = 1
|
|
31
31
|
_LINK = re.compile(r"\[[^\]]+\]\(([^)]+)\)")
|
|
32
32
|
|
|
33
|
+
# C8: valid ownerPhase values (lifecycle phases that can own tasks).
|
|
34
|
+
VALID_OWNER_PHASES = {"plan", "run", "test", "review", "submit"}
|
|
35
|
+
|
|
36
|
+
# C9: map scenario priority to required evidence kind.
|
|
37
|
+
PRIORITY_EVIDENCE_KIND = {
|
|
38
|
+
"P0": "ledger",
|
|
39
|
+
"P1": "ledger",
|
|
40
|
+
"P2": "advisory",
|
|
41
|
+
}
|
|
42
|
+
|
|
33
43
|
|
|
34
44
|
def _result_error(code: str, message: str) -> dict[str, Any]:
|
|
35
45
|
return {"ok": False, "code": code, "error": message}
|
|
36
46
|
|
|
37
47
|
|
|
48
|
+
def parse_test_scenarios(scenarios_path: Path) -> list[dict[str, str]]:
|
|
49
|
+
"""C9: parse test-scenarios.md tables, extracting scenario rows.
|
|
50
|
+
|
|
51
|
+
Returns a list of dicts with keys: id / priority / scenario / verification /
|
|
52
|
+
ownerPhase / requiredEvidenceKind (last one derived from priority).
|
|
53
|
+
"""
|
|
54
|
+
text = Path(scenarios_path).read_text(encoding="utf-8-sig")
|
|
55
|
+
lines = text.splitlines()
|
|
56
|
+
scenarios: list[dict[str, str]] = []
|
|
57
|
+
# Find all tables whose header includes "ID" and "优先级" (or "priority").
|
|
58
|
+
i = 0
|
|
59
|
+
while i < len(lines):
|
|
60
|
+
line = lines[i].strip()
|
|
61
|
+
if line.startswith("|") and "ID" in line and ("优先级" in line or "priority" in line):
|
|
62
|
+
header_line = line
|
|
63
|
+
headers = [h.strip() for h in header_line.strip("|").split("|")]
|
|
64
|
+
col_map: dict[str, int] = {}
|
|
65
|
+
for idx, name in enumerate(headers):
|
|
66
|
+
key = name.lower()
|
|
67
|
+
col_map[key] = idx
|
|
68
|
+
# Skip separator row
|
|
69
|
+
i += 2
|
|
70
|
+
while i < len(lines):
|
|
71
|
+
row = lines[i].strip()
|
|
72
|
+
if not row.startswith("|"):
|
|
73
|
+
break
|
|
74
|
+
cells = [c.strip() for c in row.strip("|").split("|")]
|
|
75
|
+
if len(cells) < len(headers):
|
|
76
|
+
i += 1
|
|
77
|
+
continue
|
|
78
|
+
scenario: dict[str, str] = {}
|
|
79
|
+
for cn, en in (
|
|
80
|
+
("ID", "id"),
|
|
81
|
+
("优先级", "priority"),
|
|
82
|
+
("场景", "scenario"),
|
|
83
|
+
("验证方式", "verification"),
|
|
84
|
+
("owner phase", "ownerPhase"),
|
|
85
|
+
):
|
|
86
|
+
if cn.lower() in col_map:
|
|
87
|
+
scenario[en] = cells[col_map[cn.lower()]]
|
|
88
|
+
# Derive requiredEvidenceKind from priority
|
|
89
|
+
priority = scenario.get("priority", "")
|
|
90
|
+
scenario["requiredEvidenceKind"] = PRIORITY_EVIDENCE_KIND.get(priority, "advisory")
|
|
91
|
+
scenarios.append(scenario)
|
|
92
|
+
i += 1
|
|
93
|
+
continue
|
|
94
|
+
i += 1
|
|
95
|
+
return scenarios
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def parse_plan_tasks(plan_path: Path) -> list[dict[str, str]]:
|
|
99
|
+
"""C8: parse plan.md task table rows, extracting optional ownerPhase/implementationDoneWhen/verificationPhase columns.
|
|
100
|
+
|
|
101
|
+
Returns a list of dicts with keys: # / 簇 / 任务 / ownerPhase / implementationDoneWhen /
|
|
102
|
+
verificationPhase / requiresExplicitAuthority (last four optional, only present when
|
|
103
|
+
the column header includes them).
|
|
104
|
+
"""
|
|
105
|
+
text = Path(plan_path).read_text(encoding="utf-8-sig")
|
|
106
|
+
lines = text.splitlines()
|
|
107
|
+
# Find the task table: a header row starting with "| #" followed by a separator row.
|
|
108
|
+
header_idx = -1
|
|
109
|
+
for i, line in enumerate(lines):
|
|
110
|
+
stripped = line.strip()
|
|
111
|
+
if stripped.startswith("|") and "#" in stripped and "任务" in stripped:
|
|
112
|
+
header_idx = i
|
|
113
|
+
break
|
|
114
|
+
if header_idx < 0:
|
|
115
|
+
return []
|
|
116
|
+
header_line = lines[header_idx]
|
|
117
|
+
headers = [h.strip() for h in header_line.strip().strip("|").split("|")]
|
|
118
|
+
# Map header names to column indices (case-insensitive, English keys).
|
|
119
|
+
col_map: dict[str, int] = {}
|
|
120
|
+
for idx, name in enumerate(headers):
|
|
121
|
+
key = name.lower()
|
|
122
|
+
col_map[key] = idx
|
|
123
|
+
tasks: list[dict[str, str]] = []
|
|
124
|
+
for line in lines[header_idx + 2 :]: # skip header + separator
|
|
125
|
+
stripped = line.strip()
|
|
126
|
+
if not stripped.startswith("|"):
|
|
127
|
+
break # end of table
|
|
128
|
+
cells = [c.strip() for c in stripped.strip("|").split("|")]
|
|
129
|
+
if len(cells) < len(headers):
|
|
130
|
+
continue
|
|
131
|
+
task: dict[str, str] = {}
|
|
132
|
+
# Chinese headers
|
|
133
|
+
for cn, en in (("#", "num"), ("簇", "cluster"), ("任务", "task")):
|
|
134
|
+
if cn in col_map:
|
|
135
|
+
task[en] = cells[col_map[cn]]
|
|
136
|
+
# English optional columns
|
|
137
|
+
for en in ("ownerPhase", "implementationDoneWhen", "verificationPhase", "requiresExplicitAuthority"):
|
|
138
|
+
if en.lower() in col_map:
|
|
139
|
+
task[en] = cells[col_map[en.lower()]]
|
|
140
|
+
tasks.append(task)
|
|
141
|
+
return tasks
|
|
142
|
+
|
|
143
|
+
|
|
38
144
|
def _atomic_write_json(path: Path, payload: dict[str, Any]) -> None:
|
|
39
145
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
40
146
|
fd, raw_tmp = tempfile.mkstemp(
|
|
@@ -146,6 +252,21 @@ def validate_staging(staging: Path, change_name: str) -> dict[str, Any]:
|
|
|
146
252
|
f"{rel.as_posix()}: missing reference {raw_link}",
|
|
147
253
|
)
|
|
148
254
|
|
|
255
|
+
# C8: validate ownerPhase values in plan.md task table.
|
|
256
|
+
plan_path = staging / "plans" / f"{change_name}-plan.md"
|
|
257
|
+
tasks = parse_plan_tasks(plan_path)
|
|
258
|
+
for task in tasks:
|
|
259
|
+
owner = task.get("ownerPhase")
|
|
260
|
+
if owner is not None and owner != "" and owner not in VALID_OWNER_PHASES:
|
|
261
|
+
return _result_error(
|
|
262
|
+
"PLAN_OWNER_PHASE_INVALID",
|
|
263
|
+
f"task {task.get('num', '?')}: ownerPhase '{owner}' not in {sorted(VALID_OWNER_PHASES)}",
|
|
264
|
+
)
|
|
265
|
+
|
|
266
|
+
# C9: parse test-scenarios.md for scenario manifest.
|
|
267
|
+
scenarios_path = staging / "plans" / f"{change_name}-test-scenarios.md"
|
|
268
|
+
scenarios = parse_test_scenarios(scenarios_path)
|
|
269
|
+
|
|
149
270
|
digest = hashlib.sha256()
|
|
150
271
|
artifact_names: list[str] = []
|
|
151
272
|
for path in files:
|
|
@@ -159,6 +280,8 @@ def validate_staging(staging: Path, change_name: str) -> dict[str, Any]:
|
|
|
159
280
|
"ok": True,
|
|
160
281
|
"files": artifact_names,
|
|
161
282
|
"artifactsHash": "sha256:" + digest.hexdigest(),
|
|
283
|
+
"tasks": tasks,
|
|
284
|
+
"scenarios": scenarios,
|
|
162
285
|
}
|
|
163
286
|
|
|
164
287
|
|
|
@@ -177,6 +300,152 @@ def _terminal_exists(change_dir: Path, run_id: str, attempt: int) -> bool:
|
|
|
177
300
|
)
|
|
178
301
|
|
|
179
302
|
|
|
303
|
+
def verify_plan(change_dir: Path) -> dict[str, Any]:
|
|
304
|
+
"""Read-only verification of a finalized plan (retro §5.8).
|
|
305
|
+
|
|
306
|
+
Validates the published artifacts, receipt and events stream without
|
|
307
|
+
requiring the original staging directory. Returns the artifact hash,
|
|
308
|
+
phase.end count/status, frontmatter, and consistency checks. Any parse
|
|
309
|
+
error or inconsistency results in ok=false with a non-zero exit code.
|
|
310
|
+
"""
|
|
311
|
+
change_dir = change_dir.resolve()
|
|
312
|
+
receipt_path = change_dir / "meta" / "plan-finalization.json"
|
|
313
|
+
if not receipt_path.is_file():
|
|
314
|
+
return _result_error("RECEIPT_MISSING", f"receipt not found: {receipt_path}")
|
|
315
|
+
|
|
316
|
+
try:
|
|
317
|
+
receipt = json.loads(receipt_path.read_text(encoding="utf-8-sig"))
|
|
318
|
+
except (OSError, json.JSONDecodeError) as exc:
|
|
319
|
+
return _result_error("RECEIPT_INVALID", str(exc))
|
|
320
|
+
if not isinstance(receipt, dict):
|
|
321
|
+
return _result_error("RECEIPT_INVALID", "receipt top-level must be an object")
|
|
322
|
+
|
|
323
|
+
change_name = str(receipt.get("changeName") or "").strip()
|
|
324
|
+
if not change_name:
|
|
325
|
+
return _result_error("RECEIPT_INVALID", "receipt missing changeName")
|
|
326
|
+
|
|
327
|
+
expected_hash = str(receipt.get("artifactsHash") or "").strip()
|
|
328
|
+
if not expected_hash.startswith("sha256:"):
|
|
329
|
+
return _result_error("RECEIPT_INVALID", "receipt artifactsHash missing or malformed")
|
|
330
|
+
|
|
331
|
+
files_list = receipt.get("files")
|
|
332
|
+
if not isinstance(files_list, list) or not files_list:
|
|
333
|
+
return _result_error("RECEIPT_INVALID", "receipt files list missing or empty")
|
|
334
|
+
|
|
335
|
+
# Recompute artifacts hash from published files.
|
|
336
|
+
digest = hashlib.sha256()
|
|
337
|
+
artifact_names: list[str] = []
|
|
338
|
+
for rel_text in files_list:
|
|
339
|
+
rel = rel_text.as_posix() if hasattr(rel_text, "as_posix") else str(rel_text)
|
|
340
|
+
target = change_dir / rel
|
|
341
|
+
if not target.is_file():
|
|
342
|
+
return _result_error(
|
|
343
|
+
"ARTIFACT_MISSING", f"published artifact missing: {rel}"
|
|
344
|
+
)
|
|
345
|
+
artifact_names.append(rel)
|
|
346
|
+
digest.update(rel.encode("utf-8"))
|
|
347
|
+
digest.update(b"\0")
|
|
348
|
+
digest.update(target.read_bytes())
|
|
349
|
+
digest.update(b"\0")
|
|
350
|
+
actual_hash = "sha256:" + digest.hexdigest()
|
|
351
|
+
if actual_hash != expected_hash:
|
|
352
|
+
return _result_error(
|
|
353
|
+
"ARTIFACT_HASH_DRIFT",
|
|
354
|
+
f"published artifacts hash {actual_hash} != receipt {expected_hash}",
|
|
355
|
+
)
|
|
356
|
+
|
|
357
|
+
# Validate frontmatter on markdown artifacts.
|
|
358
|
+
frontmatter_results: dict[str, Any] = {}
|
|
359
|
+
for rel in artifact_names:
|
|
360
|
+
if not rel.endswith(".md"):
|
|
361
|
+
continue
|
|
362
|
+
target = change_dir / rel
|
|
363
|
+
try:
|
|
364
|
+
text = target.read_text(encoding="utf-8-sig")
|
|
365
|
+
except OSError as exc:
|
|
366
|
+
return _result_error("ARTIFACT_UNREADABLE", f"{rel}: {exc}")
|
|
367
|
+
fm = _frontmatter(text)
|
|
368
|
+
if fm is None:
|
|
369
|
+
return _result_error(
|
|
370
|
+
"ARTIFACT_FRONTMATTER_MISSING", f"{rel}: no frontmatter"
|
|
371
|
+
)
|
|
372
|
+
if fm.get("change-name") != change_name:
|
|
373
|
+
return _result_error(
|
|
374
|
+
"ARTIFACT_FRONTMATTER_INVALID",
|
|
375
|
+
f"{rel}: change-name '{fm.get('change-name')}' != '{change_name}'",
|
|
376
|
+
)
|
|
377
|
+
frontmatter_results[rel] = {
|
|
378
|
+
"change-name": fm.get("change-name"),
|
|
379
|
+
"status": fm.get("status"),
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
# Validate gate-policy.json is parseable JSON.
|
|
383
|
+
gate_policy_path = change_dir / "meta" / "gate-policy.json"
|
|
384
|
+
gate_policy_consistent = True
|
|
385
|
+
if gate_policy_path.is_file():
|
|
386
|
+
try:
|
|
387
|
+
json.loads(gate_policy_path.read_text(encoding="utf-8-sig"))
|
|
388
|
+
except (OSError, json.JSONDecodeError):
|
|
389
|
+
gate_policy_consistent = False
|
|
390
|
+
else:
|
|
391
|
+
gate_policy_consistent = False
|
|
392
|
+
|
|
393
|
+
# Validate events.ndjson: count phase.end, check for parse errors.
|
|
394
|
+
events_path = change_dir / "events.ndjson"
|
|
395
|
+
phase_end_count = 0
|
|
396
|
+
phase_end_status: str | None = None
|
|
397
|
+
events_parse_errors: list[str] = []
|
|
398
|
+
if events_path.is_file():
|
|
399
|
+
for line_no, line in enumerate(events_path.read_text(encoding="utf-8").splitlines(), 1):
|
|
400
|
+
if not line.strip():
|
|
401
|
+
continue
|
|
402
|
+
try:
|
|
403
|
+
event = json.loads(line)
|
|
404
|
+
except json.JSONDecodeError as exc:
|
|
405
|
+
events_parse_errors.append(f"line {line_no}: {exc}")
|
|
406
|
+
continue
|
|
407
|
+
if not isinstance(event, dict):
|
|
408
|
+
events_parse_errors.append(f"line {line_no}: not an object")
|
|
409
|
+
continue
|
|
410
|
+
if (
|
|
411
|
+
event.get("phase") == "plan"
|
|
412
|
+
and event.get("type") == "phase.end"
|
|
413
|
+
):
|
|
414
|
+
phase_end_count += 1
|
|
415
|
+
phase_end_status = str(event.get("status") or "").upper()
|
|
416
|
+
else:
|
|
417
|
+
events_parse_errors.append("events.ndjson missing")
|
|
418
|
+
|
|
419
|
+
if events_parse_errors:
|
|
420
|
+
return _result_error(
|
|
421
|
+
"EVENTS_PARSE_ERROR", "; ".join(events_parse_errors[:5])
|
|
422
|
+
)
|
|
423
|
+
|
|
424
|
+
if phase_end_count == 0:
|
|
425
|
+
return _result_error("PHASE_END_MISSING", "no plan phase.end event found")
|
|
426
|
+
if phase_end_count > 1:
|
|
427
|
+
return _result_error(
|
|
428
|
+
"PHASE_END_DUPLICATE", f"found {phase_end_count} phase.end events"
|
|
429
|
+
)
|
|
430
|
+
|
|
431
|
+
# Receipt consistency: status should be finalized.
|
|
432
|
+
receipt_consistent = receipt.get("status") == "finalized"
|
|
433
|
+
|
|
434
|
+
return {
|
|
435
|
+
"ok": True,
|
|
436
|
+
"action": "verify",
|
|
437
|
+
"changeDir": str(change_dir),
|
|
438
|
+
"changeName": change_name,
|
|
439
|
+
"artifactsHash": actual_hash,
|
|
440
|
+
"phaseEndCount": phase_end_count,
|
|
441
|
+
"phaseEndStatus": phase_end_status,
|
|
442
|
+
"frontmatter": frontmatter_results,
|
|
443
|
+
"gatePolicyConsistent": gate_policy_consistent,
|
|
444
|
+
"receiptConsistent": receipt_consistent,
|
|
445
|
+
"files": artifact_names,
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
|
|
180
449
|
def _read_design_capabilities(staging: Path, change_name: str) -> list[str]:
|
|
181
450
|
"""Read capabilities from design frontmatter (retro §5.4)."""
|
|
182
451
|
design_path = staging / "spec" / f"{change_name}-design.md"
|
|
@@ -367,6 +636,30 @@ def finalize_plan(
|
|
|
367
636
|
finally:
|
|
368
637
|
tmp.unlink(missing_ok=True)
|
|
369
638
|
|
|
639
|
+
# C8: write implementation-checkpoints.json with parsed task ownerPhase.
|
|
640
|
+
tasks = validation.get("tasks") or []
|
|
641
|
+
if tasks:
|
|
642
|
+
checkpoints_path = change_dir / "meta" / "implementation-checkpoints.json"
|
|
643
|
+
checkpoints_payload = {
|
|
644
|
+
"schemaVersion": 1,
|
|
645
|
+
"changeName": change_name,
|
|
646
|
+
"tasks": tasks,
|
|
647
|
+
"foundationGate": "approved",
|
|
648
|
+
}
|
|
649
|
+
_atomic_write_json(checkpoints_path, checkpoints_payload)
|
|
650
|
+
created.append(checkpoints_path)
|
|
651
|
+
|
|
652
|
+
# C9: write scenario-manifest.json with parsed scenarios.
|
|
653
|
+
scenarios = validation.get("scenarios") or []
|
|
654
|
+
manifest_path = change_dir / "meta" / "scenario-manifest.json"
|
|
655
|
+
manifest_payload = {
|
|
656
|
+
"schemaVersion": 1,
|
|
657
|
+
"changeName": change_name,
|
|
658
|
+
"scenarios": scenarios,
|
|
659
|
+
}
|
|
660
|
+
_atomic_write_json(manifest_path, manifest_payload)
|
|
661
|
+
created.append(manifest_path)
|
|
662
|
+
|
|
370
663
|
pending_receipt = {
|
|
371
664
|
"schemaVersion": SCHEMA_VERSION,
|
|
372
665
|
"changeName": change_name,
|
|
@@ -422,18 +715,24 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
422
715
|
finalize.add_argument("--run-id", required=True)
|
|
423
716
|
finalize.add_argument("--attempt", required=True, type=int)
|
|
424
717
|
finalize.add_argument("--json", action="store_true")
|
|
718
|
+
verify = sub.add_parser("verify")
|
|
719
|
+
verify.add_argument("--change-dir", required=True)
|
|
720
|
+
verify.add_argument("--json", action="store_true")
|
|
425
721
|
return parser
|
|
426
722
|
|
|
427
723
|
|
|
428
724
|
def main(argv: list[str] | None = None) -> int:
|
|
429
725
|
args = build_parser().parse_args(argv)
|
|
430
|
-
|
|
431
|
-
Path(args.change_dir)
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
726
|
+
if args.command == "verify":
|
|
727
|
+
result = verify_plan(Path(args.change_dir))
|
|
728
|
+
else:
|
|
729
|
+
result = finalize_plan(
|
|
730
|
+
Path(args.change_dir),
|
|
731
|
+
Path(args.staging_dir),
|
|
732
|
+
change_name=args.change,
|
|
733
|
+
run_id=args.run_id,
|
|
734
|
+
attempt=args.attempt,
|
|
735
|
+
)
|
|
437
736
|
stream = sys.stdout if result["ok"] else sys.stderr
|
|
438
737
|
if args.json:
|
|
439
738
|
stream.write(json.dumps(result, ensure_ascii=False, indent=2) + "\n")
|