@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
package/scripts/cm-ai-drive.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {packageMaterialEligible,checkpointPackageBudget} from '../runtime/js/cm-ai/checkpoint-package-material.mjs';
|
|
2
3
|
// cm-ai host 的单步驾驶员。PLAN 路径相对 PLAN 文件;命令仅在 codeProject 内执行。
|
|
3
4
|
// 请求表来自 host-session.mjs operationNames(传输允许集)、host-conversation-execution.mjs
|
|
4
5
|
// developer/check/verificationGate、host-workflow-capabilities.mjs QA/文档接线、
|
|
@@ -59,13 +60,16 @@ import {readCloseoutReport} from '../runtime/js/cm-ai/knowledge-closeout.mjs';
|
|
|
59
60
|
import {readRunnerHistory,attemptBaseline,projectedRunnerStatus,RECHECK_CODES,DOCUMENTATION_SYNC_CODES} from '../runtime/js/cm-ai/durable-runner-state.mjs';
|
|
60
61
|
import {developmentRetryable} from '../runtime/js/cm-ai/cm-ai-conversation-entry.mjs';
|
|
61
62
|
import {stderr,stop,readJson,loadPlanFile,requireFields,preflightAnswers,driveHost,planCheckTimeout} from '../runtime/js/cm-ai/drive-core.mjs';
|
|
63
|
+
import {rateLimitRetryEligible} from '../runtime/js/cm-ai/drive-rate-limit.mjs';
|
|
64
|
+
import {cmAiSessionBoundary} from '../runtime/js/session-boundary.mjs';
|
|
65
|
+
import {printHandoff} from '../runtime/js/session-handoff.mjs';
|
|
62
66
|
import {attemptAnswerName,inspectDriverBootstrap,readBootstrapRulesAnswers,createBootstrapRulesResponder} from '../runtime/js/cm-ai/drive-bootstrap.mjs';
|
|
63
|
-
import {driverLiveEvidence} from '../runtime/js/cm-ai/live-evidence.mjs';
|
|
67
|
+
import {driverLiveEvidence,qaAnswerWindowShortfall} from '../runtime/js/cm-ai/live-evidence.mjs';
|
|
64
68
|
import {readControlPolicyFile,isControlRecovery as controlRecoveryRequest} from '../runtime/js/cm-ai/control-policy.mjs';
|
|
65
69
|
|
|
66
70
|
// PLAN.liveEvidence: fresh current-session evidence; see docs/live-evidence-drivers.md.
|
|
67
71
|
const HOST=fileURLToPath(new URL('./cm-ai-host.mjs',import.meta.url));
|
|
68
|
-
const OPERATIONS=new Set(['advance','start','resume','status','cancel','reconcile_review','abandon_review','abandon_effect','bootstrap_review_recover','develop_redo','decision','complete','qa','qa_result',
|
|
72
|
+
const OPERATIONS=new Set(['advance','start','resume','status','cancel','reconcile_review','abandon_review','abandon_effect','bootstrap_review_recover','completion_rework','development_rework','revise_scope','develop_redo','decision','complete','qa','qa_result',
|
|
69
73
|
'fix_status','fix_advance','fix_action','fix_run','run_finalize','context_refresh','finish']);
|
|
70
74
|
const ADVANCE=new Set(['advance','start','resume']);
|
|
71
75
|
const PACKAGE_OPERATIONS=new Set(['decision','complete','qa','qa_result','context_refresh','finish','run_finalize']);
|
|
@@ -87,13 +91,13 @@ const FIX_REASONED=['abandon_step','abandon_review','rediagnose','rerun_blocked_
|
|
|
87
91
|
const FILES={develop:'develop.json',qa_assess:'qa-assess.json',documentation_inspect:'documentation-inspect.json',
|
|
88
92
|
documentation_sync:'documentation-sync.json',fix_learning:'learning.json',fix_diagnose:'diagnosis.json',
|
|
89
93
|
fix_test_author:'test-edits.json',fix_repair:'repair-edits.json',fix_retrospective:'retrospective.json'};
|
|
90
|
-
const PAIR_FLAGS=new Set(['--external-models-config','--review-config','--workflow-config',
|
|
94
|
+
const PAIR_FLAGS=new Set(['--integration-evidence','--accept-integration-digest','--expected-control','--revise-scope','--scope-revision-reason','--development-rework-reason','--external-models-config','--review-config','--workflow-config',
|
|
91
95
|
'--input-limit',
|
|
92
96
|
'--protected-conversation-config','--protected-config','--revise-qa-config','--qa-config-revision-reason','--qa-environment-failure',
|
|
93
97
|
'--qa-fix-owner-config','--qa-fix-template-config','--qa-fix-review-config','--browser-qa',
|
|
94
|
-
'--bootstrap-config','--allow-provider-development-attempt','--supersede-reason','--spec-rebind-reason',
|
|
98
|
+
'--bootstrap-config','--allow-provider-development-attempt','--supersede-reason','--supersede-target','--spec-rebind-reason',
|
|
95
99
|
'--review-runtime','--feature','--qa-fix-final-review-recovery-invocation']);
|
|
96
|
-
const FLAG_FLAGS=new Set(['--execution-optimizations','--external-models','--allow-development','--allow-qa','--allow-qa-fix-start','--auto-qa-fix',
|
|
100
|
+
const FLAG_FLAGS=new Set(['--development-rework','--execution-optimizations','--external-models','--allow-development','--allow-qa','--allow-qa-fix-start','--auto-qa-fix',
|
|
97
101
|
'--verification-precheck',
|
|
98
102
|
'--allow-bootstrap-write','--allow-abandon-review','--allow-abandon-effect','--allow-bootstrap-review-recovery','--allow-develop-redo','--rerun-unknown-qa','--rerun-blocked-qa','--failover',
|
|
99
103
|
'--supersede-reviewed-evidence','--accept-superseded-code-drift','--rebind-spec-material',
|
|
@@ -111,6 +115,8 @@ export function readDriverControl(plan,base,operation,recovery=null){
|
|
|
111
115
|
throw Error('permissions 必须是宿主参数数组');
|
|
112
116
|
if(plan.permissions.some(flag=>flag.startsWith('--allow-')))
|
|
113
117
|
throw Error('control v2 迁移错误:permissions 禁止 --allow-*;请改用 controlConfig 的明确模式和 expectedControl');
|
|
118
|
+
if(['revise_scope','development_rework'].includes(operation))
|
|
119
|
+
throw Error('启动型恢复不发送 wire 操作;用 permissions 的专用启动参数、单行原因和 --expected-control FILE 保存原 launchControlTarget,再发送 status 或 advance');
|
|
114
120
|
const recovering=recovery??isControlRecovery(operation,plan);
|
|
115
121
|
if(plan.mode==='create'&&Object.hasOwn(plan,'expectedControl'))
|
|
116
122
|
throw Error('control v2 create 禁止 expectedControl');
|
|
@@ -274,7 +280,7 @@ export function journalRestBytes(records){
|
|
|
274
280
|
return {restBytes:size(last.payload)-size(frame.reviewPackage),resultBytes:size(frame.cache.at(-1)?.result),
|
|
275
281
|
receiptsBytes:size(frame.receipts),callsBytes:size(frame.calls)};
|
|
276
282
|
}
|
|
277
|
-
export function developPreview({definition,codeProject=definition.codeProject,journal=null,parallelSelection=null,exact=true}){
|
|
283
|
+
export function developPreview({definition,codeProject=definition.codeProject,journal=null,parallelSelection=null,exact=true,controlPolicy=null}){
|
|
278
284
|
let baseline=journal?.baseline??null;
|
|
279
285
|
try{
|
|
280
286
|
if(baseline===null){
|
|
@@ -291,6 +297,9 @@ export function developPreview({definition,codeProject=definition.codeProject,jo
|
|
|
291
297
|
}
|
|
292
298
|
}
|
|
293
299
|
return {definition,baseline,material:reviewMaterialSizes({root:codeProject,baseline}),parallelSelection,
|
|
300
|
+
packageMaterialEnabled:journal?.packageMaterialEnabled===true||journal===null&&packageMaterialEligible({
|
|
301
|
+
...definition,root:codeProject,controlPolicy,...(parallelSelection?{parallelSelection}:{})}),
|
|
302
|
+
archivedPackageDigests:journal?.archivedPackageDigests??[],
|
|
294
303
|
exact:exact&&!definition.codeProjects,...(journal?.frame??journalRestBytes([]))};
|
|
295
304
|
}catch(error){
|
|
296
305
|
if(error.code==='limit_exceeded')stop(2,`交付前的审查材料已超出审查包上限:${error.message}`);
|
|
@@ -433,7 +442,10 @@ export function preflightDevelopDeliveries({deliveries,answersRoot,codeProject,s
|
|
|
433
442
|
const reserve=developCheckpointReserve({examinedPathsBytes:size(reviewPaths(pkg)),receiptsBytes:preview.receiptsBytes,
|
|
434
443
|
callsBytes:preview.callsBytes+1024,writebackBytes:1024});
|
|
435
444
|
const budget=JOURNAL_PAYLOAD_LIMIT-reserve;
|
|
436
|
-
|
|
445
|
+
const enabled=preview.packageMaterialEnabled===true;
|
|
446
|
+
const capacity=enabled?checkpointPackageBudget({inlineBytes:bytes,packageBytes,reserve,enabled,
|
|
447
|
+
referenced:preview.archivedPackageDigests.includes(pkg.packageDigest)}):{fits:bytes<=budget};
|
|
448
|
+
if(!capacity.fits){
|
|
437
449
|
const largest=pkg.changes.filter(change=>change.after).map(change=>change.after).sort((a,b)=>b.size-a.size).slice(0,3)
|
|
438
450
|
.map(file=>`${file.path} ${kib(file.size)}`).join(',');
|
|
439
451
|
stop(2,`${label}: 交付后的开发检查点约 ${kib(bytes)}(其中审查包 ${kib(packageBytes)},含 handoff),超过运行存档单条记录上限 ${JOURNAL_PAYLOAD_LIMIT} `
|
|
@@ -467,7 +479,10 @@ export function readRunJournal(definition){
|
|
|
467
479
|
const snapshot=readExecutionSnapshot({specsRoot:definition.specsDir,identity:{
|
|
468
480
|
repositoryId:definition.identity.repositoryId,runId:definition.identity.runId}});
|
|
469
481
|
const first=snapshot.records[0];
|
|
470
|
-
|
|
482
|
+
const history=readRunnerHistory(snapshot.records,first.payload.config,3);
|
|
483
|
+
return {history,config:first.payload.config,baseline:history.original,
|
|
484
|
+
packageMaterialEnabled:packageMaterialEligible(first.payload.config,first.payload.version),
|
|
485
|
+
archivedPackageDigests:snapshot.records.filter(row=>row.payload.type==='effect-checkpoint'&&row.payload.packageMaterial===true).map(row=>row.payload.checkpoint.reviewPackage.packageDigest),
|
|
471
486
|
frame:journalRestBytes(snapshot.records)};
|
|
472
487
|
}
|
|
473
488
|
function reachableDevelopAttempts({plan,operation,journal,permissions,controlPolicy=null}){
|
|
@@ -533,7 +548,10 @@ export function validateCmAiAnswer(kind,value,root){
|
|
|
533
548
|
if(value.status==='succeeded'){
|
|
534
549
|
exact(value,['status','value','edits'],'develop.json');
|
|
535
550
|
requireShape(object(value.value)&&['implemented','blocked'].includes(value.value.outcome),'develop.json.value.outcome');
|
|
536
|
-
exact(value.value,['outcome','application','retrospective','reason'],'develop.json.value');
|
|
551
|
+
exact(value.value,['outcome','application','retrospective','reason','requirements'],'develop.json.value');
|
|
552
|
+
// The per-requirement report the prompt asks for; the host validates and splits it off.
|
|
553
|
+
requireShape(!Object.hasOwn(value.value,'requirements')||value.value.requirements===null
|
|
554
|
+
||Array.isArray(value.value.requirements)&&value.value.requirements.length<=64,'develop.json.value.requirements');
|
|
537
555
|
if(value.value.outcome==='implemented')requireShape(object(value.value.application)
|
|
538
556
|
&&['applied','no_relevant_lesson'].includes(value.value.application.status)
|
|
539
557
|
&&(value.value.application.status==='applied'?nonempty(value.value.application.note):value.value.application.note===null)
|
|
@@ -596,6 +614,7 @@ function load(){
|
|
|
596
614
|
requireFields(plan,['config','mode','hostContext','permissions']);
|
|
597
615
|
let control;
|
|
598
616
|
try{control=readDriverControl(plan,base,operation);}catch(error){stop(2,error.message);}
|
|
617
|
+
if(['revise_scope','development_rework'].includes(operation)&&!control)stop(2,`${operation} 只用于原 v2 单任务运行`);
|
|
599
618
|
if(control?.policy.bootstrap==='write'&&!plan.permissions.includes('--bootstrap-config'))
|
|
600
619
|
stop(2,'invalid_arguments: bootstrap write 需要 --bootstrap-config');
|
|
601
620
|
if(control?.policy.qaFix==='disabled'&&['fix_advance','fix_run','fix_action'].includes(operation))
|
|
@@ -613,6 +632,19 @@ function load(){
|
|
|
613
632
|
else if(PAIR_FLAGS.has(flag)&&nonempty(plan.permissions[i+1]))permissions.push(flag,plan.permissions[++i]);
|
|
614
633
|
else stop(2,`permissions 无效或缺少参数: ${flag}`);
|
|
615
634
|
}
|
|
635
|
+
const integrationEvidence=permissions.includes('--integration-evidence');
|
|
636
|
+
const integrationDigest=permissions.includes('--accept-integration-digest');
|
|
637
|
+
if(integrationEvidence||integrationDigest){
|
|
638
|
+
if(!integrationEvidence||!integrationDigest||!control||plan.mode!=='resume'||operation!=='status'
|
|
639
|
+
||!permissions.includes('--expected-control')
|
|
640
|
+
||!/^[a-f0-9]{64}$/.test(permissions[permissions.indexOf('--accept-integration-digest')+1]))
|
|
641
|
+
stop(2,'受控集成接纳只允许新版 resume 的 status;需要成对 --integration-evidence、--accept-integration-digest 和原 --expected-control 文件');
|
|
642
|
+
if(['--revise-scope','--scope-revision-reason','--development-rework','--development-rework-reason',
|
|
643
|
+
'--revise-qa-config','--qa-config-revision-reason','--rerun-unknown-qa','--rerun-blocked-qa','--qa-environment-failure',
|
|
644
|
+
'--rebind-spec-material','--spec-rebind-reason','--supersede-reviewed-evidence','--supersede-reason',
|
|
645
|
+
'--supersede-target','--accept-superseded-code-drift','--hold-revision'].some(flag=>permissions.includes(flag)))
|
|
646
|
+
stop(2,'受控集成接纳不得并用其他恢复或 QA 重跑');
|
|
647
|
+
}
|
|
616
648
|
const supersedeFlag=permissions.includes('--supersede-reviewed-evidence');
|
|
617
649
|
const supersedeReason=permissions.includes('--supersede-reason');
|
|
618
650
|
if(supersedeFlag!==supersedeReason)
|
|
@@ -620,12 +652,16 @@ function load(){
|
|
|
620
652
|
if(permissions.includes('--accept-superseded-code-drift')&&!supersedeFlag)
|
|
621
653
|
stop(2,'--accept-superseded-code-drift 需要 --supersede-reviewed-evidence 与 --supersede-reason');
|
|
622
654
|
if(supersedeFlag&&plan.mode!=='create')stop(2,'supersede 只允许 mode create');
|
|
655
|
+
if(permissions.includes('--supersede-target')&&(!supersedeFlag||!control))
|
|
656
|
+
stop(2,'--supersede-target 只用于新版 controlConfig 的 create 重开,并须同时提供 --supersede-reviewed-evidence 与 --supersede-reason');
|
|
657
|
+
if(control&&supersedeFlag&&!permissions.includes('--supersede-target'))
|
|
658
|
+
stop(2,'新版重开需要 --supersede-target 文件:保存旧运行 inspect-history 返回的 supersedeTarget,不自动生成或替换');
|
|
623
659
|
if(permissions.includes('--rebind-spec-material')!==permissions.includes('--spec-rebind-reason')
|
|
624
660
|
||permissions.includes('--rebind-spec-material')&&plan.mode!=='resume')
|
|
625
661
|
stop(2,'--rebind-spec-material 只用于 mode resume,并须同时提供 --spec-rebind-reason 原因');
|
|
626
662
|
// V2 recovery operations are gated by the original expectedControl in the
|
|
627
663
|
// host, while the driver still validates the explicit operation and reason.
|
|
628
|
-
if(control&&['abandon_review','abandon_effect','bootstrap_review_recover','develop_redo'].includes(operation)
|
|
664
|
+
if(control&&['abandon_review','abandon_effect','bootstrap_review_recover','completion_rework','development_rework','revise_scope','develop_redo'].includes(operation)
|
|
629
665
|
&&(plan.mode!=='resume'||!nonempty(plan.reason)||Buffer.byteLength(plan.reason,'utf8')>500||/[\r\n\0]/.test(plan.reason)))
|
|
630
666
|
stop(2,`${operation} 需要 resume、expectedControl 与单行 reason(最多 500 UTF-8 字节)`);
|
|
631
667
|
const abandonError=control?null:abandonReviewPlanError(operation,plan,permissions);
|
|
@@ -636,6 +672,9 @@ function load(){
|
|
|
636
672
|
if(developRedoError)stop(2,developRedoError);
|
|
637
673
|
const bootstrapRecoveryError=control?null:bootstrapReviewRecoveryPlanError(operation,plan,permissions);
|
|
638
674
|
if(bootstrapRecoveryError)stop(2,bootstrapRecoveryError);
|
|
675
|
+
for(const flag of ['--expected-control','--revise-scope']){
|
|
676
|
+
const at=permissions.indexOf(flag);if(at!==-1)permissions[at+1]=path.resolve(base,permissions[at+1]);
|
|
677
|
+
}
|
|
639
678
|
const config=path.resolve(base,plan.config),answers=plan.answers?path.resolve(base,plan.answers):null;
|
|
640
679
|
if(!fs.existsSync(config))stop(2,`运行定义不存在: ${config}`);
|
|
641
680
|
let definition;
|
|
@@ -655,6 +694,7 @@ function load(){
|
|
|
655
694
|
if(plan.mode==='resume'&&!fs.existsSync(path.join(store,'state.json')))stop(2,`恢复存档不存在: ${store}`);
|
|
656
695
|
let journal=null;
|
|
657
696
|
if(plan.mode==='resume')try{journal=readRunJournal(definition);}catch(error){journal={error};}
|
|
697
|
+
if(journal?.history?.scopeRevisions)definition={...definition,scope:journal.history.effectiveScope};
|
|
658
698
|
// The run definition always says attempt 1. Package-bound operations must name
|
|
659
699
|
// the attempt the run is on now, so send that; an unreadable journal keeps the
|
|
660
700
|
// original identity and the host decides, exactly as before.
|
|
@@ -667,8 +707,8 @@ function load(){
|
|
|
667
707
|
}
|
|
668
708
|
const permissionFiles=[];
|
|
669
709
|
for(let i=0;i<permissions.length;i++)if(PAIR_FLAGS.has(permissions[i])
|
|
670
|
-
&&permissions[i]!=='--browser-qa'
|
|
671
|
-
&&permissions[i]!=='--qa-config-revision-reason'&&permissions[i]!=='--qa-environment-failure'&&permissions[i]!=='--allow-provider-development-attempt'
|
|
710
|
+
&&permissions[i]!=='--browser-qa'&&permissions[i]!=='--accept-integration-digest'
|
|
711
|
+
&&permissions[i]!=='--scope-revision-reason'&&permissions[i]!=='--development-rework-reason'&&permissions[i]!=='--qa-config-revision-reason'&&permissions[i]!=='--qa-environment-failure'&&permissions[i]!=='--allow-provider-development-attempt'
|
|
672
712
|
&&permissions[i]!=='--supersede-reason'&&permissions[i]!=='--spec-rebind-reason'&&permissions[i]!=='--input-limit'
|
|
673
713
|
&&permissions[i]!=='--review-runtime'&&permissions[i]!=='--feature'&&permissions[i]!=='--qa-fix-final-review-recovery-invocation'){
|
|
674
714
|
const file=path.resolve(base,permissions[i+1]);if(!fs.existsSync(file))stop(2,`${permissions[i]} 文件不存在: ${file}`);
|
|
@@ -686,9 +726,14 @@ function load(){
|
|
|
686
726
|
else if(!providerMode)asks.push('develop');
|
|
687
727
|
if(!protectedMode)asks.push('check');
|
|
688
728
|
}
|
|
689
|
-
|
|
729
|
+
// The gate runs only where a delivery is checked: complete re-runs the checks
|
|
730
|
+
// of an already reviewed package and never asks it.
|
|
731
|
+
if((plan.verificationPrecheck===true||permissions.includes('--verification-precheck')||control?.policy.verification==='precheck')
|
|
732
|
+
&&ADVANCE.has(operation))asks.push('verification_precheck');
|
|
690
733
|
if(operation==='complete'&&!protectedMode)asks.push('check');
|
|
691
|
-
|
|
734
|
+
// v2 没有 workflow 配置时宿主也会隐式补上 QA 判定(implicit-qa-decision.mjs)。
|
|
735
|
+
// 策略 qa:"disabled" 时宿主自己确认,不再问(host-workflow-capabilities.mjs)。
|
|
736
|
+
if((operation==='advance'||operation==='qa')&&(control||workflow?.qa)&&control?.policy.qa!=='disabled'){asks.push('qa_assess');
|
|
692
737
|
}
|
|
693
738
|
if((operation==='advance'||operation==='qa')&&workflow?.qa&&(!control||control.policy.qa==='run')){
|
|
694
739
|
try{asks.push(...predictedQaAsks(definition,workflow.qa));}
|
|
@@ -719,6 +764,9 @@ function load(){
|
|
|
719
764
|
catch(error){stop(2,error.message);}
|
|
720
765
|
const missing=asks.filter(kind=>['qa_logic','qa_browser','verification_precheck'].includes(kind)&&!live.has(kind));
|
|
721
766
|
if(missing.length)stop(2,`缺少真实执行 runner: ${missing.join(', ')};不能从静态答案文件应答`);
|
|
767
|
+
const shortWindow=qaAnswerWindowShortfall(workflow?.qa,live,asks);
|
|
768
|
+
if(shortWindow&&(plan.mode??'create')==='create')stop(2,shortWindow);
|
|
769
|
+
if(shortWindow)process.stderr.write(`[drive] 警告: ${shortWindow}\n`);
|
|
722
770
|
const executionPolicy=readLaunchExecutionPolicy({definition,mode:plan.mode??'create',enabled:permissions.includes('--execution-optimizations')});
|
|
723
771
|
if(asks.includes('check')){
|
|
724
772
|
if(!Array.isArray(plan.checks)||plan.checks.length===0)stop(2,'步骤会反问 check,但 PLAN.checks 缺少真实命令列表');
|
|
@@ -766,7 +814,7 @@ function load(){
|
|
|
766
814
|
scope:definition.scope,requirements:definition.requirements,
|
|
767
815
|
baseline:plan.mode==='create'?'disk':baselineScope(journal.baseline,definition.scope),
|
|
768
816
|
protectedMode,inputLimit:inputLimitFrom(permissions),checks:plannedCheckResults(protectedMode?null:plan.checks),
|
|
769
|
-
preview:developPreview({definition,journal:plan.mode==='create'?null:journal,
|
|
817
|
+
preview:developPreview({definition,journal:plan.mode==='create'?null:journal,controlPolicy:control?.policy??null,
|
|
770
818
|
exact:!permissions.includes('--bootstrap-config')})});
|
|
771
819
|
const unique=[...new Set(asks.filter(kind=>FILES[kind]&&kind!=='develop'))];
|
|
772
820
|
const answer=preflightAnswers(unique,kind=>{
|
|
@@ -859,7 +907,8 @@ export function buildCmAiDriveRequest(operation,plan,definition,identity=definit
|
|
|
859
907
|
return {version:Object.hasOwn(plan,'controlConfig')?2:1,identity,
|
|
860
908
|
...(Object.hasOwn(plan,'controlConfig')&&isControlRecovery(operation,plan)?{expectedControl:plan.expectedControl}:{}),
|
|
861
909
|
...(operation==='reconcile_review'?{invocationId:plan.invocationId}:{}),
|
|
862
|
-
...(
|
|
910
|
+
...(operation==='revise_scope'?{scope:plan.scope}:{}),
|
|
911
|
+
...(['abandon_review','abandon_effect','bootstrap_review_recover','completion_rework','development_rework','revise_scope','develop_redo'].includes(operation)?{reason:plan.reason}:{}),
|
|
863
912
|
...(PACKAGE_OPERATIONS.has(operation)?{packageDigest:plan.packageDigest}:{}),
|
|
864
913
|
...(TEST_RUN_OPERATIONS.has(operation)?{testRunId:plan.testRunId}:{}),
|
|
865
914
|
...(['fix_status','fix_advance','fix_action','fix_run'].includes(operation)?{
|
|
@@ -885,14 +934,21 @@ async function main(){
|
|
|
885
934
|
stop(2,`${operation} 需要 packageDigest(64 位十六进制)`);
|
|
886
935
|
if(TEST_RUN_OPERATIONS.has(operation)&&!(operation==='qa_result'?nonempty(plan.testRunId)
|
|
887
936
|
:plan.testRunId===null||nonempty(plan.testRunId)))stop(2,`${operation} 需要 testRunId(可为 null)`);
|
|
888
|
-
|
|
937
|
+
// A timed rate-limit retry (drive-core.mjs) is a decision bound to the frozen
|
|
938
|
+
// stop: the host redispatches that review only if the run is still exactly there.
|
|
939
|
+
const expected=loaded.expectedReviewStop??null;
|
|
940
|
+
const request=expected?{...buildCmAiDriveRequest('decision',plan,definition,expected.identity),
|
|
941
|
+
expectedReviewStop:{invocationId:expected.invocationId}}:buildCmAiDriveRequest(operation,plan,definition,loaded.identity);
|
|
889
942
|
if(operation.startsWith('fix_')&&(!nonempty(plan.packageDigest)||!nonempty(plan.testRunId)))
|
|
890
943
|
stop(2,`${operation} 需要 packageDigest 和 testRunId`);
|
|
891
944
|
// Rules init_verify commands really run once the host has accepted the launch
|
|
892
945
|
// (host_ready) and before the operation is sent: a failure never becomes an
|
|
893
946
|
// unknown develop effect, and the host's own launch validation came first.
|
|
947
|
+
if(plan.mode==='create')printHandoff(definition.specsDir);
|
|
894
948
|
driveHost({host:HOST,args:[...buildCmAiDriveHostArgs(plan,permissions,config,loaded.control?.file),...(loaded.holdRevision?['--hold-revision']:[])],cwd:definition.codeProject,operation,request,
|
|
895
949
|
answers:answer,paths:{answers:loaded.answers},answerFor,
|
|
950
|
+
sessionBoundary:result=>cmAiSessionBoundary(result,{specsDir:definition.specsDir,feature:definition.feature,identity:definition.identity}),
|
|
951
|
+
rateLimitRetry:rateLimitRetryEligible(operation,plan),
|
|
896
952
|
...(loaded.bootstrapRules?{beforeRequest:()=>loaded.bootstrapRules.prepare(plan.mode)}:{})});
|
|
897
953
|
}
|
|
898
954
|
if(process.argv[1]&&fs.realpathSync(process.argv[1])===fileURLToPath(import.meta.url))
|
|
@@ -191,13 +191,25 @@ test(`closeout real driver completes the original workflow with ${mode}`,t=>{
|
|
|
191
191
|
f.write('documentation-inspect.json',{status:'completed',reason:'Controlled required-document fixture',
|
|
192
192
|
...(mode==='report'?{closeout}:{})});
|
|
193
193
|
plan.permissions=['--workflow-config','workflow.json','--allow-qa',...permissions];
|
|
194
|
-
|
|
194
|
+
// A previous session's handoff is printed when this new run is created, never on resume.
|
|
195
|
+
const handoff=path.join(f.specsDir,'.reviews','session-handoff.md');
|
|
196
|
+
if(mode==='report'){fs.mkdirSync(path.dirname(handoff),{recursive:true});fs.writeFileSync(handoff,'# 交接摘要\n- previous-session-marker\n');}
|
|
197
|
+
let result,last;
|
|
195
198
|
for(let n=0;n<4;n++){
|
|
196
199
|
const out=f.drive(f.plan({...plan,...(n?{mode:'resume',originalHostContext:'drive-host-a'}:{})}),'advance');
|
|
197
|
-
assert.equal(out.status,0,out.stderr);result=JSON.parse(out.stdout).result;
|
|
200
|
+
assert.equal(out.status,0,out.stderr);result=JSON.parse(out.stdout).result;last=out;
|
|
201
|
+
if(mode==='report')assert.equal(out.stderr.includes('previous-session-marker'),n===0,out.stderr);
|
|
198
202
|
if(result.state==='run_done')break;
|
|
203
|
+
assert.doesNotMatch(out.stderr,/会话边界:换新会话。/,'no verdict before run_done');
|
|
199
204
|
}
|
|
200
205
|
assert.equal(result.state,'run_done',JSON.stringify(result));
|
|
206
|
+
// The real driver prints the session-boundary verdict itself at run_done.
|
|
207
|
+
assert.match(last.stderr,/会话边界:换新会话。\n新会话里运行:无,1\.work 的任务已全部完成/);
|
|
208
|
+
// run_done writes this run's handoff over the previous one and names it in the verdict.
|
|
209
|
+
assert.match(last.stderr,/交接摘要:\S*\/\.reviews\/session-handoff\.md(/);
|
|
210
|
+
const written=fs.readFileSync(handoff,'utf8');
|
|
211
|
+
assert.match(written,/工作流:cm-ai/);assert.match(written,/1\.work T-001:已到 run_done/);
|
|
212
|
+
assert.match(written,/## 待做\n- 无/);assert.doesNotMatch(written,/previous-session-marker/);
|
|
201
213
|
assert.equal(result.knowledgeCloseout.status,mode==='report'?'reported':mode==='off'?'disabled':'not_completed');
|
|
202
214
|
if(mode==='report')assert.deepEqual(result.knowledgeCloseout.items,closeout.items);
|
|
203
215
|
const state=JSON.parse(fs.readFileSync(f.store)),before=fs.readFileSync(path.join(f.codeProject,'target.mjs'));
|
|
@@ -449,17 +461,17 @@ test('same-session resume may omit originalHostContext and cross-session omissio
|
|
|
449
461
|
assert.equal(same.status,0,same.stderr);
|
|
450
462
|
assert.equal(JSON.parse(same.stdout).result.state,'fixture_completed');
|
|
451
463
|
const cross=f.drive(f.plan({mode:'resume',hostContext:'drive-host-b',answers:undefined,checks:undefined}),'status');
|
|
452
|
-
assert.equal(cross.status,
|
|
464
|
+
assert.equal(cross.status,71,cross.stderr);assert.match(cross.stderr,/host_exited/);assert.match(cross.stderr,/fingerprint_mismatch/);
|
|
453
465
|
assert.deepEqual(fs.readFileSync(f.store),before);
|
|
454
466
|
});
|
|
455
467
|
test('supersession flags reach create and incomplete or resume pairs stop before host launch',t=>{
|
|
456
468
|
const f=fixture(t);prepared(f);
|
|
457
469
|
const both=['--supersede-reviewed-evidence','--supersede-reason','operator restart'];
|
|
458
470
|
const create=f.drive(f.plan({permissions:both}),'advance');
|
|
459
|
-
assert.equal(create.status,
|
|
471
|
+
assert.equal(create.status,71,create.stderr);assert.match(create.stderr,/host_exited/);
|
|
460
472
|
assert.match(create.stderr,/supersede_unavailable/);
|
|
461
473
|
const accepted=f.drive(f.plan({permissions:[...both,'--accept-superseded-code-drift']}),'advance');
|
|
462
|
-
assert.equal(accepted.status,
|
|
474
|
+
assert.equal(accepted.status,71,accepted.stderr);assert.match(accepted.stderr,/host_exited/);
|
|
463
475
|
assert.match(accepted.stderr,/supersede_unavailable/);
|
|
464
476
|
for(const permissions of [['--supersede-reviewed-evidence'],['--supersede-reason','operator restart']]){
|
|
465
477
|
const refused=f.drive(f.plan({permissions}),'advance');
|
|
@@ -598,3 +610,23 @@ test('driver forwards --feature for a later approved feature and --review-runtim
|
|
|
598
610
|
const unbound=f.drive(f.plan({...bare,mode:'resume'}),'status');
|
|
599
611
|
assert.notEqual(unbound.status,0);assert.match(unbound.stdout+unbound.stderr,/fingerprint_mismatch/);
|
|
600
612
|
});
|
|
613
|
+
test('a QA answer window shorter than the live wait stops a new run and only warns on resume',t=>{
|
|
614
|
+
const f=fixture(t);prepared(f);
|
|
615
|
+
const file=qaFixture(f,[{kind:'browser',expected:'Browser evidence'}]);
|
|
616
|
+
const withLive=extra=>{const plan={...JSON.parse(fs.readFileSync(file,'utf8')),
|
|
617
|
+
liveEvidence:{directory:'../exchange',kinds:['qa_browser'],timeoutMs:900000},...extra};
|
|
618
|
+
const target=path.join(f.root,`plan-${Math.random().toString(36).slice(2)}.json`);fs.writeFileSync(target,JSON.stringify(plan));return target;};
|
|
619
|
+
const refused=f.drive(withLive(),'advance');
|
|
620
|
+
assert.equal(refused.status,2,refused.stderr);
|
|
621
|
+
assert.match(refused.stderr,/qa\.timeoutMs 未填(默认 60000) 毫秒,短于 PLAN\.liveEvidence 对 qa_browser 的等待 900000 毫秒/);
|
|
622
|
+
assert.equal(fs.existsSync(f.store),false);
|
|
623
|
+
// A window that covers the wait launches as before (nobody answers: the case times out at once).
|
|
624
|
+
const workflow=JSON.parse(fs.readFileSync(path.join(f.root,'workflow.json'),'utf8'));
|
|
625
|
+
fs.writeFileSync(path.join(f.root,'workflow.json'),JSON.stringify({...workflow,qa:{...workflow.qa,timeoutMs:1000}}));
|
|
626
|
+
const created=f.drive(withLive({liveEvidence:{directory:'../exchange',kinds:['qa_browser'],timeoutMs:1000}}),'advance');
|
|
627
|
+
assert.doesNotMatch(created.stderr,/qa\.timeoutMs/);assert(fs.existsSync(f.store),created.stderr);
|
|
628
|
+
// The recorded run resumes with the shorter window; the driver only warns.
|
|
629
|
+
const resumed=f.drive(withLive({mode:'resume'}),'advance');
|
|
630
|
+
assert.match(resumed.stderr,/\[drive\] 警告: workflow 的 qa\.timeoutMs 为 1000 毫秒,短于 PLAN\.liveEvidence 对 qa_browser 的等待 900000 毫秒/);
|
|
631
|
+
assert.doesNotMatch(resumed.stderr,/^\[drive\] 停止|invalid_arguments/m);
|
|
632
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Every create probes the legacy shared writer (.reviews/.execution/writer.sqlite).
|
|
2
|
+
// Two creates started together in different processes used to fail one of them
|
|
3
|
+
// with store_busy. A briefly held legacy lock is now waited out; one that stays
|
|
4
|
+
// held still refuses, and that refused create leaves nothing behind.
|
|
5
|
+
import test from 'node:test';
|
|
6
|
+
import assert from 'node:assert/strict';
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import os from 'node:os';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import {spawn} from 'node:child_process';
|
|
11
|
+
import {openExecutionStore,LEGACY_PROBE_ATTEMPTS,LEGACY_PROBE_DELAY_MS} from '../runtime/js/cm-ai/execution-store.mjs';
|
|
12
|
+
|
|
13
|
+
const hash=char=>char.repeat(64);
|
|
14
|
+
const fingerprints={workflow:hash('a'),config:hash('b'),inputs:hash('c')};
|
|
15
|
+
|
|
16
|
+
function legacyRoot(t){
|
|
17
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-legacy-probe-')));
|
|
18
|
+
// One cleanup, in order: every lock holder has exited before the root is removed.
|
|
19
|
+
const holders=[];
|
|
20
|
+
t.after(async()=>{
|
|
21
|
+
for(const child of holders)if(child.exitCode===null&&child.signalCode===null){
|
|
22
|
+
const gone=new Promise(resolve=>child.once('exit',resolve));child.kill();await gone;
|
|
23
|
+
}
|
|
24
|
+
fs.rmSync(root,{recursive:true,force:true});
|
|
25
|
+
});
|
|
26
|
+
// A real store built by the current protocol, then placed where the legacy shared writer lives.
|
|
27
|
+
const seed=openExecutionStore({specsRoot:root,identity:{repositoryId:'probe',runId:'seed-run-0001'},fingerprints,create:true});
|
|
28
|
+
seed.close();
|
|
29
|
+
const execution=path.join(root,'.reviews','.execution'),seedDir=path.join(execution,'seed-run-0001');
|
|
30
|
+
for(const name of ['writer.sqlite','writer-ready.json'])fs.copyFileSync(path.join(seedDir,name),path.join(execution,name));
|
|
31
|
+
return {root,legacy:path.join(execution,'writer.sqlite'),execution,holders};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Another process holds the legacy writer's write lock for holdMs, as a concurrent
|
|
35
|
+
// create's probe does; resolves once the lock is actually held.
|
|
36
|
+
function holdLegacy(f,holdMs){
|
|
37
|
+
const legacy=f.legacy;
|
|
38
|
+
const child=spawn(process.execPath,['--no-warnings','-e',`
|
|
39
|
+
const {DatabaseSync}=require('node:sqlite');
|
|
40
|
+
const db=new DatabaseSync(process.argv[1],{timeout:0});
|
|
41
|
+
db.exec('BEGIN IMMEDIATE');process.stdout.write('held\\n');
|
|
42
|
+
setTimeout(()=>{db.exec('ROLLBACK');db.close();process.stdout.write('released\\n');},Number(process.argv[2]));
|
|
43
|
+
`,legacy,String(holdMs)],{stdio:['ignore','pipe','inherit']});
|
|
44
|
+
f.holders.push(child);
|
|
45
|
+
let output='';
|
|
46
|
+
const held=new Promise((resolve,reject)=>{
|
|
47
|
+
child.stdout.on('data',chunk=>{output+=chunk;if(output.includes('held'))resolve();});
|
|
48
|
+
child.on('exit',code=>{if(!output.includes('held'))reject(new Error(`holder exited ${code}`));});
|
|
49
|
+
});
|
|
50
|
+
const exited=new Promise(resolve=>child.on('exit',()=>resolve(output)));
|
|
51
|
+
return {held,exited};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
test('a create waits out a legacy writer lock that another process holds briefly',async t=>{
|
|
55
|
+
const f=legacyRoot(t);
|
|
56
|
+
const holdMs=Math.floor(LEGACY_PROBE_ATTEMPTS*LEGACY_PROBE_DELAY_MS/4);
|
|
57
|
+
const holder=holdLegacy(f,holdMs);await holder.held;
|
|
58
|
+
const store=openExecutionStore({specsRoot:f.root,identity:{repositoryId:'probe',runId:'new-run-0001'},fingerprints,create:true});
|
|
59
|
+
store.close();
|
|
60
|
+
assert(fs.existsSync(path.join(f.execution,'new-run-0001','writer.sqlite')));
|
|
61
|
+
assert.match(await holder.exited,/released/);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('a legacy writer lock held past the retry budget still refuses with store_busy and creates nothing',async t=>{
|
|
65
|
+
const f=legacyRoot(t);
|
|
66
|
+
const holder=holdLegacy(f,LEGACY_PROBE_ATTEMPTS*LEGACY_PROBE_DELAY_MS*4);await holder.held;
|
|
67
|
+
const started=Date.now();
|
|
68
|
+
assert.throws(()=>openExecutionStore({specsRoot:f.root,identity:{repositoryId:'probe',runId:'new-run-0002'},fingerprints,create:true}),
|
|
69
|
+
error=>error.code==='store_busy');
|
|
70
|
+
// It retried for roughly its budget instead of failing on the first contention.
|
|
71
|
+
assert(Date.now()-started>=(LEGACY_PROBE_ATTEMPTS-1)*LEGACY_PROBE_DELAY_MS*0.8);
|
|
72
|
+
assert.equal(fs.existsSync(path.join(f.execution,'new-run-0002')),false);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('an unreadable legacy writer is not retried and refuses at once',t=>{
|
|
76
|
+
const f=legacyRoot(t);
|
|
77
|
+
fs.writeFileSync(f.legacy,'not a sqlite database');
|
|
78
|
+
const started=Date.now();
|
|
79
|
+
assert.throws(()=>openExecutionStore({specsRoot:f.root,identity:{repositoryId:'probe',runId:'new-run-0003'},fingerprints,create:true}),
|
|
80
|
+
error=>error.code==='store_busy');
|
|
81
|
+
// Not retried: well under half of the full retry budget, with room for slow disks.
|
|
82
|
+
assert(Date.now()-started<LEGACY_PROBE_ATTEMPTS*LEGACY_PROBE_DELAY_MS/2);
|
|
83
|
+
assert.equal(fs.existsSync(path.join(f.execution,'new-run-0003')),false);
|
|
84
|
+
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {hostDiagnostic} from './fixtures/host-diagnostic.mjs';
|
|
1
2
|
// Shared real-host fixture for the cm-ai-host*.test.mjs files (the Codex-sandbox
|
|
2
3
|
// set that CI cannot host). Importing it isolates CM_WORKFLOW_HOME/LOG_HOME for the
|
|
3
4
|
// importing test file and sweeps every fixture root for leaked processes when that
|
|
@@ -81,6 +82,8 @@ export function runCli(f,mode,action='create'){
|
|
|
81
82
|
const args=[...launchArgs(f)];args[4]=action;
|
|
82
83
|
const child=spawn(process.execPath,[cli,...args],{stdio:['pipe','pipe','pipe'],env:f.env??process.env});
|
|
83
84
|
let buffer='',stderr='',closed=false,sessionId;const rows=[],calls=[];
|
|
85
|
+
const timeoutMs=Number(process.env.CM_TEST_FIXTURE_TIMEOUT_MS??60000);
|
|
86
|
+
const trace=hostDiagnostic(child,{timeoutMs:f.watchdog?null:timeoutMs});
|
|
84
87
|
// Provider children run in their own process groups: stopping only the host
|
|
85
88
|
// would orphan a hung fake reviewer, so failure and watchdog paths stop the
|
|
86
89
|
// whole fixture tree. f.watchdog(expire) may replace the timer; it returns a disarm function.
|
|
@@ -88,13 +91,13 @@ export function runCli(f,mode,action='create'){
|
|
|
88
91
|
const fail=error=>{
|
|
89
92
|
disarm();child.kill('SIGKILL');
|
|
90
93
|
try{killFixtureProcesses(f.root);}catch(cleanup){error=new AggregateError([error,cleanup],String(error?.message??error));}
|
|
91
|
-
reject(error);
|
|
94
|
+
reject(trace.attach(error));
|
|
92
95
|
};
|
|
93
|
-
disarm=(f.watchdog??(expire=>{const timer=setTimeout(expire,
|
|
96
|
+
disarm=(f.watchdog??(expire=>{const timer=setTimeout(expire,timeoutMs);
|
|
94
97
|
return ()=>clearTimeout(timer);}))(()=>fail(new Error('host fixture timed out')));
|
|
95
98
|
child.stderr.on('data',chunk=>{stderr+=chunk;});
|
|
96
|
-
child.once('error',reject);
|
|
97
|
-
const send=value=>child.stdin.write(JSON.stringify(value)+'\n');
|
|
99
|
+
child.once('error',error=>reject(trace.attach(error)));
|
|
100
|
+
const send=value=>{trace.send(value);child.stdin.write(JSON.stringify(value)+'\n');};
|
|
98
101
|
const response=(row,result)=>({type:'host_result',sessionId:row.sessionId,callId:row.callId,requestDigest:row.requestDigest,result});
|
|
99
102
|
child.stdout.on('data',chunk=>{
|
|
100
103
|
buffer+=chunk;
|
|
@@ -103,7 +106,7 @@ export function runCli(f,mode,action='create'){
|
|
|
103
106
|
const line=buffer.slice(0,newline);buffer=buffer.slice(newline+1);
|
|
104
107
|
if(!line)continue;
|
|
105
108
|
try{
|
|
106
|
-
const row=JSON.parse(line);rows.push(row);
|
|
109
|
+
const row=JSON.parse(line);rows.push(row);trace.receive(row);
|
|
107
110
|
if(row.type==='host_ready')sessionId=row.sessionId;
|
|
108
111
|
if(row.type==='host_request'){
|
|
109
112
|
calls.push(row.kind);
|
|
@@ -181,7 +184,7 @@ export function runCli(f,mode,action='create'){
|
|
|
181
184
|
}catch(error){fail(error);return;}
|
|
182
185
|
}
|
|
183
186
|
});
|
|
184
|
-
child.once('close',code=>{disarm();resolve({code,stderr,rows,calls});});
|
|
187
|
+
child.once('close',code=>{disarm();resolve({code,stderr,rows,calls,diagnostic:trace.snapshot()});});
|
|
185
188
|
send(f.request??{...request(f.operation??'advance'),requestId:'advance'});
|
|
186
189
|
});
|
|
187
190
|
}
|
|
@@ -27,7 +27,7 @@ for(const [available,coder,reviewer,runtime] of [
|
|
|
27
27
|
assert(!fs.existsSync(path.join(f.codeProject,'target.mjs')));assert(!fs.existsSync(path.join(f.specsDir,'.reviews')));
|
|
28
28
|
f.args.push('--allow-provider-development-attempt','1');
|
|
29
29
|
const first=await runCli(f,'normal');assert.equal(first.code,0,first.stderr);
|
|
30
|
-
assert.equal(first.rows.find(row=>row.requestId==='advance').result.code,null);assert.deepEqual(first.calls,[]);
|
|
30
|
+
assert.equal(first.rows.find(row=>row.requestId==='advance').result.code,null,JSON.stringify(first.diagnostic));assert.deepEqual(first.calls,[]);
|
|
31
31
|
assert.equal(fs.readFileSync(path.join(f.codeProject,'target.mjs'),'utf8'),'export const value = 42;\n');
|
|
32
32
|
const readRoutes=()=>fs.readFileSync(path.join(f.specsDir,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse)
|
|
33
33
|
.filter(row=>row.phase==='route'&&row.event==='decision');
|