@aibyzero/cm-workflow 0.16.7 → 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 +18 -0
- package/README.md +26 -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 +36 -3
- package/docs/user-guide.md +104 -0
- package/package.json +1 -1
- package/runtime/js/cm-ai/cm-ai-admission.mjs +3 -1
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +27 -6
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +82 -8
- package/runtime/js/cm-ai/codex-review-adapter.mjs +2 -1
- package/runtime/js/cm-ai/drive-core.mjs +17 -4
- package/runtime/js/cm-ai/execution-store.mjs +4 -2
- package/runtime/js/cm-ai/host-qa-executor.mjs +37 -13
- 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/reviewed-deliveries.mjs +29 -6
- 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/investigation.mjs +25 -9
- package/runtime/js/cm-fix/progress.mjs +3 -1
- 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-batch-run.mjs +5 -0
- package/scripts/cm-ai-batch-run.test.mjs +9 -1
- package/scripts/cm-ai-drive.mjs +4 -1
- package/scripts/cm-ai-drive.test.mjs +8 -0
- package/scripts/cm-ai-fix-run-delivery.test.mjs +138 -0
- package/scripts/cm-ai-host.mjs +2 -2
- package/scripts/cm-ai-project-qa-gate.test.mjs +71 -4
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +77 -4
- 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-rediagnosis.test.mjs +71 -4
- package/scripts/cm-host-qa-executor.test.mjs +121 -0
- package/scripts/cm-log-event.mjs +31 -5
- 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-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/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 +67 -329
- package/skills/cm-fix/SKILL.md +2 -0
- package/skills/cm-fix/references/js-host.md +16 -9
- package/skills/cm-prd/SKILL.md +2 -0
|
@@ -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();
|
package/scripts/cm-log-event.mjs
CHANGED
|
@@ -200,8 +200,14 @@ export function unclosedResources(states){
|
|
|
200
200
|
return [...states].filter(([,value])=>['acquired','cleanup_failed'].includes(value[0])).map(([key])=>key).sort();
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
function applyTestRunTransition(active,openCases,phase,caseId,incompleteReport=false){
|
|
203
|
+
function applyTestRunTransition(active,openCases,phase,caseId,incompleteReport=false,timedOut=false){
|
|
204
204
|
if(phase==='superseded'){
|
|
205
|
+
// A call stopped as a whole (see validateQaSupersession) may leave a case
|
|
206
|
+
// started; like abandonment, its own superseded row closes it.
|
|
207
|
+
if(timedOut){
|
|
208
|
+
if(!active)throw new UsageError('QA superseded of a timed-out invocation has no active test run');
|
|
209
|
+
openCases.clear();return false;
|
|
210
|
+
}
|
|
205
211
|
// incomplete_report: a call with its fixed report but no complete row (see
|
|
206
212
|
// validateQaSupersession) is closed by its own superseded row.
|
|
207
213
|
if(active!==incompleteReport||openCases.size)throw new UsageError('QA superseded requires a completed invocation');
|
|
@@ -369,6 +375,24 @@ function validateQaSupersession(state,event){
|
|
|
369
375
|
throw new UsageError('QA superseded of an incomplete invocation requires its active start, no complete row and blocked_cases');
|
|
370
376
|
return;
|
|
371
377
|
}
|
|
378
|
+
// A call stopped as a whole (qa_execution_timeout) with no complete row. The
|
|
379
|
+
// host re-reads its case rows (PASS or host request timeout only); here the
|
|
380
|
+
// structural part: the still active latest invocation and its PASS rows.
|
|
381
|
+
if(event.reason==='host_request_timeout'){
|
|
382
|
+
if(!state.active||state.superseded||!start||complete||start.attempt>=3
|
|
383
|
+
||event.workflow!=='cm-ai'||event.node!=='N6'||event.previous_test_run_id!==start.operation_id
|
|
384
|
+
||!Array.isArray(event.timed_out_cases)||event.timed_out_cases.length===0||event.timed_out_cases.length>start.case_count
|
|
385
|
+
||!caseList(event.timed_out_cases,event.timed_out_cases.length)
|
|
386
|
+
||JSON.stringify(event.partial_pass_cases)!==JSON.stringify([...state.partialPassCases].sort())
|
|
387
|
+
||event.request_timeout_ms!==undefined&&!(Number.isSafeInteger(event.request_timeout_ms)&&event.request_timeout_ms>0)
|
|
388
|
+
||event.legacy_timeout_attestation!==undefined&&(typeof event.legacy_timeout_attestation!=='string'
|
|
389
|
+
||!event.legacy_timeout_attestation.trim()||Buffer.byteLength(event.legacy_timeout_attestation,'utf8')>500
|
|
390
|
+
||/[\r\n\0]/.test(event.legacy_timeout_attestation))
|
|
391
|
+
||!['repository_id','run_id','feature','task','package_digest','qa_decision_id','operation_id','attempt','mode','case_count']
|
|
392
|
+
.every(key=>event[key]!==undefined&&event[key]===start[key]))
|
|
393
|
+
throw new UsageError('QA superseded of a timed-out invocation requires its active start, no complete row and timed_out_cases');
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
372
396
|
if(event.reason==='declared_environment_failure'){
|
|
373
397
|
const reason=event.environment_failure_reason;
|
|
374
398
|
if(state.active||state.superseded||!start||!complete||complete.result!=='FAIL'||!(complete.failed>0)
|
|
@@ -402,8 +426,9 @@ function loadTestRunState(file,runId){
|
|
|
402
426
|
throw new UsageError('test_run state log contains a malformed case event');
|
|
403
427
|
if(phase==='complete'&&!active&&!openCases.size)continue;
|
|
404
428
|
if(phase==='abandoned')validateQaAbandonment({active,start,hasNonPassResult,partialPassCases},value);
|
|
405
|
-
if(phase==='superseded')validateQaSupersession({active,start,complete,superseded},value);
|
|
406
|
-
active=applyTestRunTransition(active,openCases,phase,typeof caseId==='string'?caseId:null,value.incomplete_report===true
|
|
429
|
+
if(phase==='superseded')validateQaSupersession({active,start,complete,superseded,partialPassCases},value);
|
|
430
|
+
active=applyTestRunTransition(active,openCases,phase,typeof caseId==='string'?caseId:null,value.incomplete_report===true,
|
|
431
|
+
phase==='superseded'&&value.reason==='host_request_timeout');
|
|
407
432
|
if(phase==='start'){start=value;complete=null;hasNonPassResult=false;partialPassCases.clear();abandoned=false;superseded=false;}
|
|
408
433
|
if(phase==='complete')complete=value;
|
|
409
434
|
if(phase==='case_complete'){
|
|
@@ -552,12 +577,13 @@ export function writeLogEvent(rawInput,{environment=process.env,now=new Date(),u
|
|
|
552
577
|
}
|
|
553
578
|
if(existing===null&&event.event==='test_run'&&event.phase==='superseded'){
|
|
554
579
|
validateQaSupersession(testRun,event);
|
|
555
|
-
if(event.incomplete_report===true
|
|
580
|
+
if((event.incomplete_report===true||event.reason==='host_request_timeout')
|
|
581
|
+
&&unclosedResources(loadResourceStates(authoritativeLog,built.runId)).length)
|
|
556
582
|
throw new UsageError('QA superseded of an incomplete invocation blocked by unclosed resources');
|
|
557
583
|
}
|
|
558
584
|
if(existing===null&&event.event==='test_run'&&event.phase!==undefined)
|
|
559
585
|
applyTestRunTransition(testRun.active,testRun.openCases,event.phase,event.case_id??null,
|
|
560
|
-
event.phase==='superseded'&&event.incomplete_report===true);
|
|
586
|
+
event.phase==='superseded'&&event.incomplete_report===true,event.phase==='superseded'&&event.reason==='host_request_timeout');
|
|
561
587
|
|
|
562
588
|
let projectDuplicate=false;
|
|
563
589
|
if(projectLog){
|