@aibyzero/cm-workflow 0.16.7 → 0.16.9
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 +37 -0
- package/README.md +39 -3
- package/VERSION +1 -1
- package/assets/readme/workflow-recovery-detailed.png +0 -0
- package/assets/readme/workflow-stages-detailed.png +0 -0
- package/compat/claude-commands/cm-notify.md +3 -0
- package/docs/installation.md +1 -1
- package/docs/js-workflow-control.md +61 -4
- package/docs/next-steps.md +8 -2
- package/docs/user-guide.md +204 -0
- package/package.json +2 -1
- package/runtime/js/cm-ai/claude-review-stream.mjs +49 -13
- package/runtime/js/cm-ai/cm-ai-admission.mjs +3 -1
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +138 -26
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +142 -21
- package/runtime/js/cm-ai/code-projects.mjs +4 -1
- package/runtime/js/cm-ai/codex-review-adapter.mjs +2 -1
- package/runtime/js/cm-ai/developer-adapter.mjs +7 -0
- package/runtime/js/cm-ai/drive-core.mjs +26 -4
- package/runtime/js/cm-ai/durable-runner-state.mjs +951 -43
- package/runtime/js/cm-ai/effect-abandon-log.mjs +5 -2
- package/runtime/js/cm-ai/effect-contract.mjs +6 -1
- package/runtime/js/cm-ai/execution-store.mjs +4 -2
- package/runtime/js/cm-ai/external-run-guard.mjs +18 -7
- package/runtime/js/cm-ai/host-check.mjs +4 -1
- package/runtime/js/cm-ai/host-conversation-execution.mjs +11 -4
- package/runtime/js/cm-ai/host-documentation.mjs +53 -12
- package/runtime/js/cm-ai/host-project-execution.mjs +2 -2
- package/runtime/js/cm-ai/host-qa-executor.mjs +86 -17
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +44 -9
- package/runtime/js/cm-ai/host-session.mjs +47 -7
- package/runtime/js/cm-ai/host-tool-bridge.mjs +55 -6
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +4 -2
- package/runtime/js/cm-ai/operator-guidance.mjs +112 -3
- package/runtime/js/cm-ai/provider-review-observation.mjs +50 -0
- package/runtime/js/cm-ai/qa-resource-release.mjs +46 -0
- package/runtime/js/cm-ai/qa-round-budget.mjs +13 -0
- package/runtime/js/cm-ai/review-dispatch-limits.mjs +18 -0
- package/runtime/js/cm-ai/review-package.mjs +10 -1
- package/runtime/js/cm-ai/reviewed-deliveries.mjs +29 -6
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +1 -1
- package/runtime/js/cm-ai/task-commit.mjs +39 -0
- package/runtime/js/cm-ai/task-runner.mjs +636 -65
- package/runtime/js/cm-ai/worker-claude-developer.mjs +9 -0
- package/runtime/js/cm-ai/worker-claude.mjs +10 -3
- package/runtime/js/cm-ai/worker-process-identity.mjs +43 -0
- package/runtime/js/cm-fix/cause-package.mjs +37 -8
- package/runtime/js/cm-fix/diagnosis.mjs +43 -0
- package/runtime/js/cm-fix/execution.mjs +356 -187
- package/runtime/js/cm-fix/host.mjs +2 -1
- package/runtime/js/cm-fix/investigation.mjs +25 -9
- package/runtime/js/cm-fix/pinned-baseline.mjs +24 -0
- package/runtime/js/cm-fix/progress.mjs +15 -3
- package/runtime/js/cm-fix/protected-edits.mjs +10 -3
- package/runtime/js/cm-fix/repair.mjs +11 -3
- package/runtime/js/cm-fix/test-author.mjs +10 -3
- package/runtime/js/cm-idea/session.mjs +67 -4
- package/runtime/js/cm-prd/review-correction.mjs +10 -4
- package/runtime/js/cm-prd/session.mjs +43 -0
- package/runtime/js/cm-refactor/records.mjs +98 -8
- package/runtime/js/cm-refactor/workflow.mjs +79 -9
- package/runtime/js/cm-test/host.mjs +10 -3
- package/runtime/js/cm-test/session.mjs +45 -6
- package/runtime/js/notify-run.mjs +26 -0
- package/runtime/js/notify-safe-read.mjs +49 -0
- package/runtime/js/notify-send.mjs +312 -0
- package/runtime/js/notify.mjs +492 -0
- package/runtime/js/policy-binding-compat.mjs +54 -0
- package/runtime/model-efficiency.md +17 -0
- package/scripts/ci-test-shards.mjs +67 -0
- package/scripts/ci-test-shards.test.mjs +64 -0
- package/scripts/ci-test-weights.json +222 -0
- package/scripts/cm-ai-abandon-effect-position.test.mjs +70 -2
- package/scripts/cm-ai-answer-gap-dispatch.test.mjs +86 -0
- package/scripts/cm-ai-answer-gap-driver.test.mjs +51 -0
- package/scripts/cm-ai-answer-gap-fixture.mjs +96 -0
- package/scripts/cm-ai-answer-gap-recheck.test.mjs +70 -0
- package/scripts/cm-ai-answer-gap-redo.test.mjs +103 -0
- package/scripts/cm-ai-batch-drive.mjs +55 -10
- package/scripts/cm-ai-batch-drive.test.mjs +65 -0
- package/scripts/cm-ai-batch-host.mjs +132 -13
- package/scripts/cm-ai-batch-host.test.mjs +255 -7
- package/scripts/cm-ai-batch-run-fixture.mjs +499 -0
- package/scripts/cm-ai-batch-run-member-stops.test.mjs +38 -0
- package/scripts/cm-ai-batch-run-parallel.test.mjs +7 -0
- package/scripts/cm-ai-batch-run-reschedule.test.mjs +17 -0
- package/scripts/cm-ai-batch-run.mjs +189 -22
- package/scripts/cm-ai-batch-run.test.mjs +22 -334
- package/scripts/cm-ai-develop-answer-invalid.test.mjs +104 -0
- package/scripts/cm-ai-develop-call-timeout.test.mjs +153 -0
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +4 -3
- package/scripts/cm-ai-documentation-sync-gap.test.mjs +424 -0
- package/scripts/cm-ai-drive.mjs +68 -23
- package/scripts/cm-ai-drive.test.mjs +37 -2
- package/scripts/cm-ai-fix-run-delivery.test.mjs +138 -0
- package/scripts/cm-ai-host-cli-workflow.test.mjs +271 -0
- package/scripts/cm-ai-host-fixture.mjs +268 -0
- package/scripts/cm-ai-host-protected.test.mjs +251 -0
- package/scripts/cm-ai-host.mjs +28 -16
- package/scripts/cm-ai-host.test.mjs +17 -759
- package/scripts/cm-ai-light-modules.test.mjs +57 -0
- package/scripts/cm-ai-operator-guidance.test.mjs +30 -5
- package/scripts/cm-ai-project-qa-gate.test.mjs +71 -4
- package/scripts/cm-ai-protected-scope.test.mjs +7 -3
- package/scripts/cm-ai-qa-answer-gaps.test.mjs +99 -0
- package/scripts/cm-ai-qa-fix-cross-session.test.mjs +78 -11
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +127 -8
- package/scripts/cm-ai-review-dispatch-exit.test.mjs +475 -0
- package/scripts/cm-ai-review-failure.test.mjs +124 -13
- package/scripts/cm-ai-review-timeout.test.mjs +188 -10
- package/scripts/cm-ai-run.mjs +15 -6
- package/scripts/cm-ai-supersede.test.mjs +486 -41
- package/scripts/cm-check-drive-files.mjs +8 -0
- package/scripts/cm-check-drive.test.mjs +2 -5
- package/scripts/cm-check-runtime.sh +4 -2
- package/scripts/cm-claude-developer-worker.test.mjs +15 -0
- package/scripts/cm-claude-review-stream.test.mjs +21 -16
- package/scripts/cm-claude-review-synthetic.test.mjs +155 -0
- package/scripts/cm-claude-worker.test.mjs +18 -2
- package/scripts/cm-external-model-recovery.test.mjs +29 -3
- package/scripts/cm-fix-abandon.test.mjs +249 -10
- package/scripts/cm-fix-cause-package.test.mjs +33 -0
- package/scripts/cm-fix-drive-unprotected.test.mjs +37 -0
- package/scripts/cm-fix-drive.mjs +34 -8
- package/scripts/cm-fix-host.mjs +8 -7
- package/scripts/cm-fix-rediagnosis.test.mjs +71 -4
- package/scripts/cm-fix-review-budget.test.mjs +13 -0
- package/scripts/cm-fix-review-recovery.test.mjs +35 -0
- package/scripts/cm-host-answer-timeout.test.mjs +65 -0
- package/scripts/cm-host-call-kinds.test.mjs +28 -0
- package/scripts/cm-host-documentation.test.mjs +49 -0
- package/scripts/cm-host-qa-executor.test.mjs +143 -10
- package/scripts/cm-idea-answer-gaps.test.mjs +164 -0
- package/scripts/cm-idea-drive.mjs +49 -11
- package/scripts/cm-idea-drive.test.mjs +66 -0
- package/scripts/cm-idea-host.mjs +106 -16
- package/scripts/cm-init-answer-gaps.test.mjs +258 -0
- package/scripts/cm-init-drive.mjs +41 -7
- package/scripts/cm-init-host.mjs +61 -12
- package/scripts/cm-log-event.mjs +49 -12
- package/scripts/cm-notify-command.test.mjs +900 -0
- package/scripts/cm-notify-read-drift.test.mjs +205 -0
- package/scripts/cm-notify.mjs +469 -0
- package/scripts/cm-notify.test.mjs +685 -0
- package/scripts/cm-patrol.mjs +83 -0
- package/scripts/cm-patrol.test.mjs +161 -0
- package/scripts/cm-prd-answer-gaps.test.mjs +216 -0
- package/scripts/cm-prd-drive.mjs +18 -5
- package/scripts/cm-prd-drive.test.mjs +15 -0
- package/scripts/cm-prd-host.mjs +37 -4
- package/scripts/cm-prd-review-disposition.test.mjs +6 -1
- package/scripts/cm-prd-review-gate.mjs +56 -0
- package/scripts/cm-refactor-answer-gaps.test.mjs +206 -0
- package/scripts/cm-refactor-drive.mjs +52 -8
- package/scripts/cm-refactor-drive.test.mjs +44 -0
- package/scripts/cm-refactor-host.test.mjs +10 -6
- package/scripts/cm-release-smoke.sh +2 -0
- package/scripts/cm-test-answer-gaps.test.mjs +151 -0
- package/scripts/cm-test-drive.mjs +21 -5
- package/scripts/cm-token-report.mjs +497 -0
- package/scripts/cm-token-report.test.mjs +346 -0
- package/scripts/fixtures/claude-review-process.mjs +1 -1
- package/scripts/policy-binding-compat.test.mjs +99 -0
- package/scripts/scan-public-safety.py +4 -0
- package/scripts/validate-public-repo.py +4 -0
- package/skills/cm-ai/SKILL.md +7 -3
- package/skills/cm-ai/references/N6-qa-eval.md +2 -2
- package/skills/cm-ai/references/js-host-modes.md +90 -0
- package/skills/cm-ai/references/js-host-qa-recovery.md +136 -0
- package/skills/cm-ai/references/js-host-recovery.md +311 -0
- package/skills/cm-ai/references/js-host.md +76 -331
- package/skills/cm-check/SKILL.md +3 -3
- package/skills/cm-fix/SKILL.md +2 -0
- package/skills/cm-fix/references/js-host.md +56 -10
- package/skills/cm-idea/references/js-host.md +27 -2
- package/skills/cm-init/references/js-host.md +16 -3
- package/skills/cm-notify/SKILL.md +34 -0
- package/skills/cm-prd/SKILL.md +2 -0
- package/skills/cm-prd/references/js-change-recovery.md +35 -1
- package/skills/cm-refactor/references/js-host.md +17 -0
- package/skills/cm-test/references/js-host.md +14 -1
|
@@ -64,16 +64,83 @@ test('original run rediagnoses after cause rejection, preserves history, and req
|
|
|
64
64
|
await assert.rejects(owner.rediagnose({authorized:true,reason:'Again'}),{code:'fix_rediagnosis_unavailable'});
|
|
65
65
|
assert.deepEqual(f.counts(),{calls:2,diagnoses:2});
|
|
66
66
|
}));
|
|
67
|
-
|
|
67
|
+
const revised={status:'diagnosed',rootCause:'Fixture revised cause',plan:'Fixture plan',affectedPaths:['value.mjs'],affectedModules:['value'],crossLayer:false};
|
|
68
|
+
const tooManyAlternatives={...revised,investigation:{boundaryAnalysis:null,
|
|
69
|
+
discardedAlternatives:[1,2,3,4].map(n=>({option:`Fixture option ${n}`,reason:'Fixture reason'}))}};
|
|
70
|
+
async function hostRediagnose(f,reason='Address F1'){
|
|
71
|
+
const owner=f.owner(),host=createFixHost({owner,config:{...f.options.configuration,...f.options},permissions:['--allow-rediagnosis']});
|
|
72
|
+
const input=new PassThrough();let output='',errors='';
|
|
73
|
+
const sink=new Writable({write(chunk,encoding,done){output+=chunk;done();}});
|
|
74
|
+
const errorOutput=new Writable({write(chunk,encoding,done){errors+=chunk;done();}});
|
|
75
|
+
input.end(JSON.stringify({requestId:'redo',operation:'rediagnose',reason})+'\n');
|
|
76
|
+
await serveCmAiHost({host,input,output:sink,errorOutput});
|
|
77
|
+
return {reply:JSON.parse(output),errors};
|
|
78
|
+
}
|
|
79
|
+
const ids=file=>JSON.parse(fs.readFileSync(file)).records.map(row=>row.id);
|
|
80
|
+
test('regression: invalid rediagnosis answer is invalid_diagnosis, stays pending, and a valid answer under the same intent reaches cause-r2',async t=>fixture(t,async f=>{
|
|
68
81
|
const before=JSON.parse(fs.readFileSync(f.state)).records;
|
|
82
|
+
f.bridge.call=async kind=>{assert.equal(kind,'fix_diagnose');return tooManyAlternatives;};
|
|
83
|
+
f.reopen();
|
|
84
|
+
const rejected=await hostRediagnose(f);
|
|
85
|
+
assert.deepEqual(rejected.reply.error,{code:'host_request_failed'});
|
|
86
|
+
const diagnostic=JSON.parse(rejected.errors.trim().split('\n').at(-1));
|
|
87
|
+
assert.equal(diagnostic.code,'invalid_diagnosis');assert.match(diagnostic.reason,/investigation\.discardedAlternatives.*最多 3 项,实际 4 项/);
|
|
88
|
+
let owner=f.reopen();
|
|
89
|
+
assert.equal(owner.status().stage,'unknown');assert.equal(owner.status().pending,'rediagnosis');
|
|
90
|
+
const pendingIds=ids(f.state);assert.deepEqual(pendingIds.slice(before.length),['fix-rediagnosis-intent']);
|
|
91
|
+
await assert.rejects(owner.rediagnose({authorized:true,reason:'Retry'}),{code:'invalid_diagnosis'});
|
|
92
|
+
assert.deepEqual(ids(f.state),pendingIds);
|
|
93
|
+
let asked=0;f.bridge.call=async(kind,payload)=>{asked++;assert.equal(payload.reviewFeedback.verdict,'changes_requested');return revised;};
|
|
94
|
+
owner=f.reopen();
|
|
95
|
+
assert.equal((await hostRediagnose(f,'Resubmit valid answer')).reply.result.stage,'cause_review_required');
|
|
96
|
+
const next=JSON.parse(fs.readFileSync(f.state)).records;
|
|
97
|
+
assert.deepEqual(next.slice(0,before.length),before);
|
|
98
|
+
assert.deepEqual(next.slice(before.length).map(row=>row.id),['fix-rediagnosis-intent','fix-rediagnosis-result']);
|
|
99
|
+
assert.equal(next[before.length].payload.reason,'Address F1');
|
|
100
|
+
owner=f.reopen();assert.equal(owner.status().diagnosis.rootCause,'Fixture revised cause');
|
|
101
|
+
assert.equal((await f.review()).stage,'red_test_required');
|
|
102
|
+
assert.match(fs.readFileSync(path.join(f.specsRoot,'.reviews/fix-rediagnosis-cause-r2.md'),'utf8'),/round: 2\nverdict: approved/);
|
|
103
|
+
assert.equal(asked,1);assert.equal(f.counts().calls,2);
|
|
104
|
+
assert.equal(fs.readFileSync(path.join(f.code,'visits'),'utf8'),'1');
|
|
105
|
+
}));
|
|
106
|
+
for(const secondVerdict of ['approved','changes_requested'])test(`regression: an old journal ending in fix-rediagnosis-intent without a result resumes by re-asking under that intent (${secondVerdict})`,async t=>fixture(t,async f=>{
|
|
107
|
+
// Old runtime: intent appended, answer rejected inside the catch, nothing else written.
|
|
69
108
|
f.bridge.call=async()=>{throw Error('Fixture lost result');};
|
|
70
109
|
const result=await f.owner().rediagnose({authorized:true,reason:'Address F1'});
|
|
71
110
|
assert.equal(result.stage,'unknown');assert.equal(result.pending,'rediagnosis');
|
|
72
|
-
const
|
|
111
|
+
const stuck=fs.readFileSync(f.state),stuckIds=ids(f.state);
|
|
112
|
+
assert.equal(stuckIds.at(-1),'fix-rediagnosis-intent');
|
|
113
|
+
let owner=f.reopen();
|
|
73
114
|
assert.equal((await owner.advance({authorized:true})).stage,'unknown');
|
|
74
|
-
|
|
75
|
-
|
|
115
|
+
const host=createFixHost({owner,config:{...f.options.configuration,...f.options},permissions:['--allow-rediagnosis']});
|
|
116
|
+
const status=await host.handle({requestId:'s',operation:'status'});
|
|
117
|
+
assert.equal(status.progress.blocker,'rediagnosis_answer_required');assert.match(status.progress.nextAction,/rediagnose/);
|
|
118
|
+
assert.deepEqual(fs.readFileSync(f.state),stuck);
|
|
119
|
+
f.bridge.call=async()=>revised;
|
|
120
|
+
owner=f.reopen();
|
|
121
|
+
assert.equal((await owner.rediagnose({authorized:true,reason:'Resume pending rediagnosis'})).stage,'cause_review_required');
|
|
122
|
+
assert.deepEqual(ids(f.state),[...stuckIds,'fix-rediagnosis-result']);
|
|
123
|
+
assert.deepEqual(JSON.parse(fs.readFileSync(f.state)).records.slice(0,stuckIds.length),JSON.parse(stuck).records);
|
|
124
|
+
// The re-ask used the registered continuation: the review limit still applies.
|
|
125
|
+
const stage=secondVerdict==='approved'?'red_test_required':'rediagnosis_review_limit_reached';
|
|
126
|
+
assert.equal((await f.review()).stage,stage);
|
|
127
|
+
owner=f.reopen();assert.equal(owner.status().stage,stage);
|
|
128
|
+
await assert.rejects(owner.rediagnose({authorized:true,reason:'Again'}),{code:'fix_rediagnosis_unavailable'});
|
|
129
|
+
assert.equal(ids(f.state).filter(id=>id==='fix-rediagnosis-intent').length,1);
|
|
76
130
|
assert.equal(fs.readFileSync(path.join(f.code,'visits'),'utf8'),'1');
|
|
131
|
+
},{secondVerdict}));
|
|
132
|
+
test('driver preflight refuses an invalid rediagnosis answer before starting the host',async t=>fixture(t,async f=>{
|
|
133
|
+
const config=path.join(f.root,'driver-config.json'),answers=path.join(f.root,'answers');fs.mkdirSync(answers);
|
|
134
|
+
fs.writeFileSync(config,JSON.stringify({specsRoot:f.specsRoot,identity:f.identity,reproduction:f.options.configuration.reproduction}));
|
|
135
|
+
fs.writeFileSync(path.join(answers,'learning.json'),JSON.stringify({status:'no_relevant_lesson',summary:'Fixture'}));
|
|
136
|
+
const run=file=>{fs.writeFileSync(path.join(answers,'diagnosis-rediagnosis.json'),JSON.stringify(file));
|
|
137
|
+
const script=`import {preflight} from ${JSON.stringify(new URL('./cm-fix-drive.mjs',import.meta.url).href)};preflight(${JSON.stringify({operation:'rediagnose',plan:{cwd:f.code,mode:'resume'},paths:{config,answers}})});`;
|
|
138
|
+
return spawnSync(process.execPath,['--input-type=module','-e',script],{encoding:'utf8'});};
|
|
139
|
+
const before=fs.readFileSync(f.state);
|
|
140
|
+
const refused=run(tooManyAlternatives);
|
|
141
|
+
assert.equal(refused.status,2);assert.match(refused.stderr,/diagnosis-rediagnosis\.json.*investigation\.discardedAlternatives.*最多 3 项,实际 4 项.*宿主未启动/);
|
|
142
|
+
assert.equal(run(revised).status,0);
|
|
143
|
+
assert.deepEqual(fs.readFileSync(f.state),before);
|
|
77
144
|
}));
|
|
78
145
|
for(const failure of ['source','evidence','reason'])test(`rediagnosis refuses ${failure} before registering a new effect`,async t=>fixture(t,async f=>{
|
|
79
146
|
const before=fs.readFileSync(f.state);
|
|
@@ -145,3 +145,16 @@ test('#15 the cm-ai driver forwards the QA-fix abandon_review reason inside fix_
|
|
|
145
145
|
assert.deepEqual(buildCmAiDriveRequest('fix_action',plan,{identity}),{version:1,identity,packageDigest:plan.packageDigest,
|
|
146
146
|
testRunId:plan.testRunId,fixOperation:'abandon_review',reason:plan.reason});
|
|
147
147
|
});
|
|
148
|
+
|
|
149
|
+
test('Q23 the cm-ai driver forwards the new QA-fix recovery fields inside fix_action',()=>{
|
|
150
|
+
const identity={repositoryId:'r',runId:'run',taskId:'T-1',attempt:1},base={packageDigest:'a'.repeat(64),testRunId:'qa-run'};
|
|
151
|
+
for(const fixOperation of ['rediagnose','rerun_blocked_step'])
|
|
152
|
+
assert.deepEqual(buildCmAiDriveRequest('fix_action',{...base,fixOperation,reason:'理由'},{identity}),
|
|
153
|
+
{version:1,identity,...base,fixOperation,reason:'理由'});
|
|
154
|
+
const recover={...base,fixOperation:'recover_final_review',invocationId:'final-1',reviewPackageDigest:'b'.repeat(64),
|
|
155
|
+
previousInvocationStopped:true,reason:'旧审查已停'};
|
|
156
|
+
assert.deepEqual(buildCmAiDriveRequest('fix_action',recover,{identity}),{version:1,identity,...base,fixOperation:'recover_final_review',
|
|
157
|
+
reason:'旧审查已停',invocationId:'final-1',reviewPackageDigest:'b'.repeat(64),previousInvocationStopped:true});
|
|
158
|
+
assert.deepEqual(buildCmAiDriveRequest('fix_action',{...base,fixOperation:'revision_test_check'},{identity}),
|
|
159
|
+
{version:1,identity,...base,fixOperation:'revision_test_check'});
|
|
160
|
+
});
|
|
@@ -35,6 +35,7 @@ async function fixture(t,mode){
|
|
|
35
35
|
const workerFactory=()=>async({prompt},{onEvent})=>{
|
|
36
36
|
calls++;const data=JSON.parse(prompt.split('<cm-review-data-json>\n')[1]);
|
|
37
37
|
const thread=calls===1||mode==='reuse-thread'||['reuse-first-thread','revision-reuses-lost-thread'].includes(mode)&&calls===3?'old-thread':`new-thread-${calls}`;
|
|
38
|
+
if(mode==='no-thread-always'||mode==='no-thread'&&calls===1)throw Error('Synthetic loss before any thread');
|
|
38
39
|
onEvent({event:'thread.started',provider_thread:thread});
|
|
39
40
|
if(calls===1&&!['approved','changes_requested'].includes(mode)||mode==='loss-again'
|
|
40
41
|
||['twice-then-success','reuse-first-thread'].includes(mode)&&calls<=2)throw Error('Synthetic lost result');
|
|
@@ -196,3 +197,37 @@ for(const mode of ['loss-again','reuse-thread','approved','changes_requested'])t
|
|
|
196
197
|
assert.equal(f.reopen().status().stage,'unknown');assert.equal((await f.owner().reviewFinal()).stage,'unknown');
|
|
197
198
|
assert.equal(f.calls(),2);assert.equal(f.repairs(),1);
|
|
198
199
|
});
|
|
200
|
+
|
|
201
|
+
// V5 (F24): a worker that never opened a thread leaves nothing to exclude; the
|
|
202
|
+
// first final review is still recoverable, at most twice in total.
|
|
203
|
+
test('F24 a first final review lost before any thread is recovered and approved',{timeout:FIXTURE_TIMEOUT_MS},async t=>{
|
|
204
|
+
const f=await fixture(t,'no-thread');
|
|
205
|
+
const lost=f.reopen().status();assert.equal(lost.stage,'unknown');
|
|
206
|
+
assert(!JSON.parse(fs.readFileSync(f.statePath)).records.some(r=>r.id==='fix-final-started'));
|
|
207
|
+
assert.match((await f.cli([op('status')]))[0].result.progress.nextAction,/recover_final_review/);
|
|
208
|
+
const rows=await f.cli([f.request,op('final_review')],['--allow-final-review','--allow-final-review-recovery']);
|
|
209
|
+
for(const row of rows)assert(!row.error,JSON.stringify(row));
|
|
210
|
+
assert.equal(rows.at(-1).result.stage,'final_review_evidence_required');assert.equal(f.calls(),2);
|
|
211
|
+
const authorized=JSON.parse(fs.readFileSync(f.statePath)).records.find(r=>r.id==='fix-final-recovery-authorized').payload;
|
|
212
|
+
assert.equal(authorized.providerThreadId,null);
|
|
213
|
+
});
|
|
214
|
+
test('F24 thread-less recovery stops after two recoveries without changing the store',{timeout:FIXTURE_TIMEOUT_MS},async t=>{
|
|
215
|
+
const f=await fixture(t,'no-thread-always');
|
|
216
|
+
await f.cli([f.request,op('final_review')],['--allow-final-review','--allow-final-review-recovery']);
|
|
217
|
+
assert.equal(f.calls(),2);
|
|
218
|
+
const bound=()=>{const latest=f.reopen().status().finalReviewInvocation;
|
|
219
|
+
return {request:{...f.request,invocationId:latest.invocationId,packageDigest:latest.packageDigest},
|
|
220
|
+
flags:['--allow-final-review-recovery','--final-review-recovery-invocation',latest.invocationId]};};
|
|
221
|
+
const second=bound();
|
|
222
|
+
const rows=await f.cli([second.request,op('final_review')],[...second.flags,'--allow-final-review']);
|
|
223
|
+
assert(!rows[0].error,JSON.stringify(rows[0]));assert.equal(f.calls(),3);assert.equal(f.reopen().status().stage,'unknown');
|
|
224
|
+
const third=bound(),before=fs.readFileSync(f.statePath);
|
|
225
|
+
const refused=await f.cli([third.request],third.flags);
|
|
226
|
+
assert(refused[0].error);assert.deepEqual(fs.readFileSync(f.statePath),before);assert.equal(f.calls(),3);
|
|
227
|
+
const {requestId,operation,...fields}=third.request;
|
|
228
|
+
assert.throws(()=>f.reopen().recoverFinalReview({authorized:true,recoveryInvocationId:third.request.invocationId,...fields}),
|
|
229
|
+
{code:'fix_review_recovery_limit',reason:/无线程恢复已用满 2 次/});
|
|
230
|
+
const status=(await f.cli([op('status')]))[0].result;
|
|
231
|
+
assert.equal(status.progress.blocker,'fix_review_recovery_limit');assert.match(status.progress.nextAction,/新的 runId/);
|
|
232
|
+
assert.deepEqual(fs.readFileSync(f.statePath),before);
|
|
233
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// R0: every bridge call has a deadline. A call without its own timeoutMs stops
|
|
2
|
+
// at the host answer limit; an answer that arrives after a call was stopped is
|
|
3
|
+
// refused as host_response_late with one diagnostic line.
|
|
4
|
+
import test from 'node:test';
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
import {createHostToolBridge,hostAnswerTimeoutMs,HOST_ANSWER_TIMEOUT_DEFAULT_MS,HOST_ANSWER_TIMEOUT_MAX_MS,
|
|
7
|
+
HOST_ANSWER_BACKSTOP_MS} from '../runtime/js/cm-ai/host-tool-bridge.mjs';
|
|
8
|
+
|
|
9
|
+
test('host answer limit: default 30 minutes, 1-60 minutes from CM_HOST_ANSWER_TIMEOUT_MINUTES, backstop above 60',()=>{
|
|
10
|
+
assert.equal(hostAnswerTimeoutMs({}),HOST_ANSWER_TIMEOUT_DEFAULT_MS);
|
|
11
|
+
assert.equal(HOST_ANSWER_TIMEOUT_DEFAULT_MS,30*60000);
|
|
12
|
+
assert.equal(hostAnswerTimeoutMs({CM_HOST_ANSWER_TIMEOUT_MINUTES:'5'}),5*60000);
|
|
13
|
+
assert.equal(hostAnswerTimeoutMs({CM_HOST_ANSWER_TIMEOUT_MINUTES:'60'}),HOST_ANSWER_TIMEOUT_MAX_MS);
|
|
14
|
+
for(const bad of ['0','61','1.5','x','-1',' 5'])
|
|
15
|
+
assert.throws(()=>hostAnswerTimeoutMs({CM_HOST_ANSWER_TIMEOUT_MINUTES:bad}),{code:'host_answer_timeout_invalid'},bad);
|
|
16
|
+
assert.ok(HOST_ANSWER_BACKSTOP_MS>HOST_ANSWER_TIMEOUT_MAX_MS);
|
|
17
|
+
assert.throws(()=>createHostToolBridge({answerTimeoutMs:HOST_ANSWER_BACKSTOP_MS+1}),{code:'host_answer_timeout_invalid'});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('a call without its own timeout stops at the host answer limit and a late answer is refused with one diagnostic',async()=>{
|
|
21
|
+
const bridge=createHostToolBridge({answerTimeoutMs:1000}),sent=[];
|
|
22
|
+
bridge.attach(value=>{sent.push(value);});
|
|
23
|
+
// The default deadline is unref'd; keep this test process alive while it runs.
|
|
24
|
+
const keep=setInterval(()=>{},100);
|
|
25
|
+
try{
|
|
26
|
+
const started=Date.now();
|
|
27
|
+
await assert.rejects(bridge.call('prd_generate',{fixture:true},new AbortController().signal),{code:'host_request_timeout'});
|
|
28
|
+
assert.ok(Date.now()-started>=900);
|
|
29
|
+
const request=sent.find(row=>row.type==='host_request');assert.ok(request);
|
|
30
|
+
const lines=[],write=process.stderr.write;
|
|
31
|
+
process.stderr.write=(chunk,...rest)=>{lines.push(String(chunk));return true;};
|
|
32
|
+
let late;
|
|
33
|
+
try{late=bridge.accept({type:'host_result',sessionId:request.sessionId,callId:request.callId,
|
|
34
|
+
requestDigest:request.requestDigest,result:{status:'late'}});}
|
|
35
|
+
finally{process.stderr.write=write;}
|
|
36
|
+
assert.deepEqual(late,{accepted:false,code:'host_response_late'});
|
|
37
|
+
const diagnostics=lines.filter(line=>line.includes('host_response_late'));
|
|
38
|
+
assert.equal(diagnostics.length,1);
|
|
39
|
+
assert.deepEqual(JSON.parse(diagnostics[0]),{diagnostic:'host_response_late',kind:'prd_generate',
|
|
40
|
+
callId:request.callId,stoppedBy:'host_request_timeout'});
|
|
41
|
+
// An answer for a call this bridge never issued stays a plain mismatch.
|
|
42
|
+
assert.deepEqual(bridge.accept({type:'host_result',sessionId:request.sessionId,callId:'other',
|
|
43
|
+
requestDigest:request.requestDigest,result:{}}),{accepted:false,code:'host_response_mismatch'});
|
|
44
|
+
}finally{clearInterval(keep);bridge.close();}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('an explicit per-call timeout still wins over the host answer limit',async()=>{
|
|
48
|
+
const bridge=createHostToolBridge({answerTimeoutMs:60000});bridge.attach(()=>{});
|
|
49
|
+
const started=Date.now();
|
|
50
|
+
await assert.rejects(bridge.call('qa_assess',{},new AbortController().signal,{timeoutMs:50}),{code:'host_request_timeout'});
|
|
51
|
+
assert.ok(Date.now()-started<5000);bridge.close();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('a request that first runs project commands waits for the 60-minute maximum, not the general limit',async()=>{
|
|
55
|
+
const bridge=createHostToolBridge({answerTimeoutMs:1000}),sent=[];bridge.attach(value=>{sent.push(value);});
|
|
56
|
+
const keep=setInterval(()=>{},100);
|
|
57
|
+
try{
|
|
58
|
+
const pending=bridge.call('init_verify',{},new AbortController().signal);
|
|
59
|
+
await new Promise(resolve=>setTimeout(resolve,1300));
|
|
60
|
+
const request=sent.find(row=>row.type==='host_request');
|
|
61
|
+
assert.deepEqual(bridge.accept({type:'host_result',sessionId:request.sessionId,callId:request.callId,
|
|
62
|
+
requestDigest:request.requestDigest,result:{ok:true}}),{accepted:true,callId:request.callId});
|
|
63
|
+
assert.deepEqual(await pending,{ok:true});
|
|
64
|
+
}finally{clearInterval(keep);bridge.close();}
|
|
65
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// O20: every kind a workflow host asks through the real bridge must be on its
|
|
2
|
+
// whitelist; refactor_revise_tests (round-2 judge revision) was missing, so the
|
|
3
|
+
// second refactor round threw host_operation_invalid on every attempt.
|
|
4
|
+
import test from 'node:test';
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
import fs from 'node:fs';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import {fileURLToPath} from 'node:url';
|
|
9
|
+
import {createHostToolBridge,HOST_CALL_KINDS} from '../runtime/js/cm-ai/host-tool-bridge.mjs';
|
|
10
|
+
|
|
11
|
+
const root=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..');
|
|
12
|
+
test('the real bridge accepts refactor_revise_tests and answers it',async()=>{
|
|
13
|
+
const bridge=createHostToolBridge(),sent=[];bridge.attach(value=>{sent.push(value);});
|
|
14
|
+
try{
|
|
15
|
+
const pending=bridge.call('refactor_revise_tests',{attempt:2},new AbortController().signal);
|
|
16
|
+
await new Promise(resolve=>setImmediate(resolve));
|
|
17
|
+
const request=sent.find(row=>row.type==='host_request');
|
|
18
|
+
assert.equal(request?.kind,'refactor_revise_tests');
|
|
19
|
+
bridge.accept({type:'host_result',sessionId:request.sessionId,callId:request.callId,requestDigest:request.requestDigest,result:{files:[]}});
|
|
20
|
+
assert.deepEqual(await pending,{files:[]});
|
|
21
|
+
}finally{bridge.close();}
|
|
22
|
+
});
|
|
23
|
+
test('every refactor invoke kind in the workflow is a bridge kind',()=>{
|
|
24
|
+
const source=fs.readFileSync(path.join(root,'runtime/js/cm-refactor/workflow.mjs'),'utf8');
|
|
25
|
+
const kinds=[...new Set([...source.matchAll(/invoke\([^,]+,'([a-z_]+)'/g)].map(match=>match[1]))];
|
|
26
|
+
assert.ok(kinds.includes('refactor_revise_tests'),kinds.join(','));
|
|
27
|
+
assert.deepEqual(kinds.filter(kind=>!HOST_CALL_KINDS.includes(kind)),[]);
|
|
28
|
+
});
|
|
@@ -43,3 +43,52 @@ test(`pre-review documentation uses only the final approved task: ${mode}`,async
|
|
|
43
43
|
assert.equal(writes,['later-feature','unapproved-path','cancel'].includes(mode)?0:1);
|
|
44
44
|
}finally{fs.rmSync(root,{recursive:true,force:true});}
|
|
45
45
|
});
|
|
46
|
+
|
|
47
|
+
// Q16/Q17: the adapter reports the developer answer and the documentation start
|
|
48
|
+
// before it asks the sync, names out-of-scope paths, tells an invalid answer from
|
|
49
|
+
// a blocked one, and a documentation-only redo never calls the developer.
|
|
50
|
+
for(const mode of ['journal','invalid','blocked','out-of-scope','redo'])
|
|
51
|
+
test(`documentation sync recovery contract: ${mode}`,async()=>{
|
|
52
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-docs-')));
|
|
53
|
+
try{
|
|
54
|
+
const codeProject=path.join(root,'code'),specsDir=path.join(root,'specs');
|
|
55
|
+
fs.mkdirSync(codeProject);fs.mkdirSync(path.join(specsDir,'1.feature'),{recursive:true});
|
|
56
|
+
fs.writeFileSync(path.join(codeProject,'requirements.md'),'# Requirements\n');
|
|
57
|
+
fs.writeFileSync(path.join(codeProject,'README.md'),'# Before\n');
|
|
58
|
+
fs.writeFileSync(path.join(codeProject,'a.js'),'one\n');
|
|
59
|
+
for(const name of ['requirements.md','design.md'])fs.writeFileSync(path.join(specsDir,'1.feature',name),'# Fixture\n');
|
|
60
|
+
fs.writeFileSync(path.join(specsDir,'1.feature','tasks.md'),'- [ ] T-001: implement\n');
|
|
61
|
+
fs.writeFileSync(path.join(specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:['1.feature']}));
|
|
62
|
+
const identity={repositoryId:'docs',runId:'docs-test',taskId:'T-001',attempt:1};
|
|
63
|
+
const request=requestFor({invocationId:'docs-1',identity,role:'developer',provider:'codex',
|
|
64
|
+
requestedModel:'fixture',contextId:'author',payload:{scope:['README.md','a.js'],requirements:[{path:'requirements.md'}],priorReview:null}});
|
|
65
|
+
let developerCalls=0;const events=[];
|
|
66
|
+
const developer={provider:'codex',requestedModel:'fixture',contextId:'author',run:async()=>{
|
|
67
|
+
developerCalls++;
|
|
68
|
+
return {version:1,invocationId:request.invocationId,contextId:'author',provider:'codex',
|
|
69
|
+
effectiveModel:'model-x',status:'succeeded',accepted:true,result:{outcome:'implemented'}};
|
|
70
|
+
}};
|
|
71
|
+
const adapter=withHostDocumentation({developer,specsDir,codeProject,feature:'1.feature',scope:['README.md','a.js'],
|
|
72
|
+
documentationSync:{paths:['README.md'],run:async()=>{
|
|
73
|
+
fs.writeFileSync(path.join(codeProject,'README.md'),'# After\n');
|
|
74
|
+
if(mode==='out-of-scope')fs.writeFileSync(path.join(codeProject,'a.js'),'two\n');
|
|
75
|
+
return mode==='invalid'?{status:'done'}:mode==='blocked'?{status:'blocked'}:{status:'completed'};
|
|
76
|
+
}}});
|
|
77
|
+
const control={signal:new AbortController().signal,onDocumentationSync:event=>events.push(event),
|
|
78
|
+
...(mode==='redo'?{documentationRedo:{result:{outcome:'implemented'},effectiveModel:'model-y'}}:{})};
|
|
79
|
+
if(['journal','redo'].includes(mode)){
|
|
80
|
+
const response=await adapter.run(request,control);
|
|
81
|
+
assert.equal(response.status,'succeeded');assert.equal(response.effectiveModel,mode==='redo'?'model-y':'model-x');
|
|
82
|
+
}else await assert.rejects(adapter.run(request,control),mode==='out-of-scope'?{code:'out_of_scope',message:'out_of_scope: a.js'}
|
|
83
|
+
:{code:mode==='invalid'?'documentation_sync_answer_invalid':'documentation_sync_blocked'});
|
|
84
|
+
assert.equal(developerCalls,mode==='redo'?0:1);
|
|
85
|
+
assert.equal(events.length,1);
|
|
86
|
+
assert.deepEqual(Object.keys(events[0]).sort(),['documents','effectiveModel','othersDigest','result']);
|
|
87
|
+
assert.equal(events[0].documents.length,1);assert.equal(events[0].documents[0].path,'README.md');
|
|
88
|
+
assert.match(events[0].documents[0].sha256,/^[a-f0-9]{64}$/);assert.match(events[0].othersDigest,/^[a-f0-9]{64}$/);
|
|
89
|
+
const {captureDocumentationState}=await import('../runtime/js/cm-ai/host-documentation.mjs');
|
|
90
|
+
const now=captureDocumentationState({root:codeProject,specsRoot:specsDir,identity,paths:['README.md'],requirements:['requirements.md']});
|
|
91
|
+
assert.notEqual(now.documents[0].sha256,events[0].documents[0].sha256,'the sync wrote README.md after the recorded start');
|
|
92
|
+
assert.equal(now.othersDigest===events[0].othersDigest,mode!=='out-of-scope');
|
|
93
|
+
}finally{fs.rmSync(root,{recursive:true,force:true});}
|
|
94
|
+
});
|
|
@@ -663,6 +663,127 @@ test('step30b empty mid-feature plan emits one explicit deferred BLOCKED row',as
|
|
|
663
663
|
}finally{f.cleanup();assert.equal(fs.existsSync(f.root),false);}
|
|
664
664
|
});
|
|
665
665
|
|
|
666
|
+
// 2026-10-08 aihot 5.author-column: tasks dropped with the official [DROPPED]
|
|
667
|
+
// marker kept their cases (blocking or not) in the feature-completion plan, so
|
|
668
|
+
// the session was asked about hidden features and the round ended BLOCKED.
|
|
669
|
+
const DROPPED_LINE=id=>`- [ ] ~~${id}: deferred work~~ \`[DROPPED v2: 数据源未定,暂缓]\``;
|
|
670
|
+
function droppedFeature(f,{pending=false,cases,commands,tests=['logic','commands','browser']}){
|
|
671
|
+
const root=path.join(f.configuration.specsDir,f.configuration.feature);
|
|
672
|
+
fs.writeFileSync(path.join(root,'tasks.md'),['- [x] T-001: live work',DROPPED_LINE('T-002'),DROPPED_LINE('T-003'),
|
|
673
|
+
...(pending?['- [ ] T-004: later work']:[])].join('\n')+'\n');
|
|
674
|
+
const contract=JSON.parse(fs.readFileSync(path.join(root,'test-cases.json')));
|
|
675
|
+
contract.cases=cases.map(([kind,blocking,taskIds],i)=>({...contract.cases[0],id:`TC-00${i+1}`,kind,blocking,taskIds,cleanup:[]}));
|
|
676
|
+
fs.writeFileSync(path.join(root,'test-cases.json'),JSON.stringify(contract));
|
|
677
|
+
fs.writeFileSync(path.join(f.configuration.codeProject,'.cm-workflow.json'),JSON.stringify({version:1,
|
|
678
|
+
project:{workflow:'cm-default'},policies:{tests}}));
|
|
679
|
+
const marker=path.join(f.root,'dropped-command-ran');
|
|
680
|
+
f.configuration.commands=commands.map(([id,caseIds])=>({id,caseIds,command:id.startsWith('dropped')
|
|
681
|
+
?[process.execPath,'-e',`require('node:fs').appendFileSync(${JSON.stringify(marker)},'x')`]:f.configuration.commands[0].command}));
|
|
682
|
+
return marker;
|
|
683
|
+
}
|
|
684
|
+
const reportSections=file=>fs.readFileSync(file,'utf8').split(/^## /m).slice(1)
|
|
685
|
+
.map(part=>[part.slice(0,part.indexOf('\n')),JSON.parse(part.slice(part.indexOf('\n')+1))]);
|
|
686
|
+
|
|
687
|
+
for(const answer of ['PASS','BLOCKED'])test(`dropped tasks: cases bound only to them are NOT_APPLICABLE, never asked or counted; live answer ${answer}`,async()=>{
|
|
688
|
+
const {inspectCmAiQaRecovery}=await import('../runtime/js/cm-ai/cm-ai-qa-log.mjs');
|
|
689
|
+
const f=fixture();
|
|
690
|
+
try{
|
|
691
|
+
// TC-005 mixes a live and a dropped task: still planned.
|
|
692
|
+
const marker=droppedFeature(f,{cases:[['logic',true,['T-001']],['logic',false,['T-002']],['browser',true,['T-003']],
|
|
693
|
+
['browser',false,['T-002','T-003']],['browser',true,['T-001','T-002']],['logic',false,['T-002']]],
|
|
694
|
+
commands:[['live-test',['TC-001']],['dropped-test',['TC-002','TC-006']]]});
|
|
695
|
+
const seen=[];
|
|
696
|
+
const options={...f.configuration,logic:async request=>{seen.push(request.case.id);return {verdict:'SUPPORTED',evidence:['Synthetic source check']};},
|
|
697
|
+
browser:async request=>{
|
|
698
|
+
seen.push(request.case.id);
|
|
699
|
+
const artifact=path.join(f.configuration.specsDir,'.reviews',`${request.case.id}.txt`);fs.writeFileSync(artifact,'Synthetic observation');
|
|
700
|
+
return {verdict:answer,evidence:answer==='PASS'?[artifact]:[],environment:request.environment,cleanup:'not_needed'};
|
|
701
|
+
}};
|
|
702
|
+
// The persisted (fingerprinted) configuration is planned without task state, exactly as before.
|
|
703
|
+
const initial=createHostQaExecutor(options);
|
|
704
|
+
assert.equal(initial.caseCount,8);assert.equal(initial.configuration.plan.cases.length,6);
|
|
705
|
+
assert.equal(Object.hasOwn(initial.configuration.plan,'dropped_task_cases'),false);
|
|
706
|
+
assert.equal(Object.hasOwn(initial.configuration.plan,'dropped_task_commands'),false);
|
|
707
|
+
const executor={...initial,...initial.prepare()},plan=executor.configuration.plan;
|
|
708
|
+
const dropped=[{id:'TC-002',taskIds:['T-002']},{id:'TC-003',taskIds:['T-003']},{id:'TC-004',taskIds:['T-002','T-003']},{id:'TC-006',taskIds:['T-002']}];
|
|
709
|
+
assert.deepEqual(plan.cases.map(item=>item.id),['TC-001','TC-005']);assert.deepEqual(plan.deferred_cases,[]);
|
|
710
|
+
assert.deepEqual(plan.dropped_task_cases,dropped);
|
|
711
|
+
assert.deepEqual(plan.dropped_task_commands,[{id:'dropped-test',caseIds:['TC-002','TC-006']}]);
|
|
712
|
+
assert.deepEqual(plan.commands.map(item=>item.id),['live-test']);assert.equal(executor.caseCount,3);
|
|
713
|
+
const binding={...f.binding,mode:executor.mode,caseCount:executor.caseCount};
|
|
714
|
+
recordCmAiQaRun({...binding,phase:'start',deferredCases:plan.deferred_cases,droppedTaskCases:plan.dropped_task_cases,
|
|
715
|
+
droppedTaskCommands:plan.dropped_task_commands,logHome:f.configuration.logHome});
|
|
716
|
+
const result=await executor.run(binding,new AbortController().signal);
|
|
717
|
+
assert.deepEqual(seen.sort(),['TC-001','TC-005']);assert.equal(fs.existsSync(marker),false);
|
|
718
|
+
assert.deepEqual({result:result.result,passed:result.passed,failed:result.failed,blocked:result.blocked},
|
|
719
|
+
answer==='PASS'?{result:'PASS',passed:3,failed:0,blocked:0}:{result:'BLOCKED',passed:2,failed:0,blocked:1});
|
|
720
|
+
const sections=reportSections(result.report),listed=Object.fromEntries(sections);
|
|
721
|
+
assert.deepEqual(listed.not_applicable,[...dropped.map(item=>({...item,verdict:'NOT_APPLICABLE',
|
|
722
|
+
reason:`bound only to dropped tasks: ${item.taskIds.join(', ')}`})),{id:'dropped-test',caseIds:['TC-002','TC-006'],kind:'commands',
|
|
723
|
+
verdict:'NOT_APPLICABLE',reason:'declared only for cases bound only to dropped tasks: TC-002, TC-006'}]);
|
|
724
|
+
assert.deepEqual(sections.map(([name])=>name).filter(name=>!['deferred_cases','not_applicable'].includes(name)).sort(),['TC-001','TC-005','live-test']);
|
|
725
|
+
const log=fs.readFileSync(path.join(f.configuration.specsDir,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse);
|
|
726
|
+
const start=log.find(row=>row.event==='test_run'&&row.phase==='start');
|
|
727
|
+
assert.deepEqual(start.dropped_task_cases,dropped);assert.deepEqual(start.dropped_task_commands,plan.dropped_task_commands);
|
|
728
|
+
assert(!log.some(row=>dropped.some(item=>item.id===row.case_id)));
|
|
729
|
+
recordCmAiQaRun({...binding,phase:'complete',result,logHome:f.configuration.logHome});
|
|
730
|
+
const {codeProject,mode,caseCount,...query}=binding;
|
|
731
|
+
assert.equal(inspectCmAiQaResult(query).status,answer==='PASS'?'passed':'blocked');
|
|
732
|
+
// The rerun reader skips the not_applicable list like deferred_cases.
|
|
733
|
+
const {testRunId,...run}=query;
|
|
734
|
+
if(answer==='BLOCKED')assert.deepEqual(inspectCmAiQaRecovery(run,{blocked:true}).blockedCases,['TC-005']);
|
|
735
|
+
}finally{f.cleanup();}
|
|
736
|
+
});
|
|
737
|
+
|
|
738
|
+
test('dropped tasks: mid-feature, a case bound only to them is recorded as dropped, not deferred',()=>{
|
|
739
|
+
const f=fixture();
|
|
740
|
+
try{
|
|
741
|
+
droppedFeature(f,{pending:true,cases:[['logic',true,['T-001']],['browser',false,['T-002']],['browser',true,['T-004']],
|
|
742
|
+
['logic',true,['T-002','T-004']]],commands:[['live-test',['TC-001']]]});
|
|
743
|
+
const {plan}=plannedExecutor(f.configuration).configuration;
|
|
744
|
+
assert.deepEqual(plan.cases.map(item=>item.id),['TC-001']);
|
|
745
|
+
assert.deepEqual(plan.dropped_task_cases,[{id:'TC-002',taskIds:['T-002']}]);
|
|
746
|
+
assert.deepEqual(plan.deferred_cases,[{id:'TC-003',taskIds:['T-004']},{id:'TC-004',taskIds:['T-002','T-004']}]);
|
|
747
|
+
}finally{f.cleanup();}
|
|
748
|
+
});
|
|
749
|
+
|
|
750
|
+
// Codex review R1: the test-kind policy must not hide a dropped-only case and so schedule its command.
|
|
751
|
+
test('dropped tasks: a command declared only for a policy-excluded dropped case never runs; the round stays BLOCKED',async()=>{
|
|
752
|
+
const f=fixture();
|
|
753
|
+
try{
|
|
754
|
+
const marker=droppedFeature(f,{tests:['commands'],cases:[['logic',false,['T-002']]],commands:[['dropped-test',['TC-001']]]});
|
|
755
|
+
const executor=plannedExecutor({...f.configuration,logic:()=>assert.fail('no dropped logic request')});
|
|
756
|
+
const plan=executor.configuration.plan;
|
|
757
|
+
assert.deepEqual(plan.dropped_task_cases,[{id:'TC-001',taskIds:['T-002']}]);
|
|
758
|
+
assert.deepEqual(plan.dropped_task_commands,[{id:'dropped-test',caseIds:['TC-001']}]);
|
|
759
|
+
assert.deepEqual(plan.commands,[]);assert.deepEqual(plan.cases,[]);
|
|
760
|
+
const result=await executor.run(begin(f,executor),new AbortController().signal);
|
|
761
|
+
assert.equal(fs.existsSync(marker),false,'the dropped-only command never runs');
|
|
762
|
+
assert.deepEqual([result.result,result.passed,result.blocked],['BLOCKED',0,1]);
|
|
763
|
+
const listed=Object.fromEntries(reportSections(result.report));
|
|
764
|
+
assert.deepEqual(listed.not_applicable.map(item=>[item.id,item.verdict]),[['TC-001','NOT_APPLICABLE'],['dropped-test','NOT_APPLICABLE']]);
|
|
765
|
+
assert.equal(listed['commands-unavailable'].verdict,'BLOCKED');
|
|
766
|
+
}finally{f.cleanup();}
|
|
767
|
+
});
|
|
768
|
+
|
|
769
|
+
for(const tests of [['logic','browser'],['logic','commands','browser']])
|
|
770
|
+
test(`dropped tasks: nothing left to verify stays BLOCKED, never a PASS from nothing; policies ${tests.join('+')}`,async()=>{
|
|
771
|
+
const f=fixture();
|
|
772
|
+
try{
|
|
773
|
+
droppedFeature(f,{tests,cases:[['logic',true,['T-002']],['browser',false,['T-003']]],
|
|
774
|
+
commands:tests.includes('commands')?[['dropped-test',['TC-001']]]:[]});
|
|
775
|
+
const executor=plannedExecutor({...f.configuration,logic:()=>assert.fail('no dropped logic request'),
|
|
776
|
+
browser:()=>assert.fail('no dropped browser request')});
|
|
777
|
+
assert.deepEqual(executor.configuration.plan.cases,[]);assert.equal(executor.caseCount,1);
|
|
778
|
+
const result=await executor.run(begin(f,executor),new AbortController().signal);
|
|
779
|
+
assert.deepEqual([result.result,result.passed,result.blocked],['BLOCKED',0,1]);
|
|
780
|
+
const rows=reportSections(result.report).filter(([name])=>!['deferred_cases','not_applicable'].includes(name));
|
|
781
|
+
assert.equal(rows.length,1);assert.equal(rows[0][1].verdict,'BLOCKED');
|
|
782
|
+
assert.equal(rows[0][0],tests.includes('commands')?'commands-unavailable':'qa-unavailable');
|
|
783
|
+
assert(rows[0][1].evidence.includes('TC-001: bound only to dropped tasks: T-002'));
|
|
784
|
+
}finally{f.cleanup();}
|
|
785
|
+
});
|
|
786
|
+
|
|
666
787
|
for(const mode of ['unavailable-only','confirmation','failed-and-unavailable','insufficient-and-unavailable','unmapped'])
|
|
667
788
|
test(`logic report rows record why they are BLOCKED: ${mode}`,async()=>{
|
|
668
789
|
const f=fixture();
|
|
@@ -737,7 +858,9 @@ for(const name of ['evidence','cleanup','environment','timeout','logic','command
|
|
|
737
858
|
'FAIL','mixed-failure','round-limit','superseded-crash','one-shot','metadata-command',
|
|
738
859
|
'legacy-product-blocked','needs-confirmation','command-unavailable','command-exit','declared-command-exit','declared-product-fail',
|
|
739
860
|
'declared-contradicted','declared-after-repair','declared-superseded-crash','declared-blocked','declared-unknown-verdict',
|
|
740
|
-
'logic-confirmation-unavailable','logic-confirmation-insufficient','no-browser-capability'
|
|
861
|
+
'logic-confirmation-unavailable','logic-confirmation-insufficient','no-browser-capability',
|
|
862
|
+
// A browser FAIL the host downgraded to BLOCKED for its evidence: complete row recorded, and report only.
|
|
863
|
+
'downgraded-fail','downgraded-fail-incomplete',...Object.keys(FORGED)])
|
|
741
864
|
test(`completed BLOCKED QA explicit rerun: ${name}`,async()=>{
|
|
742
865
|
const scenario=FORGED[name]??name;
|
|
743
866
|
const {createCmAiConversationEntry}=await import('../runtime/js/cm-ai/cm-ai-conversation-entry.mjs');
|
|
@@ -761,7 +884,7 @@ test(`completed BLOCKED QA explicit rerun: ${name}`,async()=>{
|
|
|
761
884
|
const killed=['command-unavailable','logic-confirmation-unavailable'].includes(scenario);
|
|
762
885
|
if([...(killed?[scenario]:[]),...exits].includes(scenario))f.configuration.commands[0].command=[process.execPath,'-e',
|
|
763
886
|
`require('node:fs').existsSync(${JSON.stringify(ready)})||${killed?'process.kill(process.pid,"SIGKILL")':'process.exit(65)'}`];
|
|
764
|
-
const failLike=['FAIL','declared-product-fail'].includes(scenario),contradicted=['mixed-failure','declared-contradicted'].includes(scenario);
|
|
887
|
+
const failLike=['FAIL','declared-product-fail','downgraded-fail','downgraded-fail-incomplete'].includes(scenario),contradicted=['mixed-failure','declared-contradicted'].includes(scenario);
|
|
765
888
|
const hostBlocked=['product-blocked','legacy-product-blocked'].includes(scenario);
|
|
766
889
|
let repaired=false,browserCalls=0,logicCalls=0,corrections=0;
|
|
767
890
|
const executor=createHostQaExecutor({...f.configuration,
|
|
@@ -775,7 +898,7 @@ test(`completed BLOCKED QA explicit rerun: ${name}`,async()=>{
|
|
|
775
898
|
if(!repaired&&scenario==='source-drift')fs.appendFileSync(path.join(f.configuration.codeProject,'source.mjs'),'// drift\n');
|
|
776
899
|
if(!repaired&&scenario==='timeout')throw Object.assign(new Error('timeout'),{code:'host_request_timeout'});
|
|
777
900
|
return {verdict:!repaired&&failLike?'FAIL':!repaired&&hostBlocked?'BLOCKED':'PASS',
|
|
778
|
-
evidence:!repaired&&['evidence','source-drift','round-limit','incomplete','superseded-crash','one-shot','mixed-failure','declared-contradicted','metadata-command','declared-blocked'].includes(scenario)
|
|
901
|
+
evidence:!repaired&&['evidence','source-drift','round-limit','incomplete','superseded-crash','one-shot','mixed-failure','declared-contradicted','metadata-command','declared-blocked','downgraded-fail','downgraded-fail-incomplete'].includes(scenario)
|
|
779
902
|
?['not-an-evidence-file']: [artifact],
|
|
780
903
|
environment:!repaired&&scenario==='environment'?{...request.environment,target:'different-target'}:request.environment,
|
|
781
904
|
cleanup:!repaired&&scenario==='cleanup'?'failed':'completed'};
|
|
@@ -787,7 +910,11 @@ test(`completed BLOCKED QA explicit rerun: ${name}`,async()=>{
|
|
|
787
910
|
const formSlip=['evidence','round-limit','superseded-crash','one-shot','mixed-failure',
|
|
788
911
|
'declared-contradicted','metadata-command','declared-blocked'].includes(scenario);
|
|
789
912
|
assert.equal(corrections,formSlip?1:0,scenario);
|
|
790
|
-
|
|
913
|
+
const reportOnly=['incomplete','downgraded-fail-incomplete'].includes(scenario);
|
|
914
|
+
if(scenario.startsWith('downgraded-fail')){assert.equal(result.failed,0);
|
|
915
|
+
const logged=fs.readFileSync(path.join(binding.specsDir,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse);
|
|
916
|
+
assert.equal(logged.find(row=>row.phase==='case_blocked').answered_verdict,'FAIL');}
|
|
917
|
+
if(!reportOnly)recordCmAiQaRun({...base,phase:'complete',result});
|
|
791
918
|
// Older executors wrote host-declared BLOCKED rows without the marker; those stay ineligible.
|
|
792
919
|
if(scenario==='legacy-product-blocked')fs.writeFileSync(result.report,
|
|
793
920
|
fs.readFileSync(result.report,'utf8').replace(/,\n\s*"hostDeclaredBlocked": true/g,''));
|
|
@@ -810,16 +937,21 @@ test(`completed BLOCKED QA explicit rerun: ${name}`,async()=>{
|
|
|
810
937
|
// A report row outside PASS/FAIL/BLOCKED no longer matches the recorded counts.
|
|
811
938
|
if(scenario==='declared-unknown-verdict')fs.writeFileSync(result.report,
|
|
812
939
|
fs.readFileSync(result.report,'utf8').replace(/("id": "TC-001",[\s\S]*?"verdict": )"FAIL"/,'$1"SKIPPED"'));
|
|
813
|
-
if(
|
|
940
|
+
if(!reportOnly){
|
|
814
941
|
const state=JSON.parse(fs.readFileSync(path.join(binding.specsDir,'.cm-status.json')));
|
|
815
942
|
assert.equal(state.state,result.failed?'qa_failed':'qa_blocked');assert.equal(state.node,'N6');
|
|
816
943
|
assert.equal(state.detail,`QA 结果 ${result.result}(通过 ${result.passed} / 失败 ${result.failed} / 阻断 ${result.blocked})`);
|
|
817
944
|
}
|
|
818
945
|
const log=path.join(binding.specsDir,'运行日志.jsonl'),rows=()=>fs.readFileSync(log,'utf8').trim().split('\n').map(JSON.parse);
|
|
819
|
-
|
|
946
|
+
// Q14: evidence-gap rounds give back at most two rounds, so the cap is round 5.
|
|
947
|
+
if(scenario==='round-limit')for(let round=1;round<5;round++){
|
|
820
948
|
const previous=round===1?testRunId:`blocked-${round}`;
|
|
821
949
|
recordCmAiQaRun({...base,testRunId:previous,qaRound:round,phase:'superseded'});
|
|
822
950
|
recordCmAiQaRun({...base,testRunId:`blocked-${round+1}`,qaRound:round+1,previousTestRunId:previous,phase:'start'});
|
|
951
|
+
// A real rerun logs its own case rows (the durable session verdicts that
|
|
952
|
+
// recovery_rule 3 reads); this synthetic round mirrors round 1's.
|
|
953
|
+
fs.appendFileSync(log,rows().filter(row=>row.operation_id===testRunId&&['case_start','case_blocked'].includes(row.phase))
|
|
954
|
+
.map(row=>JSON.stringify({...row,operation_id:`blocked-${round+1}`,attempt:round+1})+'\n').join(''));
|
|
823
955
|
recordCmAiQaRun({...base,testRunId:`blocked-${round+1}`,qaRound:round+1,phase:'complete',result});
|
|
824
956
|
}
|
|
825
957
|
if(scenario==='declared-superseded-crash')recordCmAiQaRun({...base,phase:'superseded',
|
|
@@ -836,8 +968,8 @@ test(`completed BLOCKED QA explicit rerun: ${name}`,async()=>{
|
|
|
836
968
|
const operation={version:1,operation:'advance',requestId:'rerun-blocked',identity:binding.identity};
|
|
837
969
|
const before=fs.readFileSync(log);
|
|
838
970
|
const without=await createCmAiConversationEntry(options).handle(operation);
|
|
839
|
-
assert.equal(without.code,
|
|
840
|
-
if(!result.failed
|
|
971
|
+
assert.equal(without.code,reportOnly?'qa_execution_unknown':result.failed?'qa_failed':'qa_result_blocked');
|
|
972
|
+
if(!result.failed&&!reportOnly)assert.equal(without.pendingAction,'none');
|
|
841
973
|
assert.deepEqual(fs.readFileSync(log),before);
|
|
842
974
|
if(scenario==='declared-command-exit'){
|
|
843
975
|
// The declaration only travels with the one-shot rerun grant and a superseded row.
|
|
@@ -853,7 +985,8 @@ test(`completed BLOCKED QA explicit rerun: ${name}`,async()=>{
|
|
|
853
985
|
...(scenario.startsWith('declared-')&&scenario!=='declared-superseded-crash'?{qaEnvironmentFailure:'simulator runtime was missing'}:{})});
|
|
854
986
|
if(['commands','legacy-product-blocked','needs-confirmation','source-drift','FAIL','mixed-failure','round-limit','incomplete',
|
|
855
987
|
'command-exit','declared-product-fail','declared-contradicted','declared-after-repair','declared-blocked',
|
|
856
|
-
'declared-unknown-verdict','logic-confirmation-unavailable','logic-confirmation-insufficient','no-browser-capability'
|
|
988
|
+
'declared-unknown-verdict','logic-confirmation-unavailable','logic-confirmation-insufficient','no-browser-capability',
|
|
989
|
+
'downgraded-fail','downgraded-fail-incomplete'].includes(scenario)){
|
|
857
990
|
const rejected=await entry.handle(operation);
|
|
858
991
|
assert.equal(rejected.code,scenario==='round-limit'?'qa_round_invalid':scenario==='incomplete'?'qa_execution_unknown':'qa_rerun_not_blocked_by_evidence');
|
|
859
992
|
assert.deepEqual(fs.readFileSync(log),before);
|
|
@@ -904,7 +1037,7 @@ test(`completed BLOCKED QA explicit rerun: ${name}`,async()=>{
|
|
|
904
1037
|
['report',row=>{delete row.commandUnavailable;},'TC-001'],['report',row=>{row.commandEvidence=[];},'TC-001'],
|
|
905
1038
|
['report',row=>{row.needsConfirmation=true;},'TC-001'],
|
|
906
1039
|
['report',row=>{row.staticVerdict='CONTRADICTED';},'TC-001'],
|
|
907
|
-
['log',list=>{list.find(row=>row.phase==='superseded').recovery_rule=
|
|
1040
|
+
['log',list=>{list.find(row=>row.phase==='superseded').recovery_rule=4;}],
|
|
908
1041
|
['contract',contract=>{contract.cases=contract.cases.filter(item=>item.id!=='TC-001');}]);
|
|
909
1042
|
// The host-declared BLOCKED needs both the durable log row and the report mirror.
|
|
910
1043
|
if(scenario==='product-blocked')precise.push(
|