@aibyzero/cm-workflow 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/AGENTS.md +27 -0
- package/CHANGELOG.md +230 -1
- package/CONTRIBUTING.md +47 -0
- package/README.md +21 -3
- package/THIRD_PARTY_NOTICES.md +13 -0
- package/VERSION +1 -1
- package/compat/claude-commands/cm-challenge.md +3 -0
- package/docs/architecture.md +40 -13
- package/docs/cm-control-policy-v2.md +127 -9
- package/docs/fixes/20261013-claude-preinit-ui-invalidate.md +48 -0
- package/docs/installation.md +310 -4
- package/docs/js-workflow-control.md +153 -16
- package/docs/live-evidence-drivers.md +28 -4
- package/docs/out-of-scope/README.md +25 -0
- package/docs/out-of-scope/background-supervisor.md +32 -0
- package/docs/reviewed-integration.md +48 -0
- package/docs/user-guide.md +50 -21
- package/install-codex.sh +331 -18
- package/install.ps1 +28 -2
- package/install.sh +321 -17
- package/package.json +2 -1
- package/runtime/js/cm-ai/batch-location.mjs +55 -0
- package/runtime/js/cm-ai/batch-plan.mjs +242 -0
- package/runtime/js/cm-ai/checkpoint-package-material.mjs +162 -0
- package/runtime/js/cm-ai/claude-developer-proposal.schema.json +55 -1
- package/runtime/js/cm-ai/claude-review-stream.mjs +94 -21
- package/runtime/js/cm-ai/claude-tool-preview.mjs +11 -9
- package/runtime/js/cm-ai/cm-ai-admission.mjs +18 -12
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +91 -6
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +5 -1
- package/runtime/js/cm-ai/codex-config.mjs +6 -2
- package/runtime/js/cm-ai/codex-developer-basic-output.schema.json +3 -2
- package/runtime/js/cm-ai/codex-developer-output.schema.json +2 -1
- package/runtime/js/cm-ai/codex-reconnect-notice.mjs +6 -0
- package/runtime/js/cm-ai/codex-review-adapter.mjs +27 -7
- package/runtime/js/cm-ai/control-policy.mjs +24 -6
- package/runtime/js/cm-ai/developer-adapter.mjs +19 -5
- package/runtime/js/cm-ai/drive-core.mjs +236 -34
- package/runtime/js/cm-ai/drive-rate-limit.mjs +105 -0
- package/runtime/js/cm-ai/durable-runner-state.mjs +234 -33
- package/runtime/js/cm-ai/effect-contract.mjs +11 -2
- package/runtime/js/cm-ai/execution-policy.mjs +3 -1
- package/runtime/js/cm-ai/execution-snapshot.mjs +4 -2
- package/runtime/js/cm-ai/execution-store-limits.mjs +14 -7
- package/runtime/js/cm-ai/execution-store.mjs +60 -17
- package/runtime/js/cm-ai/fix-code-association.mjs +73 -2
- package/runtime/js/cm-ai/host-check.mjs +14 -6
- package/runtime/js/cm-ai/host-conversation-execution.mjs +70 -28
- package/runtime/js/cm-ai/host-qa-executor.mjs +38 -5
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +2 -2
- package/runtime/js/cm-ai/host-qa-policy.mjs +19 -2
- package/runtime/js/cm-ai/host-replay.mjs +148 -0
- package/runtime/js/cm-ai/host-session.mjs +42 -9
- package/runtime/js/cm-ai/host-stage-observer.mjs +26 -0
- package/runtime/js/cm-ai/host-tool-bridge.mjs +22 -9
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +19 -2
- package/runtime/js/cm-ai/host.mjs +1 -1
- package/runtime/js/cm-ai/implicit-qa-decision.mjs +5 -0
- package/runtime/js/cm-ai/integration-snapshots.mjs +50 -0
- package/runtime/js/cm-ai/live-evidence.mjs +28 -6
- package/runtime/js/cm-ai/operator-guidance.mjs +63 -30
- package/runtime/js/cm-ai/owned-process-cleanup.mjs +27 -9
- package/runtime/js/cm-ai/process-group-exit.mjs +46 -0
- package/runtime/js/cm-ai/provider-review-observation.mjs +3 -2
- package/runtime/js/cm-ai/qa-attachment.mjs +22 -0
- package/runtime/js/cm-ai/qa-config-revision.mjs +7 -2
- package/runtime/js/cm-ai/requirement-evidence.mjs +102 -0
- package/runtime/js/cm-ai/review-package.mjs +79 -7
- package/runtime/js/cm-ai/review-presentation-delta.mjs +166 -0
- package/runtime/js/cm-ai/review-presentation.mjs +177 -8
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +70 -2
- package/runtime/js/cm-ai/reviewed-integration.mjs +260 -0
- package/runtime/js/cm-ai/scope-revision.mjs +38 -0
- package/runtime/js/cm-ai/specification-material.mjs +2 -2
- package/runtime/js/cm-ai/task-runner.mjs +247 -41
- package/runtime/js/cm-ai/verification-auto.mjs +38 -0
- package/runtime/js/cm-ai/worker-claude-developer.mjs +39 -15
- package/runtime/js/cm-ai/worker-claude.mjs +35 -13
- package/runtime/js/cm-ai/worker-codex-developer.mjs +43 -17
- package/runtime/js/cm-ai/worker-codex.mjs +41 -7
- package/runtime/js/cm-fix/cause-invocation.mjs +16 -2
- package/runtime/js/cm-fix/cause-package.mjs +46 -1
- package/runtime/js/cm-fix/command-correction.mjs +37 -0
- package/runtime/js/cm-fix/cooperative.mjs +12 -0
- package/runtime/js/cm-fix/dossier.mjs +8 -2
- package/runtime/js/cm-fix/execution.mjs +578 -100
- package/runtime/js/cm-fix/final-review.mjs +39 -8
- package/runtime/js/cm-fix/finish.mjs +15 -11
- package/runtime/js/cm-fix/host-review.mjs +65 -10
- package/runtime/js/cm-fix/host.mjs +35 -12
- package/runtime/js/cm-fix/jest-command-correction.mjs +69 -0
- package/runtime/js/cm-fix/metrics.mjs +18 -5
- package/runtime/js/cm-fix/regression-evidence.mjs +3 -2
- package/runtime/js/cm-fix/regression.mjs +16 -7
- package/runtime/js/cm-fix/repair.mjs +29 -8
- package/runtime/js/cm-fix/review-verification-command.mjs +135 -0
- package/runtime/js/cm-fix/review-verification-contract.mjs +54 -0
- package/runtime/js/cm-fix/review-verification-diagnostic.mjs +75 -0
- package/runtime/js/cm-fix/review-verification-recovery.mjs +44 -0
- package/runtime/js/cm-fix/review-verification-server.mjs +38 -0
- package/runtime/js/cm-fix/review-verification.mjs +214 -0
- package/runtime/js/cm-fix/source-correction-recovery.mjs +65 -0
- package/runtime/js/cm-fix/start.mjs +6 -3
- package/runtime/js/cm-fix/test-type-correction.mjs +86 -0
- package/runtime/js/cm-fix/test-type-recovery.mjs +51 -0
- package/runtime/js/cm-fix/type-import-correction.mjs +89 -0
- package/runtime/js/cm-prd/accepted-design.mjs +8 -0
- package/runtime/js/cm-prd/analysis.mjs +13 -9
- package/runtime/js/cm-prd/change.mjs +37 -16
- package/runtime/js/cm-prd/draft-save.mjs +13 -6
- package/runtime/js/cm-prd/draft.mjs +31 -3
- package/runtime/js/cm-prd/failed-correction.mjs +19 -3
- package/runtime/js/cm-prd/inputs-replaced.mjs +3 -0
- package/runtime/js/cm-prd/review-correction.mjs +6 -4
- package/runtime/js/cm-prd/review-disposition.mjs +7 -1
- package/runtime/js/cm-prd/self-check-revision.mjs +2 -2
- package/runtime/js/cm-prd/self-check.mjs +125 -6
- package/runtime/js/cm-prd/session.mjs +30 -1
- package/runtime/js/cm-prd/summary.mjs +38 -17
- package/runtime/js/cm-prd/task-scope-record.mjs +97 -0
- package/runtime/js/cm-prd/tree-digest.mjs +34 -0
- package/runtime/js/cm-prd/validation-reason.mjs +8 -4
- package/runtime/js/cm-security/scan.mjs +1 -1
- package/runtime/js/commander/decision.mjs +44 -0
- package/runtime/js/commander/dispatch-registry.mjs +110 -0
- package/runtime/js/commander/ledger.mjs +265 -0
- package/runtime/js/commander/preflight.mjs +107 -0
- package/runtime/js/notify-later.mjs +13 -0
- package/runtime/js/notify-send.mjs +6 -2
- package/runtime/js/notify.mjs +570 -63
- package/runtime/js/review-findings.mjs +38 -0
- package/runtime/js/session-boundary.mjs +56 -0
- package/runtime/js/session-handoff.mjs +68 -0
- package/runtime/js/spec-task-line.mjs +27 -13
- package/runtime/js/specs-status.mjs +1 -1
- package/runtime/js/task-scope.mjs +197 -0
- package/runtime/logging.md +6 -1
- package/runtime/model-efficiency.md +69 -10
- package/runtime/orchestration.md +3 -1
- package/runtime/project-learning.md +2 -0
- package/runtime/review.md +12 -2
- package/runtime/test-contract.md +1 -0
- package/scripts/ci-test-weights.json +3 -0
- package/scripts/cm-ai-admission.mjs +11 -5
- package/scripts/cm-ai-admission.test.mjs +23 -2
- package/scripts/cm-ai-batch-drive.mjs +79 -18
- package/scripts/cm-ai-batch-drive.test.mjs +169 -3
- package/scripts/cm-ai-batch-host.mjs +38 -9
- package/scripts/cm-ai-batch-host.test.mjs +27 -14
- package/scripts/cm-ai-batch-learning-merge.test.mjs +36 -0
- package/scripts/cm-ai-batch-location.test.mjs +57 -0
- package/scripts/cm-ai-batch-plan.mjs +52 -0
- package/scripts/cm-ai-batch-plan.test.mjs +397 -0
- package/scripts/cm-ai-batch-run-fixture.mjs +446 -35
- package/scripts/cm-ai-batch-run-member-stops.test.mjs +16 -0
- package/scripts/cm-ai-batch-run-parallel.test.mjs +28 -1
- package/scripts/cm-ai-batch-run.mjs +483 -63
- package/scripts/cm-ai-batch-run.test.mjs +23 -4
- package/scripts/cm-ai-batch-session-e2e.test.mjs +235 -0
- package/scripts/cm-ai-batch-session-member.test.mjs +293 -0
- package/scripts/cm-ai-batch-session-recovery.test.mjs +423 -0
- package/scripts/cm-ai-check-recheck-cancellation.test.mjs +247 -0
- package/scripts/cm-ai-checklist-coverage.test.mjs +4 -2
- package/scripts/cm-ai-checkpoint-package-material.test.mjs +221 -0
- package/scripts/cm-ai-checkpoint-package-owner.test.mjs +193 -0
- package/scripts/cm-ai-control-launch.test.mjs +21 -0
- package/scripts/cm-ai-control-policy.test.mjs +82 -0
- package/scripts/cm-ai-control-v2-drive.test.mjs +398 -3
- package/scripts/cm-ai-control-v2-supersede-race.mjs +25 -0
- package/scripts/cm-ai-control-v2-supersede.test.mjs +318 -0
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +163 -0
- package/scripts/cm-ai-development-rework.test.mjs +423 -0
- package/scripts/cm-ai-drive-bootstrap-rules.test.mjs +3 -2
- package/scripts/cm-ai-drive.mjs +73 -17
- package/scripts/cm-ai-drive.test.mjs +37 -5
- package/scripts/cm-ai-execution-store-legacy-probe.test.mjs +84 -0
- package/scripts/cm-ai-host-fixture.mjs +9 -6
- package/scripts/cm-ai-host-protected.test.mjs +1 -1
- package/scripts/cm-ai-host.mjs +60 -19
- package/scripts/cm-ai-host.test.mjs +15 -0
- package/scripts/cm-ai-integration-adoption.test.mjs +223 -0
- package/scripts/cm-ai-integration-independence.test.mjs +23 -0
- package/scripts/cm-ai-integration-launch.test.mjs +240 -0
- package/scripts/cm-ai-integration-preview.mjs +41 -0
- package/scripts/cm-ai-integration-snapshots.test.mjs +197 -0
- package/scripts/cm-ai-nested-execution.test.mjs +29 -1
- package/scripts/cm-ai-operator-guidance.test.mjs +71 -0
- package/scripts/cm-ai-prefinal-delivery.test.mjs +278 -0
- package/scripts/cm-ai-project-qa-gate.test.mjs +56 -0
- package/scripts/cm-ai-qa-fingerprint-config.test.mjs +28 -0
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +36 -2
- package/scripts/cm-ai-requirement-evidence.test.mjs +65 -0
- package/scripts/cm-ai-review-failure.test.mjs +150 -5
- package/scripts/cm-ai-review-timeout.test.mjs +20 -0
- package/scripts/cm-ai-run.mjs +88 -21
- package/scripts/cm-ai-scope-revision.test.mjs +341 -0
- package/scripts/cm-ai-spec-rebind.test.mjs +13 -0
- package/scripts/cm-ai-supersede.test.mjs +28 -0
- package/scripts/cm-ai-verification-auto.test.mjs +99 -0
- package/scripts/cm-announce-hook.mjs +35 -8
- package/scripts/cm-announce-hook.test.mjs +25 -0
- package/scripts/cm-challenge.test.mjs +61 -0
- package/scripts/cm-check-drive-files.mjs +2 -2
- package/scripts/cm-check-host.test.mjs +1 -1
- package/scripts/cm-check-runtime.sh +58 -1
- package/scripts/cm-claude-developer-worker.test.mjs +56 -7
- package/scripts/cm-claude-install-layout.test.mjs +1 -1
- package/scripts/cm-claude-probe.test.mjs +26 -0
- package/scripts/cm-claude-review-diagnostics.test.mjs +235 -0
- package/scripts/cm-claude-review-stream.test.mjs +49 -0
- package/scripts/cm-claude-worker.test.mjs +16 -0
- package/scripts/cm-codex-developer-reconnect-notice.test.mjs +98 -0
- package/scripts/cm-codex-developer-worker.test.mjs +120 -0
- package/scripts/cm-codex-install-local-edit-guard.test.mjs +436 -0
- package/scripts/cm-codex-prompt-input.test.mjs +153 -0
- package/scripts/cm-codex-reconnect-notice.test.mjs +167 -0
- package/scripts/cm-commander-ledger.test.mjs +260 -0
- package/scripts/cm-commander-p2.test.mjs +295 -0
- package/scripts/cm-commander-preflight.mjs +84 -0
- package/scripts/cm-commander.mjs +116 -0
- package/scripts/cm-config-lock.mjs +35 -0
- package/scripts/cm-controlled-correction.test.mjs +10 -1
- package/scripts/cm-developer-failure-code.test.mjs +62 -0
- package/scripts/cm-display-task-id.test.mjs +41 -0
- package/scripts/cm-drive-liveness.test.mjs +83 -0
- package/scripts/cm-efficiency-presentation-delta.test.mjs +218 -0
- package/scripts/cm-execution-snapshot-reuse.test.mjs +115 -0
- package/scripts/cm-external-batch-host.test.mjs +12 -9
- package/scripts/cm-external-process-cleanup.test.mjs +128 -0
- package/scripts/cm-external-qa-fix.test.mjs +89 -7
- package/scripts/cm-external-review-reconciliation.test.mjs +11 -0
- package/scripts/cm-failover.mjs +48 -10
- package/scripts/cm-failover.test.mjs +46 -0
- package/scripts/cm-fix-cause-invocation.test.mjs +19 -4
- package/scripts/cm-fix-command-correction.mjs +17 -0
- package/scripts/cm-fix-command-correction.test.mjs +211 -0
- package/scripts/cm-fix-cooperative-closeout.test.mjs +87 -0
- package/scripts/cm-fix-diagnosis-module-correction.test.mjs +217 -0
- package/scripts/cm-fix-drive.mjs +33 -5
- package/scripts/cm-fix-drive.test.mjs +49 -0
- package/scripts/cm-fix-host-review-assembly.test.mjs +197 -1
- package/scripts/cm-fix-host-review.test.mjs +21 -9
- package/scripts/cm-fix-host.mjs +26 -8
- package/scripts/cm-fix-monorepo-map.test.mjs +92 -0
- package/scripts/cm-fix-observation-task-id.test.mjs +122 -0
- package/scripts/cm-fix-regression-input-budget.test.mjs +111 -0
- package/scripts/cm-fix-repair-input-budget.test.mjs +119 -0
- package/scripts/cm-fix-review-file-paging.test.mjs +91 -0
- package/scripts/cm-fix-review-preflight.mjs +24 -0
- package/scripts/cm-fix-review-storage.test.mjs +233 -0
- package/scripts/cm-fix-review-verification-command.test.mjs +242 -0
- package/scripts/cm-fix-review-verification-evidence.test.mjs +218 -0
- package/scripts/cm-fix-review-verification-integration.test.mjs +81 -0
- package/scripts/cm-fix-review-verification-recovery.test.mjs +198 -0
- package/scripts/cm-fix-review-verification.test.mjs +146 -0
- package/scripts/cm-fix-revision-transport.test.mjs +81 -0
- package/scripts/cm-fix-source-correction.test.mjs +296 -0
- package/scripts/cm-fix-test-type-correction.mjs +18 -0
- package/scripts/cm-fix-test-type-correction.test.mjs +123 -0
- package/scripts/cm-fix-test-type-owner.test.mjs +208 -0
- package/scripts/cm-fix-test-type-verification-cost.test.mjs +66 -0
- package/scripts/cm-fix-type-import-correction.test.mjs +95 -0
- package/scripts/cm-fix-verification-diagnostic.test.mjs +200 -0
- package/scripts/cm-fix-verification-recovery.mjs +33 -0
- package/scripts/cm-host-diagnostic.test.mjs +33 -0
- package/scripts/cm-host-liveness.test.mjs +150 -0
- package/scripts/cm-host-qa-executor.test.mjs +77 -0
- package/scripts/cm-host-replay.test.mjs +176 -0
- package/scripts/cm-host-stage-observer.test.mjs +41 -0
- package/scripts/cm-install-local-edit-guard.test.mjs +621 -0
- package/scripts/cm-install-manifest.sh +351 -0
- package/scripts/cm-live-evidence.test.mjs +59 -1
- package/scripts/cm-log-event.mjs +61 -10
- package/scripts/cm-log-event.test.mjs +121 -1
- package/scripts/cm-matt-skills.mjs +576 -0
- package/scripts/cm-matt-skills.test.mjs +550 -0
- package/scripts/cm-notify-command.test.mjs +42 -10
- package/scripts/cm-notify.mjs +14 -10
- package/scripts/cm-notify.test.mjs +625 -75
- package/scripts/cm-patrol.mjs +4 -1
- package/scripts/cm-patrol.test.mjs +23 -5
- package/scripts/cm-prd-answer-gaps.test.mjs +2 -2
- package/scripts/cm-prd-completion.test.mjs +56 -13
- package/scripts/cm-prd-design-phase.test.mjs +78 -8
- package/scripts/cm-prd-draft-save.test.mjs +12 -0
- package/scripts/cm-prd-draft.test.mjs +1 -1
- package/scripts/cm-prd-drive.mjs +13 -6
- package/scripts/cm-prd-drive.test.mjs +46 -2
- package/scripts/cm-prd-gate-diagnostic.test.mjs +2 -2
- package/scripts/cm-prd-host.mjs +10 -5
- package/scripts/cm-prd-host.test.mjs +4 -2
- package/scripts/cm-prd-inputs-replaced.test.mjs +1 -1
- package/scripts/cm-prd-review-disposition.test.mjs +124 -8
- package/scripts/cm-prd-revision.test.mjs +1 -1
- package/scripts/cm-prd-self-check-revision.test.mjs +16 -1
- package/scripts/cm-prd-self-check-rules.test.mjs +239 -0
- package/scripts/cm-prd-self-check.test.mjs +105 -5
- package/scripts/cm-prd-session-recovery.test.mjs +5 -3
- package/scripts/cm-prd-summary.test.mjs +55 -3
- package/scripts/cm-prd-task-grouping.test.mjs +6 -6
- package/scripts/cm-prd-tree-digest.test.mjs +74 -0
- package/scripts/cm-refactor-drive.mjs +2 -1
- package/scripts/cm-refactor-drive.test.mjs +9 -0
- package/scripts/cm-release-smoke.sh +3 -15
- package/scripts/cm-skill-hints-autowire.test.mjs +394 -0
- package/scripts/cm-skill-hints-exam.mjs +149 -0
- package/scripts/cm-skill-hints-install.test.mjs +168 -0
- package/scripts/cm-skill-hints.exam.json +706 -0
- package/scripts/cm-skill-hints.json +119 -0
- package/scripts/cm-skill-hints.mjs +669 -0
- package/scripts/cm-skill-hints.test.mjs +831 -0
- package/scripts/cm-skill-judge.mjs +181 -0
- package/scripts/cm-skill-judge.test.mjs +255 -0
- package/scripts/cm-specs-status.test.mjs +4 -2
- package/scripts/cm-start-check.mjs +208 -0
- package/scripts/cm-start-check.test.mjs +321 -0
- package/scripts/cm-task-gate.mjs +150 -29
- package/scripts/cm-task-gate.test.mjs +73 -1
- package/scripts/cm-task-id-grammar.test.mjs +66 -0
- package/scripts/cm-task-scope.test.mjs +308 -0
- package/scripts/cm-test-suite.mjs +109 -0
- package/scripts/cm-test-suite.test.mjs +162 -0
- package/scripts/cm-upgrade-compat-batch.test.mjs +172 -0
- package/scripts/cm-upgrade-compat.test.mjs +239 -0
- package/scripts/cm-workflow-config.mjs +12 -2
- package/scripts/fixtures/fix-verification-claude.mjs +44 -0
- package/scripts/fixtures/host-diagnostic.mjs +33 -0
- package/scripts/fixtures/reviewed-integration.mjs +202 -0
- package/scripts/scan-public-safety.py +1 -0
- package/scripts/session-boundary.test.mjs +170 -0
- package/scripts/test-npm-install.py +14 -3
- package/scripts/test-shell-compat.sh +2 -0
- package/scripts/validate-public-repo.py +1 -0
- package/scripts/validate-test-cases.mjs +3 -2
- package/skills/cm-ai/SKILL.md +5 -2
- package/skills/cm-ai/references/N4-review.md +2 -1
- package/skills/cm-ai/references/N6-qa-eval.md +3 -1
- package/skills/cm-ai/references/N8-finish.md +22 -0
- package/skills/cm-ai/references/js-host-qa-recovery.md +1 -1
- package/skills/cm-ai/references/js-host-recovery.md +79 -3
- package/skills/cm-ai/references/js-host.md +89 -17
- package/skills/cm-challenge/SKILL.md +65 -0
- package/skills/cm-challenge/evals/README.md +18 -0
- package/skills/cm-challenge/evals/trigger-cases.json +20 -0
- package/skills/cm-challenge/evals/trigger-config.json +28 -0
- package/skills/cm-challenge/references/examples.md +15 -0
- package/skills/cm-check/SKILL.md +5 -0
- package/skills/cm-check/references/js-host.md +2 -0
- package/skills/cm-fix/SKILL.md +12 -3
- package/skills/cm-fix/references/command-correction.md +67 -0
- package/skills/cm-fix/references/isolated-review.md +54 -0
- package/skills/cm-fix/references/js-host.md +62 -2
- package/skills/cm-fix/references/test-type-correction.md +72 -0
- package/skills/cm-fix/references/verification-recovery.md +114 -0
- package/skills/cm-idea/SKILL.md +2 -0
- package/skills/cm-idea/references/js-host.md +2 -0
- package/skills/cm-notify/SKILL.md +2 -0
- package/skills/cm-prd/SKILL.md +12 -8
- package/skills/cm-prd/references/brownfield.md +8 -1
- package/skills/cm-prd/references/change-mode.md +6 -0
- package/skills/cm-prd/references/greenfield.md +4 -0
- package/skills/cm-prd/references/js-host.md +4 -2
- package/skills/cm-prd/references/spec-self-check.md +5 -1
- package/skills/cm-refactor/SKILL.md +8 -0
- package/skills/cm-refactor/references/js-host.md +2 -0
- package/skills/cm-test/SKILL.md +4 -0
- package/templates/dashboard/dashboard.html +2 -2
- package/templates/pixel/cm-pixel.html +1 -1
- package/templates/pixel/cm-pixel.sh +1 -1
- package/templates/pixel/dev/template.html +1 -1
- package/templates/statusline/cm-statusline.sh +1 -1
|
@@ -112,7 +112,7 @@ function logStep(configuration,binding,event,phase,data,detail) {
|
|
|
112
112
|
// empty). A FAIL, a BLOCKED, another environment or a failed cleanup is never
|
|
113
113
|
// asked again: those stay as judged, and only an explicit recovery reruns them.
|
|
114
114
|
const CORRECTION_INSTRUCTION='Only the evidence list of the previous PASS answer can be corrected. Evidence must be non-empty '
|
|
115
|
-
+'files inside the .reviews directory of the specs root (for example
|
|
115
|
+
+'files inside the .reviews directory of the specs root (for example the evidenceDirectory of this request, created if missing); copy the files you observed '
|
|
116
116
|
+'there and answer again. Keep the verdict, environment and cleanup you actually observed; if you no longer stand by the '
|
|
117
117
|
+'PASS, answer FAIL or BLOCKED.';
|
|
118
118
|
// Every other condition of the verdict must already hold, so the correction can
|
|
@@ -129,6 +129,22 @@ function answerProblems(configuration,observed,environment,item){
|
|
|
129
129
|
return problems;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
// A QA command that declares reuseCheck takes the result of that task check
|
|
133
|
+
// instead of running again, only when the check ran the identical command on
|
|
134
|
+
// this reviewed package and passed. The entry hands over the package's checks
|
|
135
|
+
// after proving the code root still matches that package (runner
|
|
136
|
+
// qaCompletionChecks); anything else runs the command as before and says why.
|
|
137
|
+
function reusedTaskCheck(command,checks,packageDigest){
|
|
138
|
+
if(!Object.hasOwn(command,'reuseCheck'))return {};
|
|
139
|
+
if(checks===null)return {unavailable:'no_verified_task_checks'};
|
|
140
|
+
const check=checks.find(item=>item?.id===command.reuseCheck);
|
|
141
|
+
if(!check)return {unavailable:'check_not_in_package'};
|
|
142
|
+
if(JSON.stringify(check.command)!==JSON.stringify(command.command))return {unavailable:'command_differs'};
|
|
143
|
+
if(check.outcome!=='passed'||check.exitCode!==0)return {unavailable:'check_not_passed'};
|
|
144
|
+
const evidence=`reused task check ${check.id} of reviewed package ${packageDigest.slice(0,12)}: ${String(check.evidence??'')}`.slice(0,500);
|
|
145
|
+
return {observed:{outcome:'passed',exitCode:0,evidence}};
|
|
146
|
+
}
|
|
147
|
+
|
|
132
148
|
function evidence(raw) {
|
|
133
149
|
const result=json(raw);need(Array.isArray(result)&&result.length>0&&result.length<=32,'qa_evidence_required');
|
|
134
150
|
for(const item of result){text(item);need(item.length<=2000&&!item.includes('\0'),'qa_evidence_required');}
|
|
@@ -178,8 +194,11 @@ export function createHostQaExecutor(options) {
|
|
|
178
194
|
need(['codex','claude'].includes(configuration.runtime));validCallTimeout(configuration.timeoutMs);
|
|
179
195
|
const ids=new Set();need(Array.isArray(configuration.commands)&&configuration.commands.length<=32);
|
|
180
196
|
for(const item of configuration.commands){
|
|
181
|
-
shape(item,['id','command','caseIds',...(roots?['codeProject']:[])
|
|
197
|
+
shape(item,['id','command','caseIds',...(roots?['codeProject']:[]),...(Object.hasOwn(item,'reuseCheck')?['reuseCheck']:[])]);
|
|
198
|
+
id(item.id);need(!ids.has(item.id));ids.add(item.id);
|
|
182
199
|
if(roots)need(roots.includes(item.codeProject),'execution_root_mismatch');
|
|
200
|
+
// Opt-in: name the task check with the same command; see reusedTaskCheck below.
|
|
201
|
+
if(Object.hasOwn(item,'reuseCheck')){id(item.reuseCheck);need(!roots,'qa_check_reuse_invalid');}
|
|
183
202
|
need(Array.isArray(item.caseIds)&&new Set(item.caseIds).size===item.caseIds.length);
|
|
184
203
|
for(const caseId of item.caseIds)id(caseId);
|
|
185
204
|
// Reuse the actual host checker validator, without running a command.
|
|
@@ -205,9 +224,10 @@ export function createHostQaExecutor(options) {
|
|
|
205
224
|
return Object.freeze({...initial,timeoutMs:configuration.timeoutMs,prepare,
|
|
206
225
|
async run(rawBinding,signal){
|
|
207
226
|
const {mode,caseCount,configuration:{plan}}=prepared??prepare();
|
|
208
|
-
let binding=json(rawBinding);
|
|
227
|
+
let {completionChecks=null,...binding}=json(rawBinding);
|
|
209
228
|
shape(binding,['specsDir','codeProject','feature','identity','packageDigest','testRunId','mode','caseCount',
|
|
210
229
|
...(Object.hasOwn(binding,'qaRound')?['qaRound']:[])]);
|
|
230
|
+
need(completionChecks===null||Array.isArray(completionChecks)&&completionChecks.length<=32,'qa_check_reuse_invalid');
|
|
211
231
|
validIdentity(binding.identity);hex(binding.packageDigest);id(binding.testRunId);
|
|
212
232
|
const qaRound=readCmAiQaRunRound({specsDir:binding.specsDir,feature:binding.feature,
|
|
213
233
|
identity:binding.identity,packageDigest:binding.packageDigest,testRunId:binding.testRunId});
|
|
@@ -243,6 +263,13 @@ export function createHostQaExecutor(options) {
|
|
|
243
263
|
else if(!plan.commands.length)rows.push({id:'commands-unavailable',kind:'commands',verdict:'BLOCKED',evidence:['No declared project test command',...dropped]});
|
|
244
264
|
for(const command of plan.commands){
|
|
245
265
|
notCancelled();
|
|
266
|
+
const reuse=reusedTaskCheck(command,completionChecks,binding.packageDigest);
|
|
267
|
+
if(reuse.observed){
|
|
268
|
+
commandResults.set(command.id,reuse.observed);
|
|
269
|
+
rows.push({id:command.id,kind:'commands',verdict:'PASS',exitCode:reuse.observed.exitCode,
|
|
270
|
+
evidence:[reuse.observed.evidence],reusedCheck:command.reuseCheck});
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
246
273
|
// Q13: the command's process group identity, so a cleanup_failed row can
|
|
247
274
|
// later be released once the host proves that group gone.
|
|
248
275
|
let spawned=null;
|
|
@@ -265,11 +292,17 @@ export function createHostQaExecutor(options) {
|
|
|
265
292
|
notCancelled();
|
|
266
293
|
commandResults.set(command.id,observed);
|
|
267
294
|
rows.push({id:command.id,kind:'commands',verdict:observed.outcome==='passed'?'PASS':observed.outcome==='failed'?'FAIL':'BLOCKED',
|
|
268
|
-
exitCode:observed.exitCode,evidence:[...(roots?[`cwd=${command.codeProject}`]:[]),observed.evidence]
|
|
295
|
+
exitCode:observed.exitCode,evidence:[...(roots?[`cwd=${command.codeProject}`]:[]),observed.evidence],
|
|
296
|
+
...(reuse.unavailable?{reuseUnavailable:reuse.unavailable}:{})});
|
|
269
297
|
}
|
|
270
298
|
}else for(const item of plan.cases.filter(candidate=>candidate.kind===stage)){
|
|
271
299
|
notCancelled();
|
|
272
|
-
|
|
300
|
+
// A browser case is told where inside {specs}/.reviews to put its evidence
|
|
301
|
+
// files, the only place an answer's evidence is accepted from. Only a path:
|
|
302
|
+
// the host creates nothing there, and reportFile still judges every file.
|
|
303
|
+
const evidenceDirectory=stage==='browser'?path.join(configuration.specsDir,'.reviews','qa-evidence',binding.testRunId,item.id):null;
|
|
304
|
+
const request=freeze({...binding,case:item,route:routed,environment,...(roots?{codeProjects:roots}:{}),
|
|
305
|
+
...(evidenceDirectory?{evidenceDirectory}:{})});
|
|
273
306
|
if(stage==='logic'){
|
|
274
307
|
let observed,hostRequestTimeout=false;
|
|
275
308
|
try{observed=logic===null?{verdict:'INSUFFICIENT_EVIDENCE',evidence:['Logic host unavailable']}:json(await logic(request,signal));}
|
|
@@ -46,7 +46,7 @@ export function createQaFixOwnerHost({parent,reopenParent,hostContextId,parentHo
|
|
|
46
46
|
if(fixedTemplate)fixedTemplate=inherited;else definition=inherited;
|
|
47
47
|
}
|
|
48
48
|
if(externalModels){
|
|
49
|
-
const target=fixedTemplate??definition,runtime=target.configuration.runtime??'codex';
|
|
49
|
+
const target=fixedTemplate??definition,runtime=target.configuration.reviewRuntime??target.configuration.runtime??'codex';
|
|
50
50
|
const selected=selectExternalModels(externalModels,[runtime]);
|
|
51
51
|
if(!fixedTemplate&&!target.configuration.externalModels)need(false,'external_model_legacy_child_inheritance_forbidden');
|
|
52
52
|
if(target.configuration.externalModels)need(digest(target.configuration.externalModels)===digest(selected),'external_model_pair_conflict');
|
|
@@ -121,7 +121,7 @@ export function createQaFixOwnerHost({parent,reopenParent,hostContextId,parentHo
|
|
|
121
121
|
let actionResult;
|
|
122
122
|
if(advancing||acting){
|
|
123
123
|
const host=createFixHost({owner:child,config:{...definition.configuration,specsRoot:definition.specsRoot,identity:definition.identity},
|
|
124
|
-
runtime:definition.configuration.runtime??'codex',permissions:[...permissions,'--allow-reproduction'],...fixAuthorities,recoveryInvocationId});
|
|
124
|
+
runtime:definition.configuration.runtime??'codex',reviewRuntime:definition.configuration.reviewRuntime,permissions:[...permissions,'--allow-reproduction'],...fixAuthorities,recoveryInvocationId});
|
|
125
125
|
const action=advancing?{operation:'advance'}:{operation:value.fixOperation,
|
|
126
126
|
...(value.fixOperation==='reconcile_review'?{invocationId:value.invocationId}:{}),
|
|
127
127
|
...(QA_FIX_REASONED.includes(value.fixOperation)?{reason:value.reason}:{}),
|
|
@@ -7,7 +7,9 @@ import {digest,freeze,hex,id,json,need,shape,validIdentity} from './effect-contr
|
|
|
7
7
|
|
|
8
8
|
const key=(feature,task)=>`${feature}/${task}`;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
// unseen: completed tasks with no QA row at all; a triggered QA never clears them.
|
|
11
|
+
// since: tasks whose QA was not triggered after the last triggered one.
|
|
12
|
+
function unassessedParts(binding,context) {
|
|
11
13
|
const completed=new Set(context.completed.map(task=>key(task.feature,task.id)));
|
|
12
14
|
const pendingFeatures=new Set(context.pendingFeatures);
|
|
13
15
|
const unseen=new Set(context.completed.filter(task=>pendingFeatures.has(task.feature))
|
|
@@ -22,10 +24,25 @@ function history(binding,context) {
|
|
|
22
24
|
const task=key(row.feature,row.task);unseen.delete(task);
|
|
23
25
|
if(row.status==='triggered')since.clear();else since.add(task);
|
|
24
26
|
});
|
|
27
|
+
return {unseen,since};
|
|
28
|
+
}
|
|
29
|
+
function unassessed(binding,context) {
|
|
30
|
+
const {unseen,since}=unassessedParts(binding,context);
|
|
31
|
+
return new Set([...unseen,...since]);
|
|
32
|
+
}
|
|
33
|
+
function history(binding,context) {
|
|
25
34
|
// Missing historical QA rows are unknown coverage, never evidence of a reset.
|
|
26
35
|
// This callback only proposes a fresh decision. An older run/package for the
|
|
27
36
|
// same task cannot cover the current work; exact recovery happens in entry.
|
|
28
|
-
return new Set([...
|
|
37
|
+
return new Set([...unassessed(binding,context),key(binding.feature,binding.identity.taskId)]).size;
|
|
38
|
+
}
|
|
39
|
+
// Completed tasks counted toward five_tasks_without_qa right now (count), by the same
|
|
40
|
+
// log reading the decision uses, and how many of them a triggered QA leaves counted
|
|
41
|
+
// (floor). batch-plan.mjs predicts one-member groups from both.
|
|
42
|
+
export function qaUnassessedTaskCounts({specsDir,codeProject,feature,repositoryId}){
|
|
43
|
+
const context=inspectCmAiQaTaskContext({specsDir,codeProject,feature});
|
|
44
|
+
const {unseen,since}=unassessedParts({specsDir,feature,identity:{repositoryId}},context);
|
|
45
|
+
return {count:new Set([...unseen,...since]).size,floor:unseen.size};
|
|
29
46
|
}
|
|
30
47
|
|
|
31
48
|
const categories=['migration','authentication','authorization','payment','api'];
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// Host-run facts for a delivered task. The task's own check commands run in a
|
|
2
|
+
// private copy of the project at two extra points: as it was before development
|
|
3
|
+
// (baseline) and with only the declared test files delivered (red). The fully
|
|
4
|
+
// delivered run is the task's own checks, already run in the real project.
|
|
5
|
+
// Facts only: the host never blocks on them. The verification gate and the
|
|
6
|
+
// reviewer judge them; the real project is never written here.
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import os from 'node:os';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import {createHostCheck} from './host-check.mjs';
|
|
11
|
+
import {need,json,validIdentity} from './effect-contract.mjs';
|
|
12
|
+
|
|
13
|
+
const FILE_LIMIT=1024*1024,ENTRY_LIMIT=200000,EVIDENCE_LIMIT=1500;
|
|
14
|
+
export const HOST_REPLAY_EVIDENCE_PREFIX='cm-host-replay-v1: ';
|
|
15
|
+
|
|
16
|
+
// Scope file state before development: {bytes,mode}, or null for a file that does
|
|
17
|
+
// not exist yet. Anything else (a link, a directory, an oversized file) makes the
|
|
18
|
+
// snapshot unavailable, never a partial one.
|
|
19
|
+
export function captureBeforeSnapshot(codeProject,scope){
|
|
20
|
+
const files=new Map();
|
|
21
|
+
for(const file of scope){
|
|
22
|
+
const target=path.join(codeProject,file);let stat;
|
|
23
|
+
try{stat=fs.lstatSync(target);}catch(error){if(error.code==='ENOENT'){files.set(file,null);continue;}return {unavailable:'snapshot_unreadable'};}
|
|
24
|
+
if(!stat.isFile()||stat.size>FILE_LIMIT)return {unavailable:'snapshot_unsupported_file'};
|
|
25
|
+
files.set(file,{bytes:fs.readFileSync(target),mode:stat.mode&0o777});
|
|
26
|
+
}
|
|
27
|
+
return {files};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const summarize=rows=>{
|
|
31
|
+
const failed=rows.find(row=>row.outcome!=='passed');
|
|
32
|
+
const evidence=rows.map(row=>`${row.id}: ${row.evidence}`).join('; ');
|
|
33
|
+
return {outcome:failed?failed.outcome:rows.length?'passed':'unavailable',evidence:Buffer.byteLength(evidence)>EVIDENCE_LIMIT
|
|
34
|
+
?Buffer.from(evidence).subarray(0,EVIDENCE_LIMIT).toString('utf8').replace(/�$/,'')+'…':evidence};
|
|
35
|
+
};
|
|
36
|
+
const replayError=code=>Object.assign(new Error(code),{code});
|
|
37
|
+
|
|
38
|
+
// A path inside the project that the copy holds (not .git, not nested specs).
|
|
39
|
+
const copied=(codeProject,specsDir,target)=>{
|
|
40
|
+
const inside=dir=>target===dir||target.startsWith(dir+path.sep);
|
|
41
|
+
return inside(codeProject)&&!inside(specsDir)&&!inside(path.join(codeProject,'.git'));
|
|
42
|
+
};
|
|
43
|
+
const realOrNull=target=>{try{return fs.realpathSync(target);}catch{return null;}};
|
|
44
|
+
// A fresh private copy for each run, so no run inherits another's writes. The
|
|
45
|
+
// directory is owned here until it is returned, so a failed copy is removed too.
|
|
46
|
+
// Links are copied verbatim and never rewritten. A link whose final target (the
|
|
47
|
+
// whole chain, resolved) lies in the copied part of the project must resolve to
|
|
48
|
+
// the same place in the copy; otherwise a check could read the real project, and
|
|
49
|
+
// the run is not replayed (replay_internal_link).
|
|
50
|
+
function copyProject(codeProject,specsDir){
|
|
51
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-host-replay-')));
|
|
52
|
+
try{
|
|
53
|
+
const target=path.join(root,'project');let entries=0;const links=[];
|
|
54
|
+
const skip=new Set([path.join(codeProject,'.git'),specsDir]);
|
|
55
|
+
// Copy-on-write clones where the file system has them (APFS, btrfs); a plain copy otherwise.
|
|
56
|
+
fs.cpSync(codeProject,target,{recursive:true,mode:fs.constants.COPYFILE_FICLONE,verbatimSymlinks:true,filter:source=>{
|
|
57
|
+
if(skip.has(source))return false;
|
|
58
|
+
if(++entries>ENTRY_LIMIT)throw replayError('replay_project_too_large');
|
|
59
|
+
if(fs.lstatSync(source).isSymbolicLink())links.push(path.relative(codeProject,source));
|
|
60
|
+
return true;
|
|
61
|
+
}});
|
|
62
|
+
const project=fs.realpathSync(target);
|
|
63
|
+
for(const link of links){
|
|
64
|
+
const real=realOrNull(path.join(codeProject,link));
|
|
65
|
+
if(real===null||!copied(codeProject,specsDir,real))continue;
|
|
66
|
+
if(realOrNull(path.join(project,link))!==path.join(project,path.relative(codeProject,real)))throw replayError('replay_internal_link');
|
|
67
|
+
}
|
|
68
|
+
return {root,project};
|
|
69
|
+
}catch(error){removeCopy(root);throw error;}
|
|
70
|
+
}
|
|
71
|
+
function removeCopy(root){
|
|
72
|
+
try{fs.rmSync(root,{recursive:true,force:true});}
|
|
73
|
+
catch{try{process.stderr.write(JSON.stringify({diagnostic:'host_replay_cleanup_failed',path:root})+'\n');}catch{}}
|
|
74
|
+
}
|
|
75
|
+
// Writes only through real directories inside the copy: every ancestor and the
|
|
76
|
+
// target itself are checked without following links, before any byte is written.
|
|
77
|
+
function place(project,file,state){
|
|
78
|
+
let current=project;
|
|
79
|
+
for(const part of file.split('/').slice(0,-1)){
|
|
80
|
+
current=path.join(current,part);let stat;
|
|
81
|
+
try{stat=fs.lstatSync(current);}catch(error){if(error.code!=='ENOENT')throw error;fs.mkdirSync(current);continue;}
|
|
82
|
+
if(!stat.isDirectory()||stat.isSymbolicLink())throw replayError('replay_scope_link');
|
|
83
|
+
}
|
|
84
|
+
const target=path.join(project,file);
|
|
85
|
+
let existing=null;
|
|
86
|
+
try{existing=fs.lstatSync(target);}catch(error){if(error.code!=='ENOENT')throw error;}
|
|
87
|
+
if(existing!==null){if(!existing.isFile())throw replayError('replay_scope_link');fs.unlinkSync(target);}
|
|
88
|
+
if(state===null)return;
|
|
89
|
+
const fd=fs.openSync(target,fs.constants.O_WRONLY|fs.constants.O_CREAT|fs.constants.O_EXCL|fs.constants.O_NOFOLLOW,state.mode);
|
|
90
|
+
try{fs.writeFileSync(fd,state.bytes);fs.fchmodSync(fd,state.mode);}finally{fs.closeSync(fd);}
|
|
91
|
+
}
|
|
92
|
+
const currentState=(codeProject,file)=>{
|
|
93
|
+
const target=path.join(codeProject,file);let stat;
|
|
94
|
+
try{stat=fs.lstatSync(target);}catch(error){if(error.code==='ENOENT')return null;throw error;}
|
|
95
|
+
if(!stat.isFile()||stat.size>FILE_LIMIT)throw replayError('replay_scope_link');
|
|
96
|
+
return {bytes:fs.readFileSync(target),mode:stat.mode&0o777};
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// {version,status:'replayed',baseline,red,green} or {version,status:'not_replayed',reason,green}.
|
|
100
|
+
// red is {skipped:'no_test_files'} when tasks.md declares no test files.
|
|
101
|
+
export async function replayDelivery({codeProject,specsDir,snapshot,scope,tests,checkCommands,timeoutMs,identity,greenChecks,signal,makeCheck=createHostCheck}){
|
|
102
|
+
const green=summarize(json(greenChecks));
|
|
103
|
+
const skipped=reason=>notReplayed(reason,greenChecks);
|
|
104
|
+
if(!snapshot)return skipped('no_before_snapshot');
|
|
105
|
+
if(snapshot.unavailable)return skipped(snapshot.unavailable);
|
|
106
|
+
// A path added to the scope after the snapshot has no known prior state.
|
|
107
|
+
if(!scope.every(file=>snapshot.files.has(file)))return skipped('snapshot_scope_changed');
|
|
108
|
+
if(!Array.isArray(checkCommands)||checkCommands.length===0)return skipped('no_host_checks');
|
|
109
|
+
const testFiles=(tests??[]).filter(file=>scope.includes(file));
|
|
110
|
+
const commands=checkCommands.map(({id,command})=>({id,command}));
|
|
111
|
+
// A command that names the project by absolute path would run the real project, not the copy.
|
|
112
|
+
if(commands.some(item=>item.command.some(argument=>argument.includes(codeProject))))return skipped('absolute_project_path');
|
|
113
|
+
// Each run starts from its own copy of the real project and gets its scope states placed.
|
|
114
|
+
const run=async states=>{
|
|
115
|
+
need(!signal?.aborted,'cancelled');
|
|
116
|
+
const copy=copyProject(codeProject,specsDir);
|
|
117
|
+
try{
|
|
118
|
+
for(const file of scope)place(copy.project,file,states(file));
|
|
119
|
+
// The same sandbox as the task's own checks: the copy is the workspace, specs stay read-only.
|
|
120
|
+
return summarize(await makeCheck({cwd:copy.project,commands,timeoutMs,specsRoot:specsDir})({identity},{signal}));
|
|
121
|
+
}finally{removeCopy(copy.root);}
|
|
122
|
+
};
|
|
123
|
+
try{
|
|
124
|
+
const before=file=>snapshot.files.get(file);
|
|
125
|
+
const baseline=await run(before);
|
|
126
|
+
let red={skipped:'no_test_files'};
|
|
127
|
+
if(testFiles.length){
|
|
128
|
+
const delivered=new Map(testFiles.map(file=>[file,currentState(codeProject,file)]));
|
|
129
|
+
red=await run(file=>delivered.has(file)?delivered.get(file):before(file));
|
|
130
|
+
}
|
|
131
|
+
return {version:1,status:'replayed',baseline,red,green};
|
|
132
|
+
}catch(error){
|
|
133
|
+
if(signal?.aborted)throw error;
|
|
134
|
+
return skipped(error?.code==='replay_project_too_large'?'project_too_large'
|
|
135
|
+
:error?.code==='replay_scope_link'?'scope_link':error?.code==='replay_internal_link'?'internal_link':'replay_failed');
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Without a replay: the reason, and the fully delivered run that did happen.
|
|
140
|
+
export const notReplayed=(reason,greenChecks)=>({version:1,status:'not_replayed',reason,green:summarize(json(greenChecks))});
|
|
141
|
+
|
|
142
|
+
// The facts as their own handoff evidence entry, beside the gate's requirement
|
|
143
|
+
// entry: a host-observed record, never the developer's report, with its own bound.
|
|
144
|
+
export function encodeHostReplayEvidence({identity,facts}){
|
|
145
|
+
validIdentity(identity);
|
|
146
|
+
return HOST_REPLAY_EVIDENCE_PREFIX+JSON.stringify({version:1,identity:{repositoryId:identity.repositoryId,
|
|
147
|
+
runId:identity.runId,taskId:identity.taskId,attempt:identity.attempt},facts:json(facts,16*1024)});
|
|
148
|
+
}
|
|
@@ -3,6 +3,7 @@ import {randomUUID} from 'node:crypto';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import {executionDiagnostic,need} from './effect-contract.mjs';
|
|
5
5
|
import {diagnosticReason} from './diagnostic-reason.mjs';
|
|
6
|
+
import {withHostStageObserver} from './host-stage-observer.mjs';
|
|
6
7
|
|
|
7
8
|
const LIMIT=64*1024;
|
|
8
9
|
// One wording for every host that stops on an over-limit line.
|
|
@@ -15,7 +16,7 @@ export function parseHostInputLimit(raw){
|
|
|
15
16
|
&&value>=LIMIT&&value<=4*1024*1024,'invalid_arguments');
|
|
16
17
|
return value;
|
|
17
18
|
}
|
|
18
|
-
const operationNames=new Set(['repair_review_response','reconcile_review','rediagnose','replace_inputs','read_batch','recover_final_review','abandon_step','abandon_review','rerun_blocked_step','abandon_effect','bootstrap_review_recover','develop_redo','advance','start','plan_design','promote_design','select_design_reviews','status','fix_status','fix_advance','fix_action','fix_run','decision','complete','qa','qa_result','prepare_revision','prepare_save',
|
|
19
|
+
const operationNames=new Set(['prepare_diagnosis_module_correction','revision_test_check','prepare_test_type_correction','prepare_command_correction','prepare_verification_recovery','repair_review_response','reconcile_review','retry_review','rediagnose','replace_inputs','read_batch','recover_final_review','abandon_step','abandon_review','rerun_blocked_step','abandon_effect','bootstrap_review_recover','completion_rework','development_rework','revise_scope','develop_redo','advance','start','plan_design','promote_design','select_design_reviews','status','fix_status','fix_advance','fix_action','fix_run','decision','complete','qa','qa_result','prepare_revision','prepare_save',
|
|
19
20
|
'context_refresh','finish','completion_evidence','run_finalize','review_findings','review_disposition','save_draft','save_design','correct_findings','prepare_summary','publish_summary','inspect_correction','resume_correction','cancel','resume','prepare_judge_revision','cause_review_package','cause_review','red_test','baseline','author_tests','repair','regression','retrospective','learning_writeback','handoff','final_review_package','final_review','publish_review','check_n5','post_review_regression','publish_dossier','walkthrough']);
|
|
20
21
|
|
|
21
22
|
// Which contract codes may reach the peer is a deliberate boundary: the host
|
|
@@ -53,11 +54,18 @@ function idleNotice(sessionKey,seq,row,since){
|
|
|
53
54
|
// A line above the transport limit ends the session. Carry a code and the
|
|
54
55
|
// limit so every host can name it instead of a generic launch failure.
|
|
55
56
|
const tooLarge=limit=>Object.assign(new Error('request_too_large'),{code:'request_too_large',limit});
|
|
56
|
-
export async function serveCmAiHost({host,input,output,toolBridge=null,inputLimit=LIMIT,errorOutput=process.stderr}){
|
|
57
|
+
export async function serveCmAiHost({host,input,output,toolBridge=null,inputLimit=LIMIT,errorOutput=process.stderr,heartbeat=process.env.CM_HOST_HEARTBEAT==='1'}){
|
|
57
58
|
if(!Number.isSafeInteger(inputLimit)||inputLimit<LIMIT||inputLimit>4*1024*1024)throw Error('input_limit_invalid');
|
|
58
59
|
let pending=null,buffer=Buffer.alloc(0),failure=null,closeRequested=false;
|
|
59
60
|
let writing=Promise.resolve();
|
|
60
|
-
const controls=new Set();let queuedWrites=0;
|
|
61
|
+
const controls=new Set(),activeControls=new Map();let queuedWrites=0,activeOperation=null;
|
|
62
|
+
let progressAt=Date.now(),heartbeatTimer=null,heartbeatWriting=false;
|
|
63
|
+
const inFlight=()=>{
|
|
64
|
+
const operation=activeOperation??activeControls.values().next().value??null;
|
|
65
|
+
const call=toolBridge?.inFlight?.()??null;
|
|
66
|
+
return operation?{...operation,stage:call?.kind??operation.nativeStage?.kind??operation.operation,call}:
|
|
67
|
+
call?{requestId:null,operation:null,startedAt:call.startedAt,stage:call.kind,call}:null;
|
|
68
|
+
};
|
|
61
69
|
const sessionKey=randomUUID(),startedAt=Date.now();let idle=null,seq=0,ended=false,lastRow=undefined,idleSince=0;
|
|
62
70
|
// Host registry (runtime/js/notify.mjs): serialised so a session that ends at
|
|
63
71
|
// once still removes its own entry. Each step is best-effort and synchronous.
|
|
@@ -93,7 +101,21 @@ export async function serveCmAiHost({host,input,output,toolBridge=null,inputLimi
|
|
|
93
101
|
writing.catch(error=>{failure=error;});
|
|
94
102
|
return writing;
|
|
95
103
|
};
|
|
96
|
-
toolBridge?.attach(reply);
|
|
104
|
+
toolBridge?.attach(reply,{heartbeat});
|
|
105
|
+
// Opt-in transport telemetry: no runner reads, journal writes or fingerprint changes.
|
|
106
|
+
// Keep at most one heartbeat queued so a slow peer cannot accumulate timer output.
|
|
107
|
+
if(heartbeat&&toolBridge){
|
|
108
|
+
const beat=()=>{
|
|
109
|
+
if(ended||failure||closeRequested||heartbeatWriting||queuedWrites>0)return;
|
|
110
|
+
heartbeatWriting=true;
|
|
111
|
+
reply({type:'host_heartbeat',sessionId:toolBridge.sessionId,pid:process.pid,at:new Date().toISOString(),
|
|
112
|
+
lastProgressAt:new Date(Math.max(progressAt,toolBridge.lastProgressAt?.()??0)).toISOString(),inFlight:inFlight()})
|
|
113
|
+
.catch(error=>{failure=error;}).finally(()=>{heartbeatWriting=false;});
|
|
114
|
+
};
|
|
115
|
+
// ready is already queued; send the first beat immediately after that write.
|
|
116
|
+
writing.then(beat).catch(()=>{});
|
|
117
|
+
heartbeatTimer=setInterval(beat,5000);heartbeatTimer.unref?.();
|
|
118
|
+
}
|
|
97
119
|
async function dispatch(bytes){
|
|
98
120
|
if(failure)throw failure;
|
|
99
121
|
let request;
|
|
@@ -101,7 +123,7 @@ export async function serveCmAiHost({host,input,output,toolBridge=null,inputLimi
|
|
|
101
123
|
request=JSON.parse(bytes.toString('utf8'));
|
|
102
124
|
if(POLLS.has(request?.operation))clearIdle();else nextStep();
|
|
103
125
|
if(toolBridge!==null&&['host_result','host_close'].includes(request?.type)){
|
|
104
|
-
const accepted=toolBridge.accept(request);closeRequested=accepted.closing===true;
|
|
126
|
+
const accepted=toolBridge.accept(request,{inFlight:inFlight()});closeRequested=accepted.closing===true;
|
|
105
127
|
reply({type:'host_response',...accepted}).catch(error=>{failure=error;});return;
|
|
106
128
|
}
|
|
107
129
|
if(!request||typeof request!=='object'||Array.isArray(request)
|
|
@@ -110,11 +132,20 @@ export async function serveCmAiHost({host,input,output,toolBridge=null,inputLimi
|
|
|
110
132
|
}catch{nextStep();reply({requestId:null,error:{code:'invalid_request'}}).catch(error=>{failure=error;});return;}
|
|
111
133
|
const requestId=request.requestId;
|
|
112
134
|
let row=null;
|
|
135
|
+
let operationActive=false,metadata=null;
|
|
136
|
+
const release=()=>{if(!operationActive)return;operationActive=false;
|
|
137
|
+
if(activeOperation===metadata)activeOperation=null;
|
|
138
|
+
activeControls.delete(request);if(!POLLS.has(request.operation))progressAt=Date.now();};
|
|
139
|
+
const begin=control=>{operationActive=true;const at=Date.now();if(!POLLS.has(request.operation))progressAt=at;
|
|
140
|
+
metadata={requestId,operation:request.operation,startedAt:new Date(at).toISOString(),nativeStage:null};
|
|
141
|
+
if(control)activeControls.set(request,metadata);else activeOperation=metadata;};
|
|
113
142
|
const invoke=async()=>{
|
|
114
|
-
try{const result=await
|
|
143
|
+
try{const result=await withHostStageObserver(stage=>{
|
|
144
|
+
if(operationActive){metadata.nativeStage=stage;if(!POLLS.has(request.operation))progressAt=Date.now();}
|
|
145
|
+
},()=>host.handle(request));row={result};release();await reply({requestId,result});}
|
|
115
146
|
catch(error){
|
|
116
147
|
reportRequestFailure(errorOutput,request.operation,error);
|
|
117
|
-
row={error:{code:'host_request_failed'}};
|
|
148
|
+
row={error:{code:'host_request_failed'}};release();
|
|
118
149
|
await reply({requestId,...row});
|
|
119
150
|
}
|
|
120
151
|
finally{if(!POLLS.has(request.operation))register(row,request.operation);}
|
|
@@ -123,10 +154,12 @@ export async function serveCmAiHost({host,input,output,toolBridge=null,inputLimi
|
|
|
123
154
|
if(request.operation==='status'||request.operation==='cancel'){
|
|
124
155
|
// The input reader must not wait for a slow response consumer before it
|
|
125
156
|
// can deliver the next control request (especially cancellation).
|
|
157
|
+
begin(true);
|
|
126
158
|
const control=invoke().finally(()=>{controls.delete(control);finished(row,request.operation);});
|
|
127
159
|
controls.add(control);control.catch(error=>{failure=error;});return;
|
|
128
160
|
}
|
|
129
|
-
if(pending){reply({requestId,error:{code:'host_busy'}}).catch(error=>{failure=error;});return;}
|
|
161
|
+
if(pending){reply({requestId,error:{code:'host_busy',inFlight:inFlight(),message:'上一步仍在执行,请继续等待该请求的结果。'}}).catch(error=>{failure=error;});return;}
|
|
162
|
+
begin(false);
|
|
130
163
|
pending=invoke().finally(()=>{pending=null;finished(row,request.operation);});
|
|
131
164
|
pending.catch(error=>{failure=error;});
|
|
132
165
|
}
|
|
@@ -150,7 +183,7 @@ export async function serveCmAiHost({host,input,output,toolBridge=null,inputLimi
|
|
|
150
183
|
}finally{
|
|
151
184
|
// With a duplex conversation, EOF means no more tool replies can arrive.
|
|
152
185
|
// Reject that wait as disconnected, not as an explicit user cancellation.
|
|
153
|
-
toolBridge?.close();ended=true;clearIdle();
|
|
186
|
+
toolBridge?.close();ended=true;clearInterval(heartbeatTimer);clearIdle();
|
|
154
187
|
// EOF is not a user cancellation. Finish the in-flight result before close.
|
|
155
188
|
try{await Promise.allSettled([...(pending?[pending]:[]),...controls,writing]);}
|
|
156
189
|
finally{
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Process-local transport telemetry only. No durable state, authority or timers.
|
|
2
|
+
import {AsyncLocalStorage} from 'node:async_hooks';
|
|
3
|
+
import {randomUUID} from 'node:crypto';
|
|
4
|
+
|
|
5
|
+
const operations=new AsyncLocalStorage();
|
|
6
|
+
const emit=context=>{
|
|
7
|
+
if(context.closed)return;
|
|
8
|
+
const stages=[...context.stages.values()],latest=stages.at(-1);
|
|
9
|
+
const snapshot=latest?Object.freeze({...latest,deadlineMs:Math.min(...stages.map(stage=>stage.deadlineMs))}):null;
|
|
10
|
+
try{context.observer(snapshot);}catch{/* diagnostic observers cannot change execution */}
|
|
11
|
+
};
|
|
12
|
+
export async function withHostStageObserver(observer,run){
|
|
13
|
+
const context={observer,stages:new Map(),closed:false};
|
|
14
|
+
return operations.run(context,async()=>{
|
|
15
|
+
try{return await run();}
|
|
16
|
+
finally{context.stages.clear();emit(context);context.closed=true;}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export function beginHostStage(kind,timeoutMs){
|
|
20
|
+
const context=operations.getStore();
|
|
21
|
+
if(!context||context.closed||!Number.isSafeInteger(timeoutMs)||timeoutMs<1)return ()=>{};
|
|
22
|
+
const now=Date.now(),id=randomUUID();
|
|
23
|
+
context.stages.set(id,{id,kind,startedAt:new Date(now).toISOString(),deadlineMs:now+timeoutMs});emit(context);
|
|
24
|
+
let ended=false;
|
|
25
|
+
return ()=>{if(ended||context.closed)return;ended=true;context.stages.delete(id);emit(context);};
|
|
26
|
+
}
|
|
@@ -48,19 +48,25 @@ const lateDiagnostic=fields=>{try{process.stderr.write(JSON.stringify({diagnosti
|
|
|
48
48
|
export function createHostToolBridge({responseLimit=64*1024,answerTimeoutMs=hostAnswerTimeoutMs()}={}){
|
|
49
49
|
need(Number.isSafeInteger(responseLimit)&&responseLimit>=64*1024&&responseLimit<=4*1024*1024,'host_response_limit_invalid');
|
|
50
50
|
need(Number.isSafeInteger(answerTimeoutMs)&&answerTimeoutMs>=1000&&answerTimeoutMs<=HOST_ANSWER_BACKSTOP_MS,'host_answer_timeout_invalid');
|
|
51
|
-
const sessionId=randomUUID();let send=null,pending=null,closed=false;
|
|
51
|
+
const sessionId=randomUUID();let send=null,pending=null,closed=false,lastProgressAt=Date.now();
|
|
52
|
+
// Metadata only: never expose the request payload or answer through liveness.
|
|
53
|
+
const inFlight=()=>pending?{callId:pending.request.callId,kind:pending.request.kind,
|
|
54
|
+
startedAt:new Date(pending.startedAt).toISOString(),deadlineMs:pending.deadlineMs}:null;
|
|
52
55
|
const stopped=new Map();
|
|
53
56
|
const stop=(code,call=pending)=>{
|
|
54
|
-
if(!call||pending!==call)return;pending=null;clearTimeout(call.timer);call.notice?.();
|
|
57
|
+
if(!call||pending!==call)return;pending=null;lastProgressAt=Date.now();clearTimeout(call.timer);call.notice?.();
|
|
55
58
|
call.signal.removeEventListener('abort',call.abort);
|
|
56
59
|
if(code!=='host_disconnected'){stopped.set(call.request.callId,{kind:call.request.kind,stoppedBy:code});
|
|
57
60
|
if(stopped.size>LATE_CALLS)stopped.delete(stopped.keys().next().value);}
|
|
58
61
|
call.reject(Object.assign(new Error(code),{code}));
|
|
59
62
|
};
|
|
60
63
|
return Object.freeze({
|
|
61
|
-
|
|
64
|
+
sessionId,
|
|
65
|
+
inFlight,
|
|
66
|
+
lastProgressAt:()=>lastProgressAt,
|
|
67
|
+
attach(sender,{heartbeat=false}={}){
|
|
62
68
|
need(send===null&&typeof sender==='function'&&!closed,'host_bridge_unavailable');send=sender;
|
|
63
|
-
Promise.resolve(send({type:'host_ready',sessionId})).catch(()=>{closed=true;stop('host_disconnected');});
|
|
69
|
+
Promise.resolve(send({type:'host_ready',sessionId,...(heartbeat?{heartbeat:{intervalMs:5000,timeoutMs:30000}}:{})})).catch(()=>{closed=true;stop('host_disconnected');});
|
|
64
70
|
},
|
|
65
71
|
call(kind,payload,signal,{timeoutMs=null}={}){
|
|
66
72
|
need(send!==null&&!closed,'host_bridge_unavailable');need(pending===null,'host_bridge_busy');
|
|
@@ -73,7 +79,9 @@ export function createHostToolBridge({responseLimit=64*1024,answerTimeoutMs=host
|
|
|
73
79
|
stop('cancelled',call);
|
|
74
80
|
Promise.resolve(send({type:'host_call_cancelled',sessionId,callId:request.callId})).catch(()=>{});
|
|
75
81
|
};
|
|
76
|
-
const
|
|
82
|
+
const startedAt=Date.now(),duration=timeoutMs??(COMMAND_KINDS.has(kind)?Math.max(answerTimeoutMs,HOST_ANSWER_TIMEOUT_MAX_MS):answerTimeoutMs);
|
|
83
|
+
const call={request,signal,abort,resolve,reject,startedAt,deadlineMs:startedAt+duration,timer:null,notice:waitNotice(kind,request.callId)};
|
|
84
|
+
pending=call;lastProgressAt=startedAt;
|
|
77
85
|
if(timeoutMs!==null)call.timer=setTimeout(()=>stop('host_request_timeout',call),timeoutMs);
|
|
78
86
|
// The default deadline never keeps an otherwise finished process alive.
|
|
79
87
|
else {call.timer=setTimeout(()=>stop('host_request_timeout',call),
|
|
@@ -85,12 +93,17 @@ export function createHostToolBridge({responseLimit=64*1024,answerTimeoutMs=host
|
|
|
85
93
|
}).catch(()=>stop('host_disconnected',call));
|
|
86
94
|
});
|
|
87
95
|
},
|
|
88
|
-
accept(raw){
|
|
96
|
+
accept(raw,{inFlight:operation=null}={}){
|
|
89
97
|
let reply;
|
|
90
98
|
try{
|
|
91
99
|
if(raw?.type==='host_close'){
|
|
92
|
-
shape(raw,['type','sessionId']);need(raw.sessionId===sessionId&&!closed,'host_response_mismatch');
|
|
93
|
-
|
|
100
|
+
shape(raw,['type','sessionId',...(Object.hasOwn(raw,'force')?['force']:[])]);need(raw.sessionId===sessionId&&!closed,'host_response_mismatch');
|
|
101
|
+
need(raw.force===undefined||typeof raw.force==='boolean','host_response_mismatch');
|
|
102
|
+
const active=operation??(pending?{requestId:null,operation:null,startedAt:inFlight().startedAt,stage:pending.request.kind,call:inFlight()}:null);
|
|
103
|
+
if(active&&raw.force!==true)return {accepted:false,code:'host_close_busy',inFlight:active,
|
|
104
|
+
message:'上一步仍在执行,请继续等待其结果;只有明确放弃本次在途工作时才传 force:true。'};
|
|
105
|
+
closed=true;stop('host_disconnected');return {accepted:true,closing:true,...(active?{
|
|
106
|
+
warning:'已强制关闭在途工作,原运行可能进入 unknown;请核对原运行状态后恢复。',inFlight:active}:{})};
|
|
94
107
|
}
|
|
95
108
|
reply=json(raw,responseLimit);shape(reply,['type','sessionId','callId','requestDigest','result']);
|
|
96
109
|
const late=reply.type==='host_result'&&reply.sessionId===sessionId&&pending?.request.callId!==reply.callId
|
|
@@ -100,7 +113,7 @@ export function createHostToolBridge({responseLimit=64*1024,answerTimeoutMs=host
|
|
|
100
113
|
need(reply.type==='host_result'&&pending!==null&&!closed,'host_response_mismatch');
|
|
101
114
|
for(const key of ['sessionId','callId','requestDigest'])need(reply[key]===pending.request[key],'host_response_mismatch');
|
|
102
115
|
}catch(error){return {accepted:false,code:error?.code==='limit_exceeded'?'host_response_too_large':'host_response_mismatch'};}
|
|
103
|
-
const call=pending;pending=null;clearTimeout(call.timer);call.notice?.();call.signal.removeEventListener('abort',call.abort);
|
|
116
|
+
const call=pending;pending=null;lastProgressAt=Date.now();clearTimeout(call.timer);call.notice?.();call.signal.removeEventListener('abort',call.abort);
|
|
104
117
|
call.resolve(reply.result);return {accepted:true,callId:reply.callId};
|
|
105
118
|
},
|
|
106
119
|
close(){closed=true;stop('host_disconnected');},
|
|
@@ -3,6 +3,7 @@ import fs from 'node:fs';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import {digest,json,need,shape,validIdentity,hex} from './effect-contract.mjs';
|
|
5
5
|
import {createHostQaDecisionProvider,readQaCriticalPaths} from './host-qa-policy.mjs';
|
|
6
|
+
import {markImplicitQaDecision} from './implicit-qa-decision.mjs';
|
|
6
7
|
import {createHostQaExecutor} from './host-qa-executor.mjs';
|
|
7
8
|
import {loadConfig} from '../../../scripts/cm-workflow-config.mjs';
|
|
8
9
|
import {validateTestCases} from '../../../scripts/validate-test-cases.mjs';
|
|
@@ -83,8 +84,16 @@ export function createHostWorkflowCapabilities({definition,configuration,bridge,
|
|
|
83
84
|
if(configuration.qa!==null||controlPolicy!==null){
|
|
84
85
|
result.qaLogHome=logHome;
|
|
85
86
|
const requestTimeout={timeoutMs:configuration.qa?.timeoutMs??60000};
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
// The assessment is a read-only confirmation; the decision itself comes from
|
|
88
|
+
// the host policy (host-qa-policy.mjs). A v2 run whose policy disables QA has
|
|
89
|
+
// nobody to ask when it runs unattended, so the host confirms it here; the
|
|
90
|
+
// decision, its triggers and its record are unchanged.
|
|
91
|
+
const assess=controlPolicy?.qa==='disabled'?async()=>({confirmed:true})
|
|
92
|
+
:(request,signal)=>bridge.call('qa_assess',request,signal,requestTimeout);
|
|
93
|
+
// parallelMember: a member developed alongside others, whose QA is deferred. A
|
|
94
|
+
// one-member worktree group passes false and keeps the fixed checkpoints.
|
|
95
|
+
result.qaDecisionProvider=parallelMember?createParallelMemberQaDecisionProvider():createHostQaDecisionProvider({timeoutMs:60000,
|
|
96
|
+
criticalPaths:configuration.qa?.criticalPaths??{},assess});
|
|
88
97
|
}
|
|
89
98
|
if(configuration.qa!==null&&(controlPolicy===null||controlPolicy.qa==='run')){
|
|
90
99
|
need(allowQa===true,'qa_authorization_required');
|
|
@@ -113,3 +122,11 @@ export function createParallelMemberQaDecisionProvider(){
|
|
|
113
122
|
...(binding.changedFiles?{changedFilesSource:binding.changedFiles.source}:{}),at:new Date().toISOString().replace(/\.\d{3}Z$/,'Z')};
|
|
114
123
|
}});
|
|
115
124
|
}
|
|
125
|
+
|
|
126
|
+
// v2 的 N6 判定不依赖 workflow 配置;没有 --workflow-config 时只补判定本身,
|
|
127
|
+
// 不加执行器、文档核对或写回,避免改变这类运行的其他请求。
|
|
128
|
+
export function createImplicitQaDecision({definition,bridge,parallelMember=false,controlPolicy}){
|
|
129
|
+
const {qaLogHome,qaDecisionProvider}=createHostWorkflowCapabilities({definition,
|
|
130
|
+
configuration:{qa:null,documentationPaths:[],applicableAgentFiles:[]},bridge,allowQa:false,parallelMember,controlPolicy});
|
|
131
|
+
return {qaLogHome,qaDecisionProvider:markImplicitQaDecision(qaDecisionProvider)};
|
|
132
|
+
}
|
|
@@ -15,5 +15,5 @@ export function createCmAiHost(options) {
|
|
|
15
15
|
...(qaExecutor===undefined?{}:{qaExecutor}),
|
|
16
16
|
...(documentationProvider===undefined?{}:{documentationProvider}),
|
|
17
17
|
...(qaDecisionProvider===undefined?{}:{qaDecisionProvider})});
|
|
18
|
-
return Object.freeze({handle:entry.handle,inspectFixAssociation:runner.inspectFixAssociation,acceptCompletedFix:runner.acceptCompletedFix,attachQa:runner.attachQa,reviseQa:runner.reviseQa,supersedeEvidence:runner.supersedeEvidence,rebindSpecification:runner.rebindSpecification});
|
|
18
|
+
return Object.freeze({handle:entry.handle,inspectFixAssociation:runner.inspectFixAssociation,acceptCompletedFix:runner.acceptCompletedFix,acceptReviewedIntegration:runner.acceptReviewedIntegration,attachQa:runner.attachQa,reviseQa:runner.reviseQa,supersedeEvidence:runner.supersedeEvidence,rebindSpecification:runner.rebindSpecification,reviseScope:runner.reviseScope,reworkDevelopment:runner.reworkDevelopment});
|
|
19
19
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// v2 运行没有 --workflow-config 时,宿主隐式补上 QA 判定(只有判定,没有执行器和文档能力)。
|
|
2
|
+
// 修复前创建的同类运行指纹里没有它;恢复时宿主据此识别并按原样打开,不改变它们的行为。
|
|
3
|
+
const IMPLICIT=new WeakSet();
|
|
4
|
+
export function markImplicitQaDecision(provider){IMPLICIT.add(provider);return provider;}
|
|
5
|
+
export function isImplicitQaDecision(provider){return provider!=null&&typeof provider==='object'&&IMPLICIT.has(provider);}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Exact additions of reviewed evidence copies, never an ignore rule or an
|
|
2
|
+
// instruction-promotion mechanism. These helpers do not read or write a product.
|
|
3
|
+
import {hex,need,shape} from './effect-contract.mjs';
|
|
4
|
+
|
|
5
|
+
const snapshotPath=p=>typeof p==='string'
|
|
6
|
+
&&/^reports\/(?:[A-Za-z0-9][A-Za-z0-9_.-]*\/)+AGENTS\.md$/.test(p)
|
|
7
|
+
&&!p.split('/').some(part=>['.git','node_modules'].includes(part));
|
|
8
|
+
|
|
9
|
+
export function readIntegrationSnapshots(value){
|
|
10
|
+
shape(value,['files','provenanceSha256']);hex(value.provenanceSha256);
|
|
11
|
+
need(Array.isArray(value.files)&&value.files.length>0&&value.files.length<=64,'integration_snapshot_invalid');
|
|
12
|
+
let previous='',total=0;
|
|
13
|
+
for(const file of value.files){
|
|
14
|
+
shape(file,['path','type','mode','size','sha256']);
|
|
15
|
+
need(snapshotPath(file.path)&&file.path>previous&&file.type==='file'
|
|
16
|
+
&&[0o644,0o664].includes(file.mode)&&Number.isSafeInteger(file.size)&&file.size>=0
|
|
17
|
+
&&file.size<=256*1024,'integration_snapshot_invalid');
|
|
18
|
+
hex(file.sha256);previous=file.path;total+=file.size;
|
|
19
|
+
}
|
|
20
|
+
need(total<=2*1024*1024,'integration_snapshot_invalid');
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function assertSnapshotBoundaries(snapshots,base,packages,learningPaths=[]){
|
|
25
|
+
if(!snapshots)return;
|
|
26
|
+
readIntegrationSnapshots(snapshots);
|
|
27
|
+
const existing=new Set(base.files.map(file=>file.path));
|
|
28
|
+
const protectedPaths=new Set([...base.scope,...base.requirements,...learningPaths,
|
|
29
|
+
...packages.flatMap(pkg=>[...pkg.scope,...pkg.requirements.map(file=>file.path),
|
|
30
|
+
...pkg.changes.map(file=>file.path),...(pkg.instructions??[]).map(file=>file.path)])]);
|
|
31
|
+
for(const file of snapshots.files){
|
|
32
|
+
const directory=file.path.slice(0,-'AGENTS.md'.length);
|
|
33
|
+
need(!existing.has(file.path)&&![...protectedPaths].some(p=>p===file.path||p.startsWith(directory)),
|
|
34
|
+
'integration_snapshot_protected');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function verifySnapshotReview(pkg,snapshots){
|
|
39
|
+
if(!snapshots)return;
|
|
40
|
+
const provenance=pkg.requirements.find(file=>file.path==='integration/snapshot-provenance.json');
|
|
41
|
+
need(provenance?.sha256===snapshots.provenanceSha256&&typeof provenance.contentBase64==='string',
|
|
42
|
+
'integration_snapshot_not_reviewed');
|
|
43
|
+
for(const expected of snapshots.files){
|
|
44
|
+
// Keep copied instructions in data files. Hash deduplication retains all
|
|
45
|
+
// bytes while the plan separately binds every target path and original mode.
|
|
46
|
+
const file=pkg.requirements.find(item=>item.path==='integration/snapshots/'+expected.sha256+'.txt');
|
|
47
|
+
need(file?.type==='file'&&file.sha256===expected.sha256&&file.size===expected.size
|
|
48
|
+
&&typeof file.contentBase64==='string','integration_snapshot_not_reviewed');
|
|
49
|
+
}
|
|
50
|
+
}
|