@aibyzero/cm-workflow 0.16.6 → 0.16.8
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 +29 -0
- package/README.md +32 -1
- package/VERSION +1 -1
- package/assets/readme/workflow-recovery-detailed.png +0 -0
- package/assets/readme/workflow-stages-detailed.png +0 -0
- package/docs/installation.md +1 -1
- package/docs/js-workflow-control.md +84 -9
- package/docs/user-guide.md +104 -0
- package/package.json +1 -1
- package/runtime/js/cm-ai/cm-ai-admission.mjs +37 -11
- package/runtime/js/cm-ai/cm-ai-context-refresh.mjs +9 -5
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +56 -17
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +172 -33
- package/runtime/js/cm-ai/codex-review-adapter.mjs +2 -1
- package/runtime/js/cm-ai/developer-adapter.mjs +8 -5
- package/runtime/js/cm-ai/drive-bootstrap.mjs +2 -2
- package/runtime/js/cm-ai/drive-core.mjs +17 -4
- package/runtime/js/cm-ai/durable-runner-state.mjs +29 -0
- package/runtime/js/cm-ai/execution-store.mjs +4 -2
- package/runtime/js/cm-ai/host-conversation-execution.mjs +11 -3
- package/runtime/js/cm-ai/host-documentation.mjs +2 -2
- package/runtime/js/cm-ai/host-qa-executor.mjs +89 -19
- package/runtime/js/cm-ai/host-session.mjs +46 -6
- package/runtime/js/cm-ai/host-tool-bridge.mjs +15 -3
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +4 -2
- package/runtime/js/cm-ai/log-rows.mjs +36 -0
- package/runtime/js/cm-ai/operator-guidance.mjs +3 -0
- package/runtime/js/cm-ai/reviewed-deliveries.mjs +29 -6
- package/runtime/js/cm-ai/task-runner.mjs +6 -1
- 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 +189 -148
- package/runtime/js/cm-fix/finish.mjs +2 -19
- package/runtime/js/cm-fix/investigation.mjs +25 -9
- package/runtime/js/cm-fix/log-events.mjs +29 -0
- package/runtime/js/cm-fix/metrics.mjs +3 -2
- package/runtime/js/cm-fix/progress.mjs +3 -1
- package/runtime/js/cm-prd/analysis.mjs +5 -2
- package/runtime/js/cm-prd/review-host.mjs +2 -1
- package/runtime/js/cm-test/recovery.mjs +4 -4
- package/runtime/js/notify-run.mjs +26 -0
- package/runtime/js/notify.mjs +388 -0
- package/runtime/model-efficiency.md +17 -0
- package/scripts/cm-ai-admission.mjs +14 -3
- package/scripts/cm-ai-batch-drive.mjs +2 -2
- package/scripts/cm-ai-batch-host.mjs +7 -2
- package/scripts/cm-ai-batch-run.mjs +11 -2
- package/scripts/cm-ai-batch-run.test.mjs +9 -1
- package/scripts/cm-ai-drive.mjs +18 -4
- package/scripts/cm-ai-drive.test.mjs +30 -0
- package/scripts/cm-ai-feature-selection.test.mjs +178 -0
- package/scripts/cm-ai-fix-run-delivery.test.mjs +138 -0
- package/scripts/cm-ai-host.mjs +20 -8
- package/scripts/cm-ai-host.test.mjs +88 -0
- package/scripts/cm-ai-project-qa-gate.test.mjs +71 -4
- package/scripts/cm-ai-protected-scope.test.mjs +194 -0
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +77 -4
- package/scripts/cm-ai-run.mjs +36 -5
- package/scripts/cm-fix-abandon.test.mjs +89 -3
- package/scripts/cm-fix-cause-package.test.mjs +33 -0
- package/scripts/cm-fix-drive.mjs +9 -1
- package/scripts/cm-fix-host.mjs +1 -1
- package/scripts/cm-fix-large-log.test.mjs +113 -0
- package/scripts/cm-fix-rediagnosis.test.mjs +71 -4
- package/scripts/cm-host-qa-executor.test.mjs +429 -3
- package/scripts/cm-log-event.mjs +53 -6
- package/scripts/cm-notify.test.mjs +468 -0
- package/scripts/cm-patrol.mjs +83 -0
- package/scripts/cm-patrol.test.mjs +161 -0
- package/scripts/cm-prd-host.mjs +13 -2
- package/scripts/cm-prd-host.test.mjs +4 -0
- package/scripts/cm-prd-review-host.test.mjs +17 -0
- package/scripts/cm-prd-session-recovery.test.mjs +44 -2
- package/scripts/cm-prd-task-grouping.test.mjs +206 -0
- package/scripts/cm-review-scope-recovery.test.mjs +5 -3
- package/scripts/cm-test-branch-impact.test.mjs +11 -0
- package/scripts/cm-token-report.mjs +497 -0
- package/scripts/cm-token-report.test.mjs +346 -0
- package/skills/cm-ai/SKILL.md +7 -3
- package/skills/cm-ai/references/N1-init.md +1 -1
- 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 +110 -0
- package/skills/cm-ai/references/js-host-recovery.md +199 -0
- package/skills/cm-ai/references/js-host.md +69 -330
- package/skills/cm-fix/SKILL.md +2 -0
- package/skills/cm-fix/references/js-host.md +16 -9
- package/skills/cm-prd/SKILL.md +7 -4
- package/skills/cm-prd/references/spec-self-check.md +3 -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);
|
|
@@ -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();
|
|
@@ -732,8 +853,9 @@ const FORGED={'contract-resolved-after-run':'logic-confirmation-insufficient','f
|
|
|
732
853
|
'forged-confirmation-unavailable':'logic-confirmation-unavailable','forged-browser-confirmation':'needs-confirmation',
|
|
733
854
|
// No browser answer happened: a marker added to the report must not stand in for one.
|
|
734
855
|
'forged-no-capability':'no-browser-capability','forged-browser-evidence':'needs-confirmation'};
|
|
856
|
+
// source-drift and incomplete have their own tests below (2026-10-06 author-column-T-009).
|
|
735
857
|
for(const name of ['evidence','cleanup','environment','timeout','logic','commands','product-blocked',
|
|
736
|
-
'
|
|
858
|
+
'FAIL','mixed-failure','round-limit','superseded-crash','one-shot','metadata-command',
|
|
737
859
|
'legacy-product-blocked','needs-confirmation','command-unavailable','command-exit','declared-command-exit','declared-product-fail',
|
|
738
860
|
'declared-contradicted','declared-after-repair','declared-superseded-crash','declared-blocked','declared-unknown-verdict',
|
|
739
861
|
'logic-confirmation-unavailable','logic-confirmation-insufficient','no-browser-capability',...Object.keys(FORGED)])
|
|
@@ -762,14 +884,15 @@ test(`completed BLOCKED QA explicit rerun: ${name}`,async()=>{
|
|
|
762
884
|
`require('node:fs').existsSync(${JSON.stringify(ready)})||${killed?'process.kill(process.pid,"SIGKILL")':'process.exit(65)'}`];
|
|
763
885
|
const failLike=['FAIL','declared-product-fail'].includes(scenario),contradicted=['mixed-failure','declared-contradicted'].includes(scenario);
|
|
764
886
|
const hostBlocked=['product-blocked','legacy-product-blocked'].includes(scenario);
|
|
765
|
-
let repaired=false,browserCalls=0,logicCalls=0;
|
|
887
|
+
let repaired=false,browserCalls=0,logicCalls=0,corrections=0;
|
|
766
888
|
const executor=createHostQaExecutor({...f.configuration,
|
|
767
889
|
logic:async()=>{logicCalls++;return {verdict:contradicted?'CONTRADICTED':
|
|
768
890
|
['logic','logic-confirmation-insufficient'].includes(scenario)?'INSUFFICIENT_EVIDENCE':'SUPPORTED',evidence:['Synthetic static observation']};},
|
|
769
891
|
// Without a browser capability the executor itself blocks the case; no
|
|
770
892
|
// session answered it, so a rerun on the same host cannot change it.
|
|
771
893
|
...(scenario==='no-browser-capability'?{}:{browser:async request=>{
|
|
772
|
-
|
|
894
|
+
// A correction round re-asks the same case once; this session answers it the same way.
|
|
895
|
+
if(request.correction){corrections++;}else browserCalls++;
|
|
773
896
|
if(!repaired&&scenario==='source-drift')fs.appendFileSync(path.join(f.configuration.codeProject,'source.mjs'),'// drift\n');
|
|
774
897
|
if(!repaired&&scenario==='timeout')throw Object.assign(new Error('timeout'),{code:'host_request_timeout'});
|
|
775
898
|
return {verdict:!repaired&&failLike?'FAIL':!repaired&&hostBlocked?'BLOCKED':'PASS',
|
|
@@ -781,6 +904,10 @@ test(`completed BLOCKED QA explicit rerun: ${name}`,async()=>{
|
|
|
781
904
|
const binding=begin(f,executor),result=await executor.run(binding,new AbortController().signal);
|
|
782
905
|
const {codeProject,testRunId,mode,caseCount,...query}=binding;
|
|
783
906
|
const base={...binding,logHome:f.configuration.logHome};
|
|
907
|
+
// Unusable evidence on a PASS from the registered environment is asked back once.
|
|
908
|
+
const formSlip=['evidence','round-limit','superseded-crash','one-shot','mixed-failure',
|
|
909
|
+
'declared-contradicted','metadata-command','declared-blocked'].includes(scenario);
|
|
910
|
+
assert.equal(corrections,formSlip?1:0,scenario);
|
|
784
911
|
if(scenario!=='incomplete')recordCmAiQaRun({...base,phase:'complete',result});
|
|
785
912
|
// Older executors wrote host-declared BLOCKED rows without the marker; those stay ineligible.
|
|
786
913
|
if(scenario==='legacy-product-blocked')fs.writeFileSync(result.report,
|
|
@@ -926,3 +1053,302 @@ test(`completed BLOCKED QA explicit rerun: ${name}`,async()=>{
|
|
|
926
1053
|
}
|
|
927
1054
|
}finally{f.cleanup();}
|
|
928
1055
|
});
|
|
1056
|
+
|
|
1057
|
+
// A source change during QA (2026-10-06 author-column-T-009): files in scope were
|
|
1058
|
+
// replaced mid-run. The executor marks every row BLOCKED/sourceChanged; a host
|
|
1059
|
+
// before this fix wrote the report, then rejected stale_qa before `complete`,
|
|
1060
|
+
// leaving qa_execution_unknown with no recovery path.
|
|
1061
|
+
async function driftFixture({browserOnly=false,firstBrowser='PASS',commandFails=false,drift=true,confirmLogic=false}={}){
|
|
1062
|
+
const {createCmAiConversationEntry}=await import('../runtime/js/cm-ai/cm-ai-conversation-entry.mjs');
|
|
1063
|
+
const f=fixture();
|
|
1064
|
+
const sourceFile=path.join(f.configuration.codeProject,'source.mjs'),reviewed=fs.readFileSync(sourceFile);
|
|
1065
|
+
if(browserOnly){
|
|
1066
|
+
const source=path.join(f.binding.specsDir,f.binding.feature,'test-cases.json'),contract=JSON.parse(fs.readFileSync(source));
|
|
1067
|
+
contract.cases=contract.cases.filter(item=>item.kind==='browser').map((item,index)=>({...item,id:`TC-00${index+1}`}));fs.writeFileSync(source,JSON.stringify(contract));
|
|
1068
|
+
f.configuration.commands[0].caseIds=[];
|
|
1069
|
+
}
|
|
1070
|
+
const artifact=path.join(f.binding.specsDir,'.reviews','browser.txt');fs.writeFileSync(artifact,'Synthetic observation');
|
|
1071
|
+
// A real product failure: the declared command exits 1 (an exit code, not unavailable).
|
|
1072
|
+
if(commandFails)f.configuration.commands[0].command=[process.execPath,'-e','process.exit(1)'];
|
|
1073
|
+
if(confirmLogic){
|
|
1074
|
+
const source=path.join(f.binding.specsDir,f.binding.feature,'test-cases.json'),contract=JSON.parse(fs.readFileSync(source));
|
|
1075
|
+
contract.cases[0].expected=['[需确认] synthetic expectation'];fs.writeFileSync(source,JSON.stringify(contract));
|
|
1076
|
+
}
|
|
1077
|
+
const state={round:0,browserCalls:0,stale:false};
|
|
1078
|
+
const executor=createHostQaExecutor({...f.configuration,
|
|
1079
|
+
logic:async()=>({verdict:'SUPPORTED',evidence:['Synthetic static observation']}),
|
|
1080
|
+
browser:async request=>{
|
|
1081
|
+
state.browserCalls++;
|
|
1082
|
+
if(state.round===0&&drift)fs.appendFileSync(sourceFile,'// replaced mid-QA\n');
|
|
1083
|
+
return {verdict:state.round===0?firstBrowser:'PASS',evidence:[artifact],environment:request.environment,cleanup:'completed'};
|
|
1084
|
+
}});
|
|
1085
|
+
const completed={state:'fixture_completed',code:null,identity:f.binding.identity,packageDigest:f.binding.packageDigest};
|
|
1086
|
+
const stale={...completed,code:'correction_review_required'};
|
|
1087
|
+
const {codeProject,testRunId,...query}=f.binding;
|
|
1088
|
+
const log=path.join(f.binding.specsDir,'运行日志.jsonl'),rows=()=>fs.readFileSync(log,'utf8').trim().split('\n').map(JSON.parse);
|
|
1089
|
+
const entry=(extra={})=>createCmAiConversationEntry({specsDir:query.specsDir,feature:query.feature,identity:query.identity,codeProject,
|
|
1090
|
+
runner:{status:()=>state.stale?stale:completed,executeEffect:()=>assert.fail('no development/Review replay'),
|
|
1091
|
+
cancel:()=>completed,run:()=>assert.fail('no task replay')},
|
|
1092
|
+
qaExecutor:{...executor,run:async(...args)=>{const result=await executor.run(...args);
|
|
1093
|
+
// The fix association notices the replaced files right after the run.
|
|
1094
|
+
if(state.round===0)state.stale=true;state.round++;return result;}},
|
|
1095
|
+
qaLogHome:f.configuration.logHome,qaDecisionProvider:{timeoutMs:1000,decide:()=>assert.fail('no repeated QA decision')},...extra});
|
|
1096
|
+
const advance={version:1,operation:'advance',requestId:'advance',identity:f.binding.identity};
|
|
1097
|
+
const restore=()=>{fs.writeFileSync(sourceFile,reviewed);state.stale=false;};
|
|
1098
|
+
const report=()=>path.join(f.binding.specsDir,'.reviews',`${rows().find(row=>row.phase==='start').operation_id}-execution.md`);
|
|
1099
|
+
const reportRows=()=>fs.readFileSync(report(),'utf8').split(/^## /m).slice(1).map(part=>{
|
|
1100
|
+
const split=part.indexOf('\n');return [part.slice(0,split),JSON.parse(part.slice(split+1))];}).filter(([name])=>name!=='deferred_cases');
|
|
1101
|
+
return {f,state,entry,advance,restore,rows,log,report,reportRows,query};
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
test('a stale QA run records what it observed (complete, BLOCKED/sourceChanged) before stale_qa, then reruns once restored',async()=>{
|
|
1105
|
+
const d=await driftFixture();
|
|
1106
|
+
try{
|
|
1107
|
+
const stale=await d.entry().handle(d.advance);
|
|
1108
|
+
assert.equal(stale.outcome,'rejected');assert.equal(stale.code,'stale_qa');
|
|
1109
|
+
const complete=d.rows().filter(row=>row.phase==='complete');
|
|
1110
|
+
assert.equal(complete.length,1);assert.equal(complete[0].result,'BLOCKED');assert.equal(complete[0].passed,0);
|
|
1111
|
+
for(const [,row] of d.reportRows()){assert.equal(row.sourceChanged,true);assert.equal(row.verdictBeforeSourceChange,'PASS');}
|
|
1112
|
+
d.restore();
|
|
1113
|
+
const blocked=await d.entry().handle(d.advance);
|
|
1114
|
+
assert.equal(blocked.code,'qa_result_blocked');
|
|
1115
|
+
const rerun=await d.entry({rerunBlockedQa:true}).handle(d.advance);
|
|
1116
|
+
assert.equal(rerun.code,'qa_passed',JSON.stringify(rerun));
|
|
1117
|
+
const superseded=d.rows().filter(row=>row.phase==='superseded');
|
|
1118
|
+
assert.equal(superseded.length,1);assert.equal(superseded[0].incomplete_report,undefined);
|
|
1119
|
+
assert.deepEqual(superseded[0].blocked_cases,['TC-001','TC-002','declared-test']);
|
|
1120
|
+
assert.deepEqual(d.rows().filter(row=>row.phase==='start').map(row=>row.attempt),[1,2]);
|
|
1121
|
+
}finally{d.f.cleanup();}
|
|
1122
|
+
});
|
|
1123
|
+
|
|
1124
|
+
test('a source-changed row that was FAIL before the change is never rerun, and a forged pre-change verdict is refused',async()=>{
|
|
1125
|
+
const fail=await driftFixture({firstBrowser:'FAIL'});
|
|
1126
|
+
try{
|
|
1127
|
+
await fail.entry().handle(fail.advance);fail.restore();
|
|
1128
|
+
const refused=await fail.entry({rerunBlockedQa:true}).handle(fail.advance);
|
|
1129
|
+
assert.equal(refused.code,'qa_rerun_not_blocked_by_evidence');
|
|
1130
|
+
assert.equal(fail.rows().filter(row=>row.phase==='superseded').length,0);
|
|
1131
|
+
}finally{fail.f.cleanup();}
|
|
1132
|
+
// A command that really exited 1 before the change is a product FAIL: never rerun.
|
|
1133
|
+
const exited=await driftFixture({browserOnly:true,commandFails:true});
|
|
1134
|
+
try{
|
|
1135
|
+
await exited.entry().handle(exited.advance);exited.restore();
|
|
1136
|
+
assert.deepEqual(exited.reportRows().filter(([name])=>name==='declared-test').map(([,row])=>[row.verdict,row.verdictBeforeSourceChange,row.exitCode]),
|
|
1137
|
+
[['BLOCKED','FAIL',1]]);
|
|
1138
|
+
const refused=await exited.entry({rerunBlockedQa:true}).handle(exited.advance);
|
|
1139
|
+
assert.equal(refused.code,'qa_rerun_not_blocked_by_evidence');
|
|
1140
|
+
assert.equal(exited.rows().filter(row=>row.phase==='superseded').length,0);
|
|
1141
|
+
}finally{exited.f.cleanup();}
|
|
1142
|
+
const forged=await driftFixture();
|
|
1143
|
+
try{
|
|
1144
|
+
await forged.entry().handle(forged.advance);forged.restore();
|
|
1145
|
+
// The command really exited 1; the report claims it was PASS before the change.
|
|
1146
|
+
const text=fs.readFileSync(forged.report(),'utf8');
|
|
1147
|
+
fs.writeFileSync(forged.report(),text.replace(/("id": "declared-test",[\s\S]*?"exitCode": )0/,'$11'));
|
|
1148
|
+
const refused=await forged.entry({rerunBlockedQa:true}).handle(forged.advance);
|
|
1149
|
+
assert.equal(refused.code,'qa_rerun_not_blocked_by_evidence');
|
|
1150
|
+
}finally{forged.f.cleanup();}
|
|
1151
|
+
});
|
|
1152
|
+
|
|
1153
|
+
// The exact T-009 history: report written, no complete row, report rows without
|
|
1154
|
+
// verdictBeforeSourceChange (pre-fix executor). The log is never edited.
|
|
1155
|
+
async function legacyIncomplete(options){
|
|
1156
|
+
const d=await driftFixture(options);
|
|
1157
|
+
const {recordCmAiQaRun:record}=await import('../runtime/js/cm-ai/cm-ai-qa-log.mjs');
|
|
1158
|
+
const begun={...d.f.binding,logHome:d.f.configuration.logHome};
|
|
1159
|
+
const executor=d.entry();
|
|
1160
|
+
// Reproduce the pre-fix host: run, report, then no complete row.
|
|
1161
|
+
const qa=createHostQaExecutor({...d.f.configuration,logic:async()=>({verdict:'SUPPORTED',evidence:['Synthetic static observation']}),
|
|
1162
|
+
browser:async request=>{d.state.browserCalls++;fs.appendFileSync(path.join(d.f.configuration.codeProject,'source.mjs'),'// replaced\n');
|
|
1163
|
+
return {verdict:options?.firstBrowser??'PASS',evidence:[path.join(d.f.binding.specsDir,'.reviews','browser.txt')],environment:request.environment,cleanup:'completed'};}});
|
|
1164
|
+
const binding=begin(d.f,qa);await qa.run(binding,new AbortController().signal);
|
|
1165
|
+
void record;void begun;void executor;
|
|
1166
|
+
const text=fs.readFileSync(d.report(),'utf8');
|
|
1167
|
+
fs.writeFileSync(d.report(),text.replace(/,\n\s*"verdictBeforeSourceChange": "[A-Z]+"/g,''));
|
|
1168
|
+
d.state.round=1;d.restore();
|
|
1169
|
+
return d;
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
test('a pre-fix call with a fixed report but no complete row reruns under --rerun-blocked-qa; the log is only appended',async()=>{
|
|
1173
|
+
const d=await legacyIncomplete({browserOnly:true});
|
|
1174
|
+
try{
|
|
1175
|
+
assert.equal(d.rows().some(row=>row.phase==='complete'),false);
|
|
1176
|
+
assert.equal(d.reportRows().some(([,row])=>Object.hasOwn(row,'verdictBeforeSourceChange')),false);
|
|
1177
|
+
const before=fs.readFileSync(d.log);
|
|
1178
|
+
assert.equal((await d.entry().handle(d.advance)).code,'qa_execution_unknown');
|
|
1179
|
+
assert.equal((await d.entry({rerunUnknownQa:true}).handle(d.advance)).code,'qa_execution_unknown');
|
|
1180
|
+
assert.deepEqual(fs.readFileSync(d.log),before);
|
|
1181
|
+
const rerun=await d.entry({rerunBlockedQa:true}).handle(d.advance);
|
|
1182
|
+
assert.equal(rerun.code,'qa_passed',JSON.stringify(rerun));
|
|
1183
|
+
const after=fs.readFileSync(d.log);
|
|
1184
|
+
assert.deepEqual(after.subarray(0,before.length),before);
|
|
1185
|
+
const superseded=d.rows().filter(row=>row.phase==='superseded');
|
|
1186
|
+
assert.equal(superseded.length,1);assert.equal(superseded[0].incomplete_report,true);
|
|
1187
|
+
assert.deepEqual(superseded[0].blocked_cases,['TC-001','declared-test']);
|
|
1188
|
+
// Replay re-reads the same report: changing its Overall breaks the history.
|
|
1189
|
+
const text=fs.readFileSync(d.report(),'utf8');
|
|
1190
|
+
fs.writeFileSync(d.report(),text.replace('Overall: BLOCKED','Overall: PASS'));
|
|
1191
|
+
assert.throws(()=>readCmAiQaRunRound({...d.query,testRunId:d.rows().filter(row=>row.phase==='start')[1].operation_id}));
|
|
1192
|
+
fs.writeFileSync(d.report(),text);
|
|
1193
|
+
}finally{d.f.cleanup();}
|
|
1194
|
+
});
|
|
1195
|
+
|
|
1196
|
+
test('a pre-fix incomplete call stays refused when a row cannot be told (legacy logic) or was a FAIL',async()=>{
|
|
1197
|
+
for(const options of [{},{browserOnly:true,firstBrowser:'FAIL'}]){
|
|
1198
|
+
const d=await legacyIncomplete(options);
|
|
1199
|
+
try{
|
|
1200
|
+
const before=fs.readFileSync(d.log);
|
|
1201
|
+
const refused=await d.entry({rerunBlockedQa:true}).handle(d.advance);
|
|
1202
|
+
assert.equal(refused.code,'qa_rerun_not_blocked_by_evidence',JSON.stringify(options));
|
|
1203
|
+
assert.deepEqual(fs.readFileSync(d.log),before);
|
|
1204
|
+
}finally{d.f.cleanup();}
|
|
1205
|
+
}
|
|
1206
|
+
});
|
|
1207
|
+
|
|
1208
|
+
test('a stale run with an all-PASS observation records no complete; only --rerun-unknown-qa discards and reruns it',async()=>{
|
|
1209
|
+
const d=await driftFixture({drift:false});
|
|
1210
|
+
try{
|
|
1211
|
+
const stale=await d.entry().handle(d.advance);
|
|
1212
|
+
assert.equal(stale.code,'stale_qa');
|
|
1213
|
+
assert.equal(d.rows().some(row=>row.phase==='complete'),false);
|
|
1214
|
+
assert.match(fs.readFileSync(d.report(),'utf8'),/^Overall: PASS$/m);
|
|
1215
|
+
d.restore();
|
|
1216
|
+
// Never read as a pass, by this run or by the project gate's latest-run reader.
|
|
1217
|
+
const {latestCmAiQaRun}=await import('../runtime/js/cm-ai/cm-ai-qa-log.mjs');
|
|
1218
|
+
assert.throws(()=>latestCmAiQaRun(d.query),{code:'qa_result_incomplete'});
|
|
1219
|
+
assert.equal((await d.entry().handle(d.advance)).code,'qa_execution_unknown');
|
|
1220
|
+
assert.equal((await d.entry({rerunBlockedQa:true}).handle(d.advance)).code,'qa_rerun_not_blocked_by_evidence');
|
|
1221
|
+
// A forged PASS on the command row without its zero exit is not backed.
|
|
1222
|
+
const text=fs.readFileSync(d.report(),'utf8');
|
|
1223
|
+
fs.writeFileSync(d.report(),text.replace(/("id": "declared-test",[\s\S]*?"exitCode": )0/,'$11'));
|
|
1224
|
+
assert.equal((await d.entry({rerunUnknownQa:true}).handle(d.advance)).code,'qa_execution_unknown');
|
|
1225
|
+
fs.writeFileSync(d.report(),text);
|
|
1226
|
+
const rerun=await d.entry({rerunUnknownQa:true}).handle(d.advance);
|
|
1227
|
+
assert.equal(rerun.code,'qa_passed',JSON.stringify(rerun));
|
|
1228
|
+
assert.equal(d.rows().filter(row=>row.phase==='abandoned').length,1);
|
|
1229
|
+
}finally{d.f.cleanup();}
|
|
1230
|
+
});
|
|
1231
|
+
|
|
1232
|
+
test('a pre-fix incomplete report cannot hide a real failure behind a PASS verdict, nor a [需确认] case behind a PASS pre-change verdict',async()=>{
|
|
1233
|
+
// The command really exited 1; only its final verdict is edited to PASS.
|
|
1234
|
+
const hidden=await legacyIncomplete({browserOnly:true,commandFails:true});
|
|
1235
|
+
try{
|
|
1236
|
+
const text=fs.readFileSync(hidden.report(),'utf8');
|
|
1237
|
+
fs.writeFileSync(hidden.report(),text.replace(/("id": "declared-test",\s*"kind": "commands",\s*"verdict": )"BLOCKED"/,'$1"PASS"'));
|
|
1238
|
+
assert.match(fs.readFileSync(hidden.report(),'utf8'),/"verdict": "PASS"/);
|
|
1239
|
+
const refused=await hidden.entry({rerunBlockedQa:true}).handle(hidden.advance);
|
|
1240
|
+
assert.equal(refused.code,'qa_rerun_not_blocked_by_evidence');
|
|
1241
|
+
assert.equal(hidden.rows().filter(row=>row.phase==='superseded').length,0);
|
|
1242
|
+
}finally{hidden.f.cleanup();}
|
|
1243
|
+
// The approved contract still says [需确认]; the report drops the marker and claims PASS before the change.
|
|
1244
|
+
const unconfirmed=await driftFixture({confirmLogic:true});
|
|
1245
|
+
try{
|
|
1246
|
+
await unconfirmed.entry().handle(unconfirmed.advance);unconfirmed.restore();
|
|
1247
|
+
const text=fs.readFileSync(unconfirmed.report(),'utf8');
|
|
1248
|
+
const parts=text.split(/^## /m),index=parts.findIndex(part=>part.startsWith('TC-001\n'));
|
|
1249
|
+
const body=parts[index].slice('TC-001'.length+1),row=JSON.parse(body);
|
|
1250
|
+
assert.equal(row.verdictBeforeSourceChange,'BLOCKED');assert.equal(row.needsConfirmation,true);
|
|
1251
|
+
delete row.needsConfirmation;row.verdictBeforeSourceChange='PASS';
|
|
1252
|
+
parts[index]=`TC-001\n\n${JSON.stringify(row,null,2)}${body.match(/\s*$/)[0]}`;
|
|
1253
|
+
fs.writeFileSync(unconfirmed.report(),parts.map((part,i)=>i?`## ${part}`:part).join(''));
|
|
1254
|
+
const refused=await unconfirmed.entry({rerunBlockedQa:true}).handle(unconfirmed.advance);
|
|
1255
|
+
assert.equal(refused.code,'qa_rerun_not_blocked_by_evidence');
|
|
1256
|
+
}finally{unconfirmed.f.cleanup();}
|
|
1257
|
+
});
|
|
1258
|
+
|
|
1259
|
+
// 2026-10-07 AI潮: most QA BLOCKED rows were answer-form slips (evidence outside
|
|
1260
|
+
// the QA directory, the reported device not the registered one), each spending a
|
|
1261
|
+
// whole QA round. The host now asks such an answer back once, inside the case.
|
|
1262
|
+
test('a browser answer with fixable form problems is asked back once and then judged as usual',async()=>{
|
|
1263
|
+
const f=fixture();
|
|
1264
|
+
try{
|
|
1265
|
+
f.configuration.commands[0].caseIds=[];
|
|
1266
|
+
const inside=path.join(f.binding.specsDir,'.reviews','qa-evidence','walk.txt');
|
|
1267
|
+
fs.mkdirSync(path.dirname(inside),{recursive:true});fs.writeFileSync(inside,'Synthetic observation');
|
|
1268
|
+
const outside=path.join(f.configuration.codeProject,'README.md');fs.writeFileSync(outside,'not QA evidence');
|
|
1269
|
+
// Inside the specs root but outside its .reviews directory: still not QA evidence.
|
|
1270
|
+
const specsOnly=path.join(f.binding.specsDir,'evidence','walk.txt');fs.mkdirSync(path.dirname(specsOnly));fs.writeFileSync(specsOnly,'x');
|
|
1271
|
+
const requests=[];
|
|
1272
|
+
const executor=createHostQaExecutor({...f.configuration,
|
|
1273
|
+
logic:async()=>({verdict:'INSUFFICIENT_EVIDENCE',evidence:['Synthetic static observation']}),
|
|
1274
|
+
browser:async request=>{requests.push(request);
|
|
1275
|
+
return request.correction?{verdict:'PASS',evidence:[inside],environment:request.environment,cleanup:'completed'}
|
|
1276
|
+
:{verdict:'PASS',evidence:[inside,outside,specsOnly],environment:request.environment,cleanup:'completed'};}});
|
|
1277
|
+
const binding=begin(f,executor),result=await executor.run(binding,new AbortController().signal);
|
|
1278
|
+
const rows=fs.readFileSync(result.report,'utf8').split(/^## /m).slice(1).map(part=>JSON.parse(part.slice(part.indexOf('\n')+1)));
|
|
1279
|
+
const browserRows=rows.filter(row=>row.kind==='browser');
|
|
1280
|
+
assert(browserRows.length>=1);
|
|
1281
|
+
for(const row of browserRows){
|
|
1282
|
+
assert.equal(row.verdict,'PASS');assert.equal(row.evidenceProblem,null);
|
|
1283
|
+
assert.deepEqual(row.answerCorrection.problems.map(item=>[item.code,item.path]),
|
|
1284
|
+
[['evidence_outside_reviews_or_missing',outside],['evidence_outside_reviews_or_missing',specsOnly]]);
|
|
1285
|
+
assert.equal(row.answerCorrection.first.verdict,'PASS');
|
|
1286
|
+
}
|
|
1287
|
+
// Each corrected case was asked exactly twice, the second time with the problems and the honesty instruction.
|
|
1288
|
+
assert.equal(requests.length,browserRows.length*2);
|
|
1289
|
+
const correction=requests.find(request=>request.correction).correction;
|
|
1290
|
+
assert.match(correction.instruction,/\.reviews directory of the specs root/);assert.match(correction.instruction,/Keep the verdict, environment and cleanup/);
|
|
1291
|
+
const log=fs.readFileSync(path.join(f.binding.specsDir,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse);
|
|
1292
|
+
assert.equal(log.filter(row=>row.phase==='case_start').length,browserRows.length);
|
|
1293
|
+
assert.equal(log.filter(row=>row.phase==='case_blocked').length,0);
|
|
1294
|
+
}finally{f.cleanup();}
|
|
1295
|
+
});
|
|
1296
|
+
|
|
1297
|
+
test('a correction is asked at most once, never for a BLOCKED answer, and a timed-out correction stays BLOCKED',async()=>{
|
|
1298
|
+
for(const mode of ['blocked','timeout','fail','environment']){
|
|
1299
|
+
const f=fixture();
|
|
1300
|
+
try{
|
|
1301
|
+
f.configuration.commands[0].caseIds=[];let calls=0;
|
|
1302
|
+
const executor=createHostQaExecutor({...f.configuration,
|
|
1303
|
+
logic:async()=>({verdict:'INSUFFICIENT_EVIDENCE',evidence:['Synthetic static observation']}),
|
|
1304
|
+
browser:async request=>{calls++;
|
|
1305
|
+
if(mode==='blocked')return {verdict:'BLOCKED',evidence:['simulator unreachable'],environment:{...request.environment,target:'x'},cleanup:'not_needed'};
|
|
1306
|
+
// A FAIL, or a PASS from another device, is never asked again (no FAIL→PASS, no field swap).
|
|
1307
|
+
if(mode==='fail')return {verdict:'FAIL',evidence:['not-a-file'],environment:request.environment,cleanup:'completed'};
|
|
1308
|
+
if(mode==='environment')return {verdict:'PASS',evidence:['not-a-file'],environment:{...request.environment,target:'another-device'},cleanup:'completed'};
|
|
1309
|
+
if(request.correction)throw Object.assign(new Error('timeout'),{code:'host_request_timeout'});
|
|
1310
|
+
return {verdict:'PASS',evidence:['not-a-file'],environment:request.environment,cleanup:'completed'};}});
|
|
1311
|
+
const binding=begin(f,executor),result=await executor.run(binding,new AbortController().signal);
|
|
1312
|
+
const rows=fs.readFileSync(result.report,'utf8').split(/^## /m).slice(1).map(part=>JSON.parse(part.slice(part.indexOf('\n')+1)))
|
|
1313
|
+
.filter(row=>row.kind==='browser');
|
|
1314
|
+
assert.equal(calls,rows.length*(mode==='timeout'?2:1),mode);
|
|
1315
|
+
for(const row of rows){
|
|
1316
|
+
assert.equal(row.verdict,'BLOCKED');
|
|
1317
|
+
if(mode!=='timeout')assert.equal(row.answerCorrection,undefined);
|
|
1318
|
+
if(mode==='blocked')assert.equal(row.hostDeclaredBlocked,true);
|
|
1319
|
+
else if(mode!=='timeout'){assert.equal(row.hostDeclaredBlocked,undefined);assert.equal(row.evidenceProblem,'qa_evidence_required');}
|
|
1320
|
+
else{assert.equal(row.hostRequestTimeout,true);assert.equal(row.hostDeclaredBlocked,undefined);
|
|
1321
|
+
assert.deepEqual(row.answerCorrection.problems.map(item=>item.code),['evidence_outside_reviews_or_missing']);}
|
|
1322
|
+
}
|
|
1323
|
+
}finally{f.cleanup();}
|
|
1324
|
+
}
|
|
1325
|
+
});
|
|
1326
|
+
|
|
1327
|
+
test('a correction never changes anything but evidence: required cleanup not done is not asked, a changed answer does not pass',async()=>{
|
|
1328
|
+
for(const mode of ['cleanup-not-done','changed-cleanup']){
|
|
1329
|
+
const f=fixture();
|
|
1330
|
+
try{
|
|
1331
|
+
f.configuration.commands[0].caseIds=[];let calls=0;
|
|
1332
|
+
const inside=path.join(f.binding.specsDir,'.reviews','qa-evidence','walk.txt');
|
|
1333
|
+
fs.mkdirSync(path.dirname(inside),{recursive:true});fs.writeFileSync(inside,'Synthetic observation');
|
|
1334
|
+
const executor=createHostQaExecutor({...f.configuration,
|
|
1335
|
+
logic:async()=>({verdict:'INSUFFICIENT_EVIDENCE',evidence:['Synthetic static observation']}),
|
|
1336
|
+
browser:async request=>{calls++;
|
|
1337
|
+
const needsCleanup=request.case.cleanup.length>0;
|
|
1338
|
+
if(mode==='cleanup-not-done')return {verdict:'PASS',evidence:['not-a-file'],environment:request.environment,
|
|
1339
|
+
cleanup:needsCleanup?'not_needed':'not_needed'};
|
|
1340
|
+
// First answer is acceptable but for its evidence; the "correction" also flips cleanup.
|
|
1341
|
+
return request.correction?{verdict:'PASS',evidence:[inside],environment:request.environment,cleanup:needsCleanup?'not_needed':'completed'}
|
|
1342
|
+
:{verdict:'PASS',evidence:['not-a-file'],environment:request.environment,cleanup:needsCleanup?'completed':'not_needed'};}});
|
|
1343
|
+
const binding=begin(f,executor),result=await executor.run(binding,new AbortController().signal);
|
|
1344
|
+
const rows=fs.readFileSync(result.report,'utf8').split(/^## /m).slice(1).map(part=>JSON.parse(part.slice(part.indexOf('\n')+1)))
|
|
1345
|
+
.filter(row=>row.kind==='browser');
|
|
1346
|
+
const cleaned=rows.filter(row=>f.configuration&&row.id==='TC-002');
|
|
1347
|
+
assert(cleaned.length===1,'TC-002 requires cleanup in the fixture');
|
|
1348
|
+
const row=cleaned[0];
|
|
1349
|
+
assert.equal(row.verdict,'BLOCKED',mode);
|
|
1350
|
+
if(mode==='cleanup-not-done')assert.equal(row.answerCorrection,undefined);
|
|
1351
|
+
else{assert.equal(row.evidenceProblem,'qa_correction_changed_answer');assert.equal(row.answerCorrection.first.cleanup,'completed');}
|
|
1352
|
+
}finally{f.cleanup();}
|
|
1353
|
+
}
|
|
1354
|
+
});
|