@aibyzero/cm-workflow 0.17.1 → 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 +23 -0
- package/CHANGELOG.md +224 -0
- package/README.md +14 -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/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 +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 +21 -4
- package/runtime/js/cm-ai/developer-adapter.mjs +19 -5
- package/runtime/js/cm-ai/drive-core.mjs +114 -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 +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 +3 -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 +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-challenge.test.mjs +61 -0
- package/scripts/cm-check-drive-files.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-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 +575 -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 +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-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 +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 +56 -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 +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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {readBatchExecutionPolicy,freezeBatchExecutionPolicy} from '../runtime/js/cm-ai/execution-policy.mjs';
|
|
3
|
+
import {batchSegments,batchMemberWorktree} from '../runtime/js/cm-ai/batch-location.mjs';
|
|
3
4
|
import {readBatchExternalModels,freezeBatchExternalModels,batchModelsFile} from '../runtime/js/cm-ai/external-group-models.mjs';
|
|
4
5
|
// Current-conversation transport for the existing batch driver, not a new loop.
|
|
5
6
|
import fs from 'node:fs';
|
|
@@ -89,7 +90,7 @@ export function migrateLegacyPreflightCache(batch,review,runtime){
|
|
|
89
90
|
try{const a=fs.lstatSync(file),b=fs.lstatSync(destination);interrupted=a.dev===b.dev&&a.ino===b.ino;}catch(error){if(error.code!=='ENOENT')throw error;}
|
|
90
91
|
const source=pinned(file,interrupted?2:1);
|
|
91
92
|
if(source===null)refuse(`${entry.name} 在核对时消失`);
|
|
92
|
-
const cwd=
|
|
93
|
+
const cwd=batchMemberWorktree({codeProject:batch.codeProject,taskId,segments:batchSegments({specsDir:batch.specsDir,batchId:batch.batchId})});
|
|
93
94
|
const options={cwd,model:review.model,disabledSkills:review.disabledSkills,promptTransport:'stdin'};
|
|
94
95
|
let cached;try{cached=readConversationReviewConfigurationValue(JSON.parse(source.bytes.toString('utf8')),null);}
|
|
95
96
|
catch{refuse(`${entry.name} 不是预检缓存格式`);}
|
|
@@ -179,6 +180,9 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
179
180
|
const {batch,workflows,bootstraps=null}=bundle;need(Array.isArray(batch.tasks),'invalid_batch_config');
|
|
180
181
|
need(workflows!==null&&typeof workflows==='object'&&!Array.isArray(workflows),'invalid_batch_config');
|
|
181
182
|
const keys=batch.tasks.map(task=>`${task.feature}/${task.taskId}`);
|
|
183
|
+
// Grammar 3 execution table (batch-plan.mjs; validated again by createCmAiBatch): the
|
|
184
|
+
// members the current session develops even when a provider develops the rest.
|
|
185
|
+
const sessionMembers=new Set(batch.memberDevelopment!==null&&typeof batch.memberDevelopment==='object'?Object.keys(batch.memberDevelopment):[]);
|
|
182
186
|
if(bootstraps!==null){
|
|
183
187
|
need(typeof bootstraps==='object'&&!Array.isArray(bootstraps),'invalid_bootstrap_config');
|
|
184
188
|
for(const [key,config] of Object.entries(bootstraps)){
|
|
@@ -245,12 +249,14 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
245
249
|
}
|
|
246
250
|
else need(false,'invalid_arguments');
|
|
247
251
|
}
|
|
252
|
+
if([...developments.keys()].some(key=>sessionMembers.has(key)))throw Object.assign(new Error('invalid_arguments'),
|
|
253
|
+
{code:'invalid_arguments',reason:'--allow-provider-development 不能授权批次执行表里由会话开发的成员'});
|
|
248
254
|
if(controlPolicy){
|
|
249
255
|
allowQa=controlPolicy.qa==='run';allowBootstrap=controlPolicy.bootstrap==='write';
|
|
250
256
|
need((controlPolicy.development==='provider')===Boolean(providerConfig),'invalid_arguments');
|
|
251
257
|
need(controlPolicy.bootstrap!=='write'||bootstraps!==null,'invalid_arguments');
|
|
252
258
|
need(bootstraps===null||controlPolicy.bootstrap==='write','invalid_arguments');
|
|
253
|
-
if(providerConfig)for(const key of keys)developments.set(key,1);
|
|
259
|
+
if(providerConfig)for(const key of keys)if(!sessionMembers.has(key))developments.set(key,1);
|
|
254
260
|
need(!rerunUnknownQa&&!rerunBlockedQa,'supersede_unavailable');
|
|
255
261
|
}
|
|
256
262
|
const started=keys.some(key=>fs.existsSync(path.join(batch.specsDir,'.reviews','.execution',batchTaskRunId(batch.batchId,key),'state.json')));
|
|
@@ -268,6 +274,15 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
268
274
|
need(!Object.hasOwn(providerConfig,'effort')||providerConfig.effort===pair.effort,'external_model_configuration_conflict');
|
|
269
275
|
providerConfig={...providerConfig,...pair};
|
|
270
276
|
}
|
|
277
|
+
need(!sessionMembers.size||!externalModels&&!executionPolicy,'session_member_unsupported_config');
|
|
278
|
+
// A v2 provider batch: a session member's coder is this host, so it must be the
|
|
279
|
+
// declared coder; it is reviewed by the declared reviewer like the provider members
|
|
280
|
+
// (reviewRuntime), never by the host itself.
|
|
281
|
+
const sessionReviewRuntime=controlPolicy?.development==='provider'&&sessionMembers.size?routes.reviewerRuntime:null;
|
|
282
|
+
if(sessionReviewRuntime!==null&&routes.coderRuntime!==(runtime??'codex'))
|
|
283
|
+
throw Object.assign(new Error('session_coder_runtime_mismatch'),{code:'session_coder_runtime_mismatch',
|
|
284
|
+
reason:`成员 ${[...sessionMembers].join(', ')} 由当前会话开发,宿主运行时必须是项目声明的写代码方 ${routes.coderRuntime};`
|
|
285
|
+
+`现在是 ${runtime??'codex(未传 --runtime 时的缺省值)'}。在 PLAN.permissions 加 --runtime ${routes.coderRuntime}`});
|
|
271
286
|
review=review===null?null:readConversationReviewConfiguration(review,externalModels?.providers[routes.reviewerRuntime]??null);
|
|
272
287
|
need(!developments.size||providerConfig!==null,'protected_configuration_required');
|
|
273
288
|
// Same launch-time assertion as the single-task host, evaluated across every
|
|
@@ -302,14 +317,23 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
302
317
|
let reconciling=false;
|
|
303
318
|
const driver=createCmAiBatch({configuration:{...batch,...(controlPolicy?{controlPolicy}:{}),...(externalModels?{externalModels}:{}),...(executionPolicy?{executionPolicy}:{})},logHome:path.join(batch.specsDir,'.reviews','host-log-mirror'),
|
|
304
319
|
runtime:runtime??'codex',checkCommands:(providerConfig??protection)?.checkCommands??null,checkTimeoutMs:(providerConfig??protection)?.timeoutMs??60000,
|
|
305
|
-
rerunUnknownQa,rerunBlockedQa,qaEnvironmentFailure,memberActions,holdRevisions:[...holds],bootstrapKeys:Object.keys(bootstraps??{}),
|
|
306
|
-
executionFor:async(definition,{parallelMember=false}={})=>{
|
|
320
|
+
rerunUnknownQa,rerunBlockedQa,qaEnvironmentFailure,memberActions,holdRevisions:[...holds],bootstrapKeys:Object.keys(bootstraps??{}),workflows,
|
|
321
|
+
executionFor:async(definition,{parallelMember=false,soloMember=false}={})=>{
|
|
307
322
|
await freezeBatchExecutionPolicy(batch,executionPolicy);
|
|
308
323
|
freezeBatchExternalModels(batch,externalModels);
|
|
309
324
|
const key=`${definition.feature}/${definition.identity.taskId}`;
|
|
310
|
-
|
|
325
|
+
// A parallel member's review loopback runs on the reviewer the factory will bind: the
|
|
326
|
+
// declared one for a provider-developed member (the host runtime may be the coder
|
|
327
|
+
// there), else the one this member always had (host runtime, or the external route).
|
|
328
|
+
const memberReviewer=developments.has(key)?resolveProtectedRuntimes(loadConfig({projectRoot:definition.codeProject}),runtime??'codex').reviewerRuntime
|
|
329
|
+
:externalModels?routes.reviewerRuntime:runtime??'codex';
|
|
330
|
+
const memberReview=parallelMember?await memberReviewConfiguration(batch,definition,review,memberReviewer,externalModels?.providers[routes.reviewerRuntime]??null,!reconciling,Boolean(executionPolicy)):review;
|
|
311
331
|
const execution=createConversationExecution(definition,hostContextId,parallelMember?memberBridge:bridge,memberReview,null,workflows[key],allowQa,runtime??'codex',
|
|
312
|
-
{parallelMember,...(controlPolicy?{controlPolicy}:{}),...(executionPolicy?{executionPolicy}:{}),...(externalModels?{externalModels,...(providerConfig?{reviewerRuntime:routes.reviewerRuntime}:{})}:{}),...(verificationPrecheck?{verificationPrecheck:true}:{}),
|
|
332
|
+
{parallelMember,...(soloMember?{soloMember}:{}),...(controlPolicy?{controlPolicy}:{}),...(executionPolicy?{executionPolicy}:{}),...(externalModels?{externalModels,...(providerConfig?{reviewerRuntime:routes.reviewerRuntime}:{})}:{}),...(verificationPrecheck?{verificationPrecheck:true}:{}),
|
|
333
|
+
// A batch without an execution table keeps its exact projection.
|
|
334
|
+
batchWorkflowsDigest:digest(executionPolicy?{workflows,bootstraps,externalModels,executionPolicy}:externalModels?{workflows,bootstraps,externalModels}
|
|
335
|
+
:Object.hasOwn(batch,'memberDevelopment')?{workflows,bootstraps,memberDevelopment:batch.memberDevelopment}:bootstraps?{workflows,bootstraps}:workflows),qaLogHome:path.join(batch.specsDir,'.reviews','host-log-mirror'),
|
|
336
|
+
...(sessionMembers.has(key)?{memberDevelopment:'session',...(sessionReviewRuntime!==null?{reviewRuntime:sessionReviewRuntime}:{})}:{}),
|
|
313
337
|
// A protected CLI config also protects unauthorized tasks: they stay on the
|
|
314
338
|
// current-session transport but with the same sandbox checks (protected-text edits).
|
|
315
339
|
...(protection?{protection}:providerConfig?{protection:{checkCommands:providerConfig.checkCommands,timeoutMs:providerConfig.timeoutMs}}:{}),
|
|
@@ -324,8 +348,13 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
324
348
|
const host={async handle(request){
|
|
325
349
|
try{
|
|
326
350
|
reconciling=request.operation==='reconcile_review';const result=await driver.handle(request);
|
|
327
|
-
if(controlPolicy&&request.operation==='status'&&result.state!=='running')
|
|
328
|
-
|
|
351
|
+
if(controlPolicy&&request.operation==='status'&&result.state!=='running'){
|
|
352
|
+
// A merge conflict stays reported when its member cannot be targeted (e.g.
|
|
353
|
+
// its worktree is gone); the target is marked unavailable, not invented.
|
|
354
|
+
if(result.code!=='merge_conflict')return {...result,controlTarget:await driver.controlTarget()};
|
|
355
|
+
try{return {...result,controlTarget:await driver.controlTarget()};}
|
|
356
|
+
catch(cause){return {...result,controlTargetUnavailable:{code:safeCode(cause)}};}
|
|
357
|
+
}
|
|
329
358
|
return result;
|
|
330
359
|
}
|
|
331
360
|
catch(cause){const reason=boundedReason(cause);return {outcome:'blocked',code:safeCode(cause),...(reason?{reason}:{})};}
|
|
@@ -334,7 +363,7 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
334
363
|
try{await serveHostTransport({host,input,output,toolBridge:bridge},inputLimitRaw);}
|
|
335
364
|
finally{if(rawMode)input.setRawMode(false);}
|
|
336
365
|
return 0;
|
|
337
|
-
}catch(cause){const code=safeCode(cause);error.write(JSON.stringify({error:{code,...(['browser_capability_required','browser_capability_unavailable','invalid_arguments','review_configuration_required','protected_scope',...Object.keys(UNSUPPORTED_REASON)].includes(code)
|
|
366
|
+
}catch(cause){const code=safeCode(cause);error.write(JSON.stringify({error:{code,...(['browser_capability_required','browser_capability_unavailable','invalid_arguments','review_configuration_required','protected_scope','session_coder_runtime_mismatch',...Object.keys(UNSUPPORTED_REASON)].includes(code)
|
|
338
367
|
&&typeof cause.reason==='string'?{reason:cause.reason}:{}),...(code==='request_too_large'?{reason:inputLimitReason(cause.limit)}:{})}})+'\n');return 1;}
|
|
339
368
|
finally{bridge?.close();}
|
|
340
369
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {hostDiagnostic} from './fixtures/host-diagnostic.mjs';
|
|
2
2
|
import test from 'node:test';
|
|
3
|
+
import {batchSegment} from '../runtime/js/cm-ai/batch-location.mjs';
|
|
3
4
|
import assert from 'node:assert/strict';
|
|
4
5
|
import fs from 'node:fs';
|
|
5
6
|
import os from 'node:os';
|
|
@@ -108,7 +109,7 @@ function execute(f,{cancel=false,args=[],operations=[{operation:'advance',reques
|
|
|
108
109
|
if(row.type==='host_request'){
|
|
109
110
|
const payload=row.payload,identity=payload.identity??payload.request.identity;
|
|
110
111
|
const cwd=f.parallel&&identity.taskId!=='T-003'
|
|
111
|
-
?path.join(f.root,'.cm-worktrees',f.batch.batchId
|
|
112
|
+
?path.join(f.root,'.cm-worktrees',batchSegment(f.batch.batchId),identity.taskId):f.codeProject;
|
|
112
113
|
calls.push(`${identity.taskId}:${row.kind}`);
|
|
113
114
|
if(cancel){pendingControls.add('status');pendingControls.add('cancel');send({operation:'status',requestId:'status'});send({operation:'cancel',requestId:'cancel'});continue;}
|
|
114
115
|
if(row.kind==='develop'){
|
|
@@ -239,7 +240,7 @@ test('parallel member loopback preflights bind worktree cwd, stop before start a
|
|
|
239
240
|
try{
|
|
240
241
|
f.batch.tasks=[1,2,3].map(n=>({feature:'1.work',taskId:`T-00${n}`,scope:[`task${n}.mjs`],requirements:['requirements.md']}));
|
|
241
242
|
f.batch.parallel=[['1.work/T-001','1.work/T-002']];
|
|
242
|
-
fs.writeFileSync(path.join(f.specsDir,'1.work','tasks.md'),'- [ ] T-001: first\n- [ ] T-002: second\n- [ ] T-003: final\n\n- T-003 依赖 T-001, T-002\n');
|
|
243
|
+
fs.writeFileSync(path.join(f.specsDir,'1.work','tasks.md'),'- [ ] T-001: first\n - 范围: `task1.mjs`\n- [ ] T-002: second\n - 范围: `task2.mjs`\n- [ ] T-003: final\n - 范围: `task3.mjs`\n\n- T-003 依赖 T-001, T-002\n');
|
|
243
244
|
fs.writeFileSync(path.join(f.specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:['1.work'],specFiles:buildManifest(f.specsDir)}));
|
|
244
245
|
const original=JSON.parse(fs.readFileSync(f.config,'utf8')).workflows['1.work/T-001'];
|
|
245
246
|
fs.writeFileSync(f.config,JSON.stringify({batch:f.batch,workflows:Object.fromEntries(f.batch.tasks.map(task=>[`1.work/${task.taskId}`,original]))}));
|
|
@@ -272,7 +273,7 @@ let input='';process.stdin.on('data',part=>input+=part);process.stdin.on('end',(
|
|
|
272
273
|
const directory=path.join(f.specsDir,'.reviews','.execution',f.batch.batchId);
|
|
273
274
|
const receipts=[1,2].map(n=>fs.readFileSync(path.join(directory,`preflight-T-00${n}.json`),'utf8'));
|
|
274
275
|
for(const [index,bytes] of receipts.entries()){
|
|
275
|
-
const config=JSON.parse(bytes),cwd=path.join(f.root,'.cm-worktrees',f.batch.batchId
|
|
276
|
+
const config=JSON.parse(bytes),cwd=path.join(f.root,'.cm-worktrees',batchSegment(f.batch.batchId),`T-00${index+1}`);
|
|
276
277
|
assert(preflightMatches(config.preflight,{cwd,model:'fixture',disabledSkills:[],promptTransport:'stdin'}));
|
|
277
278
|
assert(!preflightMatches(config.preflight,{cwd:f.codeProject,model:'fixture',disabledSkills:[],promptTransport:'stdin'}));
|
|
278
279
|
assert.equal(config.preflight.real_model_requests,0);assert.equal(config.preflight.listener_closed,true);
|
|
@@ -298,13 +299,13 @@ function legacyParallelFixture(){
|
|
|
298
299
|
const f=fixture();f.parallel=true;
|
|
299
300
|
f.batch.tasks=[1,2,3].map(n=>({feature:'1.work',taskId:`T-00${n}`,scope:[`task${n}.mjs`],requirements:['requirements.md']}));
|
|
300
301
|
f.batch.parallel=[['1.work/T-001','1.work/T-002']];
|
|
301
|
-
fs.writeFileSync(path.join(f.specsDir,'1.work','tasks.md'),'- [ ] T-001: first\n- [ ] T-002: second\n- [ ] T-003: final\n\n- T-003 依赖 T-001, T-002\n');
|
|
302
|
+
fs.writeFileSync(path.join(f.specsDir,'1.work','tasks.md'),'- [ ] T-001: first\n - 范围: `task1.mjs`\n- [ ] T-002: second\n - 范围: `task2.mjs`\n- [ ] T-003: final\n - 范围: `task3.mjs`\n\n- T-003 依赖 T-001, T-002\n');
|
|
302
303
|
fs.writeFileSync(path.join(f.specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:['1.work'],specFiles:buildManifest(f.specsDir)}));
|
|
303
304
|
const original=JSON.parse(fs.readFileSync(f.config,'utf8')).workflows['1.work/T-001'];
|
|
304
305
|
fs.writeFileSync(f.config,JSON.stringify({batch:f.batch,workflows:Object.fromEntries(f.batch.tasks.map(task=>[`1.work/${task.taskId}`,original]))}));
|
|
305
306
|
f.legacy=path.join(f.specsDir,'.reviews','.execution',f.batch.batchId);
|
|
306
307
|
f.current=path.join(f.specsDir,'.reviews','external-preflight',f.batch.batchId);
|
|
307
|
-
f.worktree=taskId=>path.join(f.root,'.cm-worktrees',f.batch.batchId
|
|
308
|
+
f.worktree=taskId=>path.join(f.root,'.cm-worktrees',batchSegment(f.batch.batchId),taskId);
|
|
308
309
|
return f;
|
|
309
310
|
}
|
|
310
311
|
const legacyReceipt=(f,taskId,extra={})=>JSON.stringify({model:'fixture',disabledSkills:[],preflight:{passed:true,cli_model:'fixture',
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import {spawnSync} from 'node:child_process';
|
|
7
|
+
import {mergeLessons} from '../runtime/js/cm-ai/cm-ai-learning-writer.mjs';
|
|
8
|
+
|
|
9
|
+
// Two parallel members each write their lesson into AGENTS.md in their own
|
|
10
|
+
// worktree; the batch merges with AGENTS.md merge=union (cm-ai-batch-run.mjs
|
|
11
|
+
// unionAttributes). When the base has no "## 项目教训" section, both members
|
|
12
|
+
// create it. Git refines the identical added lines as common, so the merged
|
|
13
|
+
// file has one heading and both lessons, not a conflict or a doubled heading.
|
|
14
|
+
const git=(cwd,args)=>{const run=spawnSync('git',['-C',cwd,'-c','user.email=t@example.invalid','-c','user.name=t',...args],{encoding:'utf8'});
|
|
15
|
+
assert.equal(run.status,0,run.stderr);return run.stdout.trim();};
|
|
16
|
+
const lesson=(taskId,trigger)=>({feature:'1.work',identity:{repositoryId:'r',runId:'u',taskId,attempt:1},
|
|
17
|
+
candidates:[{classification:'memory_only',trigger,action:`${trigger} 的做法`,evidence:['src/a.js']}]});
|
|
18
|
+
|
|
19
|
+
for(const base of ['# 项目\n\n规则\n','# 项目\n\n## 项目教训\n\n- 旧教训\n\n## 其他\n\n内容\n'])
|
|
20
|
+
test(`two members' lessons merge into one section (${base.includes('项目教训')?'section exists':'no section yet'})`,t=>{
|
|
21
|
+
const repo=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-learning-union-')));
|
|
22
|
+
t.after(()=>fs.rmSync(repo,{recursive:true,force:true}));
|
|
23
|
+
git(repo,['init','-q','-b','base']);fs.writeFileSync(path.join(repo,'AGENTS.md'),base);git(repo,['add','.']);git(repo,['commit','-qm','base']);
|
|
24
|
+
for(const [branch,taskId,trigger] of [['a','T-002','左边的教训'],['b','T-003','右边的教训']]){
|
|
25
|
+
git(repo,['checkout','-q','-b',branch,'base']);
|
|
26
|
+
fs.writeFileSync(path.join(repo,'AGENTS.md'),mergeLessons(fs.readFileSync(path.join(repo,'AGENTS.md'),'utf8'),lesson(taskId,trigger)));
|
|
27
|
+
git(repo,['commit','-qam',branch]);
|
|
28
|
+
}
|
|
29
|
+
git(repo,['checkout','-q','a']);
|
|
30
|
+
fs.writeFileSync(path.join(repo,'.git','info','attributes'),'AGENTS.md merge=union\n');
|
|
31
|
+
git(repo,['merge','-q','--no-ff','--no-edit','b']);
|
|
32
|
+
const merged=fs.readFileSync(path.join(repo,'AGENTS.md'),'utf8');
|
|
33
|
+
assert.equal(merged.match(/^## 项目教训$/gm).length,1,merged);
|
|
34
|
+
assert.match(merged,/左边的教训/);assert.match(merged,/右边的教训/);
|
|
35
|
+
if(base.includes('## 其他'))assert.ok(merged.indexOf('右边的教训')<merged.indexOf('## 其他'),'lessons stay inside their section');
|
|
36
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// A batch's member worktrees and branches. New batches derive their segment from
|
|
2
|
+
// the full batchId and record it in batch_start; a batch that started without it
|
|
3
|
+
// keeps the old 8-character prefix so a resume finds what it created.
|
|
4
|
+
import test from 'node:test';
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
import fs from 'node:fs';
|
|
7
|
+
import os from 'node:os';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import {BATCH_SEGMENT_FIELD,batchSegment,batchSegments,batchMemberWorktree,batchMemberBranch} from '../runtime/js/cm-ai/batch-location.mjs';
|
|
10
|
+
|
|
11
|
+
function specs(t,rows=[]){
|
|
12
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-batch-location-')));
|
|
13
|
+
t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
|
|
14
|
+
const specsDir=path.join(root,'specs');fs.mkdirSync(specsDir);
|
|
15
|
+
if(rows.length)fs.writeFileSync(path.join(specsDir,'运行日志.jsonl'),rows.map(row=>JSON.stringify(row)).join('\n')+'\n');
|
|
16
|
+
return {root,specsDir,codeProject:path.join(root,'app')};
|
|
17
|
+
}
|
|
18
|
+
const start=(batchId,extra={})=>({schema_version:1,workflow:'cm-ai',event:'decision',phase:'batch_start',run_id:batchId,...extra});
|
|
19
|
+
|
|
20
|
+
test('two batches sharing an 8-character prefix get different worktrees and branches',t=>{
|
|
21
|
+
const f=specs(t);
|
|
22
|
+
const a=batchSegments({specsDir:f.specsDir,batchId:'batch-20261022-A'}),b=batchSegments({specsDir:f.specsDir,batchId:'batch-20261022-B'});
|
|
23
|
+
assert.notEqual(a.dir,b.dir);assert.notEqual(a.ref,b.ref);
|
|
24
|
+
const where=segments=>[batchMemberWorktree({codeProject:f.codeProject,segments,taskId:'T-001'}),
|
|
25
|
+
batchMemberBranch({segments,feature:'1.work',taskId:'T-001'})];
|
|
26
|
+
assert.notDeepEqual(where(a),where(b));
|
|
27
|
+
assert.equal(where(a)[0],path.join(f.root,'.cm-worktrees',batchSegment('batch-20261022-A'),'T-001'));
|
|
28
|
+
assert.equal(where(a)[1],`cm/${batchSegment('batch-20261022-A')}/work/T-001`);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('a batch that already started without a recorded segment keeps the old prefix',t=>{
|
|
32
|
+
const f=specs(t,[start('v1.2.3-batch')]);
|
|
33
|
+
const segments=batchSegments({specsDir:f.specsDir,batchId:'v1.2.3-batch'});
|
|
34
|
+
assert.equal(segments.legacy,true);
|
|
35
|
+
assert.equal(batchMemberWorktree({codeProject:f.codeProject,segments,taskId:'T-002'}),path.join(f.root,'.cm-worktrees','v1.2.3-b','T-002'));
|
|
36
|
+
assert.equal(batchMemberBranch({segments,feature:'2.search',taskId:'T-002'}),'cm/v1-2-3-b/search/T-002');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('a recorded segment is used only when it is the one the full id derives',t=>{
|
|
40
|
+
const good=specs(t,[start('batch-ok',{[BATCH_SEGMENT_FIELD]:batchSegment('batch-ok')})]);
|
|
41
|
+
assert.deepEqual(batchSegments({specsDir:good.specsDir,batchId:'batch-ok'}),{dir:batchSegment('batch-ok'),ref:batchSegment('batch-ok'),legacy:false});
|
|
42
|
+
for(const forged of ['../../etc','batch-ok',batchSegment('other-batch'),null]){
|
|
43
|
+
const f=specs(t,[start('batch-ok',{[BATCH_SEGMENT_FIELD]:forged})]);
|
|
44
|
+
assert.throws(()=>batchSegments({specsDir:f.specsDir,batchId:'batch-ok'}),{code:'batch_history_invalid'},String(forged));
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('rows of other batches and other workflows do not decide the segment',t=>{
|
|
49
|
+
const f=specs(t,[start('another-batch'),{schema_version:1,workflow:'cm-prd',event:'run_done',run_id:'mine-1234'},
|
|
50
|
+
{schema_version:1,workflow:'cm-ai',event:'progress',run_id:'mine-1234'}]);
|
|
51
|
+
assert.equal(batchSegments({specsDir:f.specsDir,batchId:'mine-1234'}).dir,batchSegment('mine-1234'));
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('the segment is a safe single path component and ref component',()=>{
|
|
55
|
+
for(const id of ['a','a.b.c.d.e.f.g.h','....----','batch_2026.10.23-x'])
|
|
56
|
+
assert.match(batchSegment(id),/^[A-Za-z0-9_-]{1,8}-[a-f0-9]{12}$/,id);
|
|
57
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Prints the batch configuration /cm-ai runs for the feature admission selects,
|
|
3
|
+
// grouped from the approved tasks.md (runtime/js/cm-ai/batch-plan.mjs). The
|
|
4
|
+
// session no longer writes groups by hand; the batch host validates them again.
|
|
5
|
+
//
|
|
6
|
+
// stdout: {mode:"batch",feature,groups,config} — pass config to cm-ai-batch-host
|
|
7
|
+
// as the batch configuration file;
|
|
8
|
+
// {mode:"serial",feature,reason} — run the feature's tasks one at a time
|
|
9
|
+
// with cm-ai-admission --print-run-definition, as before;
|
|
10
|
+
// {mode:"complete"} — no task is left.
|
|
11
|
+
import fs from 'node:fs';
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
import {fileURLToPath} from 'node:url';
|
|
14
|
+
import {loadConfig} from './cm-workflow-config.mjs';
|
|
15
|
+
import {planCmAiBatch,parallelSettings} from '../runtime/js/cm-ai/batch-plan.mjs';
|
|
16
|
+
import {validateHostWorkflowConfiguration} from '../runtime/js/cm-ai/host-workflow-capabilities.mjs';
|
|
17
|
+
|
|
18
|
+
const usage='usage: cm-ai-batch-plan.mjs --specs-dir PATH --code-project PATH --repository-id ID --batch-id ID [--workflow-config PATH]';
|
|
19
|
+
function parse(argv){
|
|
20
|
+
const flags=new Map([['--specs-dir','specsDir'],['--code-project','codeProject'],['--repository-id','repositoryId'],
|
|
21
|
+
['--batch-id','batchId'],['--workflow-config','workflowConfig']]);
|
|
22
|
+
const input={};
|
|
23
|
+
for(let index=0;index<argv.length;index+=2){
|
|
24
|
+
const key=flags.get(argv[index]);
|
|
25
|
+
if(!key||index+1>=argv.length||Object.hasOwn(input,key))return null;
|
|
26
|
+
input[key]=argv[index+1];
|
|
27
|
+
}
|
|
28
|
+
return ['specsDir','codeProject','repositoryId','batchId'].every(key=>typeof input[key]==='string')?input:null;
|
|
29
|
+
}
|
|
30
|
+
export function main(argv=process.argv.slice(2)){
|
|
31
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0])){process.stdout.write(usage+'\n');return 0;}
|
|
32
|
+
const input=parse(argv);
|
|
33
|
+
if(!input){process.stderr.write(usage+'\n');return 2;}
|
|
34
|
+
try{
|
|
35
|
+
const specsDir=fs.realpathSync(path.resolve(input.specsDir)),codeProject=fs.realpathSync(path.resolve(input.codeProject));
|
|
36
|
+
const settings=parallelSettings(loadConfig({projectRoot:codeProject}));
|
|
37
|
+
// The single-task workflow configuration the batch host gets for these tasks: its
|
|
38
|
+
// QA critical paths keep tasks that would hit them out of one-member groups.
|
|
39
|
+
const workflow=input.workflowConfig===undefined?null
|
|
40
|
+
:validateHostWorkflowConfiguration(JSON.parse(fs.readFileSync(path.resolve(input.workflowConfig),'utf8')));
|
|
41
|
+
const plan=planCmAiBatch({specsDir,codeProject,repositoryId:input.repositoryId,batchId:input.batchId,settings,workflow});
|
|
42
|
+
process.stdout.write(JSON.stringify(plan)+'\n');return 0;
|
|
43
|
+
}catch(error){
|
|
44
|
+
process.stderr.write(JSON.stringify({error:{code:error.code??'batch_plan_failed',
|
|
45
|
+
...(typeof error.reason==='string'?{reason:error.reason}:{})}})+'\n');return 1;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function isMain(entry){
|
|
49
|
+
if(!entry)return false;
|
|
50
|
+
try{return fs.realpathSync(entry)===fileURLToPath(import.meta.url);}catch{return path.resolve(entry)===fileURLToPath(import.meta.url);}
|
|
51
|
+
}
|
|
52
|
+
if(isMain(process.argv[1]))process.exitCode=main();
|