@aibyzero/cm-workflow 0.17.1 → 0.19.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 +23 -0
- package/CHANGELOG.md +242 -0
- package/README.md +20 -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 +11 -0
- package/docs/cm-control-policy-v2.md +127 -9
- package/docs/installation.md +310 -4
- package/docs/js-workflow-control.md +150 -15
- 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/autonomy.mjs +152 -0
- 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 +83 -14
- package/runtime/js/cm-ai/claude-tool-preview.mjs +11 -9
- package/runtime/js/cm-ai/cm-ai-admission.mjs +56 -17
- 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 +21 -4
- package/runtime/js/cm-ai/developer-adapter.mjs +19 -5
- package/runtime/js/cm-ai/drive-core.mjs +115 -11
- 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 +11 -5
- 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 +1 -1
- 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 +9 -2
- 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 +242 -39
- 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 +11 -5
- 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 +581 -65
- 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 +5 -4
- 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 +3 -2
- package/runtime/test-contract.md +1 -0
- package/scripts/ci-test-weights.json +3 -0
- package/scripts/cm-ai-admission.mjs +21 -7
- package/scripts/cm-ai-admission.test.mjs +171 -3
- 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 +6 -5
- 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 +471 -57
- 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 +14 -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.mjs +73 -17
- package/scripts/cm-ai-drive.test.mjs +34 -2
- package/scripts/cm-ai-execution-store-legacy-probe.test.mjs +84 -0
- package/scripts/cm-ai-host.mjs +60 -19
- 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 +16 -1
- 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-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-autonomy.mjs +94 -0
- package/scripts/cm-autonomy.test.mjs +162 -0
- package/scripts/cm-challenge.test.mjs +61 -0
- package/scripts/cm-check-drive-files.mjs +1 -1
- package/scripts/cm-check-runtime.sh +60 -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-review-diagnostics.test.mjs +235 -0
- package/scripts/cm-claude-review-stream.test.mjs +13 -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-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 +4 -3
- 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-qa-executor.test.mjs +77 -0
- package/scripts/cm-host-replay.test.mjs +176 -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 +581 -59
- 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 +45 -1
- 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 +1 -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-summary.test.mjs +24 -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 +1 -1
- 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 +323 -0
- package/scripts/cm-start-check.test.mjs +406 -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-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/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 +4 -0
- package/scripts/validate-test-cases.mjs +3 -2
- package/skills/cm-ai/SKILL.md +5 -2
- package/skills/cm-ai/references/N3-execute-task.md +1 -1
- 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 +82 -16
- 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 +14 -9
- package/skills/cm-prd/references/brownfield.md +8 -1
- package/skills/cm-prd/references/change-mode.md +8 -1
- package/skills/cm-prd/references/greenfield.md +4 -0
- package/skills/cm-prd/references/js-change-recovery.md +14 -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/runtime/test-contract.md
CHANGED
|
@@ -112,6 +112,7 @@ API、广告/支付测试环境和真机差异。`kind: "browser"` 在此表示
|
|
|
112
112
|
|
|
113
113
|
- 每条 AC 至少映射一个用例;无法验证的 AC 仍生成 blocking 用例并写清阻塞前提。
|
|
114
114
|
- 每个 `taskIds`、`acIds` 都能在同 feature 三件套中找到。
|
|
115
|
+
- `expected` 依赖二开防护网基线的用例(如「用例数不少于基线」),`taskIds` 含首个改代码任务,文字锚点写「首个改代码任务的宿主重放基线」,不再指向单列的基线任务(见 `skills/cm-prd/references/brownfield.md` B3)。
|
|
115
116
|
- 根字段、case 必需字段、类型、枚举和唯一 ID 全部符合结构合同。
|
|
116
117
|
- browser 用例的每个关键动作都有对应 expected。
|
|
117
118
|
- 有副作用的用例包含 cleanup;无法安全清理时标为执行阻塞,不得对生产环境试跑。
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"cm-claude-worker.test.mjs": 14,
|
|
71
71
|
"cm-codex-developer-adapter.test.mjs": 1,
|
|
72
72
|
"cm-codex-developer-worker.test.mjs": 14,
|
|
73
|
+
"cm-codex-install-local-edit-guard.test.mjs": 540,
|
|
73
74
|
"cm-codex-plugin-metadata.test.mjs": 1,
|
|
74
75
|
"cm-codex-review-progress.test.mjs": 4,
|
|
75
76
|
"cm-efficiency-checks.test.mjs": 1,
|
|
@@ -154,6 +155,7 @@
|
|
|
154
155
|
"cm-init-project-scan.test.mjs": 1,
|
|
155
156
|
"cm-init-revision-host.test.mjs": 1,
|
|
156
157
|
"cm-init-session.test.mjs": 4,
|
|
158
|
+
"cm-install-local-edit-guard.test.mjs": 890,
|
|
157
159
|
"cm-interactive-qa-diagnostic.test.mjs": 1,
|
|
158
160
|
"cm-knowledge-closeout.test.mjs": 6,
|
|
159
161
|
"cm-live-evidence.test.mjs": 1,
|
|
@@ -217,6 +219,7 @@
|
|
|
217
219
|
"cm-workflow.test.mjs": 1,
|
|
218
220
|
"correction-check.test.mjs": 1,
|
|
219
221
|
"policy-binding-compat.test.mjs": 2,
|
|
222
|
+
"session-boundary.test.mjs": 1,
|
|
220
223
|
"validate-test-cases.test.mjs": 1
|
|
221
224
|
}
|
|
222
225
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// Product CLI for cm-ai N1/N2 inspection and explicit human approval.
|
|
3
3
|
import fs from 'node:fs';
|
|
4
|
+
import {declaredTaskScope,sameScope} from '../runtime/js/task-scope.mjs';
|
|
4
5
|
import path from 'node:path';
|
|
5
6
|
import {fileURLToPath} from 'node:url';
|
|
6
7
|
import {inspectCmAiAdmission,approveCmAiSpecs,matchesCmAiTaskSelection,explainCmAiTaskSelection} from '../runtime/js/cm-ai/cm-ai-admission.mjs';
|
|
7
8
|
import {validateRunDefinition} from './cm-ai-run.mjs';
|
|
8
9
|
|
|
9
|
-
const usage='usage: cm-ai-admission.mjs --specs-dir PATH --code-project PATH [--code-project PATH ...] [--approval-response TEXT | --yes] [--approve --approval-response TEXT (no --yes)] [--feature N.slug] [--print-run-definition --scope a,b [--task T-xxx] [--requirements c,d] [--run-id X] [--repository-id Y]]';
|
|
10
|
+
const usage='usage: cm-ai-admission.mjs --specs-dir PATH --code-project PATH [--code-project PATH ...] [--approval-response TEXT | --yes] [--approve (--approval-response TEXT | --standing-authorization) (no --yes) [--expect-revision-digest HEX]] [--feature N.slug] [--print-run-definition --scope a,b [--task T-xxx] [--requirements c,d] [--run-id X] [--repository-id Y]]';
|
|
10
11
|
|
|
11
12
|
function parse(argv){
|
|
12
13
|
const result={codeProjects:[]};
|
|
@@ -17,6 +18,10 @@ function parse(argv){
|
|
|
17
18
|
if(result.approve)throw new Error('invalid arguments');
|
|
18
19
|
result.approve=true;continue;
|
|
19
20
|
}
|
|
21
|
+
if(flag==='--standing-authorization'){
|
|
22
|
+
if(result.standingAuthorization)throw new Error('invalid arguments');
|
|
23
|
+
result.standingAuthorization=true;continue;
|
|
24
|
+
}
|
|
20
25
|
if(flag==='--print-run-definition'){
|
|
21
26
|
if(result.printRunDefinition)throw new Error('invalid arguments');
|
|
22
27
|
result.printRunDefinition=true;continue;
|
|
@@ -26,13 +31,17 @@ function parse(argv){
|
|
|
26
31
|
if(index+1>=argv.length||result.codeProjects.length>=16)throw new Error('invalid arguments');
|
|
27
32
|
result.codeProjects.push(argv[++index]);continue;
|
|
28
33
|
}
|
|
29
|
-
const key={'--specs-dir':'specsDir','--approval-response':'approvalResponse','--feature':'feature',
|
|
34
|
+
const key={'--specs-dir':'specsDir','--approval-response':'approvalResponse','--expect-revision-digest':'expectRevisionDigest','--feature':'feature',
|
|
30
35
|
'--scope':'scope','--task':'task','--requirements':'requirements','--run-id':'runId','--repository-id':'repositoryId'}[flag];
|
|
31
36
|
if(!key||index+1>=argv.length||Object.hasOwn(result,key))throw new Error('invalid arguments');
|
|
32
37
|
result[key]=argv[++index];
|
|
33
38
|
}
|
|
34
39
|
if(!result.specsDir||result.codeProjects.length===0)throw new Error('specs and code project paths are required');
|
|
35
40
|
if(result.assumeYes&&Object.hasOwn(result,'approvalResponse'))throw new Error('approval input is duplicated');
|
|
41
|
+
if(Object.hasOwn(result,'expectRevisionDigest')&&(!result.approve||!/^[0-9a-f]{64}$/.test(result.expectRevisionDigest)))
|
|
42
|
+
throw new Error('--expect-revision-digest requires --approve and a 64-character lowercase hex digest');
|
|
43
|
+
if(result.standingAuthorization&&(!result.approve||!Object.hasOwn(result,'expectRevisionDigest')||result.assumeYes||Object.hasOwn(result,'approvalResponse')))
|
|
44
|
+
throw new Error('--standing-authorization requires --approve and --expect-revision-digest, without --approval-response or --yes');
|
|
36
45
|
if(!result.printRunDefinition&&['scope','task','requirements','runId','repositoryId'].some(key=>Object.hasOwn(result,key)))
|
|
37
46
|
throw new Error('run definition options require --print-run-definition');
|
|
38
47
|
return result;
|
|
@@ -56,11 +65,20 @@ function buildRunDefinition(admission,input){
|
|
|
56
65
|
repositoryId=name??path.basename(admission.codeProject);
|
|
57
66
|
}
|
|
58
67
|
const list=value=>value===undefined||value===''?[]:value.split(',').map(item=>item.trim());
|
|
68
|
+
// tasks.md is the authority once it declares the task's files; a session-supplied
|
|
69
|
+
// --scope must then match it exactly. Without a declaration --scope stays required.
|
|
70
|
+
const declared=declaredTaskScope(admission.specsDir,selected.feature,selected.id);
|
|
71
|
+
if(declared&&Object.hasOwn(input,'scope')&&!sameScope(declared.scope,list(input.scope)))
|
|
72
|
+
throw Object.assign(new Error('task_scope_mismatch'),{code:'task_scope_mismatch',
|
|
73
|
+
reason:`tasks.md 为 ${selected.id} 写的范围是 ${declared.scope.join(', ')};--scope 给的是 ${list(input.scope).join(', ')}。去掉 --scope 即按 tasks.md`});
|
|
74
|
+
if(!declared&&!Object.hasOwn(input,'scope'))
|
|
75
|
+
throw Object.assign(new Error('scope_required'),{code:'scope_required',
|
|
76
|
+
reason:'tasks.md 没有为该任务写范围,--print-run-definition 需要 --scope:本任务允许修改的文件,相对代码根,逗号分隔(例:--scope src/todos.js,test/todos.test.js)'});
|
|
59
77
|
const definition={version:1,specsDir:admission.specsDir,codeProject:admission.codeProject,
|
|
60
78
|
feature:selected.feature,
|
|
61
79
|
identity:{repositoryId,runId:input.runId??`${selected.feature.replace(/^\d+\./,'')}-${selected.id}`,
|
|
62
80
|
taskId:selected.id,attempt:1},
|
|
63
|
-
scope:list(input.scope),requirements:list(input.requirements),
|
|
81
|
+
scope:declared?[...declared.scope]:list(input.scope),requirements:list(input.requirements),
|
|
64
82
|
...(input.task===undefined?{}:{taskSelection:{version:1,taskId:selected.id}}),
|
|
65
83
|
...(input.feature===undefined?{}:{featureSelection:{version:1,feature:input.feature}})};
|
|
66
84
|
return validateRunDefinition(definition);
|
|
@@ -70,10 +88,6 @@ export function main(argv=process.argv.slice(2)){
|
|
|
70
88
|
let input;
|
|
71
89
|
try{input=parse(argv);}catch(error){process.stderr.write(`${usage}\nERROR: ${error.message}\n`);return 2;}
|
|
72
90
|
if(input.help){process.stdout.write(`${usage}\n`);return 0;}
|
|
73
|
-
if(input.printRunDefinition&&!Object.hasOwn(input,'scope')){
|
|
74
|
-
process.stderr.write('--print-run-definition 需要 --scope:本任务允许修改的文件,相对代码根,逗号分隔(例:--scope src/todos.js,test/todos.test.js)\n');
|
|
75
|
-
return 2;
|
|
76
|
-
}
|
|
77
91
|
const approval=input.approve?approveCmAiSpecs(input):null;
|
|
78
92
|
const projectResults=approval?.projectResults??input.codeProjects.map(codeProject=>inspectCmAiAdmission({...input,codeProject}));
|
|
79
93
|
const firstBlocked=projectResults.find(item=>item.state==='blocked');
|
|
@@ -5,8 +5,9 @@ import os from 'node:os';
|
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import {spawnSync} from 'node:child_process';
|
|
7
7
|
import {fileURLToPath} from 'node:url';
|
|
8
|
-
import {parseFeatureTaskText,validDependencies,identifyApprovedBootstrapFeature} from '../runtime/js/cm-ai/cm-ai-admission.mjs';
|
|
8
|
+
import {parseFeatureTaskText,validDependencies,identifyApprovedBootstrapFeature,approveCmAiSpecs} from '../runtime/js/cm-ai/cm-ai-admission.mjs';
|
|
9
9
|
import {validateRunDefinition} from './cm-ai-run.mjs';
|
|
10
|
+
import {buildManifest} from './cm-spec-manifest.mjs';
|
|
10
11
|
|
|
11
12
|
const entry=fileURLToPath(new URL('./cm-ai-admission.mjs',import.meta.url));
|
|
12
13
|
function fixture(run){
|
|
@@ -69,6 +70,152 @@ test('approve writes only after a whitelisted reply and preserves the original r
|
|
|
69
70
|
assert.equal(JSON.parse(fs.readFileSync(status,'utf8')).approval.response,'开始吧!');
|
|
70
71
|
}));
|
|
71
72
|
|
|
73
|
+
test('approve bound to a change proposal writes only for that saved proposal and its unchanged bytes',()=>fixture(({specs,code})=>{
|
|
74
|
+
const status=path.join(specs,'.cm-specs-status'),digest='a'.repeat(64),other='b'.repeat(64);
|
|
75
|
+
const saved=()=>fs.writeFileSync(status,JSON.stringify({status:'awaiting_review',revisionDigest:digest,
|
|
76
|
+
features:['1.login'],specFiles:buildManifest(specs),testCases:[]}));
|
|
77
|
+
const invoke=(...extra)=>spawnSync(process.execPath,[entry,'--specs-dir',specs,'--code-project',code,
|
|
78
|
+
'--approve','--approval-response','开始',...extra],{encoding:'utf8'});
|
|
79
|
+
const refused=(result,reason)=>{assert.equal(result.status,1,result.stderr);assert.equal(JSON.parse(result.stdout).approveRefused,reason);};
|
|
80
|
+
saved();const before=fs.readFileSync(status);
|
|
81
|
+
refused(invoke('--expect-revision-digest',other),'revision_digest_mismatch');
|
|
82
|
+
assert.deepEqual(fs.readFileSync(status),before);
|
|
83
|
+
// Bytes edited after the save are not the proposal the user confirmed.
|
|
84
|
+
fs.appendFileSync(path.join(specs,'1.login','tasks.md'),'- [ ] T-002: unreviewed\n');
|
|
85
|
+
refused(invoke('--expect-revision-digest',digest),'revision_files_changed');
|
|
86
|
+
assert.deepEqual(fs.readFileSync(status),before);
|
|
87
|
+
fs.writeFileSync(path.join(specs,'1.login','tasks.md'),'- [ ] T-001: implement login\n');
|
|
88
|
+
// An unbound status (no revisionDigest) is refused rather than approved under the flag.
|
|
89
|
+
fs.writeFileSync(status,JSON.stringify({status:'awaiting_review',features:['1.login'],specFiles:buildManifest(specs),testCases:[]}));
|
|
90
|
+
refused(invoke('--expect-revision-digest',digest),'revision_digest_mismatch');
|
|
91
|
+
// An approved status that only reopened because the feature list changed is not this proposal's save.
|
|
92
|
+
fs.writeFileSync(status,JSON.stringify({status:'approved',revisionDigest:digest,features:['0.old'],
|
|
93
|
+
specFiles:buildManifest(specs),testCases:[]}));
|
|
94
|
+
refused(invoke('--expect-revision-digest',digest),'revision_digest_mismatch');
|
|
95
|
+
saved();
|
|
96
|
+
const accepted=invoke('--expect-revision-digest',digest);
|
|
97
|
+
assert.equal(accepted.status,0,`stdout: ${accepted.stdout}\nstderr: ${accepted.stderr}`);
|
|
98
|
+
assert.equal(JSON.parse(accepted.stdout).state,'ready');
|
|
99
|
+
const approved=JSON.parse(fs.readFileSync(status,'utf8'));
|
|
100
|
+
assert.equal(approved.status,'approved');assert.equal(approved.revisionDigest,digest);assert.equal(approved.approval.response,'开始');
|
|
101
|
+
// Already approved: the same reply cannot approve again or rewrite the record.
|
|
102
|
+
const once=fs.readFileSync(status),again=invoke('--expect-revision-digest',digest);
|
|
103
|
+
assert.equal(again.status,1);assert.ok(JSON.parse(again.stdout).approveRefused);assert.deepEqual(fs.readFileSync(status),once);
|
|
104
|
+
// The flag only binds an explicit approval; it never stands alone or takes a malformed digest.
|
|
105
|
+
for(const args of [['--expect-revision-digest',digest],['--approve','--approval-response','开始','--expect-revision-digest','ABC']]){
|
|
106
|
+
const result=spawnSync(process.execPath,[entry,'--specs-dir',specs,'--code-project',code,...args],{encoding:'utf8'});
|
|
107
|
+
assert.equal(result.status,2);assert.match(result.stderr,/--expect-revision-digest requires --approve/);
|
|
108
|
+
}
|
|
109
|
+
}));
|
|
110
|
+
|
|
111
|
+
test('bound approve refuses changes made after its first check, before the approval is written',()=>fixture(({specs,code})=>{
|
|
112
|
+
const status=path.join(specs,'.cm-specs-status'),digest='a'.repeat(64);
|
|
113
|
+
const saved=(revision=digest)=>JSON.stringify({status:'awaiting_review',revisionDigest:revision,
|
|
114
|
+
features:['1.login'],specFiles:buildManifest(specs),testCases:[]});
|
|
115
|
+
const approve=beforeApprovalWrite=>approveCmAiSpecs({specsDir:specs,codeProjects:[code],approvalResponse:'开始',
|
|
116
|
+
expectRevisionDigest:digest,beforeApprovalWrite});
|
|
117
|
+
const requirements=path.join(specs,'1.login','requirements.md'),original=fs.readFileSync(requirements);
|
|
118
|
+
const interleavings={
|
|
119
|
+
'spec edited':()=>fs.appendFileSync(requirements,'unreviewed\n'),
|
|
120
|
+
'another proposal saved':()=>fs.writeFileSync(status,saved('b'.repeat(64))),
|
|
121
|
+
'duplicate approval landed':()=>assert.equal(approve().approveRefused,undefined)};
|
|
122
|
+
for(const [name,interleave] of Object.entries(interleavings)){
|
|
123
|
+
fs.writeFileSync(requirements,original);fs.writeFileSync(status,saved());
|
|
124
|
+
let after;
|
|
125
|
+
const result=approve(()=>{interleave();after=fs.readFileSync(status);});
|
|
126
|
+
assert.equal(result.approveRefused,'revision_changed_during_approval',name);
|
|
127
|
+
// The late writer never replaces what the interleaved writer left.
|
|
128
|
+
assert.deepEqual(fs.readFileSync(status),after,name);
|
|
129
|
+
assert.equal(fs.readdirSync(specs).filter(file=>file.startsWith('.cm-specs-status-')).length,0,name);
|
|
130
|
+
}
|
|
131
|
+
// Undisturbed, it approves with the manifest that was checked.
|
|
132
|
+
fs.writeFileSync(requirements,original);fs.writeFileSync(status,saved());
|
|
133
|
+
const checked=JSON.parse(fs.readFileSync(status,'utf8')).specFiles;
|
|
134
|
+
assert.equal(approve().approveRefused,undefined);
|
|
135
|
+
assert.deepEqual(JSON.parse(fs.readFileSync(status,'utf8')).specFiles,checked);
|
|
136
|
+
}));
|
|
137
|
+
|
|
138
|
+
test('bound approve compares against the exact status bytes it validated',()=>fixture(({specs,code})=>{
|
|
139
|
+
const status=path.join(specs,'.cm-specs-status'),digest='a'.repeat(64);
|
|
140
|
+
const saved=revision=>JSON.stringify({status:'awaiting_review',revisionDigest:revision,
|
|
141
|
+
features:['1.login'],specFiles:buildManifest(specs),testCases:[]});
|
|
142
|
+
const approve=()=>approveCmAiSpecs({specsDir:specs,codeProjects:[code],approvalResponse:'开始',expectRevisionDigest:digest});
|
|
143
|
+
// Swap the status right after the bound check has parsed it (its first read of
|
|
144
|
+
// the status in the approval), before anything else of the approval runs.
|
|
145
|
+
const swapped={'another proposal saved':()=>fs.writeFileSync(status,saved('b'.repeat(64))),
|
|
146
|
+
'duplicate approval landed':()=>assert.equal(approve().approveRefused,undefined)};
|
|
147
|
+
const read=fs.readFileSync;
|
|
148
|
+
for(const [name,swap] of Object.entries(swapped)){
|
|
149
|
+
fs.writeFileSync(status,saved(digest));
|
|
150
|
+
let reads=0,armed=true,after;
|
|
151
|
+
fs.readFileSync=function(file,...rest){
|
|
152
|
+
const result=read.call(this,file,...rest);
|
|
153
|
+
// The inspections before the approval read the status too; count from the approval's own read.
|
|
154
|
+
if(armed&&String(file).endsWith('.cm-specs-status')&&++reads===2){armed=false;swap();after=read(status);}
|
|
155
|
+
return result;
|
|
156
|
+
};
|
|
157
|
+
let result;
|
|
158
|
+
try{result=approveCmAiSpecs({specsDir:specs,codeProjects:[code],approvalResponse:'开始',expectRevisionDigest:digest});}
|
|
159
|
+
finally{fs.readFileSync=read;}
|
|
160
|
+
assert.equal(armed,false,name);
|
|
161
|
+
assert.equal(result.approveRefused,'revision_changed_during_approval',name);
|
|
162
|
+
assert.deepEqual(read(status),after,name);
|
|
163
|
+
}
|
|
164
|
+
}));
|
|
165
|
+
|
|
166
|
+
test('standing authorization approves a bound scope-only change and nothing else',()=>fixture(({root,specs,code})=>{
|
|
167
|
+
const status=path.join(specs,'.cm-specs-status'),digest='c'.repeat(64),home=path.join(root,'cm-home');
|
|
168
|
+
fs.mkdirSync(home);
|
|
169
|
+
const env={...process.env,CM_WORKFLOW_HOME:home};
|
|
170
|
+
const read=name=>fs.readFileSync(path.join(specs,'1.login',name),'utf8');
|
|
171
|
+
const requirements=read('requirements.md'),design=read('design.md');
|
|
172
|
+
const archive=(over={})=>{fs.mkdirSync(path.join(specs,'.reviews'),{recursive:true});
|
|
173
|
+
fs.writeFileSync(path.join(specs,'.reviews',`prd-change-${digest}.json`),JSON.stringify({version:1,
|
|
174
|
+
before:{directories:['1.login'],files:{'1.login/requirements.md':requirements,'1.login/design.md':design,'1.login/tasks.md':'- [ ] T-001: old\n'}},
|
|
175
|
+
proposal:{proposalDigest:digest,changedUserCases:[],removed:[],files:{'1.login/requirements.md':requirements,'1.login/design.md':design,
|
|
176
|
+
'1.login/tasks.md':'- [ ] T-001: implement login\n'},...over},selected:['1.login']}));};
|
|
177
|
+
const saved=()=>fs.writeFileSync(status,JSON.stringify({status:'awaiting_review',revisionDigest:digest,
|
|
178
|
+
features:['1.login'],specFiles:buildManifest(specs),testCases:[]}));
|
|
179
|
+
const invoke=(...extra)=>spawnSync(process.execPath,[entry,'--specs-dir',specs,'--code-project',code,'--approve',
|
|
180
|
+
'--standing-authorization','--expect-revision-digest',digest,...extra],{encoding:'utf8',env});
|
|
181
|
+
const refused=(result,reason)=>{assert.equal(result.status,1,result.stderr);assert.equal(JSON.parse(result.stdout).approveRefused,reason);};
|
|
182
|
+
saved();archive();const before=fs.readFileSync(status);
|
|
183
|
+
refused(invoke(),'standing_authorization_off');
|
|
184
|
+
fs.writeFileSync(path.join(home,'autonomy.json'),JSON.stringify({version:1,mode:'until_fatal',response:'就按这份',at:'2026-11-01T00:00:00.000Z'}));
|
|
185
|
+
for(const [over,why] of [[{files:{'1.login/requirements.md':'# changed\n','1.login/design.md':design,'1.login/tasks.md':'- [ ] T-001: implement login\n'}},/改了需求/],[{changedUserCases:[{id:'TC-001'}]},/用户用例/],
|
|
186
|
+
[{proposalDigest:'d'.repeat(64)},/找不到/],[{files:[]},/不完整/]]){
|
|
187
|
+
archive(over);const result=invoke();refused(result,'standing_authorization_not_applicable');
|
|
188
|
+
assert.match(JSON.parse(result.stdout).approveReason,why);assert.deepEqual(fs.readFileSync(status),before);
|
|
189
|
+
}
|
|
190
|
+
// The archive must be what the specs hold: a requirement edited on disk, or an extra feature, is not this proposal.
|
|
191
|
+
archive();
|
|
192
|
+
fs.writeFileSync(path.join(specs,'1.login','requirements.md'),'# Requirements\nnew rule\n');saved();
|
|
193
|
+
let result=invoke();refused(result,'standing_authorization_not_applicable');assert.match(JSON.parse(result.stdout).approveReason,/规格文件与提案不一致/);
|
|
194
|
+
fs.writeFileSync(path.join(specs,'1.login','requirements.md'),requirements);
|
|
195
|
+
const extra=path.join(specs,'2.new');fs.mkdirSync(extra);
|
|
196
|
+
for(const name of ['requirements.md','design.md','tasks.md'])fs.writeFileSync(path.join(extra,name),'- [ ] T-001: x\n');
|
|
197
|
+
fs.writeFileSync(status,JSON.stringify({status:'awaiting_review',revisionDigest:digest,features:['1.login','2.new'],specFiles:buildManifest(specs),testCases:[]}));
|
|
198
|
+
result=invoke();refused(result,'standing_authorization_not_applicable');assert.match(JSON.parse(result.stdout).approveReason,/功能与提案不一致/);
|
|
199
|
+
fs.rmSync(extra,{recursive:true});
|
|
200
|
+
// A spec file the archive does not list (here a test contract with a user case) cannot ride along.
|
|
201
|
+
fs.writeFileSync(path.join(specs,'1.login','test-cases.json'),JSON.stringify({schemaVersion:1,feature:'login',cases:[]}));saved();
|
|
202
|
+
result=invoke();refused(result,'standing_authorization_not_applicable');assert.match(JSON.parse(result.stdout).approveReason,/规格文件与提案不一致/);
|
|
203
|
+
fs.rmSync(path.join(specs,'1.login','test-cases.json'));saved();
|
|
204
|
+
fs.rmSync(path.join(specs,'.reviews',`prd-change-${digest}.json`));
|
|
205
|
+
refused(invoke(),'standing_authorization_not_applicable');
|
|
206
|
+
// Standing authorization never mixes with a reply or stands alone without a bound proposal.
|
|
207
|
+
for(const args of [['--approval-response','开始'],['--yes']]){
|
|
208
|
+
const result=invoke(...args);assert.equal(result.status,2);assert.match(result.stderr,/--standing-authorization requires/);
|
|
209
|
+
}
|
|
210
|
+
const unbound=spawnSync(process.execPath,[entry,'--specs-dir',specs,'--code-project',code,'--approve','--standing-authorization'],{encoding:'utf8',env});
|
|
211
|
+
assert.equal(unbound.status,2);
|
|
212
|
+
archive();
|
|
213
|
+
const accepted=invoke();assert.equal(accepted.status,0,`stdout: ${accepted.stdout}\nstderr: ${accepted.stderr}`);
|
|
214
|
+
const approved=JSON.parse(fs.readFileSync(status,'utf8'));
|
|
215
|
+
assert.equal(approved.status,'approved');assert.equal(approved.revisionDigest,digest);
|
|
216
|
+
assert.equal(approved.approval.response,'常设授权(2026-11-01T00:00:00.000Z):就按这份');
|
|
217
|
+
}));
|
|
218
|
+
|
|
72
219
|
test('ready admission prints a directly valid run definition without writing the project',()=>fixture(({root,specs,code})=>{
|
|
73
220
|
fs.writeFileSync(path.join(specs,'.cm-specs-status'),JSON.stringify({status:'approved',features:['1.login'],testCases:[]}));
|
|
74
221
|
fs.writeFileSync(path.join(code,'package.json'),JSON.stringify({name:'login-app'}));
|
|
@@ -91,9 +238,30 @@ test('print-run-definition requires explicit scope and emits no draft when omitt
|
|
|
91
238
|
fs.writeFileSync(path.join(specs,'.cm-specs-status'),JSON.stringify({status:'approved',features:['1.login'],testCases:[]}));
|
|
92
239
|
const result=spawnSync(process.execPath,[entry,'--specs-dir',specs,'--code-project',code,
|
|
93
240
|
'--print-run-definition'],{encoding:'utf8'});
|
|
94
|
-
|
|
241
|
+
// Without a scope in tasks.md the session must still name the files.
|
|
242
|
+
assert.equal(result.status,1);
|
|
95
243
|
assert.equal(result.stdout,'');
|
|
96
|
-
|
|
244
|
+
const error=JSON.parse(result.stderr).error;
|
|
245
|
+
assert.equal(error.code,'scope_required');
|
|
246
|
+
assert.match(error.reason,/--print-run-definition 需要 --scope:本任务允许修改的文件,相对代码根,逗号分隔/);
|
|
247
|
+
}));
|
|
248
|
+
|
|
249
|
+
test('print-run-definition takes the scope tasks.md declares and refuses a different --scope',()=>fixture(({specs,code})=>{
|
|
250
|
+
fs.writeFileSync(path.join(specs,'1.login','tasks.md'),'- [ ] T-001: implement login\n - 范围: `src/login.js`, `test/login.test.js`\n - 测试文件: `test/login.test.js`\n');
|
|
251
|
+
fs.writeFileSync(path.join(specs,'.cm-specs-status'),JSON.stringify({status:'approved',features:['1.login'],testCases:[]}));
|
|
252
|
+
const run=(...extra)=>spawnSync(process.execPath,[entry,'--specs-dir',specs,'--code-project',code,'--print-run-definition',...extra],{encoding:'utf8'});
|
|
253
|
+
const declared=run();
|
|
254
|
+
assert.equal(declared.status,0,declared.stderr);
|
|
255
|
+
assert.deepEqual(JSON.parse(declared.stdout).scope,['src/login.js','test/login.test.js']);
|
|
256
|
+
// The same files in another order are the same scope.
|
|
257
|
+
assert.equal(run('--scope','test/login.test.js,src/login.js').status,0);
|
|
258
|
+
const different=run('--scope','src/login.js');
|
|
259
|
+
assert.equal(different.status,1);assert.equal(different.stdout,'');
|
|
260
|
+
assert.equal(JSON.parse(different.stderr).error.code,'task_scope_mismatch');
|
|
261
|
+
// A malformed scope sub-item refuses instead of falling back to --scope.
|
|
262
|
+
fs.writeFileSync(path.join(specs,'1.login','tasks.md'),'- [ ] T-001: implement login\n - 范围: `src/*.js`\n');
|
|
263
|
+
const invalid=run('--scope','src/login.js');
|
|
264
|
+
assert.equal(invalid.status,1);assert.equal(JSON.parse(invalid.stderr).error.code,'task_scope_invalid');
|
|
97
265
|
}));
|
|
98
266
|
|
|
99
267
|
test('print-run-definition preserves non-ready admission output and exit status',()=>fixture(({specs,code})=>{
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
// operation -> possible host_request kinds (conservative over all batch tasks):
|
|
4
4
|
// advance -> develop, check: cm-ai-batch-run.mjs handle/driveMember -> start,
|
|
5
5
|
// host-conversation-execution.mjs worker/check. Protected config makes check
|
|
6
|
-
// host-owned in createProjectExecution; provider development makes develop host-owned
|
|
6
|
+
// host-owned in createProjectExecution; provider development makes develop host-owned,
|
|
7
|
+
// except batch.memberDevelopment session members, answered only through live develop.
|
|
7
8
|
// advance -> qa_assess, qa_logic, qa_browser, documentation_sync,
|
|
8
9
|
// documentation_inspect: host-workflow-capabilities.mjs createHostWorkflowCapabilities;
|
|
9
10
|
// batch-run.mjs driveMember/handle can reach qa, context_refresh and finalization.
|
|
@@ -16,6 +17,7 @@
|
|
|
16
17
|
// develop_redo/abandon_effect/abandon_review/bootstrap_review_recover -> none:
|
|
17
18
|
// batch-run.mjs memberAction forwards one to the stopped member's cm-ai entry (Q24).
|
|
18
19
|
import {readBatchExecutionPolicy} from '../runtime/js/cm-ai/execution-policy.mjs';
|
|
20
|
+
import {batchSegments,batchMemberWorktree} from '../runtime/js/cm-ai/batch-location.mjs';
|
|
19
21
|
import {readBatchExternalModels,batchModelsFile} from '../runtime/js/cm-ai/external-group-models.mjs';
|
|
20
22
|
import {loadConfig,resolveProtectedRuntimes} from './cm-workflow-config.mjs';
|
|
21
23
|
import fs from 'node:fs';
|
|
@@ -35,8 +37,10 @@ import {readExecutionSnapshot} from '../runtime/js/cm-ai/execution-snapshot.mjs'
|
|
|
35
37
|
import {readRunnerHistory,projectedRunnerStatus,RECHECK_CODES,DOCUMENTATION_SYNC_CODES} from '../runtime/js/cm-ai/durable-runner-state.mjs';
|
|
36
38
|
import {developmentRetryable} from '../runtime/js/cm-ai/cm-ai-conversation-entry.mjs';
|
|
37
39
|
import {stderr,stop,readJson,loadPlanFile,requireFields,preflightAnswers,driveHost,planCheckTimeout} from '../runtime/js/cm-ai/drive-core.mjs';
|
|
40
|
+
import {rateLimitRetryEligible} from '../runtime/js/cm-ai/drive-rate-limit.mjs';
|
|
38
41
|
|
|
39
|
-
import {driverLiveEvidence} from '../runtime/js/cm-ai/live-evidence.mjs';
|
|
42
|
+
import {driverLiveEvidence,qaAnswerWindowShortfall} from '../runtime/js/cm-ai/live-evidence.mjs';
|
|
43
|
+
import {HOST_ANSWER_TIMEOUT_DEFAULT_MS,hostAnswerTimeoutMs} from '../runtime/js/cm-ai/host-tool-bridge.mjs';
|
|
40
44
|
|
|
41
45
|
// PLAN.liveEvidence: fresh current-session evidence; see docs/live-evidence-drivers.md.
|
|
42
46
|
const HOST=fileURLToPath(new URL('./cm-ai-batch-host.mjs',import.meta.url));
|
|
@@ -52,6 +56,32 @@ const FLAGS=new Set(['--execution-optimizations','--external-models','--allow-qa
|
|
|
52
56
|
const isObject=x=>x!==null&&typeof x==='object'&&!Array.isArray(x);
|
|
53
57
|
const nonempty=x=>typeof x==='string'&&x.trim().length>0;
|
|
54
58
|
function taskKey(task){return `${task.feature}/${task.taskId}`;}
|
|
59
|
+
// v2 provider batch members the current session develops (batch.memberDevelopment,
|
|
60
|
+
// validated by createCmAiBatch). No field or another policy: none, the old behavior.
|
|
61
|
+
export function batchSessionMembers(batch,policy){
|
|
62
|
+
if(policy?.development!=='provider'||!isObject(batch.memberDevelopment))return new Set();
|
|
63
|
+
const keys=batch.tasks.map(taskKey);
|
|
64
|
+
return new Set(Object.entries(batch.memberDevelopment).filter(([key,value])=>value==='session'&&keys.includes(key)).map(([key])=>key));
|
|
65
|
+
}
|
|
66
|
+
export function batchLiveDevelopError(sessionMembers,declared,operation){
|
|
67
|
+
if(declared&&!sessionMembers.size)return 'PLAN.liveEvidence.kinds 声明了 develop,但批次没有开发方为会话的成员(v2 development:"provider" 且 batch.memberDevelopment 列出);develop 只用于这些成员';
|
|
68
|
+
if(operation==='advance'&&sessionMembers.size&&!declared)
|
|
69
|
+
return `批次成员 ${[...sessionMembers].join(', ')} 由当前会话开发:PLAN.liveEvidence.kinds 需要声明 develop;会话成员不能用静态 develop 答案应答`;
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
// The session member's develop call is cut by the runner at the host answer limit
|
|
73
|
+
// (host-conversation-execution.mjs outerTimeoutMs, 30 minutes) and recorded as
|
|
74
|
+
// call_timeout; the driver's wait ends a margin later, never first.
|
|
75
|
+
export const LIVE_DEVELOP_MARGIN_MS=60000;
|
|
76
|
+
export function liveDevelopWaitMs(env=process.env){
|
|
77
|
+
let limit=HOST_ANSWER_TIMEOUT_DEFAULT_MS;
|
|
78
|
+
try{limit=Math.max(limit,hostAnswerTimeoutMs(env));}catch{/* the batch host does not read it either */}
|
|
79
|
+
return limit+LIVE_DEVELOP_MARGIN_MS;
|
|
80
|
+
}
|
|
81
|
+
export function liveAnswerRoute(row,{live,runs,sessionMembers}){
|
|
82
|
+
if(!live.has(row.kind))return false;
|
|
83
|
+
return row.kind!=='develop'||sessionMembers.has(runs.get(row.payload?.request?.identity?.runId)?.key);
|
|
84
|
+
}
|
|
55
85
|
export function batchMemberActionPlanError(operation,plan,permissions,keys){
|
|
56
86
|
const flag=MEMBER_ACTION_FLAGS[operation];if(!flag)return null;
|
|
57
87
|
if(plan.mode!=='resume')return `${operation} 只用于 mode resume`;
|
|
@@ -83,7 +113,8 @@ function actualCwd(bundle,key,generation=1){
|
|
|
83
113
|
const group=bundle.batch.parallel?.find(group=>group.includes(key));
|
|
84
114
|
if(!group)return bundle.batch.codeProject;
|
|
85
115
|
const id=key.slice(key.lastIndexOf('/')+1);
|
|
86
|
-
return
|
|
116
|
+
return batchMemberWorktree({codeProject:bundle.batch.codeProject,taskId:id,
|
|
117
|
+
segments:batchSegments({specsDir:bundle.batch.specsDir,batchId:bundle.batch.batchId})});
|
|
87
118
|
}
|
|
88
119
|
function checkCommandShape(commands,key,plan,executionPolicy){
|
|
89
120
|
if(!Array.isArray(commands)||!commands.length||commands.length>32)stop(2,`任务 ${key} 会反问 check,但 PLAN.checks.${key} 缺少真实命令列表`);
|
|
@@ -104,7 +135,7 @@ function checkCommandShape(commands,key,plan,executionPolicy){
|
|
|
104
135
|
}
|
|
105
136
|
function preflight(){
|
|
106
137
|
if(process.argv.length===3&&['--help','-h'].includes(process.argv[2])){
|
|
107
|
-
process.stdout.write('新版 PLAN.controlConfig 为相对 PLAN 的 v2 控制配置路径;permissions 禁止所有 --allow-*,批次 qaFix 只能为 disabled。普通 advance 自动独立审查;缺少 develop-a2.json 时保持 revision_answer_required。显式成员恢复需要 resume、taskKey 与此前 status 返回的 PLAN.expectedControl
|
|
138
|
+
process.stdout.write('新版 PLAN.controlConfig 为相对 PLAN 的 v2 控制配置路径;permissions 禁止所有 --allow-*,批次 qaFix 只能为 disabled。普通 advance 自动独立审查;缺少 develop-a2.json 时保持 revision_answer_required。显式成员恢复需要 resume、taskKey 与此前 status 返回的 PLAN.expectedControl,驾驶员不会读取新目标覆盖它。v2 development:"provider" 批次里 batch.memberDevelopment 列为 session 的成员由当前会话开发:PLAN.liveEvidence.kinds 必须声明 develop,回复原样交宿主校验,不预写 develop 答案。\n');
|
|
108
139
|
process.stdout.write('用法: cm-ai-batch-drive.mjs --plan PLAN.json <operation>\n'
|
|
109
140
|
+'operation: advance, status, cancel, reconcile_review(taskKey、invocationId), develop_redo / abandon_effect / abandon_review / bootstrap_review_recover(resume、PLAN.taskKey、单行 PLAN.reason,permissions 带对应 --allow-… 任务)。PLAN: config, mode, hostContext, permissions, answers, checks, checkTimeoutMs。\n'
|
|
110
141
|
+'checks 每项为 {id,command,timeoutMs?};超时为 1..3600000 整数,默认 900000 ms(15 分钟)。\n'
|
|
@@ -143,6 +174,9 @@ function preflight(){
|
|
|
143
174
|
const batch=bundle.batch,keys=batch.tasks.map(taskKey);
|
|
144
175
|
if(new Set(keys).size!==keys.length||keys.length!==Object.keys(bundle.workflows).length
|
|
145
176
|
||keys.some(key=>!Object.hasOwn(bundle.workflows,key)))stop(2,'批次定义 workflows 与 tasks 不匹配');
|
|
177
|
+
const sessionMembers=batchSessionMembers(batch,control?.policy);
|
|
178
|
+
const liveDevelopError=batchLiveDevelopError(sessionMembers,Array.isArray(plan.liveEvidence?.kinds)&&plan.liveEvidence.kinds.includes('develop'),operation);
|
|
179
|
+
if(liveDevelopError)stop(2,liveDevelopError);
|
|
146
180
|
const definitions=new Map(),runs=new Map();
|
|
147
181
|
try{
|
|
148
182
|
for(const task of batch.tasks){
|
|
@@ -158,15 +192,21 @@ function preflight(){
|
|
|
158
192
|
if(bundle.workflows[key]!==null)validateHostWorkflowConfiguration(bundle.workflows[key]);
|
|
159
193
|
}
|
|
160
194
|
// Use the batch owner's selection/parallel-group validator without opening a run.
|
|
161
|
-
createCmAiBatch({configuration:batch,executionFor:async()=>({}),bootstrapKeys:Object.keys(bundle.bootstraps??{}),
|
|
195
|
+
createCmAiBatch({configuration:batch,executionFor:async()=>({}),bootstrapKeys:Object.keys(bundle.bootstraps??{}),workflows:bundle.workflows,
|
|
162
196
|
logHome:path.join(batch.specsDir,'.reviews','host-log-mirror')});
|
|
163
197
|
}catch(error){stop(2,`批次定义、scope 或 workflow 无效: ${error.code??error.message}${error.code==='protected_scope'&&typeof error.reason==='string'?`;${error.reason}`:''}`);}
|
|
164
198
|
const log=path.join(batch.specsDir,'运行日志.jsonl');
|
|
165
199
|
// Members the batch already rescheduled into a serial second generation
|
|
166
200
|
// (batch_member_blocked). Their gen-2 run starts fresh at attempt 1.
|
|
167
201
|
const rescheduled=new Set(),handedOff=new Set();
|
|
202
|
+
// The project log is shared by every run in this specs root; only rows this
|
|
203
|
+
// batch wrote (the scheduler's own decision rows, keyed by batchId) mean the
|
|
204
|
+
// batch already exists. Any earlier task, PRD or batch run leaves the file.
|
|
205
|
+
let batchRows=0;
|
|
168
206
|
if(fs.existsSync(log))for(const line of fs.readFileSync(log,'utf8').split('\n')){
|
|
169
207
|
if(!line.trim())continue;let row;try{row=JSON.parse(line);}catch{continue;}
|
|
208
|
+
if(row?.workflow==='cm-ai'&&row.event==='decision'&&row.run_id===batch.batchId
|
|
209
|
+
&&typeof row.phase==='string'&&row.phase.startsWith('batch_'))batchRows++;
|
|
170
210
|
if(row?.workflow==='cm-ai'&&row.event==='decision'&&row.phase==='batch_member_blocked'&&row.run_id===batch.batchId
|
|
171
211
|
&&row.generation===2&&typeof row.from_key==='string')rescheduled.add(row.from_key);
|
|
172
212
|
// A handed-off task never develops again; a merged parallel member's worktree is gone,
|
|
@@ -175,12 +215,17 @@ function preflight(){
|
|
|
175
215
|
&&typeof row.from_key==='string')handedOff.add(row.from_key);
|
|
176
216
|
}
|
|
177
217
|
const stores=Array.from(definitions.values(),d=>path.join(batch.specsDir,'.reviews','.execution',d.identity.runId,'state.json'));
|
|
178
|
-
const hasLog=
|
|
218
|
+
const hasLog=batchRows>0,hasStore=stores.some(file=>fs.existsSync(file));
|
|
179
219
|
if(plan.mode==='resume'&&!hasLog&&!hasStore)
|
|
180
220
|
stop(2,`恢复存档不存在: ${log} / ${stores.join(', ')}`);
|
|
181
221
|
if(plan.mode==='create'&&operation==='advance'&&(hasLog||hasStore))
|
|
182
222
|
stop(2,`批次已有存档,请用 resume: ${log}`);
|
|
183
223
|
if(operation==='status'&&!hasStore)stop(2,`只读 status 需要已有任务存档: ${stores.join(', ')}`);
|
|
224
|
+
// Only a new batch: an existing one resumes on its original boundary.
|
|
225
|
+
if(operation==='advance'&&control?.policy.qa==='run'&&!hasLog&&!hasStore){
|
|
226
|
+
const missing=keys.filter(key=>bundle.workflows[key]?.qa==null);
|
|
227
|
+
if(missing.length)stop(2,`batch_workflow_missing: 策略 qa:"run" 的成员缺少 QA workflow: ${missing.join(', ')};用 cm-ai-batch-plan --workflow-config 生成或补齐`);
|
|
228
|
+
}
|
|
184
229
|
const argumentValue=name=>permissions.includes(name)?permissions[permissions.indexOf(name)+1]:undefined;
|
|
185
230
|
if(argumentValue('--external-models-config'))permissions[permissions.indexOf('--external-models-config')+1]=path.resolve(base,argumentValue('--external-models-config'));
|
|
186
231
|
const chosenRuntime=argumentValue('--runtime')??'codex';
|
|
@@ -234,9 +279,11 @@ function preflight(){
|
|
|
234
279
|
permissions.includes(`${key}:1`)&&permissions[permissions.indexOf(`${key}:1`)-1]==='--allow-provider-development');
|
|
235
280
|
let live;
|
|
236
281
|
try{live=driverLiveEvidence(plan,{base,protectedRoots:[batch.codeProject,batch.specsDir,path.resolve(batch.codeProject,'..','.cm-worktrees'),...(batch.codeProjects??[])],
|
|
237
|
-
allowedKinds:['qa_logic','qa_browser','verification_precheck'],maxBytes:inputLimitFrom(permissions)
|
|
282
|
+
allowedKinds:['qa_logic','qa_browser','verification_precheck','develop'],maxBytes:inputLimitFrom(permissions),
|
|
283
|
+
minimumTimeouts:{develop:liveDevelopWaitMs()}});}
|
|
238
284
|
catch(error){stop(2,error.message);}
|
|
239
|
-
if(operation==='advance'&&permissions.includes('--verification-precheck')
|
|
285
|
+
if(operation==='advance'&&(permissions.includes('--verification-precheck')||control?.policy.verification==='precheck')
|
|
286
|
+
&&!live.has('verification_precheck'))
|
|
240
287
|
stop(2,'缺少真实执行 runner: verification_precheck;不能从静态答案文件应答');
|
|
241
288
|
if(operation==='advance'&&bundle.bootstraps&&Object.keys(bundle.bootstraps).length)
|
|
242
289
|
stop(2,'缺少真实执行 runner: init_verify;不能从静态答案文件应答');
|
|
@@ -247,15 +294,18 @@ function preflight(){
|
|
|
247
294
|
const firstGroup=batch.parallel?.find(group=>group.includes(keys[0]))??[keys[0]];
|
|
248
295
|
if(operation==='advance')for(const task of batch.tasks){
|
|
249
296
|
const key=taskKey(task),workflow=bundle.workflows[key],kinds=[];
|
|
250
|
-
if(!providerAll)kinds.push('develop');
|
|
297
|
+
if(!providerAll||sessionMembers.has(key))kinds.push('develop');
|
|
251
298
|
if(!protectedMode){
|
|
252
299
|
kinds.push('check');
|
|
253
300
|
if(workflow?.documentationPaths?.length)kinds.push('documentation_sync');
|
|
254
301
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
302
|
+
// v2 成员没有 workflow 配置时宿主也会隐式补上 QA 判定(implicit-qa-decision.mjs)。
|
|
303
|
+
if(control||workflow?.qa){
|
|
304
|
+
// A rescheduled second generation runs serially and asks qa_assess like a serial task;
|
|
305
|
+
// so does a one-member worktree group, whose QA keeps the fixed checkpoints.
|
|
306
|
+
// 策略 qa:"disabled" 时宿主自己确认,不再问(host-workflow-capabilities.mjs)。
|
|
307
|
+
if((!batch.parallel?.some(group=>group.length>1&&group.includes(key))||rescheduled.has(key))&&control?.policy.qa!=='disabled')kinds.push('qa_assess');
|
|
308
|
+
if(workflow?.qa&&(!control||control.policy.qa==='run')){
|
|
259
309
|
const cases=readJson(path.join(batch.specsDir,task.feature,'test-cases.json'),'test-cases');
|
|
260
310
|
for(const kind of ['logic','browser'])if(cases?.cases?.some(item=>item.kind===kind))kinds.push(`qa_${kind}`);
|
|
261
311
|
}
|
|
@@ -263,10 +313,14 @@ function preflight(){
|
|
|
263
313
|
if(workflow)kinds.push('documentation_inspect');
|
|
264
314
|
const evidence=kinds.filter(kind=>['qa_logic','qa_browser'].includes(kind)&&!live.has(kind));
|
|
265
315
|
if(evidence.length)stop(2,`缺少真实执行 runner: ${evidence.join(', ')};不能从静态答案文件应答`);
|
|
316
|
+
const shortWindow=qaAnswerWindowShortfall(workflow?.qa,live,kinds);
|
|
317
|
+
if(shortWindow&&plan.mode==='create')stop(2,`${key}: ${shortWindow}`);
|
|
318
|
+
if(shortWindow)process.stderr.write(`[drive] 警告: ${key}: ${shortWindow}\n`);
|
|
266
319
|
if(kinds.includes('check'))checkCommandShape(plan.checks?.[key],key,plan,executionPolicy);
|
|
267
320
|
const taskRoot=root&&path.join(root,task.feature,task.taskId);
|
|
268
321
|
const perAttempt=new Map();
|
|
269
|
-
|
|
322
|
+
// A session member answers develop only live: no authored answer, no revision hold.
|
|
323
|
+
if(kinds.includes('develop')&&!sessionMembers.has(key)){
|
|
270
324
|
let attempts=[1],current=1,journal=null;
|
|
271
325
|
if(plan.mode==='resume'&&handedOff.has(key)){attempts=[];journal={handedOff:true};}
|
|
272
326
|
else if(plan.mode==='resume'){
|
|
@@ -330,7 +384,7 @@ function preflight(){
|
|
|
330
384
|
if(answers[key].documentation_sync)for(const target of Object.keys(answers[key].documentation_sync.edits))
|
|
331
385
|
if(!workflow.documentationPaths.includes(target))stop(2,`任务 ${key} documentation-sync.json.edits 越过文档 scope: ${target}`);
|
|
332
386
|
}
|
|
333
|
-
return {...loaded,control,executionPolicy,bundle,definitions,runs,config,permissions,answers,developAnswers,answerRoot:root,holds,live};
|
|
387
|
+
return {...loaded,control,executionPolicy,bundle,definitions,runs,config,permissions,answers,developAnswers,answerRoot:root,holds,live,sessionMembers};
|
|
334
388
|
}
|
|
335
389
|
|
|
336
390
|
let loaded;
|
|
@@ -347,7 +401,8 @@ function safeWrite(map,root,cwd,allowed){
|
|
|
347
401
|
}
|
|
348
402
|
}
|
|
349
403
|
async function answerFor(row,answers,paths,control){
|
|
350
|
-
|
|
404
|
+
// Live replies (including a session member's protected develop proposal) go back as written; the host validates them.
|
|
405
|
+
if(liveAnswerRoute(row,loaded))return loaded.live.answer(row,control);
|
|
351
406
|
const identity=row.payload.identity??row.payload.request?.identity;
|
|
352
407
|
const binding=loaded.runs.get(identity?.runId),key=binding?.key;
|
|
353
408
|
if(!Object.hasOwn(loaded.answers,key))return null;
|
|
@@ -409,8 +464,14 @@ export function buildCmAiBatchDriveRequest(operation,plan){
|
|
|
409
464
|
function main(){
|
|
410
465
|
loaded=preflight();
|
|
411
466
|
const {plan,operation,bundle,config,permissions}=loaded;
|
|
467
|
+
// A timed rate-limit retry (drive-core.mjs) is retry_review carrying the frozen
|
|
468
|
+
// batch and member stop; the batch host redispatches only that review or answers staleRetry.
|
|
469
|
+
const expected=loaded.expectedReviewStop??null;
|
|
470
|
+
const request=expected?{...buildCmAiBatchDriveRequest('status',plan),taskKey:expected.batch.taskKey,identity:expected.identity,
|
|
471
|
+
packageDigest:expected.packageDigest,expectedReviewStop:{invocationId:expected.invocationId},batchDigest:expected.batch.batchDigest}
|
|
472
|
+
:buildCmAiBatchDriveRequest(operation,plan);
|
|
412
473
|
driveHost({host:HOST,args:buildCmAiBatchDriveHostArgs(plan,permissions,config,loaded.control?.file,loaded.holds),
|
|
413
|
-
cwd:bundle.batch.codeProject,operation,request
|
|
414
|
-
answers:loaded.answers,answerFor});
|
|
474
|
+
cwd:bundle.batch.codeProject,operation,request,
|
|
475
|
+
answers:loaded.answers,answerFor,rateLimitRetry:rateLimitRetryEligible(operation,plan)?'batch':false});
|
|
415
476
|
}
|
|
416
477
|
if(process.argv[1]&&fs.realpathSync(process.argv[1])===fileURLToPath(import.meta.url))main();
|