phase-loop-runtime 0.2.0__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.
- phase_loop_runtime/__init__.py +20 -0
- phase_loop_runtime/_contract_docs/phase-loop/extraction-readiness.md +90 -0
- phase_loop_runtime/_contract_docs/phase-loop/granular-execution-policy.md +137 -0
- phase_loop_runtime/_contract_docs/phase-loop/harness-capability-matrix.md +510 -0
- phase_loop_runtime/_contract_docs/phase-loop/harness-skill-matrix.md +125 -0
- phase_loop_runtime/_contract_docs/phase-loop/harness-substrate-manifest.md +232 -0
- phase_loop_runtime/_contract_docs/phase-loop/pi-loop-control.md +247 -0
- phase_loop_runtime/_contract_docs/phase-loop/protocol.md +2759 -0
- phase_loop_runtime/_contract_docs/phase-loop/runtime-boundary.md +289 -0
- phase_loop_runtime/_contract_docs/phase-loop/spec-discovery-roots.md +47 -0
- phase_loop_runtime/_contract_docs/phase-loop/substrate-soak-governed-pipeline.md +42 -0
- phase_loop_runtime/_contract_docs/phase-loop/substrate-soak-portal-projection.md +34 -0
- phase_loop_runtime/_contract_docs/phase-loop/substrate-soak-regenesis.md +29 -0
- phase_loop_runtime/_contract_docs/phase-loop/substrate-soak-report.md +32 -0
- phase_loop_runtime/_contract_docs/runtime/verification-evidence-contract.md +52 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/borderline/borderline-mixed-signals/commands.txt +2 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/borderline/borderline-mixed-signals/manifest.json +16 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/borderline/borderline-mixed-signals/mixed.json +5 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/borderline/borderline-provider-timeout/manifest.json +16 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/borderline/borderline-provider-timeout/timeout-note.txt +2 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/borderline/borderline-redacted-summary/manifest.json +16 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/borderline/borderline-redacted-summary/redacted-summary.json +6 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/borderline/borderline-small-sample/manifest.json +16 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/borderline/borderline-small-sample/sample.json +7 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/borderline/borderline-threshold-edge/edge.txt +2 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/borderline/borderline-threshold-edge/manifest.json +16 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-fake/fake-duplicate-png/manifest.json +16 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-fake/fake-duplicate-png/shot-a.txt +1 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-fake/fake-duplicate-png/shot-b.txt +1 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-fake/fake-duplicate-png/shot-c.txt +1 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-fake/fake-missing-references/claimed-results.json +5 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-fake/fake-missing-references/manifest.json +16 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-fake/fake-subtle-low-variance/manifest.json +16 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-fake/fake-subtle-low-variance/metrics.json +9 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-fake/fake-templated-prose/findings.md +10 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-fake/fake-templated-prose/manifest.json +16 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-fake/fake-uniform-scores/manifest.json +16 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-fake/fake-uniform-scores/scores.json +4 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-fake/fake-uniform-scores/summary.txt +1 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-adoption-bundle/bundle-check.json +8 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-adoption-bundle/manifest.json +16 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-adoption-bundle/operator-note.txt +2 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-handoff-ledger/events-sample.jsonl +3 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-handoff-ledger/manifest.json +16 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-handoff-ledger/receipt.txt +1 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-runner-diff/evidence.json +13 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-runner-diff/manifest.json +16 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-runner-diff/summary.txt +2 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-test-matrix/manifest.json +16 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-test-matrix/matrix.json +9 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-test-matrix/notes.md +4 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-ui-screenshot-standin/console-summary.txt +2 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-ui-screenshot-standin/manifest.json +16 -0
- phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-ui-screenshot-standin/screenshot-standin.ppm +5 -0
- phase_loop_runtime/adoption_bundle.py +273 -0
- phase_loop_runtime/advisor_board/CONTRACTS.md +257 -0
- phase_loop_runtime/advisor_board/__init__.py +288 -0
- phase_loop_runtime/advisor_board/backing.py +137 -0
- phase_loop_runtime/advisor_board/backing_omnigent.py +498 -0
- phase_loop_runtime/advisor_board/config.py +225 -0
- phase_loop_runtime/advisor_board/events.py +115 -0
- phase_loop_runtime/advisor_board/fixtures/advisor-boards.example.toml +59 -0
- phase_loop_runtime/advisor_board/fixtures.py +91 -0
- phase_loop_runtime/advisor_board/harness_mapping.py +125 -0
- phase_loop_runtime/advisor_board/matrix.py +146 -0
- phase_loop_runtime/advisor_board/observability.py +481 -0
- phase_loop_runtime/advisor_board/presets.py +188 -0
- phase_loop_runtime/advisor_board/registries.py +309 -0
- phase_loop_runtime/advisor_board/resolver.py +253 -0
- phase_loop_runtime/advisor_board/schema.py +269 -0
- phase_loop_runtime/advisor_board/standin.py +166 -0
- phase_loop_runtime/advisor_board/validation.py +159 -0
- phase_loop_runtime/agent_runtime_provider.py +676 -0
- phase_loop_runtime/baml_modular.py +656 -0
- phase_loop_runtime/baml_src/dotfiles_adoption_manifest.baml +37 -0
- phase_loop_runtime/baml_src/dotfiles_c4_document.baml +14 -0
- phase_loop_runtime/baml_src/dotfiles_plan_manifest.baml +50 -0
- phase_loop_runtime/baml_src/dotfiles_runtime_projection.baml +16 -0
- phase_loop_runtime/baml_src/dotfiles_task_catalog.baml +20 -0
- phase_loop_runtime/baml_src/emit_phase_closeout.baml +86 -0
- phase_loop_runtime/baml_src/evaluate_suspected_fake_evidence.baml +36 -0
- phase_loop_runtime/baml_src/verification_evidence.baml +40 -0
- phase_loop_runtime/broker.py +181 -0
- phase_loop_runtime/build_bundle.py +294 -0
- phase_loop_runtime/capability_registry.py +835 -0
- phase_loop_runtime/classifier.py +87 -0
- phase_loop_runtime/claude_agent_view.py +625 -0
- phase_loop_runtime/claude_channel_sidecar.py +1086 -0
- phase_loop_runtime/cli.py +2599 -0
- phase_loop_runtime/closeout.py +865 -0
- phase_loop_runtime/closeout_classifier.py +120 -0
- phase_loop_runtime/closeout_evidence_audit.py +112 -0
- phase_loop_runtime/closeout_validation.py +144 -0
- phase_loop_runtime/closeout_validators.py +203 -0
- phase_loop_runtime/consiliency_gates.py +374 -0
- phase_loop_runtime/consiliency_ingest.py +399 -0
- phase_loop_runtime/consiliency_layout.py +176 -0
- phase_loop_runtime/consiliency_scaffold.py +305 -0
- phase_loop_runtime/cross_repo_channel.py +331 -0
- phase_loop_runtime/discovery.py +2368 -0
- phase_loop_runtime/dispatch_lock.py +167 -0
- phase_loop_runtime/doc_delta_validator.py +98 -0
- phase_loop_runtime/docs_audit.py +285 -0
- phase_loop_runtime/docs_freshness.py +468 -0
- phase_loop_runtime/docs_surfaces.py +150 -0
- phase_loop_runtime/dotfiles_profile_plugin.py +96 -0
- phase_loop_runtime/events.py +154 -0
- phase_loop_runtime/events_migration.py +96 -0
- phase_loop_runtime/evidence_audit.py +1082 -0
- phase_loop_runtime/evidence_audit_config.py +172 -0
- phase_loop_runtime/fleet_map.py +426 -0
- phase_loop_runtime/fleet_metrics.py +298 -0
- phase_loop_runtime/fleet_metrics_export.py +196 -0
- phase_loop_runtime/git_discipline.py +479 -0
- phase_loop_runtime/git_ops.py +122 -0
- phase_loop_runtime/git_topology.py +252 -0
- phase_loop_runtime/governed_bundle.py +137 -0
- phase_loop_runtime/governed_premerge.py +219 -0
- phase_loop_runtime/governed_review.py +264 -0
- phase_loop_runtime/handoff.py +932 -0
- phase_loop_runtime/handoff_path.py +14 -0
- phase_loop_runtime/injection.py +740 -0
- phase_loop_runtime/install_status.py +88 -0
- phase_loop_runtime/lane_scheduler.py +317 -0
- phase_loop_runtime/launcher.py +2760 -0
- phase_loop_runtime/lease_store.py +553 -0
- phase_loop_runtime/maintenance.py +401 -0
- phase_loop_runtime/migrate_handoffs.py +201 -0
- phase_loop_runtime/models.py +2144 -0
- phase_loop_runtime/observability.py +1290 -0
- phase_loop_runtime/panel_invoker.py +1638 -0
- phase_loop_runtime/phase_loop_drift_audit.py +388 -0
- phase_loop_runtime/phase_worktree_executor.py +433 -0
- phase_loop_runtime/pipeline_adapter/__init__.py +12 -0
- phase_loop_runtime/pipeline_adapter/branch_ops.py +274 -0
- phase_loop_runtime/pipeline_adapter/flag.py +55 -0
- phase_loop_runtime/pipeline_adapter/markers.py +13 -0
- phase_loop_runtime/pipeline_adapter/merge_policy.py +72 -0
- phase_loop_runtime/pipeline_adapter/ratification.py +100 -0
- phase_loop_runtime/pipeline_adapter/sibling_matcher.py +123 -0
- phase_loop_runtime/plan_ir.py +523 -0
- phase_loop_runtime/plan_manifest.py +415 -0
- phase_loop_runtime/planner_validation.py +176 -0
- phase_loop_runtime/profiles.py +462 -0
- phase_loop_runtime/prompts.py +365 -0
- phase_loop_runtime/provenance.py +165 -0
- phase_loop_runtime/publishing.py +339 -0
- phase_loop_runtime/py.typed +1 -0
- phase_loop_runtime/reconcile.py +1550 -0
- phase_loop_runtime/redaction.py +184 -0
- phase_loop_runtime/reflection_sync.py +293 -0
- phase_loop_runtime/release_guard.py +186 -0
- phase_loop_runtime/render.py +432 -0
- phase_loop_runtime/repo_validation.py +427 -0
- phase_loop_runtime/review_summary.py +150 -0
- phase_loop_runtime/roadmap_lint.py +425 -0
- phase_loop_runtime/route_log.py +59 -0
- phase_loop_runtime/route_policy/__init__.py +11 -0
- phase_loop_runtime/route_policy/fixtures/route_selection.golden.json +263 -0
- phase_loop_runtime/runner.py +8400 -0
- phase_loop_runtime/runtime_paths.py +225 -0
- phase_loop_runtime/runtime_projection.py +113 -0
- phase_loop_runtime/runtime_resources.py +36 -0
- phase_loop_runtime/schema_export.py +292 -0
- phase_loop_runtime/schemas/phase_loop_closeout.schema.json +366 -0
- phase_loop_runtime/skill_install.py +176 -0
- phase_loop_runtime/skill_inventory.py +662 -0
- phase_loop_runtime/skill_paths.py +42 -0
- phase_loop_runtime/skill_sources_plugin.py +37 -0
- phase_loop_runtime/skills_bundle/claude-advisor-board/README.md +1 -0
- phase_loop_runtime/skills_bundle/claude-advisor-board/SKILL.md +38 -0
- phase_loop_runtime/skills_bundle/claude-advisor-panel/README.md +1 -0
- phase_loop_runtime/skills_bundle/claude-advisor-panel/SKILL.md +38 -0
- phase_loop_runtime/skills_bundle/claude-execute-detailed/README.md +1 -0
- phase_loop_runtime/skills_bundle/claude-execute-detailed/SKILL.md +152 -0
- phase_loop_runtime/skills_bundle/claude-execute-phase/README.md +1 -0
- phase_loop_runtime/skills_bundle/claude-execute-phase/SKILL.md +745 -0
- phase_loop_runtime/skills_bundle/claude-execute-phase/scripts/allocate_worktree_name.sh +33 -0
- phase_loop_runtime/skills_bundle/claude-execute-phase/scripts/audit_lane_file_touches.py +197 -0
- phase_loop_runtime/skills_bundle/claude-execute-phase/scripts/cleanup_lane_worktrees.sh +103 -0
- phase_loop_runtime/skills_bundle/claude-execute-phase/scripts/parent_tree_leakage_check.sh +125 -0
- phase_loop_runtime/skills_bundle/claude-execute-phase/scripts/post_merge_import_smoke.sh +62 -0
- phase_loop_runtime/skills_bundle/claude-execute-phase/scripts/pre_merge_destructiveness_check.sh +127 -0
- phase_loop_runtime/skills_bundle/claude-execute-phase/scripts/resolve_branch_from_sha.sh +51 -0
- phase_loop_runtime/skills_bundle/claude-execute-phase/scripts/state.py +274 -0
- phase_loop_runtime/skills_bundle/claude-execute-phase/scripts/sweep_stale_worktrees.sh +62 -0
- phase_loop_runtime/skills_bundle/claude-execute-phase/scripts/team_teardown.sh +32 -0
- phase_loop_runtime/skills_bundle/claude-execute-phase/scripts/validate_plan_doc.py +642 -0
- phase_loop_runtime/skills_bundle/claude-execute-phase/scripts/verify_harness.sh +96 -0
- phase_loop_runtime/skills_bundle/claude-phase-loop/README.md +1 -0
- phase_loop_runtime/skills_bundle/claude-phase-loop/SKILL.md +115 -0
- phase_loop_runtime/skills_bundle/claude-phase-roadmap-builder/README.md +1 -0
- phase_loop_runtime/skills_bundle/claude-phase-roadmap-builder/SKILL.md +439 -0
- phase_loop_runtime/skills_bundle/claude-phase-roadmap-builder/assets/review_prompt.md +19 -0
- phase_loop_runtime/skills_bundle/claude-phase-roadmap-builder/references/parallelization-heuristics.md +111 -0
- phase_loop_runtime/skills_bundle/claude-phase-roadmap-builder/references/roadmap-template.md +193 -0
- phase_loop_runtime/skills_bundle/claude-phase-roadmap-builder/scripts/validate_roadmap.py +32 -0
- phase_loop_runtime/skills_bundle/claude-plan-detailed/README.md +1 -0
- phase_loop_runtime/skills_bundle/claude-plan-detailed/SKILL.md +334 -0
- phase_loop_runtime/skills_bundle/claude-plan-detailed/assets/review_prompt.md +25 -0
- phase_loop_runtime/skills_bundle/claude-plan-phase/README.md +1 -0
- phase_loop_runtime/skills_bundle/claude-plan-phase/SKILL.md +776 -0
- phase_loop_runtime/skills_bundle/claude-plan-phase/assets/review_prompt.md +17 -0
- phase_loop_runtime/skills_bundle/claude-plan-phase/scripts/validate_plan_doc.py +1092 -0
- phase_loop_runtime/skills_bundle/claude-run-train/README.md +1 -0
- phase_loop_runtime/skills_bundle/claude-run-train/SKILL.md +75 -0
- phase_loop_runtime/skills_bundle/claude-skill-editor/README.md +1 -0
- phase_loop_runtime/skills_bundle/claude-skill-editor/SKILL.md +243 -0
- phase_loop_runtime/skills_bundle/claude-skill-editor/assets/editor_prompt.md +72 -0
- phase_loop_runtime/skills_bundle/claude-skill-improvement-planner/README.md +1 -0
- phase_loop_runtime/skills_bundle/claude-skill-improvement-planner/SKILL.md +249 -0
- phase_loop_runtime/skills_bundle/claude-skill-improvement-planner/assets/aggregator_prompt.md +79 -0
- phase_loop_runtime/skills_bundle/claude-task-contextualizer/README.md +1 -0
- phase_loop_runtime/skills_bundle/claude-task-contextualizer/SKILL.md +74 -0
- phase_loop_runtime/skills_bundle/claude-task-contextualizer/references/task-templates.md +103 -0
- phase_loop_runtime/skills_bundle/codex-advisor-board/README.md +1 -0
- phase_loop_runtime/skills_bundle/codex-advisor-board/SKILL.md +38 -0
- phase_loop_runtime/skills_bundle/codex-advisor-panel/README.md +1 -0
- phase_loop_runtime/skills_bundle/codex-advisor-panel/SKILL.md +38 -0
- phase_loop_runtime/skills_bundle/codex-execute-detailed/README.md +1 -0
- phase_loop_runtime/skills_bundle/codex-execute-detailed/SKILL.md +154 -0
- phase_loop_runtime/skills_bundle/codex-execute-phase/README.md +1 -0
- phase_loop_runtime/skills_bundle/codex-execute-phase/SKILL.md +231 -0
- phase_loop_runtime/skills_bundle/codex-execute-phase/scripts/allocate_worktree_name.sh +33 -0
- phase_loop_runtime/skills_bundle/codex-execute-phase/scripts/audit_lane_file_touches.py +197 -0
- phase_loop_runtime/skills_bundle/codex-execute-phase/scripts/cleanup_lane_worktrees.sh +103 -0
- phase_loop_runtime/skills_bundle/codex-execute-phase/scripts/parent_tree_leakage_check.sh +125 -0
- phase_loop_runtime/skills_bundle/codex-execute-phase/scripts/post_merge_import_smoke.sh +62 -0
- phase_loop_runtime/skills_bundle/codex-execute-phase/scripts/pre_merge_destructiveness_check.sh +127 -0
- phase_loop_runtime/skills_bundle/codex-execute-phase/scripts/resolve_branch_from_sha.sh +51 -0
- phase_loop_runtime/skills_bundle/codex-execute-phase/scripts/state.py +274 -0
- phase_loop_runtime/skills_bundle/codex-execute-phase/scripts/sweep_stale_worktrees.sh +62 -0
- phase_loop_runtime/skills_bundle/codex-execute-phase/scripts/team_teardown.sh +32 -0
- phase_loop_runtime/skills_bundle/codex-execute-phase/scripts/validate_plan_doc.py +642 -0
- phase_loop_runtime/skills_bundle/codex-execute-phase/scripts/verify_harness.sh +96 -0
- phase_loop_runtime/skills_bundle/codex-phase-loop/README.md +1 -0
- phase_loop_runtime/skills_bundle/codex-phase-loop/SKILL.md +248 -0
- phase_loop_runtime/skills_bundle/codex-phase-roadmap-builder/README.md +1 -0
- phase_loop_runtime/skills_bundle/codex-phase-roadmap-builder/SKILL.md +150 -0
- phase_loop_runtime/skills_bundle/codex-phase-roadmap-builder/assets/review_prompt.md +19 -0
- phase_loop_runtime/skills_bundle/codex-phase-roadmap-builder/references/parallelization-heuristics.md +111 -0
- phase_loop_runtime/skills_bundle/codex-phase-roadmap-builder/references/roadmap-template.md +193 -0
- phase_loop_runtime/skills_bundle/codex-phase-roadmap-builder/scripts/validate_roadmap.py +32 -0
- phase_loop_runtime/skills_bundle/codex-plan-detailed/README.md +1 -0
- phase_loop_runtime/skills_bundle/codex-plan-detailed/SKILL.md +119 -0
- phase_loop_runtime/skills_bundle/codex-plan-detailed/assets/review_prompt.md +25 -0
- phase_loop_runtime/skills_bundle/codex-plan-phase/README.md +1 -0
- phase_loop_runtime/skills_bundle/codex-plan-phase/SKILL.md +307 -0
- phase_loop_runtime/skills_bundle/codex-plan-phase/assets/review_prompt.md +17 -0
- phase_loop_runtime/skills_bundle/codex-plan-phase/scripts/validate_plan_doc.py +1092 -0
- phase_loop_runtime/skills_bundle/codex-run-train/README.md +1 -0
- phase_loop_runtime/skills_bundle/codex-run-train/SKILL.md +75 -0
- phase_loop_runtime/skills_bundle/codex-skill-editor/README.md +1 -0
- phase_loop_runtime/skills_bundle/codex-skill-editor/SKILL.md +94 -0
- phase_loop_runtime/skills_bundle/codex-skill-editor/assets/editor_prompt.md +72 -0
- phase_loop_runtime/skills_bundle/codex-skill-improvement-planner/README.md +1 -0
- phase_loop_runtime/skills_bundle/codex-skill-improvement-planner/SKILL.md +114 -0
- phase_loop_runtime/skills_bundle/codex-skill-improvement-planner/assets/aggregator_prompt.md +79 -0
- phase_loop_runtime/skills_bundle/codex-task-contextualizer/README.md +1 -0
- phase_loop_runtime/skills_bundle/codex-task-contextualizer/SKILL.md +102 -0
- phase_loop_runtime/skills_bundle/codex-task-contextualizer/references/task-templates.md +103 -0
- phase_loop_runtime/skills_bundle/gemini-advisor-board/README.md +1 -0
- phase_loop_runtime/skills_bundle/gemini-advisor-board/SKILL.md +38 -0
- phase_loop_runtime/skills_bundle/gemini-advisor-panel/README.md +1 -0
- phase_loop_runtime/skills_bundle/gemini-advisor-panel/SKILL.md +38 -0
- phase_loop_runtime/skills_bundle/gemini-execute-detailed/README.md +1 -0
- phase_loop_runtime/skills_bundle/gemini-execute-detailed/SKILL.md +144 -0
- phase_loop_runtime/skills_bundle/gemini-execute-phase/README.md +1 -0
- phase_loop_runtime/skills_bundle/gemini-execute-phase/SKILL.md +198 -0
- phase_loop_runtime/skills_bundle/gemini-execute-phase/scripts/allocate_worktree_name.sh +33 -0
- phase_loop_runtime/skills_bundle/gemini-execute-phase/scripts/audit_lane_file_touches.py +197 -0
- phase_loop_runtime/skills_bundle/gemini-execute-phase/scripts/cleanup_lane_worktrees.sh +103 -0
- phase_loop_runtime/skills_bundle/gemini-execute-phase/scripts/parent_tree_leakage_check.sh +125 -0
- phase_loop_runtime/skills_bundle/gemini-execute-phase/scripts/post_merge_import_smoke.sh +62 -0
- phase_loop_runtime/skills_bundle/gemini-execute-phase/scripts/pre_merge_destructiveness_check.sh +127 -0
- phase_loop_runtime/skills_bundle/gemini-execute-phase/scripts/resolve_branch_from_sha.sh +51 -0
- phase_loop_runtime/skills_bundle/gemini-execute-phase/scripts/state.py +274 -0
- phase_loop_runtime/skills_bundle/gemini-execute-phase/scripts/sweep_stale_worktrees.sh +62 -0
- phase_loop_runtime/skills_bundle/gemini-execute-phase/scripts/team_teardown.sh +32 -0
- phase_loop_runtime/skills_bundle/gemini-execute-phase/scripts/validate_plan_doc.py +642 -0
- phase_loop_runtime/skills_bundle/gemini-execute-phase/scripts/verify_harness.sh +96 -0
- phase_loop_runtime/skills_bundle/gemini-phase-loop/README.md +1 -0
- phase_loop_runtime/skills_bundle/gemini-phase-loop/SKILL.md +111 -0
- phase_loop_runtime/skills_bundle/gemini-phase-roadmap-builder/README.md +1 -0
- phase_loop_runtime/skills_bundle/gemini-phase-roadmap-builder/SKILL.md +147 -0
- phase_loop_runtime/skills_bundle/gemini-phase-roadmap-builder/assets/review_prompt.md +19 -0
- phase_loop_runtime/skills_bundle/gemini-phase-roadmap-builder/references/parallelization-heuristics.md +111 -0
- phase_loop_runtime/skills_bundle/gemini-phase-roadmap-builder/references/roadmap-template.md +193 -0
- phase_loop_runtime/skills_bundle/gemini-phase-roadmap-builder/scripts/validate_roadmap.py +32 -0
- phase_loop_runtime/skills_bundle/gemini-plan-detailed/README.md +1 -0
- phase_loop_runtime/skills_bundle/gemini-plan-detailed/SKILL.md +119 -0
- phase_loop_runtime/skills_bundle/gemini-plan-detailed/assets/review_prompt.md +25 -0
- phase_loop_runtime/skills_bundle/gemini-plan-phase/README.md +1 -0
- phase_loop_runtime/skills_bundle/gemini-plan-phase/SKILL.md +217 -0
- phase_loop_runtime/skills_bundle/gemini-plan-phase/assets/review_prompt.md +17 -0
- phase_loop_runtime/skills_bundle/gemini-plan-phase/scripts/validate_plan_doc.py +1092 -0
- phase_loop_runtime/skills_bundle/gemini-run-train/README.md +1 -0
- phase_loop_runtime/skills_bundle/gemini-run-train/SKILL.md +75 -0
- phase_loop_runtime/skills_bundle/gemini-skill-editor/README.md +1 -0
- phase_loop_runtime/skills_bundle/gemini-skill-editor/SKILL.md +87 -0
- phase_loop_runtime/skills_bundle/gemini-skill-editor/assets/editor_prompt.md +72 -0
- phase_loop_runtime/skills_bundle/gemini-skill-improvement-planner/README.md +1 -0
- phase_loop_runtime/skills_bundle/gemini-skill-improvement-planner/SKILL.md +109 -0
- phase_loop_runtime/skills_bundle/gemini-skill-improvement-planner/assets/aggregator_prompt.md +79 -0
- phase_loop_runtime/skills_bundle/gemini-task-contextualizer/README.md +1 -0
- phase_loop_runtime/skills_bundle/gemini-task-contextualizer/SKILL.md +98 -0
- phase_loop_runtime/skills_bundle/gemini-task-contextualizer/references/task-templates.md +103 -0
- phase_loop_runtime/skills_bundle/opencode-advisor-board/README.md +1 -0
- phase_loop_runtime/skills_bundle/opencode-advisor-board/SKILL.md +38 -0
- phase_loop_runtime/skills_bundle/opencode-advisor-panel/README.md +1 -0
- phase_loop_runtime/skills_bundle/opencode-advisor-panel/SKILL.md +38 -0
- phase_loop_runtime/skills_bundle/opencode-execute-detailed/README.md +1 -0
- phase_loop_runtime/skills_bundle/opencode-execute-detailed/SKILL.md +144 -0
- phase_loop_runtime/skills_bundle/opencode-execute-phase/README.md +1 -0
- phase_loop_runtime/skills_bundle/opencode-execute-phase/SKILL.md +196 -0
- phase_loop_runtime/skills_bundle/opencode-execute-phase/scripts/allocate_worktree_name.sh +33 -0
- phase_loop_runtime/skills_bundle/opencode-execute-phase/scripts/audit_lane_file_touches.py +197 -0
- phase_loop_runtime/skills_bundle/opencode-execute-phase/scripts/cleanup_lane_worktrees.sh +103 -0
- phase_loop_runtime/skills_bundle/opencode-execute-phase/scripts/parent_tree_leakage_check.sh +125 -0
- phase_loop_runtime/skills_bundle/opencode-execute-phase/scripts/post_merge_import_smoke.sh +62 -0
- phase_loop_runtime/skills_bundle/opencode-execute-phase/scripts/pre_merge_destructiveness_check.sh +127 -0
- phase_loop_runtime/skills_bundle/opencode-execute-phase/scripts/resolve_branch_from_sha.sh +51 -0
- phase_loop_runtime/skills_bundle/opencode-execute-phase/scripts/state.py +274 -0
- phase_loop_runtime/skills_bundle/opencode-execute-phase/scripts/sweep_stale_worktrees.sh +62 -0
- phase_loop_runtime/skills_bundle/opencode-execute-phase/scripts/team_teardown.sh +32 -0
- phase_loop_runtime/skills_bundle/opencode-execute-phase/scripts/validate_plan_doc.py +642 -0
- phase_loop_runtime/skills_bundle/opencode-execute-phase/scripts/verify_harness.sh +96 -0
- phase_loop_runtime/skills_bundle/opencode-phase-loop/README.md +1 -0
- phase_loop_runtime/skills_bundle/opencode-phase-loop/SKILL.md +113 -0
- phase_loop_runtime/skills_bundle/opencode-phase-roadmap-builder/README.md +1 -0
- phase_loop_runtime/skills_bundle/opencode-phase-roadmap-builder/SKILL.md +147 -0
- phase_loop_runtime/skills_bundle/opencode-phase-roadmap-builder/assets/review_prompt.md +19 -0
- phase_loop_runtime/skills_bundle/opencode-phase-roadmap-builder/references/parallelization-heuristics.md +111 -0
- phase_loop_runtime/skills_bundle/opencode-phase-roadmap-builder/references/roadmap-template.md +193 -0
- phase_loop_runtime/skills_bundle/opencode-phase-roadmap-builder/scripts/validate_roadmap.py +32 -0
- phase_loop_runtime/skills_bundle/opencode-plan-detailed/README.md +1 -0
- phase_loop_runtime/skills_bundle/opencode-plan-detailed/SKILL.md +119 -0
- phase_loop_runtime/skills_bundle/opencode-plan-detailed/assets/review_prompt.md +25 -0
- phase_loop_runtime/skills_bundle/opencode-plan-phase/README.md +1 -0
- phase_loop_runtime/skills_bundle/opencode-plan-phase/SKILL.md +211 -0
- phase_loop_runtime/skills_bundle/opencode-plan-phase/assets/review_prompt.md +17 -0
- phase_loop_runtime/skills_bundle/opencode-plan-phase/scripts/validate_plan_doc.py +1092 -0
- phase_loop_runtime/skills_bundle/opencode-run-train/README.md +1 -0
- phase_loop_runtime/skills_bundle/opencode-run-train/SKILL.md +75 -0
- phase_loop_runtime/skills_bundle/opencode-skill-editor/README.md +1 -0
- phase_loop_runtime/skills_bundle/opencode-skill-editor/SKILL.md +87 -0
- phase_loop_runtime/skills_bundle/opencode-skill-editor/assets/editor_prompt.md +72 -0
- phase_loop_runtime/skills_bundle/opencode-skill-improvement-planner/README.md +1 -0
- phase_loop_runtime/skills_bundle/opencode-skill-improvement-planner/SKILL.md +109 -0
- phase_loop_runtime/skills_bundle/opencode-skill-improvement-planner/assets/aggregator_prompt.md +79 -0
- phase_loop_runtime/skills_bundle/opencode-task-contextualizer/README.md +1 -0
- phase_loop_runtime/skills_bundle/opencode-task-contextualizer/SKILL.md +98 -0
- phase_loop_runtime/skills_bundle/opencode-task-contextualizer/references/task-templates.md +103 -0
- phase_loop_runtime/state.py +156 -0
- phase_loop_runtime/state_degradation.py +136 -0
- phase_loop_runtime/state_ops.py +676 -0
- phase_loop_runtime/train_ledger.py +215 -0
- phase_loop_runtime/train_roadmap.py +339 -0
- phase_loop_runtime/train_runner.py +1197 -0
- phase_loop_runtime/verification_evidence.py +650 -0
- phase_loop_runtime/verification_evidence_validator.py +75 -0
- phase_loop_runtime/visual_evidence_validator.py +36 -0
- phase_loop_runtime/worker_pool.py +123 -0
- phase_loop_runtime/worktree_index.py +270 -0
- phase_loop_runtime-0.2.0.data/data/share/phase-loop-runtime/protocol/protocol.md +2475 -0
- phase_loop_runtime-0.2.0.dist-info/METADATA +106 -0
- phase_loop_runtime-0.2.0.dist-info/RECORD +370 -0
- phase_loop_runtime-0.2.0.dist-info/WHEEL +5 -0
- phase_loop_runtime-0.2.0.dist-info/entry_points.txt +9 -0
- phase_loop_runtime-0.2.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"""Dotfiles profile plugin: dotfiles-domain phase-loop CLI commands.
|
|
2
|
+
|
|
3
|
+
DECOUPLE SL-1 moves the dotfiles-specific subcommands (`adoption-bundle`,
|
|
4
|
+
`sync-skills`, `build-bundle`, `hotfix`) out of the generic CLI and behind this
|
|
5
|
+
profile-command plugin. The generic ``phase_loop_runtime.cli`` registers NONE of
|
|
6
|
+
them at import; they appear only when this plugin is loaded -- either via the
|
|
7
|
+
``phase_loop_runtime.profile_commands`` entry-point group (declared by a profile
|
|
8
|
+
distribution) or via the explicit ``PHASE_LOOP_PROFILE_PLUGINS`` opt-in used in
|
|
9
|
+
source-mode runs and tests.
|
|
10
|
+
|
|
11
|
+
This module is the dotfiles *profile*: it is allowed to depend on dotfiles-domain
|
|
12
|
+
runtime modules. Decoupling means the generic CLI no longer imports them, not that
|
|
13
|
+
they cease to exist.
|
|
14
|
+
"""
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import argparse
|
|
18
|
+
from typing import TYPE_CHECKING
|
|
19
|
+
|
|
20
|
+
if TYPE_CHECKING: # pragma: no cover - typing only
|
|
21
|
+
from argparse import _SubParsersAction
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# Default canonical skill-bundle source roots advertised by `build-bundle --help`.
|
|
25
|
+
# Imported lazily inside register to keep `import phase_loop_runtime.cli` clean.
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def register_profile_commands(subparsers: "_SubParsersAction") -> None:
|
|
29
|
+
"""Register the dotfiles-domain subcommands on an existing subparsers action.
|
|
30
|
+
|
|
31
|
+
Each subparser carries the shared common args (via the generic CLI helper) and
|
|
32
|
+
a ``func`` default that the generic dispatcher invokes as
|
|
33
|
+
``func(repo=repo, args=args, as_json=as_json)``.
|
|
34
|
+
"""
|
|
35
|
+
from . import cli
|
|
36
|
+
from .build_bundle import DEFAULT_SOURCES
|
|
37
|
+
|
|
38
|
+
def _add_common(sub: argparse.ArgumentParser, name: str) -> None:
|
|
39
|
+
cli._add_common_subparser_args(sub, name=name)
|
|
40
|
+
|
|
41
|
+
# adoption-bundle -------------------------------------------------------
|
|
42
|
+
adoption = subparsers.add_parser("adoption-bundle")
|
|
43
|
+
adoption.description = "Check or refresh the committed dotfiles adoption bundle."
|
|
44
|
+
adoption.add_argument("adoption_bundle_action", choices=("status", "refresh"))
|
|
45
|
+
_add_common(adoption, "adoption-bundle")
|
|
46
|
+
adoption.set_defaults(command="adoption-bundle", func=_adoption_bundle_dispatch)
|
|
47
|
+
|
|
48
|
+
# sync-skills -----------------------------------------------------------
|
|
49
|
+
sync = subparsers.add_parser("sync-skills")
|
|
50
|
+
sync.description = "Audit or repair harness-local phase-loop bridge skills for manual reentry."
|
|
51
|
+
sync.add_argument("--harness", action="append", default=[], choices=("codex", "claude", "gemini", "opencode"))
|
|
52
|
+
sync.add_argument("--check", action="store_true")
|
|
53
|
+
sync.add_argument("--apply", action="store_true")
|
|
54
|
+
_add_common(sync, "sync-skills")
|
|
55
|
+
sync.set_defaults(command="sync-skills", func=cli._sync_skills_command)
|
|
56
|
+
|
|
57
|
+
# build-bundle ----------------------------------------------------------
|
|
58
|
+
build = subparsers.add_parser("build-bundle")
|
|
59
|
+
build.description = "Regenerate the harness-neutral phase-loop skills bundle from canonical harness roots."
|
|
60
|
+
build.add_argument(
|
|
61
|
+
"--source",
|
|
62
|
+
action="append",
|
|
63
|
+
help=(
|
|
64
|
+
"Canonical source root. Repeat for claude, codex, gemini, and opencode. "
|
|
65
|
+
"Defaults: " + ", ".join(DEFAULT_SOURCES.values())
|
|
66
|
+
),
|
|
67
|
+
)
|
|
68
|
+
build.add_argument("--destination", default="vendor/phase-loop-skills")
|
|
69
|
+
build.add_argument("--apply", action="store_true", help="Write generated bundle files. Without --apply, this command is read-only.")
|
|
70
|
+
build.add_argument("--force", action="store_true", help="Rewrite generated outputs even when content is unchanged.")
|
|
71
|
+
_add_common(build, "build-bundle")
|
|
72
|
+
build.set_defaults(command="build-bundle", func=cli._build_bundle_command)
|
|
73
|
+
|
|
74
|
+
# hotfix ----------------------------------------------------------------
|
|
75
|
+
hotfix = subparsers.add_parser("hotfix")
|
|
76
|
+
hotfix.description = "Run a bounded emergency hotfix through runner-owned verification evidence."
|
|
77
|
+
hotfix.add_argument("--reason", help="Non-secret reason recorded in the hotfix closeout event.")
|
|
78
|
+
hotfix.add_argument("--plan", help="Path to a hotfix stub containing a verification_command field.")
|
|
79
|
+
hotfix.add_argument("--init-stub", help="Write a minimal hotfix stub and exit without executing.")
|
|
80
|
+
_add_common(hotfix, "hotfix")
|
|
81
|
+
hotfix.set_defaults(command="hotfix", func=cli._hotfix_command)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
# --- dispatch ------------------------------------------------------------
|
|
85
|
+
# sync-skills/build-bundle/hotfix bind set_defaults(func=...) straight to the
|
|
86
|
+
# cli._*_command handlers (signatures already match the generic dispatcher's
|
|
87
|
+
# func(repo=, args=, as_json=) convention). Only adoption-bundle needs an adapter,
|
|
88
|
+
# to map the positional adoption_bundle_action -> the handler's `action` kwarg.
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def _adoption_bundle_dispatch(*, repo, args, as_json):
|
|
92
|
+
from . import cli
|
|
93
|
+
|
|
94
|
+
return cli._adoption_bundle_command(
|
|
95
|
+
repo=repo, action=args.adoption_bundle_action, as_json=as_json
|
|
96
|
+
)
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
from dataclasses import replace
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from .closeout import phase_loop_closeout_diagnostic
|
|
9
|
+
from .git_topology import attach_git_topology, collect_git_topology
|
|
10
|
+
from .models import LoopEvent, WorkUnitEventMetadata
|
|
11
|
+
from .runtime_paths import ensure_phase_loop_excluded, phase_loop_event_file, phase_loop_event_read_files
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def event_path(repo: Path) -> Path:
|
|
15
|
+
return phase_loop_event_file(repo)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def event_read_paths(repo: Path) -> tuple[Path, ...]:
|
|
19
|
+
return phase_loop_event_read_files(repo)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def append_event(repo: Path, event: LoopEvent) -> None:
|
|
23
|
+
ensure_phase_loop_excluded(repo)
|
|
24
|
+
event = _event_with_closeout_metadata(event)
|
|
25
|
+
event = attach_git_topology(repo, event)
|
|
26
|
+
path = event_path(repo)
|
|
27
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
28
|
+
_append_jsonl(path, event.to_json())
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def append_work_unit_event(repo: Path, event: WorkUnitEventMetadata, *, roadmap: Path | None = None) -> None:
|
|
32
|
+
ensure_phase_loop_excluded(repo)
|
|
33
|
+
payload = event.to_json()
|
|
34
|
+
closeout = _extract_work_unit_closeout(payload)
|
|
35
|
+
if closeout is not None:
|
|
36
|
+
payload["metadata"] = _pipeline_metadata(closeout)
|
|
37
|
+
payload.update(
|
|
38
|
+
{
|
|
39
|
+
"repo": str(repo),
|
|
40
|
+
"roadmap": str(roadmap or ""),
|
|
41
|
+
"phase": event.identity.phase,
|
|
42
|
+
"action": "work_unit",
|
|
43
|
+
"status": event.status,
|
|
44
|
+
"source": "work_unit_ledger",
|
|
45
|
+
"schema_version": 2,
|
|
46
|
+
"git_topology": collect_git_topology(repo),
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
path = event_path(repo)
|
|
50
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
51
|
+
_append_jsonl(path, payload)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _append_jsonl(path: Path, payload: dict) -> None:
|
|
55
|
+
encoded = (json.dumps(payload, sort_keys=True) + "\n").encode("utf-8")
|
|
56
|
+
fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_APPEND, 0o666)
|
|
57
|
+
try:
|
|
58
|
+
os.write(fd, encoded)
|
|
59
|
+
finally:
|
|
60
|
+
os.close(fd)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def read_events(repo: Path) -> list[dict]:
|
|
64
|
+
events: list[dict] = []
|
|
65
|
+
for path in event_read_paths(repo):
|
|
66
|
+
if not path.exists():
|
|
67
|
+
continue
|
|
68
|
+
with path.open(encoding="utf-8") as handle:
|
|
69
|
+
for line in handle:
|
|
70
|
+
line = line.strip()
|
|
71
|
+
if not line:
|
|
72
|
+
continue
|
|
73
|
+
event = json.loads(line)
|
|
74
|
+
event.setdefault("schema_version", 1)
|
|
75
|
+
events.append(event)
|
|
76
|
+
return events
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def read_work_unit_events(repo: Path, work_unit_id: str | None = None) -> list[dict]:
|
|
80
|
+
records: list[dict] = []
|
|
81
|
+
for event in read_events(repo):
|
|
82
|
+
if event.get("event_kind") != "work_unit":
|
|
83
|
+
continue
|
|
84
|
+
work_unit = event.get("work_unit")
|
|
85
|
+
if not isinstance(work_unit, dict):
|
|
86
|
+
metadata = event.get("metadata")
|
|
87
|
+
work_unit = metadata.get("work_unit") if isinstance(metadata, dict) else None
|
|
88
|
+
if not isinstance(work_unit, dict):
|
|
89
|
+
continue
|
|
90
|
+
if work_unit_id is not None and work_unit.get("work_unit_id") != work_unit_id:
|
|
91
|
+
continue
|
|
92
|
+
records.append(event)
|
|
93
|
+
return records
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def _event_with_closeout_metadata(event: LoopEvent) -> LoopEvent:
|
|
97
|
+
metadata = dict(event.metadata or {})
|
|
98
|
+
closeout = _extract_closeout(metadata)
|
|
99
|
+
if closeout is None:
|
|
100
|
+
return event
|
|
101
|
+
metadata.update(_pipeline_metadata(closeout))
|
|
102
|
+
return replace(event, metadata=metadata)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _extract_closeout(metadata: dict) -> dict | None:
|
|
106
|
+
closeout = metadata.get("phase_loop_closeout")
|
|
107
|
+
if not isinstance(closeout, dict):
|
|
108
|
+
terminal = metadata.get("terminal_summary")
|
|
109
|
+
closeout = terminal.get("phase_loop_closeout") if isinstance(terminal, dict) else None
|
|
110
|
+
if isinstance(closeout, dict) and phase_loop_closeout_diagnostic(closeout) is None:
|
|
111
|
+
return closeout
|
|
112
|
+
return None
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def _extract_work_unit_closeout(payload: dict) -> dict | None:
|
|
116
|
+
work_unit = payload.get("work_unit")
|
|
117
|
+
if not isinstance(work_unit, dict):
|
|
118
|
+
return None
|
|
119
|
+
closeout_summary = work_unit.get("closeout_summary")
|
|
120
|
+
closeout = closeout_summary.get("phase_loop_closeout") if isinstance(closeout_summary, dict) else None
|
|
121
|
+
if isinstance(closeout, dict) and phase_loop_closeout_diagnostic(closeout) is None:
|
|
122
|
+
return closeout
|
|
123
|
+
return None
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def _pipeline_metadata(closeout: dict) -> dict:
|
|
127
|
+
source_bundle = closeout.get("source_bundle") if isinstance(closeout.get("source_bundle"), dict) else {}
|
|
128
|
+
artifacts = closeout.get("artifacts") if isinstance(closeout.get("artifacts"), dict) else {}
|
|
129
|
+
verification = closeout.get("verification") if isinstance(closeout.get("verification"), dict) else {}
|
|
130
|
+
blocker = closeout.get("blocker") if isinstance(closeout.get("blocker"), dict) else {}
|
|
131
|
+
impact = closeout.get("source_truth_impact") if isinstance(closeout.get("source_truth_impact"), dict) else {}
|
|
132
|
+
return {
|
|
133
|
+
"phase_loop_closeout": closeout,
|
|
134
|
+
"phase_alias": closeout.get("phase_alias") or closeout.get("phase"),
|
|
135
|
+
"pipeline_phase_id": source_bundle.get("phase_id") or closeout.get("pipeline_phase_id"),
|
|
136
|
+
"source_bundle_path": source_bundle.get("path") or closeout.get("source_bundle_path"),
|
|
137
|
+
"source_bundle_sha256": source_bundle.get("sha256") or closeout.get("source_bundle_sha256"),
|
|
138
|
+
"pipeline_mode": source_bundle.get("pipeline_mode"),
|
|
139
|
+
"verification_status": verification.get("status") or closeout.get("verification_status"),
|
|
140
|
+
"changed_paths": artifacts.get("changed_paths") or closeout.get("changed_paths") or [],
|
|
141
|
+
"evidence_refs": artifacts.get("evidence_refs") or closeout.get("evidence_refs") or [],
|
|
142
|
+
"blocker_class": blocker.get("blocker_class"),
|
|
143
|
+
"source_truth_impact": impact,
|
|
144
|
+
"canonical_refresh_recommended": impact.get("canonical_refresh_recommended", False),
|
|
145
|
+
"canonical_refresh_reason_codes": impact.get("canonical_refresh_reason_codes") or [],
|
|
146
|
+
"changed_path_boundaries": impact.get("changed_path_boundaries") or [],
|
|
147
|
+
"changed_path_categories": sorted(
|
|
148
|
+
{
|
|
149
|
+
str(item.get("category"))
|
|
150
|
+
for item in impact.get("changed_path_boundaries") or []
|
|
151
|
+
if isinstance(item, dict) and item.get("category")
|
|
152
|
+
}
|
|
153
|
+
),
|
|
154
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from .runtime_paths import phase_loop_event_file
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@dataclass(frozen=True)
|
|
12
|
+
class MigrationResult:
|
|
13
|
+
migrated: int
|
|
14
|
+
already_migrated: int
|
|
15
|
+
backup: str | None = None
|
|
16
|
+
dry_run: bool = False
|
|
17
|
+
|
|
18
|
+
def to_json(self) -> dict[str, object]:
|
|
19
|
+
if self.dry_run:
|
|
20
|
+
return {
|
|
21
|
+
"would_migrate": self.migrated,
|
|
22
|
+
"already_migrated": self.already_migrated,
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
"migrated": self.migrated,
|
|
26
|
+
"already_migrated": self.already_migrated,
|
|
27
|
+
"backup": self.backup,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class MigrationError(RuntimeError):
|
|
32
|
+
pass
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def migrate_ledger(repo: Path, *, dry_run: bool, backup_suffix: str) -> MigrationResult:
|
|
36
|
+
repo = Path(repo).expanduser().resolve()
|
|
37
|
+
event_path = phase_loop_event_file(repo)
|
|
38
|
+
source = event_path.read_text(encoding="utf-8") if event_path.exists() else ""
|
|
39
|
+
lines = source.splitlines()
|
|
40
|
+
trailing_newline = source.endswith("\n")
|
|
41
|
+
|
|
42
|
+
parsed: list[dict | None] = []
|
|
43
|
+
for index, line in enumerate(lines, start=1):
|
|
44
|
+
if not line.strip():
|
|
45
|
+
parsed.append(None)
|
|
46
|
+
continue
|
|
47
|
+
try:
|
|
48
|
+
event = json.loads(line)
|
|
49
|
+
except json.JSONDecodeError as exc:
|
|
50
|
+
raise MigrationError(f"malformed JSONL at line {index}: {exc.msg}") from exc
|
|
51
|
+
if not isinstance(event, dict):
|
|
52
|
+
raise MigrationError(f"malformed JSONL at line {index}: expected object")
|
|
53
|
+
parsed.append(event)
|
|
54
|
+
|
|
55
|
+
migrated = 0
|
|
56
|
+
already_migrated = 0
|
|
57
|
+
rewritten_lines = list(lines)
|
|
58
|
+
for index, event in enumerate(parsed):
|
|
59
|
+
if event is None:
|
|
60
|
+
continue
|
|
61
|
+
if _is_executor_closeout(event, action="executor.closeout"):
|
|
62
|
+
already_migrated += 1
|
|
63
|
+
continue
|
|
64
|
+
if not _is_executor_closeout(event, action="run"):
|
|
65
|
+
continue
|
|
66
|
+
migrated += 1
|
|
67
|
+
rewritten = dict(event)
|
|
68
|
+
rewritten["action"] = "executor.closeout"
|
|
69
|
+
rewritten_lines[index] = json.dumps(rewritten, separators=(",", ":"))
|
|
70
|
+
|
|
71
|
+
if dry_run:
|
|
72
|
+
return MigrationResult(migrated=migrated, already_migrated=already_migrated, dry_run=True)
|
|
73
|
+
|
|
74
|
+
backup_path = event_path.with_name(event_path.name + backup_suffix)
|
|
75
|
+
if migrated == 0:
|
|
76
|
+
backup = str(backup_path) if backup_path.exists() else None
|
|
77
|
+
return MigrationResult(migrated=0, already_migrated=already_migrated, backup=backup)
|
|
78
|
+
if backup_path.exists():
|
|
79
|
+
raise MigrationError(f"backup path already exists: {backup_path}")
|
|
80
|
+
|
|
81
|
+
event_path.parent.mkdir(parents=True, exist_ok=True)
|
|
82
|
+
backup_path.write_text(source, encoding="utf-8")
|
|
83
|
+
tmp_path = event_path.with_name(event_path.name + ".tmp-def4-migrate")
|
|
84
|
+
output = "\n".join(rewritten_lines)
|
|
85
|
+
if trailing_newline and output:
|
|
86
|
+
output += "\n"
|
|
87
|
+
tmp_path.write_text(output, encoding="utf-8")
|
|
88
|
+
os.replace(tmp_path, event_path)
|
|
89
|
+
return MigrationResult(migrated=migrated, already_migrated=already_migrated, backup=str(backup_path))
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def _is_executor_closeout(event: dict, *, action: str) -> bool:
|
|
93
|
+
if event.get("action") != action:
|
|
94
|
+
return False
|
|
95
|
+
metadata = event.get("metadata")
|
|
96
|
+
return isinstance(metadata, dict) and isinstance(metadata.get("executor_closeout_event"), dict)
|