@aibyzero/cm-workflow 0.21.7 → 0.25.1
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/CHANGELOG.md +64 -0
- package/README.md +15 -1
- package/VERSION +1 -1
- package/docs/architecture.md +9 -0
- package/docs/cm-acceptance-completion.md +3 -1
- package/docs/cm-control-policy-v2.md +35 -3
- package/docs/execution-optimizations.md +1 -1
- package/docs/external-models.md +1 -0
- package/docs/human-correction.md +1 -1
- package/docs/installation.md +63 -19
- package/docs/js-workflow-control.md +67 -31
- package/docs/next-steps.md +10 -0
- package/docs/runtime-failover.md +2 -2
- package/docs/user-guide.md +1 -1
- package/package.json +1 -1
- package/runtime/js/cm-ai/batch-location.mjs +14 -0
- package/runtime/js/cm-ai/batch-plan.mjs +6 -2
- package/runtime/js/cm-ai/claude-probe-diagnosis.mjs +21 -0
- package/runtime/js/cm-ai/claude-review-stream.mjs +20 -7
- package/runtime/js/cm-ai/claude-tool-preview.mjs +4 -2
- package/runtime/js/cm-ai/cm-ai-admission.mjs +9 -3
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +51 -8
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +30 -4
- package/runtime/js/cm-ai/codex-review-adapter.mjs +2 -4
- package/runtime/js/cm-ai/delivery-evidence.mjs +3 -1
- package/runtime/js/cm-ai/developer-adapter.mjs +15 -1
- package/runtime/js/cm-ai/drive-core.mjs +50 -6
- package/runtime/js/cm-ai/drive-next-step.mjs +61 -0
- package/runtime/js/cm-ai/durable-runner-state.mjs +85 -23
- package/runtime/js/cm-ai/execution-snapshot.mjs +5 -2
- package/runtime/js/cm-ai/execution-store.mjs +21 -3
- package/runtime/js/cm-ai/external-run-guard.mjs +9 -1
- package/runtime/js/cm-ai/host-check.mjs +4 -2
- package/runtime/js/cm-ai/host-conversation-execution.mjs +29 -2
- package/runtime/js/cm-ai/host-handoff.mjs +7 -0
- package/runtime/js/cm-ai/host-progress.mjs +18 -0
- package/runtime/js/cm-ai/host-qa-executor.mjs +47 -15
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +11 -2
- package/runtime/js/cm-ai/host-qa-policy.mjs +24 -14
- package/runtime/js/cm-ai/host-session.mjs +1 -1
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +1 -1
- package/runtime/js/cm-ai/host.mjs +1 -1
- package/runtime/js/cm-ai/operator-guidance.mjs +126 -2
- package/runtime/js/cm-ai/project-qa-gate.mjs +13 -2
- package/runtime/js/cm-ai/provider-review-observation.mjs +7 -3
- package/runtime/js/cm-ai/qa-plan-notes.mjs +106 -0
- package/runtime/js/cm-ai/review-continuation.mjs +102 -0
- package/runtime/js/cm-ai/review-evidence-file.mjs +11 -0
- package/runtime/js/cm-ai/review-package.mjs +25 -4
- package/runtime/js/cm-ai/review-presentation.mjs +31 -14
- package/runtime/js/cm-ai/review-runner.mjs +5 -4
- package/runtime/js/cm-ai/review-verdict-rules.mjs +7 -0
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +30 -1
- package/runtime/js/cm-ai/task-commit-codec.mjs +11 -1
- package/runtime/js/cm-ai/task-commit.mjs +7 -4
- package/runtime/js/cm-ai/task-owner.mjs +5 -2
- package/runtime/js/cm-ai/task-runner.mjs +343 -52
- package/runtime/js/cm-ai/worker-claude-developer.mjs +3 -1
- package/runtime/js/cm-ai/worker-claude.mjs +5 -1
- package/runtime/js/cm-check/host.mjs +13 -3
- package/runtime/js/cm-fix/diagnosis.mjs +16 -3
- package/runtime/js/cm-fix/execution.mjs +47 -9
- package/runtime/js/cm-fix/finish.mjs +9 -1
- package/runtime/js/cm-fix/step-timing.mjs +222 -0
- package/runtime/js/cm-idea/session.mjs +22 -3
- package/runtime/js/cm-init/review-evidence.mjs +20 -7
- package/runtime/js/cm-prd/ai-draft.mjs +260 -0
- package/runtime/js/cm-prd/analysis.mjs +27 -9
- package/runtime/js/cm-prd/change.mjs +29 -8
- package/runtime/js/cm-prd/failed-correction.mjs +24 -4
- package/runtime/js/cm-prd/narrow-review.mjs +63 -3
- package/runtime/js/cm-prd/review-channels.mjs +5 -0
- package/runtime/js/cm-prd/review-correction.mjs +65 -5
- package/runtime/js/cm-prd/review-disposition.mjs +10 -1
- package/runtime/js/cm-prd/review-publication.mjs +2 -1
- package/runtime/js/cm-prd/self-check.mjs +121 -9
- package/runtime/js/cm-prd/session.mjs +55 -13
- package/runtime/js/cm-prd/summary.mjs +34 -6
- package/runtime/js/cm-prd/task-scope-record.mjs +40 -15
- package/runtime/js/cm-refactor/records.mjs +82 -11
- package/runtime/js/cm-refactor/workflow.mjs +3 -1
- package/runtime/js/executor-version.mjs +81 -0
- package/runtime/js/python-log-writer.mjs +15 -0
- package/runtime/js/run-analysis.mjs +136 -11
- package/runtime/logging.md +6 -0
- package/runtime/review.md +2 -1
- package/scripts/ci-test-weights.json +1 -0
- package/scripts/cm-ai-admission.mjs +27 -1
- package/scripts/cm-ai-admission.test.mjs +34 -2
- package/scripts/cm-ai-answer-gap-recheck.test.mjs +3 -2
- package/scripts/cm-ai-batch-drive.mjs +54 -17
- package/scripts/cm-ai-batch-drive.test.mjs +123 -6
- package/scripts/cm-ai-batch-host.mjs +64 -11
- package/scripts/cm-ai-batch-host.test.mjs +23 -3
- package/scripts/cm-ai-batch-location.test.mjs +22 -1
- package/scripts/cm-ai-batch-merge.mjs +102 -0
- package/scripts/cm-ai-batch-plan.mjs +55 -2
- package/scripts/cm-ai-batch-plan.test.mjs +228 -6
- package/scripts/cm-ai-batch-run-fixture.mjs +239 -15
- package/scripts/cm-ai-batch-run-parallel.test.mjs +23 -1
- package/scripts/cm-ai-batch-run.mjs +437 -34
- package/scripts/cm-ai-batch-session-member.test.mjs +85 -0
- package/scripts/cm-ai-check-recheck-cancellation.test.mjs +23 -2
- package/scripts/cm-ai-completion-summary.test.mjs +2 -1
- package/scripts/cm-ai-control-v2-drive.test.mjs +39 -9
- package/scripts/cm-ai-direct-review.test.mjs +1 -1
- package/scripts/cm-ai-disk-edits.test.mjs +229 -0
- package/scripts/cm-ai-drive-next-step.test.mjs +191 -0
- package/scripts/cm-ai-drive.mjs +66 -14
- package/scripts/cm-ai-drive.test.mjs +13 -3
- package/scripts/cm-ai-host-cli-workflow.test.mjs +4 -2
- package/scripts/cm-ai-host.mjs +20 -9
- package/scripts/cm-ai-host.test.mjs +12 -0
- package/scripts/cm-ai-operator-guidance.test.mjs +132 -1
- package/scripts/cm-ai-project-qa-gate.test.mjs +26 -0
- package/scripts/cm-ai-qa-fix-cross-session.test.mjs +18 -0
- package/scripts/cm-ai-review-continuation.test.mjs +335 -0
- package/scripts/cm-ai-review-failure.test.mjs +13 -10
- package/scripts/cm-ai-review-timeout.test.mjs +1 -1
- package/scripts/cm-ai-run.mjs +42 -11
- package/scripts/cm-ai-run.test.mjs +26 -0
- package/scripts/cm-ai-supersede.test.mjs +10 -2
- package/scripts/cm-capability-gate.test.mjs +1 -1
- package/scripts/cm-check-host.test.mjs +54 -0
- package/scripts/cm-check-runtime.sh +27 -15
- package/scripts/cm-check-update.mjs +83 -8
- package/scripts/cm-check-update.test.mjs +114 -1
- package/scripts/cm-claude-developer-worker.test.mjs +29 -1
- package/scripts/cm-claude-managed-preflight.test.mjs +126 -0
- package/scripts/cm-claude-probe.test.mjs +5 -0
- package/scripts/cm-claude-review-stream.test.mjs +4 -1
- package/scripts/cm-claude-worker.test.mjs +29 -0
- package/scripts/cm-codex-prompt-input.test.mjs +2 -1
- package/scripts/cm-developer-self-review.test.mjs +27 -0
- package/scripts/cm-efficiency-presentation-delta.test.mjs +4 -3
- package/scripts/cm-efficiency-response.test.mjs +2 -1
- package/scripts/cm-executor-version-draft.test.mjs +251 -0
- package/scripts/cm-executor-version-entries.test.mjs +93 -0
- package/scripts/cm-executor-version-prd.test.mjs +154 -0
- package/scripts/cm-executor-version-records.test.mjs +256 -0
- package/scripts/cm-executor-version.test.mjs +250 -0
- package/scripts/cm-external-model-host.test.mjs +6 -1
- package/scripts/cm-external-review-reconciliation.test.mjs +1 -1
- package/scripts/cm-fix-closeout-preflight.test.mjs +123 -0
- package/scripts/cm-fix-diagnosis-module-correction.test.mjs +5 -1
- package/scripts/cm-fix-drive.mjs +7 -2
- package/scripts/cm-fix-drive.test.mjs +45 -0
- package/scripts/cm-fix-entry.mjs +5 -2
- package/scripts/cm-fix-frozen-baseline.test.mjs +50 -0
- package/scripts/cm-fix-host.mjs +9 -2
- package/scripts/cm-fix-review-preflight.mjs +2 -0
- package/scripts/cm-fix-review-verification-integration.test.mjs +19 -0
- package/scripts/cm-fix-test-extension.test.mjs +30 -2
- package/scripts/cm-host-check.test.mjs +12 -0
- package/scripts/cm-host-qa-executor.test.mjs +172 -1
- package/scripts/cm-host-qa-policy.test.mjs +55 -1
- package/scripts/cm-idea-drive.mjs +5 -2
- package/scripts/cm-idea-entry.mjs +5 -2
- package/scripts/cm-idea-host.mjs +3 -1
- package/scripts/cm-init-drive.mjs +8 -5
- package/scripts/cm-init-entry.mjs +5 -2
- package/scripts/cm-init-host.mjs +6 -2
- package/scripts/cm-log-event.mjs +10 -2
- package/scripts/cm-log-event.test.mjs +29 -0
- package/scripts/cm-prd-ai-draft-fixture.mjs +18 -0
- package/scripts/cm-prd-ai-draft.test.mjs +505 -0
- package/scripts/cm-prd-answer-gaps.test.mjs +110 -5
- package/scripts/cm-prd-completion.test.mjs +67 -4
- package/scripts/cm-prd-design-phase.test.mjs +48 -13
- package/scripts/cm-prd-drive.mjs +91 -21
- package/scripts/cm-prd-drive.test.mjs +126 -4
- package/scripts/cm-prd-entry.mjs +5 -2
- package/scripts/cm-prd-host.mjs +89 -20
- package/scripts/cm-prd-host.test.mjs +17 -8
- package/scripts/cm-prd-narrow-review.test.mjs +49 -1
- package/scripts/cm-prd-review-disposition.test.mjs +94 -1
- package/scripts/cm-prd-review-gate.mjs +13 -5
- package/scripts/cm-prd-review-publication.test.mjs +34 -0
- package/scripts/cm-prd-self-check-rules.test.mjs +175 -10
- package/scripts/cm-prd-self-check.test.mjs +1 -1
- package/scripts/cm-refactor-drive.mjs +10 -4
- package/scripts/cm-refactor-entry.mjs +5 -2
- package/scripts/cm-refactor-host.mjs +3 -1
- package/scripts/cm-release-smoke.sh +3 -2
- package/scripts/cm-run-analysis.test.mjs +373 -1
- package/scripts/cm-skill-hints-autowire.test.mjs +1 -1
- package/scripts/cm-skill-hints-exam.mjs +3 -1
- package/scripts/cm-skill-hints-install.test.mjs +1 -1
- package/scripts/cm-skill-hints.mjs +106 -10
- package/scripts/cm-skill-hints.test.mjs +162 -6
- package/scripts/cm-skill-judge.mjs +2 -1
- package/scripts/cm-task-gate.mjs +88 -18
- package/scripts/cm-task-scope.test.mjs +1 -1
- package/scripts/cm-test-drive.mjs +13 -8
- package/scripts/cm-test-entry.mjs +5 -2
- package/scripts/cm-test-host.mjs +3 -1
- package/scripts/cm-upgrade-compat-batch.test.mjs +62 -9
- package/scripts/cm-workflow-config.test.mjs +8 -3
- package/scripts/fixtures/fresh-completion-checks.mjs +8 -0
- package/scripts/fixtures/prd-review-gate-python-oracle.py +10 -1
- package/scripts/policy-binding-compat.test.mjs +3 -2
- package/scripts/scan-public-safety.py +1 -0
- package/scripts/shell-pipe-early-exit.test.mjs +96 -0
- package/scripts/test-cm-prd-review-gate.py +55 -0
- package/scripts/test-shell-compat.sh +7 -5
- package/skills/cm-ai/SKILL.md +1 -1
- package/skills/cm-ai/references/N1-init.md +1 -1
- package/skills/cm-ai/references/N4-review.md +2 -2
- package/skills/cm-ai/references/N6-qa-eval.md +3 -1
- package/skills/cm-ai/references/js-host-recovery.md +5 -1
- package/skills/cm-ai/references/js-host.md +17 -8
- package/skills/cm-check/SKILL.md +3 -0
- package/skills/cm-fix/references/isolated-review.md +1 -1
- package/skills/cm-fix/references/js-host.md +20 -0
- package/skills/cm-fix/references/test-extension.md +1 -1
- package/skills/cm-prd/SKILL.md +8 -6
- package/skills/cm-prd/references/ai-draft.md +81 -0
- package/skills/cm-prd/references/change-mode.md +2 -0
- package/skills/cm-prd/references/greenfield.md +2 -0
- package/skills/cm-prd/references/js-change-recovery.md +2 -2
- package/skills/cm-prd/references/js-host.md +9 -6
- package/skills/cm-prd/references/light-mode.md +19 -0
- package/skills/cm-prd/references/requirement-grilling.md +2 -0
- package/skills/cm-prd/references/spec-self-check.md +1 -0
- package/skills/cm-prd/references/summary-card.md +1 -0
- package/templates/auto-update/cm-update.sh +2 -2
|
@@ -13,6 +13,8 @@ import {spawnSync} from 'node:child_process';
|
|
|
13
13
|
import {createParallelMemberQaDecisionProvider} from '../runtime/js/cm-ai/host-workflow-capabilities.mjs';
|
|
14
14
|
import path from 'node:path';
|
|
15
15
|
import {createCmAiBatch} from './cm-ai-batch-run.mjs';
|
|
16
|
+
import {createdByRecord} from '../runtime/js/executor-version.mjs';
|
|
17
|
+
import {openControlRun} from './cm-ai-run.mjs';
|
|
16
18
|
import {createCodexDeveloperRun} from '../runtime/js/cm-ai/codex-developer-adapter.mjs';
|
|
17
19
|
import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
18
20
|
import {reviewPaths} from '../runtime/js/cm-ai/review-runner.mjs';
|
|
@@ -47,6 +49,7 @@ export async function batchFixture(mode,options={}){
|
|
|
47
49
|
const git=(cwd,args)=>{const result=spawnSync('git',['-C',cwd,...args],{encoding:'utf8'});assert.equal(result.status,0,result.stderr);return result.stdout.trim();};
|
|
48
50
|
{git(codeProject,['init','-b','main']);git(codeProject,['config','user.name','Fixture']);git(codeProject,['config','user.email','fixture@example.invalid']);
|
|
49
51
|
fs.writeFileSync(path.join(codeProject,parallel?'base.js':'file0.js'),'base\n');
|
|
52
|
+
if(options.learningUnion)fs.writeFileSync(path.join(codeProject,'AGENTS.md'),'# Fixture agent instructions\n');
|
|
50
53
|
// configDivergence (review r4): the main checkout's file equals its HEAD blob, yet a
|
|
51
54
|
// worktree checked out from HEAD loads another configuration.
|
|
52
55
|
if(options.configDivergence==='smudge'){
|
|
@@ -71,6 +74,9 @@ export async function batchFixture(mode,options={}){
|
|
|
71
74
|
...(parallel?{parallel:each?[[`${feature}/T-001`],[`${feature}/T-002`]]:[[`${feature}/T-001`,`${feature}/T-002`]]}:{}),
|
|
72
75
|
tasks:(parallel?['T-001','T-002','T-003']:['T-001','T-002']).map((taskId,index)=>({feature,taskId,scope:[`file${index}.js`],requirements:['requirements.md']}))};
|
|
73
76
|
const calls=[],qaCalls=[],assessments=[],blockedEvidence=[],checkCalls=new Map();let qaReady=mode!=='qa-resume',started;
|
|
77
|
+
const checkTrace=path.join(root,'project-checks.jsonl');
|
|
78
|
+
const tracedCheck={id:'fixture-project-check',command:[process.execPath,'-e',
|
|
79
|
+
"require('node:fs').appendFileSync(process.argv[1],JSON.stringify(process.cwd())+'\\n')",checkTrace]};
|
|
74
80
|
const began=new Promise(resolve=>{started=resolve;});
|
|
75
81
|
let conflictHead=null,interrupted=false,reviewFailed=0,redoThrown=false,reviewHeld=null;const rateLimitedSeen={};const eachSeen=[];let activeBatchId=config.batchId;
|
|
76
82
|
const developerModel=mode==='parallel-redo'?'current-session':'fixture';
|
|
@@ -128,7 +134,7 @@ export async function batchFixture(mode,options={}){
|
|
|
128
134
|
if(recovery&&blockedIds.includes(definition.identity.taskId)&&(parallelMember||options.terminalAgain))
|
|
129
135
|
return {status:'succeeded',value:{outcome:'blocked',...(options.withReason?{reason:'Expected stub throws; waiting for peer'}:{})}};
|
|
130
136
|
if(parallel&&definition.identity.taskId==='T-002')await new Promise(resolve=>setTimeout(resolve,50));
|
|
131
|
-
if(
|
|
137
|
+
if(['parallel-conflict','parallel-new-conflict'].includes(mode)&&definition.identity.taskId==='T-002'){
|
|
132
138
|
fs.writeFileSync(path.join(codeProject,'file0.js'),'main conflict\n');git(codeProject,['add','file0.js']);git(codeProject,['commit','-m','concurrent main change']);conflictHead=git(codeProject,['rev-parse','HEAD']);
|
|
133
139
|
}
|
|
134
140
|
if(mode==='cancel'){started();await new Promise(resolve=>signal.addEventListener('abort',resolve,{once:true}));}
|
|
@@ -137,6 +143,9 @@ export async function batchFixture(mode,options={}){
|
|
|
137
143
|
if(mode==='learning'&&definition.identity.taskId==='T-001')retrospective={status:'lesson_candidate',reason:null,
|
|
138
144
|
candidates:[{classification:'structured',trigger:'Synthetic task input requires explicit validation',
|
|
139
145
|
action:'Read the validated input before writing the next fixture',evidence:['file0.js']}]};
|
|
146
|
+
if(options.learningUnion&¶llelMember)retrospective={status:'lesson_candidate',reason:null,
|
|
147
|
+
candidates:[{classification:'structured',trigger:`Member ${definition.identity.taskId} requires its own regression trace`,
|
|
148
|
+
action:'Read the regression trace before merging the fixture',evidence:[definition.scope[0]]}]};
|
|
140
149
|
if(mode==='learning'&&definition.identity.taskId==='T-002'){
|
|
141
150
|
const source=fs.readFileSync(path.join(codeProject,'AGENTS.md'),'utf8');
|
|
142
151
|
assert(source.includes('Synthetic task input requires explicit validation'));
|
|
@@ -147,8 +156,16 @@ export async function batchFixture(mode,options={}){
|
|
|
147
156
|
}})},
|
|
148
157
|
check:async()=>{
|
|
149
158
|
const key=definition.identity.taskId,count=(checkCalls.get(key)??0)+1;checkCalls.set(key,count);
|
|
150
|
-
|
|
151
|
-
|
|
159
|
+
if(options.mergeChecks==='count'){
|
|
160
|
+
const [executable,...args]=tracedCheck.command;
|
|
161
|
+
const result=spawnSync(executable,args,{cwd:definition.codeProject,encoding:'utf8'});
|
|
162
|
+
assert.equal(result.status,0,result.stderr);
|
|
163
|
+
return [{...tracedCheck,outcome:'passed',exitCode:0,evidence:'Recorded actual project check process'}];
|
|
164
|
+
}
|
|
165
|
+
if(options.interruptedComplete==='check'&&key==='T-001'&&count===2)
|
|
166
|
+
throw Object.assign(new Error('simulated interrupt'),{code:'EIO'});
|
|
167
|
+
const failed=parallelMember&&(key==='T-002'
|
|
168
|
+
&&(mode==='parallel-completion-retry'&&count===2||mode==='parallel-develop-check-retry'&&count===1));
|
|
152
169
|
return [{id:'fixture',command:['fixture'],outcome:failed?'failed':'passed',exitCode:failed?1:0,
|
|
153
170
|
evidence:failed?'Synthetic transient failure':'Synthetic task check'}];
|
|
154
171
|
},
|
|
@@ -219,7 +236,20 @@ export async function batchFixture(mode,options={}){
|
|
|
219
236
|
documentationProvider:{timeoutMs:1000,inspect:async binding=>({syncId:binding.syncId,identity:binding.identity,
|
|
220
237
|
packageDigest:binding.packageDigest,contextDigest:binding.contextDigest,status:'completed',reason:'Synthetic docs',at:'2026-09-08T01:00:00Z'})},
|
|
221
238
|
});
|
|
222
|
-
const
|
|
239
|
+
const logHome=path.join(root,'logs');
|
|
240
|
+
const checkCommands=options.mergeChecks==='count'?[tracedCheck]:options.mergeChecks?[{id:'fixture-post-merge',command:[process.execPath,'-e',
|
|
241
|
+
options.mergeChecks==='fail-second'?"process.exit(require('node:fs').existsSync('file1.js') ? 9 : 0)":"process.exit(0)"]}]:null;
|
|
242
|
+
const open=(extra={})=>createCmAiBatch({configuration:config,executionFor,logHome,checkCommands,...extra});
|
|
243
|
+
if(['parallel-conflict','parallel-old-merge'].includes(mode)){
|
|
244
|
+
const createdBy=createdByRecord();
|
|
245
|
+
const start=spawnSync('python3',[new URL('./cm-log-event.py',import.meta.url).pathname,'--workflow','cm-ai',
|
|
246
|
+
'--event','decision','--phase','batch_start','--runtime','codex','--project-root',codeProject,'--specs-dir',specsDir,
|
|
247
|
+
'--run-id',config.batchId,'--detail','Approved task batch started','--data-json',JSON.stringify({
|
|
248
|
+
from_key:`${feature}/T-001`,worktree_segment:batchSegment(config.batchId),repository_id:config.repositoryId,
|
|
249
|
+
created_by:createdBy,plan_digest:digest({config,createdBy})})],
|
|
250
|
+
{encoding:'utf8',env:{...process.env,CM_WORKFLOW_LOG_HOME:logHome}});
|
|
251
|
+
assert.equal(start.status,0,start.stderr);
|
|
252
|
+
}
|
|
223
253
|
// retry_review (a driver's timed rate-limit retry) redispatches exactly the frozen
|
|
224
254
|
// review: a different invocation, batch log or member is refused as staleRetry
|
|
225
255
|
// with nothing dispatched or written; the exact one dispatches that review only.
|
|
@@ -232,8 +262,9 @@ export async function batchFixture(mode,options={}){
|
|
|
232
262
|
const batchTaskRunIdFor=taskId=>`task-${digest({batchId:config.batchId,task:`${feature}/${taskId}`}).slice(0,48)}`;
|
|
233
263
|
const reviewIntents=runId=>JSON.parse(fs.readFileSync(path.join(specsDir,'.reviews','.execution',runId,'state.json'),'utf8')).records
|
|
234
264
|
.filter(row=>row.payload.type==='effect-intent'&&row.payload.effect.kind==='review').map(row=>row.payload.effect.id);
|
|
235
|
-
|
|
236
|
-
const
|
|
265
|
+
// Raw bytes: decoded text maps invalid UTF-8 and U+FFFD to the same character.
|
|
266
|
+
const logBytes=()=>{const file=path.join(specsDir,'运行日志.jsonl');return fs.existsSync(file)?fs.readFileSync(file):Buffer.alloc(0);};
|
|
267
|
+
const tasksBytes=()=>fs.readFileSync(path.join(specsDir,feature,'tasks.md'));
|
|
237
268
|
async function boundReviewRetry(stop){
|
|
238
269
|
// Both group members hit the rate limit; the batch names the first one it stopped on.
|
|
239
270
|
const both=(options.rateLimitedTasks??[]).includes('T-002');
|
|
@@ -242,11 +273,11 @@ export async function batchFixture(mode,options={}){
|
|
|
242
273
|
taskKey:stop.reviewRetryTarget.taskKey,identity:stop.identity,packageDigest:stop.packageDigest,
|
|
243
274
|
expectedReviewStop:{invocationId:stop.reviewInvocationId},batchDigest:stop.reviewRetryTarget.batchDigest,...over});
|
|
244
275
|
const unchanged=async(over,why)=>{
|
|
245
|
-
const before={log:
|
|
276
|
+
const before={log:logBytes(),tasks:tasksBytes(),effects:reviewCount(),reviews:reviewFailed};
|
|
246
277
|
const refused=await bound(over);
|
|
247
278
|
assert.equal(refused.staleRetry,true,`${why}: ${JSON.stringify(refused)}`);assert.equal(refused.outcome,'rejected',why);
|
|
248
279
|
assert.match(refused.reason,/^状态已变,未自动重试/,why);
|
|
249
|
-
assert.deepEqual({log:
|
|
280
|
+
assert.deepEqual({log:logBytes(),tasks:tasksBytes(),effects:reviewCount(),reviews:reviewFailed},before,`${why}: nothing dispatched or written`);
|
|
250
281
|
};
|
|
251
282
|
await unchanged({expectedReviewStop:{invocationId:'another-invocation'}},'another member invocation');
|
|
252
283
|
await unchanged({batchDigest:'0'.repeat(64)},'another batch log');
|
|
@@ -278,16 +309,16 @@ export async function batchFixture(mode,options={}){
|
|
|
278
309
|
if(options.cancelAt==='open')assert.equal(reviewCount(),effects,'no review dispatched after the cancel');
|
|
279
310
|
else assert.equal(reviewCount(),effects+1,'the running review was the one cancelled');
|
|
280
311
|
assert.equal(reviewFailed,options.cancelAt==='open'?1:1);
|
|
281
|
-
const rows=
|
|
312
|
+
const rows=logBytes().toString('utf8').split('\n').filter(Boolean).map(JSON.parse);
|
|
282
313
|
assert.equal(rows.filter(row=>row.phase==='batch_cancel').length,1,'batch_cancel logged once');
|
|
283
314
|
assert.equal((await open().handle({operation:'advance',requestId:'after-cancel'})).code,'cancelled');
|
|
284
315
|
return null;
|
|
285
316
|
}
|
|
286
|
-
const effects=reviewCount(),log=
|
|
317
|
+
const effects=reviewCount(),log=logBytes(),tasks=tasksBytes();
|
|
287
318
|
const retried=await bound();
|
|
288
319
|
assert.equal(retried.taskKey,`${feature}/T-001`);assert.equal(reviewCount(),effects+1,'exactly one review effect');
|
|
289
320
|
// Only that review: no completion, merge or handoff, no tasks.md change.
|
|
290
|
-
assert.
|
|
321
|
+
assert.deepEqual(logBytes(),log);assert.deepEqual(tasksBytes(),tasks);
|
|
291
322
|
if((options.reviewFailures??1)>1){
|
|
292
323
|
// The round's second rate limit: the runner's blocked stop, never retried again.
|
|
293
324
|
assert.equal(retried.state,'blocked',JSON.stringify(retried));assert.equal(retried.code,'review_provider_failed');
|
|
@@ -324,6 +355,29 @@ export async function batchFixture(mode,options={}){
|
|
|
324
355
|
assert.equal(git(codeProject,['status','--porcelain']),'?? dirty.txt');return;
|
|
325
356
|
}
|
|
326
357
|
const originalRead=fs.readFileSync,originalExists=fs.existsSync;
|
|
358
|
+
const startingHead=git(codeProject,['rev-parse','HEAD']),startingTasks=tasksBytes();
|
|
359
|
+
const rows=()=>logBytes().toString('utf8').split('\n').filter(Boolean).map(JSON.parse);
|
|
360
|
+
const rawRun=taskId=>JSON.parse(fs.readFileSync(path.join(specsDir,'.reviews','.execution',batchTaskRunIdFor(taskId),'state.json'),'utf8'));
|
|
361
|
+
const markIntents=taskId=>rawRun(taskId).records.filter(row=>row.payload.type==='task-commit-intent');
|
|
362
|
+
const originalRename=fs.renameSync;
|
|
363
|
+
if(options.interruptedComplete==='commit')fs.renameSync=function(from,to){
|
|
364
|
+
if(to===path.join(specsDir,feature,'tasks.md'))throw Object.assign(new Error('simulated interrupt'),{code:'EIO'});
|
|
365
|
+
return originalRename(from,to);
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
if(options.integrationCrash){
|
|
369
|
+
const phase=options.integrationCrash==='git-merged'?'batch_merge_tree':options.integrationCrash;
|
|
370
|
+
const logfile=path.join(specsDir,'运行日志.jsonl');
|
|
371
|
+
fs.existsSync=function(file,...args){
|
|
372
|
+
if(!interrupted&&String(file)===logfile&&originalExists(logfile)
|
|
373
|
+
&&originalRead(logfile,'utf8').includes(`"phase":"${phase}"`)
|
|
374
|
+
&&(options.integrationCrash!=='git-merged'||git(codeProject,['rev-parse','HEAD'])!==startingHead)){
|
|
375
|
+
interrupted=true;throw Object.assign(new Error('simulated interrupt'),{code:'simulated_interrupt'});
|
|
376
|
+
}
|
|
377
|
+
return originalExists.call(fs,file,...args);
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
|
|
327
381
|
const crashExists=function(file,...args){
|
|
328
382
|
if(!interrupted&&(options.crashAt==='serial'?String(file).endsWith('state.json'):String(file).endsWith('T-002'))){
|
|
329
383
|
const logfile=path.join(specsDir,'运行日志.jsonl');
|
|
@@ -341,12 +395,13 @@ export async function batchFixture(mode,options={}){
|
|
|
341
395
|
}
|
|
342
396
|
}return originalExists.call(fs,file,...args);
|
|
343
397
|
};
|
|
344
|
-
//
|
|
345
|
-
if(
|
|
398
|
+
// Both members have published their approval before the first merge opens a run.
|
|
399
|
+
if(['parallel-old-merge','parallel-preflight-failed'].includes(mode))fs.existsSync=function(file,...args){
|
|
346
400
|
if(!interrupted&&String(file).endsWith('state.json')){
|
|
347
401
|
const logfile=path.join(specsDir,'运行日志.jsonl');
|
|
348
402
|
const rows=originalExists(logfile)?originalRead(logfile,'utf8').split('\n').filter(Boolean).map(JSON.parse):[];
|
|
349
|
-
|
|
403
|
+
const ready=rows.filter(row=>row.phase==='batch_member_ready');
|
|
404
|
+
if(ready.length===2&&!rows.some(row=>row.phase==='batch_merge_started')){
|
|
350
405
|
interrupted=true;throw Object.assign(new Error('simulated interrupt'),{code:'simulated_interrupt'});
|
|
351
406
|
}
|
|
352
407
|
}return originalExists.call(fs,file,...args);
|
|
@@ -365,7 +420,152 @@ export async function batchFixture(mode,options={}){
|
|
|
365
420
|
assert.deepEqual(calls,['T-001']);return;
|
|
366
421
|
}
|
|
367
422
|
let result;
|
|
368
|
-
try{result=await pending;}catch(error){if(!
|
|
423
|
+
try{result=await pending;}catch(error){if(!interrupted||error.code!=='simulated_interrupt')throw error;}finally{fs.existsSync=originalExists;fs.renameSync=originalRename;}
|
|
424
|
+
if(options.interruptedComplete){
|
|
425
|
+
if(options.interruptedComplete==='check')assert.equal(result.code,'complete_recheck_failed',JSON.stringify(result));
|
|
426
|
+
else assert.equal(result.state,'unknown',JSON.stringify(result));
|
|
427
|
+
assert.deepEqual(tasksBytes(),startingTasks);
|
|
428
|
+
const run=rawRun('T-001'),{revision:discard,...body}=run;
|
|
429
|
+
const type=options.interruptedComplete==='commit'?'task-commit-intent':'effect-intent';
|
|
430
|
+
const cutoff=body.records.findLastIndex(row=>row.payload.type===type
|
|
431
|
+
&&(type==='task-commit-intent'||row.payload.effect.kind==='complete'));
|
|
432
|
+
assert(cutoff>0);
|
|
433
|
+
// Keep the real durable prefix written before the simulated process exit.
|
|
434
|
+
body.records=body.records.slice(0,cutoff+1);
|
|
435
|
+
const stateFile=path.join(specsDir,'.reviews','.execution',batchTaskRunIdFor('T-001'),'state.json');
|
|
436
|
+
fs.writeFileSync(stateFile,JSON.stringify({...body,revision:digest(body)})+'\n');
|
|
437
|
+
if(options.interruptedComplete==='check'){
|
|
438
|
+
const stopped=await open().handle({operation:'advance',requestId:'report-complete-interrupted'});
|
|
439
|
+
assert.equal(stopped.code,'batch_parallel_member_recovery_required',JSON.stringify(stopped));
|
|
440
|
+
const action={operation:'abandon_effect',requestId:'confirm-check-stopped',taskKey:`${feature}/T-001`,reason:'Fixture check process exited'};
|
|
441
|
+
assert.equal((await open().handle(action)).code,'batch_member_action_authorization_required');
|
|
442
|
+
const confirmed=await open({memberActions:{abandon_effect:[action.taskKey]}}).handle(action);
|
|
443
|
+
assert.equal(confirmed.outcome,'recorded',JSON.stringify(confirmed));
|
|
444
|
+
assert.deepEqual(tasksBytes(),startingTasks);
|
|
445
|
+
}
|
|
446
|
+
const resumed=await open().handle({operation:'advance',requestId:'resume-native-complete'});
|
|
447
|
+
assert.equal(resumed.code,'run_done',JSON.stringify(resumed));
|
|
448
|
+
assert.equal(markIntents('T-001').length,1);
|
|
449
|
+
assert.equal(rows().filter(row=>row.phase==='batch_merge_verified').length,2);
|
|
450
|
+
assert.deepEqual(calls,['T-001','T-002','T-003']);
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
if(options.integrationCrash){
|
|
454
|
+
assert(interrupted);
|
|
455
|
+
assert.deepEqual(tasksBytes(),startingTasks);
|
|
456
|
+
assert.equal(markIntents('T-001').length,0);assert.equal(markIntents('T-002').length,0);
|
|
457
|
+
const intent=rows().find(row=>row.phase==='batch_merge_started');
|
|
458
|
+
const ready=rows().find(row=>row.phase==='batch_member_ready'&&row.from_key.endsWith('/T-001'));
|
|
459
|
+
const head=git(codeProject,['rev-parse','HEAD']);
|
|
460
|
+
if(['batch_member_sealing','batch_merge_started'].includes(options.integrationCrash))assert.equal(head,startingHead);
|
|
461
|
+
else assert.notEqual(head,startingHead);
|
|
462
|
+
if(options.drift==='head')git(codeProject,['commit','--allow-empty','-m','unrelated target drift']);
|
|
463
|
+
if(options.drift==='member'){
|
|
464
|
+
git(ready.worktree,['update-index','--assume-unchanged','file0.js']);
|
|
465
|
+
fs.writeFileSync(path.join(ready.worktree,'file0.js'),'unreviewed edit\n');
|
|
466
|
+
assert.equal(git(ready.worktree,['status','--porcelain']),'');
|
|
467
|
+
}
|
|
468
|
+
if(options.pendingMerge){
|
|
469
|
+
const info=path.join(codeProject,'.git','info','attributes');
|
|
470
|
+
assert.equal(intent.attributes_before,null);
|
|
471
|
+
fs.writeFileSync(info,'\nAGENTS.md merge=union\n');
|
|
472
|
+
git(codeProject,['merge','--no-ff','--no-edit','--no-commit',intent.member_commit]);
|
|
473
|
+
}
|
|
474
|
+
if(options.drift==='config')await assert.rejects(open({checkTimeoutMs:2222}).handle({operation:'advance',requestId:'drift-config'}),
|
|
475
|
+
{code:'batch_merge_check_config_changed'});
|
|
476
|
+
if(options.drift==='forged'){
|
|
477
|
+
const batch=open();
|
|
478
|
+
await assert.rejects(batch.handle({operation:'advance',requestId:'forged-proof',
|
|
479
|
+
mergeCommit:head,mergeVerified:true}),{code:'invalid_input'});
|
|
480
|
+
const task=config.tasks[0],definition={version:1,specsDir,codeProject:ready.worktree,feature,
|
|
481
|
+
identity:ready.identity,scope:task.scope,requirements:task.requirements};
|
|
482
|
+
const execution={...await executionFor(definition,{parallelMember:true}),qaLogHome:logHome};
|
|
483
|
+
const parallelSelection={version:1,group:['T-001','T-002']};
|
|
484
|
+
await assert.rejects(openControlRun(definition,'resume',execution,{parallelSelection}),{code:'fingerprint_mismatch'});
|
|
485
|
+
const member=await openControlRun(definition,'resume',execution,{parallelSelection,
|
|
486
|
+
batchCompletion:{binding:{protocol:'merge-before-complete-v1',batchId:config.batchId,planDigest:ready.plan_digest},
|
|
487
|
+
verify:()=>false}});
|
|
488
|
+
try{
|
|
489
|
+
const complete={version:1,operation:'complete',requestId:'member-complete',identity:ready.identity,packageDigest:ready.package_digest};
|
|
490
|
+
const forged=await member.host.handle({...complete,mergeCommit:head,mergeVerified:true});
|
|
491
|
+
assert.equal(forged.outcome,'rejected');
|
|
492
|
+
assert.equal((await member.host.handle(complete)).code,'batch_merge_not_verified');
|
|
493
|
+
assert.equal(markIntents('T-001').length,0);
|
|
494
|
+
}finally{member.close();}
|
|
495
|
+
}
|
|
496
|
+
if(['head','member'].includes(options.drift)){
|
|
497
|
+
await assert.rejects(open().handle({operation:'advance',requestId:'refuse-drift'}),
|
|
498
|
+
{code:options.drift==='head'?'batch_merge_history_changed':'batch_member_delivery_changed'});
|
|
499
|
+
assert.deepEqual(tasksBytes(),startingTasks);
|
|
500
|
+
assert.equal(markIntents('T-001').length,0);
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
if(options.integrationCrash==='git-merged')assert(!rows().some(row=>row.phase==='batch_merge_verified'));
|
|
504
|
+
if(options.integrationCrash==='batch_merge_verified')assert(rows().some(row=>row.phase==='batch_merge_verified'));
|
|
505
|
+
result=await open().handle({operation:'advance',requestId:'resume-integration'});
|
|
506
|
+
assert.equal(result.code,'run_done',JSON.stringify(result));
|
|
507
|
+
assert.equal(rows().filter(row=>row.phase==='batch_merge_started').length,2);
|
|
508
|
+
assert.equal(rows().filter(row=>row.phase==='batch_merge_verified').length,2);
|
|
509
|
+
assert.equal(markIntents('T-001').length,1);
|
|
510
|
+
const handoff=rows().find(row=>row.phase==='batch_handoff');
|
|
511
|
+
if(intent&&head!==startingHead)assert.equal(handoff.merge_commit,head,'resume must keep the original merge');
|
|
512
|
+
assert.deepEqual(calls,['T-001','T-002','T-003']);
|
|
513
|
+
if(options.pendingMerge)assert(!fs.existsSync(path.join(codeProject,'.git','info','attributes')));
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
if(mode==='parallel-new-conflict'){
|
|
517
|
+
assert.equal(result.code,'merge_conflict',JSON.stringify(result));
|
|
518
|
+
assert.equal(git(codeProject,['rev-parse','HEAD']),conflictHead);
|
|
519
|
+
assert.deepEqual(tasksBytes(),startingTasks);
|
|
520
|
+
assert.equal(markIntents('T-001').length,0);assert.equal(markIntents('T-002').length,0);
|
|
521
|
+
assert.match(result.reason,/未合入/);
|
|
522
|
+
assert.match(result.guidance.prerequisites.join(' '),/未勾选任务.*T-001.*T-002/);
|
|
523
|
+
assert.equal(rows().filter(row=>row.phase==='batch_merge_verified').length,0);
|
|
524
|
+
assert.equal((await open().handle({operation:'advance',requestId:'stopped'})).reason,result.reason);
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
if(mode==='parallel-post-merge-failed'){
|
|
528
|
+
assert.equal(result.code,'post_merge_check_failed',JSON.stringify(result));
|
|
529
|
+
assert.match(result.reason,/已合入,检查失败/);
|
|
530
|
+
assert.match(tasksBytes().toString(),/- \[x\] T-001/);
|
|
531
|
+
assert.match(tasksBytes().toString(),/- \[ \] T-002/);
|
|
532
|
+
assert.equal(markIntents('T-001').length,1);assert.equal(markIntents('T-002').length,0);
|
|
533
|
+
const handoffs=rows().filter(row=>row.phase==='batch_handoff');
|
|
534
|
+
assert.deepEqual(handoffs.map(row=>row.from_key),[`${feature}/T-001`]);
|
|
535
|
+
assert.equal(handoffs[0].post_merge_check,'passed');
|
|
536
|
+
const head=git(codeProject,['rev-parse','HEAD']);
|
|
537
|
+
const failed=rows().find(row=>row.phase==='batch_merge_blocked');
|
|
538
|
+
assert.equal(head,result.mergeCommit);assert.equal(head,failed.merge_commit);
|
|
539
|
+
assert.equal(git(codeProject,['show','HEAD:file1.js']),'implemented');
|
|
540
|
+
assert.equal((await open().handle({operation:'status',requestId:'stopped-check'})).reason,result.reason);
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
if(mode==='parallel-preflight-failed'){
|
|
544
|
+
assert(interrupted);
|
|
545
|
+
const ready=rows().find(row=>row.phase==='batch_member_ready'&&row.from_key===`${feature}/T-001`);
|
|
546
|
+
const task=config.tasks[0],definition={version:1,specsDir,codeProject:ready.worktree,feature,
|
|
547
|
+
identity:ready.identity,scope:task.scope,requirements:task.requirements};
|
|
548
|
+
const member=await openControlRun(definition,'resume',{
|
|
549
|
+
...await executionFor(definition,{parallelMember:true}),qaLogHome:logHome},
|
|
550
|
+
{parallelSelection:{version:1,group:['T-001','T-002']},batchCompletion:{
|
|
551
|
+
binding:{protocol:'merge-before-complete-v1',batchId:config.batchId,planDigest:ready.plan_digest},verify:()=>false}});
|
|
552
|
+
try{
|
|
553
|
+
// Drift after the approved status was read, as if a file changed before sealing.
|
|
554
|
+
const status=await member.host.handle({version:1,operation:'status',requestId:'preflight-status',identity:ready.identity});
|
|
555
|
+
assert.equal(status.state,'approved');assert.equal(status.code,null);
|
|
556
|
+
fs.writeFileSync(path.join(ready.worktree,'file0.js'),'changed after approval\n');
|
|
557
|
+
const blocked=await member.preflightBatchCompletion(ready.identity,ready.package_digest);
|
|
558
|
+
assert.equal(blocked.outcome,'blocked');assert.equal(blocked.code,'package_mismatch');assert.match(blocked.reason,/file0\.js/);
|
|
559
|
+
}finally{member.close();}
|
|
560
|
+
result=await open().handle({operation:'advance',requestId:'refuse-approved-drift'});
|
|
561
|
+
assert.equal(result.code,'review_package_changed',JSON.stringify(result));
|
|
562
|
+
assert.deepEqual(Object.fromEntries(checkCalls),{'T-001':1,'T-002':1});
|
|
563
|
+
assert.deepEqual(tasksBytes(),startingTasks);
|
|
564
|
+
assert.equal(git(codeProject,['rev-parse','HEAD']),startingHead);
|
|
565
|
+
assert.equal(markIntents('T-001').length,0);assert.equal(markIntents('T-002').length,0);
|
|
566
|
+
assert(!rows().some(row=>row.phase==='batch_merge_started'));
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
369
569
|
if(options.configDivergence){
|
|
370
570
|
// Compared where it counts: after the worktree is created and before any develop
|
|
371
571
|
// dispatch, both checkouts' effective configurations as loaded. A difference (or a
|
|
@@ -572,6 +772,8 @@ export async function batchFixture(mode,options={}){
|
|
|
572
772
|
const logfile=path.join(specsDir,'运行日志.jsonl');
|
|
573
773
|
let rows=fs.readFileSync(logfile,'utf8').trim().split('\n').map(JSON.parse);
|
|
574
774
|
assert.equal(rows.filter(row=>row.phase==='batch_member_blocked').length,0);
|
|
775
|
+
assert(rows.some(row=>row.phase==='batch_merge_verified'&&row.from_key===`${feature}/T-002`));
|
|
776
|
+
assert.equal(markIntents('T-002').length,0);
|
|
575
777
|
assert(fs.existsSync(path.join(root,'.cm-worktrees',batchSegment(config.batchId),'T-002')));
|
|
576
778
|
result=await open().handle({operation:'advance',requestId:'retry-completion'});
|
|
577
779
|
assert.equal(result.code,'run_done',JSON.stringify(result));
|
|
@@ -590,6 +792,8 @@ export async function batchFixture(mode,options={}){
|
|
|
590
792
|
assert.equal(result.code,'run_done',JSON.stringify(result));
|
|
591
793
|
rows=fs.readFileSync(logfile,'utf8').trim().split('\n').map(JSON.parse);
|
|
592
794
|
assert.equal(rows.filter(row=>row.phase==='batch_member_blocked').length,0);
|
|
795
|
+
// Two develop-phase checks, then the post-merge N5 check: a parallel member
|
|
796
|
+
// completing after its merge never reuses the reviewed checks.
|
|
593
797
|
assert.equal(checkCalls.get('T-002'),3);
|
|
594
798
|
assert.equal(calls.filter(task=>task==='T-002').length,2);
|
|
595
799
|
return;
|
|
@@ -743,6 +947,15 @@ export async function batchFixture(mode,options={}){
|
|
|
743
947
|
return;
|
|
744
948
|
}
|
|
745
949
|
assert.equal(result.code,mode==='failed-qa'?'qa_failed':'run_done',JSON.stringify(result));
|
|
950
|
+
if(options.mergeChecks==='count'){
|
|
951
|
+
const worktree=taskId=>path.join(root,'.cm-worktrees',batchSegment(config.batchId),taskId);
|
|
952
|
+
const executedIn=fs.readFileSync(checkTrace,'utf8').trim().split('\n').map(JSON.parse);
|
|
953
|
+
// Each worktree runs delivery and N5 once. Main runs two merge checks plus
|
|
954
|
+
// delivery for the final serial task, whose first completion reuses its reviewed checks.
|
|
955
|
+
assert.deepEqual(executedIn.reduce((counts,cwd)=>({...counts,[cwd]:(counts[cwd]??0)+1}),{}),
|
|
956
|
+
{[worktree('T-001')]:2,[worktree('T-002')]:2,[codeProject]:3});
|
|
957
|
+
return;
|
|
958
|
+
}
|
|
746
959
|
if(mode==='resources-open'){
|
|
747
960
|
const {batchTaskRunId}=await import('./cm-ai-batch-run.mjs');
|
|
748
961
|
const runId=batchTaskRunId(config.batchId,`${feature}/T-001`),writer=new URL('./cm-log-event.py',import.meta.url).pathname;
|
|
@@ -774,6 +987,11 @@ export async function batchFixture(mode,options={}){
|
|
|
774
987
|
// Only members developed alongside others defer their QA; a one-member group decides
|
|
775
988
|
// with the fixed checkpoints and runs a triggered QA in its own worktree before merging.
|
|
776
989
|
assert.equal(rows.filter(row=>row.event==='qa'&&row.reason==='parallel_member_deferred'&&row.status==='skipped').length,each?0:2);
|
|
990
|
+
if(!each){
|
|
991
|
+
assert.equal(rows[0].completion_protocol,'merge-before-complete-v1');
|
|
992
|
+
assert.equal(ready.every(row=>row.member_state==='approved'),true);
|
|
993
|
+
assert.deepEqual(rows.filter(row=>row.phase==='batch_merge_verified').map(row=>row.post_merge_check),['skipped','skipped']);
|
|
994
|
+
}
|
|
777
995
|
assert.deepEqual(qaCalls,mode==='worktree-each-qa'?['T-001','T-003']:['T-003']);
|
|
778
996
|
if(each){
|
|
779
997
|
const decision=task=>rows.find(row=>row.event==='qa'&&row.node==='N6'&&row.task===task&&['skipped','triggered'].includes(row.status));
|
|
@@ -816,6 +1034,12 @@ export async function batchFixture(mode,options={}){
|
|
|
816
1034
|
// Git names a detached target in its default message ("… into HEAD").
|
|
817
1035
|
for(const merge of [subjects[1],subjects[3]])assert.match(merge,options.detachedMain?/^Merge commit '[a-f0-9]{40}' into HEAD$/:/^Merge commit '[a-f0-9]{40}'$/);
|
|
818
1036
|
}
|
|
1037
|
+
if(options.learningUnion){
|
|
1038
|
+
const agents=fs.readFileSync(path.join(codeProject,'AGENTS.md'),'utf8');
|
|
1039
|
+
assert.equal(agents.match(/^## 项目教训$/gm).length,1);
|
|
1040
|
+
for(const id of ['T-001','T-002'])assert(agents.includes(`Member ${id} requires its own regression trace`));
|
|
1041
|
+
assert(!fs.existsSync(path.join(codeProject,'.git','info','attributes')));
|
|
1042
|
+
}
|
|
819
1043
|
if(mode==='parallel-existing')for(const file of ['file0.js','file1.js']){
|
|
820
1044
|
assert.equal(fs.readFileSync(path.join(codeProject,file),'utf8'),'implemented\n');
|
|
821
1045
|
assert.equal(git(codeProject,['show',`HEAD~3:${file}`]),'existing');
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import test from 'node:test';
|
|
2
2
|
import {batchFixture} from './cm-ai-batch-run-fixture.mjs';
|
|
3
|
+
import {withFreshCompletionChecks} from './fixtures/fresh-completion-checks.mjs';
|
|
3
4
|
|
|
4
5
|
for(const mode of ['parallel','parallel-retry','parallel-conflict','parallel-resume','parallel-old-merge'])
|
|
5
6
|
test(`parallel batch runs real isolated members: ${mode}`,()=>batchFixture(mode));
|
|
6
|
-
test('
|
|
7
|
+
test('parallel members keep the established number of actual project checks',
|
|
8
|
+
()=>batchFixture('parallel',{mergeChecks:'count'}));
|
|
9
|
+
test('A4 parallel member retries changed completion checks in its original run',()=>withFreshCompletionChecks(()=>batchFixture('parallel-completion-retry')));
|
|
7
10
|
test('D1 parallel member retries failed develop checks before review',()=>batchFixture('parallel-develop-check-retry'));
|
|
8
11
|
// Worktree for every task: a chain that cannot pair still develops each task before the
|
|
9
12
|
// last alone in its own worktree, merges it back in order and removes worktree and branch.
|
|
@@ -32,3 +35,22 @@ test('a leftover member branch with its own commit stops the batch and is kept',
|
|
|
32
35
|
()=>batchFixture('worktree-each',{configDivergence:'smudge',cleanup:'unique-commit'}));
|
|
33
36
|
test('a diverged one-member worktree with a change hidden by assume-unchanged is kept',
|
|
34
37
|
()=>batchFixture('worktree-each',{configDivergence:'smudge',cleanup:'hidden'}));
|
|
38
|
+
|
|
39
|
+
test('a new batch keeps both tasks open after the first merge conflicts',()=>batchFixture('parallel-new-conflict'));
|
|
40
|
+
test('a new batch marks only the first member if the second merge check fails',
|
|
41
|
+
()=>batchFixture('parallel-post-merge-failed',{mergeChecks:'fail-second'}));
|
|
42
|
+
test('a new batch stops before merging when N5 preflight fails',()=>batchFixture('parallel-preflight-failed'));
|
|
43
|
+
for(const phase of ['batch_member_sealing','batch_merge_started','git-merged','batch_merge_verified'])
|
|
44
|
+
test(`a new batch resumes at ${phase} without a second merge or development`,
|
|
45
|
+
()=>batchFixture('parallel',{integrationCrash:phase,...(phase==='git-merged'?{mergeChecks:'pass'}:{})}));
|
|
46
|
+
for(const drift of ['head','member','config','forged'])
|
|
47
|
+
test(`a new batch refuses ${drift} drift or unverifiable completion evidence`,
|
|
48
|
+
()=>batchFixture('parallel',{integrationCrash:'batch_merge_started',drift}));
|
|
49
|
+
test('a new batch verifies a staged Git merge and restores its temporary attributes on resume',
|
|
50
|
+
()=>batchFixture('parallel',{integrationCrash:'batch_merge_started',pendingMerge:true}));
|
|
51
|
+
test('a new batch keeps both reviewed Learning entries through the AGENTS.md union merge',
|
|
52
|
+
()=>batchFixture('parallel',{learningUnion:true}));
|
|
53
|
+
test('a new batch finishes the interrupted native task-commit plan on the verified merge',
|
|
54
|
+
()=>batchFixture('parallel',{interruptedComplete:'commit'}));
|
|
55
|
+
test('a new batch requires the original recovery grant for an interrupted completion check',
|
|
56
|
+
()=>batchFixture('parallel',{interruptedComplete:'check'}));
|