@aibyzero/cm-workflow 0.15.4 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/CHANGELOG.md +31 -0
- package/README.md +6 -1
- package/VERSION +1 -1
- package/docs/installation.md +9 -2
- package/docs/js-workflow-control.md +168 -3
- package/install.sh +12 -1
- package/package.json +1 -1
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +12 -2
- package/runtime/js/cm-ai/durable-runner-state.mjs +12 -1
- package/runtime/js/cm-ai/effect-contract.mjs +28 -3
- package/runtime/js/cm-ai/host-conversation-execution.mjs +55 -3
- package/runtime/js/cm-ai/host-handoff.mjs +59 -1
- package/runtime/js/cm-ai/host-session.mjs +21 -2
- package/runtime/js/cm-ai/host-tool-bridge.mjs +1 -1
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +4 -1
- package/runtime/js/cm-ai/task-runner.mjs +38 -3
- package/scripts/cm-ai-batch-host.mjs +18 -6
- package/scripts/cm-ai-batch-run.mjs +12 -4
- package/scripts/cm-ai-execution-diagnostic.test.mjs +68 -0
- package/scripts/cm-ai-host.mjs +7 -2
- package/scripts/cm-ai-qa-recovery-args.test.mjs +80 -0
- package/scripts/cm-ai-review-timeout-config.test.mjs +53 -0
- package/scripts/cm-ai-run.mjs +2 -1
- package/scripts/cm-ai-verification-gate.test.mjs +98 -0
- package/scripts/cm-announce-hook.mjs +83 -0
- package/scripts/cm-announce-hook.test.mjs +90 -0
- package/scripts/cm-host-handoff.test.mjs +116 -1
- package/scripts/cm-host-session-diagnostic.test.mjs +82 -0
- package/skills/cm-ai/references/N3-execute-task.md +10 -0
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
// JSONL transport only. The existing host/runner owns decisions and durable state.
|
|
2
|
+
import {executionDiagnostic} from './effect-contract.mjs';
|
|
2
3
|
|
|
3
4
|
const LIMIT=64*1024;
|
|
4
5
|
const operationNames=new Set(['recover_final_review','advance','start','plan_design','promote_design','select_design_reviews','status','fix_status','fix_advance','fix_action','fix_run','decision','complete','qa','qa_result','prepare_revision','prepare_save',
|
|
5
6
|
'context_refresh','finish','completion_evidence','run_finalize','review_findings','review_disposition','save_draft','save_design','correct_findings','prepare_summary','publish_summary','inspect_correction','resume_correction','cancel','resume','cause_review_package','cause_review','red_test','baseline','author_tests','repair','regression','retrospective','learning_writeback','handoff','final_review_package','final_review','publish_review','check_n5','post_review_regression','publish_dossier','walkthrough']);
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
// Which contract codes may reach the peer is a deliberate boundary: the host
|
|
9
|
+
// exposes chosen ones as a blocked result with a reason and redacts the rest to
|
|
10
|
+
// host_request_failed. That boundary is kept exactly as is. What was missing is
|
|
11
|
+
// that the redacted ones vanished entirely, leaving the operator with no way to
|
|
12
|
+
// tell a missing field from a wrong one. The real code now goes to this
|
|
13
|
+
// process's own stderr and nowhere else: not to the peer, not to any log or
|
|
14
|
+
// state. Named fields only, never error.message.
|
|
15
|
+
function reportRequestFailure(errorOutput,operation,error){
|
|
16
|
+
try{
|
|
17
|
+
const detail=executionDiagnostic(error);
|
|
18
|
+
errorOutput.write(JSON.stringify({diagnostic:'host_request_failed',operation,
|
|
19
|
+
...(detail??{detail:'unavailable'})})+'\n');
|
|
20
|
+
}catch{/* diagnostics never change the reply */}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export async function serveCmAiHost({host,input,output,toolBridge=null,inputLimit=LIMIT,errorOutput=process.stderr}){
|
|
8
24
|
if(!Number.isSafeInteger(inputLimit)||inputLimit<LIMIT||inputLimit>4*1024*1024)throw Error('input_limit_invalid');
|
|
9
25
|
let pending=null,buffer=Buffer.alloc(0),failure=null,closeRequested=false;
|
|
10
26
|
let writing=Promise.resolve();
|
|
@@ -47,7 +63,10 @@ export async function serveCmAiHost({host,input,output,toolBridge=null,inputLimi
|
|
|
47
63
|
const requestId=request.requestId;
|
|
48
64
|
const invoke=async()=>{
|
|
49
65
|
try{await reply({requestId,result:await host.handle(request)});}
|
|
50
|
-
catch
|
|
66
|
+
catch(error){
|
|
67
|
+
reportRequestFailure(errorOutput,request.operation,error);
|
|
68
|
+
await reply({requestId,error:{code:'host_request_failed'}});
|
|
69
|
+
}
|
|
51
70
|
};
|
|
52
71
|
// Never queue cancel/status behind a long developer or reviewer call.
|
|
53
72
|
if(request.operation==='status'||request.operation==='cancel'){
|
|
@@ -18,7 +18,7 @@ export function createHostToolBridge({responseLimit=64*1024}={}){
|
|
|
18
18
|
},
|
|
19
19
|
call(kind,payload,signal,{timeoutMs=null}={}){
|
|
20
20
|
need(send!==null&&!closed,'host_bridge_unavailable');need(pending===null,'host_bridge_busy');
|
|
21
|
-
need(['develop','check','check_runtime','check_semantic','qa_assess','qa_logic','qa_browser','change_impact','test_cases','refactor_analyze','refactor_confirm','refactor_apply','refactor_review','refactor_batch','refactor_prepare_tests','refactor_retrospective','refactor_recover','documentation_sync','documentation_inspect','fix_diagnose','fix_learning','fix_test_author','fix_repair','fix_retrospective','init_analyze','init_generate','init_verify','init_confirm','init_review','init_write','idea_interview','idea_confirm_save','prd_analyze','prd_materials','prd_generate','prd_self_check','prd_review','prd_correct','prd_summary']
|
|
21
|
+
need(['develop','check','verification_precheck','check_runtime','check_semantic','qa_assess','qa_logic','qa_browser','change_impact','test_cases','refactor_analyze','refactor_confirm','refactor_apply','refactor_review','refactor_batch','refactor_prepare_tests','refactor_retrospective','refactor_recover','documentation_sync','documentation_inspect','fix_diagnose','fix_learning','fix_test_author','fix_repair','fix_retrospective','init_analyze','init_generate','init_verify','init_confirm','init_review','init_write','idea_interview','idea_confirm_save','prd_analyze','prd_materials','prd_generate','prd_self_check','prd_review','prd_correct','prd_summary']
|
|
22
22
|
.includes(kind),'host_operation_invalid');need(!signal.aborted,'cancelled');
|
|
23
23
|
const data=json({kind,payload},12*1024*1024);
|
|
24
24
|
const request={type:'host_request',sessionId,callId:randomUUID(),requestDigest:digest(data),...data};
|
|
@@ -46,8 +46,11 @@ export function validateHostWorkflowConfiguration(raw){
|
|
|
46
46
|
need(Array.isArray(config[key])&&config[key].length<=256&&config[key].every(item=>typeof item==='string'),'invalid_workflow_config');
|
|
47
47
|
if(config.qa!==null){
|
|
48
48
|
shape(config.qa,['commands','environment',...(Object.hasOwn(config.qa,'timeoutMs')?['timeoutMs']:[])]);
|
|
49
|
+
// A real browser walkthrough of one blocking case runs for minutes, so this
|
|
50
|
+
// follows the shared call-timeout range rather than a fixed minute. The
|
|
51
|
+
// default below is unchanged; only an explicit configuration may raise it.
|
|
49
52
|
if(Object.hasOwn(config.qa,'timeoutMs'))need(Number.isSafeInteger(config.qa.timeoutMs)
|
|
50
|
-
&&config.qa.timeoutMs>0&&config.qa.timeoutMs<=
|
|
53
|
+
&&config.qa.timeoutMs>0&&config.qa.timeoutMs<=3600000,'invalid_workflow_config');
|
|
51
54
|
}
|
|
52
55
|
return config;
|
|
53
56
|
}
|
|
@@ -92,9 +92,14 @@ export function createTaskRunner(options) {
|
|
|
92
92
|
if(options && Object.hasOwn(options,'specification'))optionKeys.push('specification');
|
|
93
93
|
if(options && Object.hasOwn(options,'bootstrap'))optionKeys.push('bootstrap');
|
|
94
94
|
if(options && Object.hasOwn(options,'codeProjectPaths'))optionKeys.push('codeProjectPaths');
|
|
95
|
+
if(options && Object.hasOwn(options,'verificationGate'))optionKeys.push('verificationGate');
|
|
95
96
|
if(invocationMode)optionKeys.push('reviewInvocation');
|
|
96
97
|
shape(options,optionKeys);
|
|
97
98
|
const {check,commit}=options;need(typeof check==='function' && (taskMode||typeof commit==='function'));
|
|
99
|
+
// Opt-in gate between the task's own checks and the independent review. It may
|
|
100
|
+
// only block: passing it grants nothing and never substitutes for that review.
|
|
101
|
+
const verificationGate=options.verificationGate??null;
|
|
102
|
+
need(verificationGate===null||typeof verificationGate==='function');
|
|
98
103
|
if(taskMode)need(Object.hasOwn(options,'persistence'),'runner_completion');
|
|
99
104
|
const config=json({root:options.root,identity:options.identity,scope:options.scope,requirements:options.requirements,
|
|
100
105
|
...(Object.hasOwn(options,'codeProjectPaths')?{codeProjectPaths:validateCodeProjectPaths(options.codeProjectPaths)}:{}),
|
|
@@ -198,6 +203,12 @@ export function createTaskRunner(options) {
|
|
|
198
203
|
...handoffBinding(),reviewPackage,receipt,registered:registered.get(receipt.id),
|
|
199
204
|
at:reviewInvocation.registration.registeredAt});
|
|
200
205
|
}
|
|
206
|
+
// A develop effect the host gate blocked keeps its audit entry like any other,
|
|
207
|
+
// so the next corrected delivery needs a new effect id or it would just read
|
|
208
|
+
// the blocked result back out of the cache. Counting them here keeps that
|
|
209
|
+
// derivation in one place, next to the cache it is derived from.
|
|
210
|
+
const verificationBlocks=()=>[...cache.values()].filter(entry=>entry.effect.kind==='develop'
|
|
211
|
+
&&entry.result?.state==='blocked'&&entry.result?.code==='verification_precheck_failed').length;
|
|
201
212
|
const privateStatus=()=>json({state,code,identity:{...config.identity,attempt},packageDigest:reviewPackage?.packageDigest??null,
|
|
202
213
|
receipt,receipts,calls,cancelAfterCommit,workflowError,...(store?{cancellationRequested}:{}),...(taskMode?{taskCommit}:{}),
|
|
203
214
|
...(invocationMode?{reviewInvocation}:{}),...(taskLearning!==null?{learningWriteback:learningResult?.writeback??null}:{})},16*1024*1024);
|
|
@@ -562,6 +573,21 @@ export function createTaskRunner(options) {
|
|
|
562
573
|
if(cancelReject)controller.signal.removeEventListener('abort',cancelReject);}
|
|
563
574
|
}
|
|
564
575
|
async function collectChecks(){return json(await bounded(check,json({identity:{...config.identity,attempt}})));}
|
|
576
|
+
// Runs on the checks just collected, before any handoff or review package is
|
|
577
|
+
// built, so a deliverable that does not satisfy the task's own written
|
|
578
|
+
// verification never spends an independent review round.
|
|
579
|
+
async function verificationSatisfied(checks) {
|
|
580
|
+
if(verificationGate===null)return true;
|
|
581
|
+
// No written verification means nothing to check against; the gate stays out
|
|
582
|
+
// of the way rather than inventing requirements of its own.
|
|
583
|
+
const specification=Object.hasOwn(original,'specification')?verifySpecificationMaterial(original):null;
|
|
584
|
+
const verification=specification?.task?.verification??null;
|
|
585
|
+
if(typeof verification!=='string'||verification.trim().length===0)return true;
|
|
586
|
+
const verdict=json(await bounded(verificationGate,
|
|
587
|
+
json({identity:{...config.identity,attempt},verification,checks})));
|
|
588
|
+
shape(verdict,['satisfied']);need(typeof verdict.satisfied==='boolean','invalid_result');
|
|
589
|
+
return verdict.satisfied;
|
|
590
|
+
}
|
|
565
591
|
async function perform(v) {
|
|
566
592
|
if(v.kind==='develop') {
|
|
567
593
|
need(stageAllowed('develop',state,code),'stage_mismatch');state='developing';code=null;receipt=null;
|
|
@@ -601,6 +627,8 @@ export function createTaskRunner(options) {
|
|
|
601
627
|
if(writeback.outcome==='writeback_pending'){halt('blocked','learning_writeback_pending');return;}
|
|
602
628
|
if(taskLearning.hostHandoff===true){
|
|
603
629
|
currentChecks=await collectChecks();active();
|
|
630
|
+
if(!await verificationSatisfied(currentChecks)){halt('blocked','verification_precheck_failed');return;}
|
|
631
|
+
active();
|
|
604
632
|
createHostHandoff({root:config.root,baseline:base,checks:currentChecks,
|
|
605
633
|
handoffPath:completion.handoffs[attempt-1]});
|
|
606
634
|
}
|
|
@@ -608,7 +636,11 @@ export function createTaskRunner(options) {
|
|
|
608
636
|
identity:{...config.identity,attempt},learningInput:v.learningInput,application,retrospective,writeback});
|
|
609
637
|
}
|
|
610
638
|
need(result.response.result.outcome==='implemented','invalid_result');
|
|
611
|
-
if(taskLearning?.hostHandoff!==true)
|
|
639
|
+
if(taskLearning?.hostHandoff!==true){
|
|
640
|
+
currentChecks=await collectChecks();active();
|
|
641
|
+
if(!await verificationSatisfied(currentChecks)){halt('blocked','verification_precheck_failed');return;}
|
|
642
|
+
}
|
|
643
|
+
active();
|
|
612
644
|
const nextPackage=createReviewPackage({root:config.root,baseline:base,checks:currentChecks,
|
|
613
645
|
...(taskLearning?.hostHandoff===true?{handoffPath:completion.handoffs[attempt-1]}:{})});
|
|
614
646
|
if(taskLearning!==null)validateTaskLearningReviewPackage(nextPackage,learningResult.writeback,v.learningInput,
|
|
@@ -689,7 +721,10 @@ export function createTaskRunner(options) {
|
|
|
689
721
|
try {
|
|
690
722
|
if(state==='ready')need(digest(captureReviewBaseline({...configToBaseline(metadata),version:original.version,
|
|
691
723
|
...(Object.hasOwn(original,'specification')?{specification:{specsRoot:original.specificationRoot,feature:original.specification.feature}}:{})}))===digest(original),'package_mismatch');
|
|
692
|
-
|
|
724
|
+
// A develop restarted from a locally rejected delivery has no review package
|
|
725
|
+
// to verify yet: the invalid result never built one, and the host gate blocks
|
|
726
|
+
// before one is built.
|
|
727
|
+
else if(!(v.kind==='develop'&&stageAllowed('develop',state,code)))verifyReviewPackage({root:config.root,baseline:state==='changes_requested'?attemptBaseline(original,attempt-1):base,
|
|
693
728
|
checks:reviewPackage.checks,reviewPackage,expectedDigest:reviewPackage.packageDigest,...handoffBinding()});
|
|
694
729
|
} catch {return Promise.resolve(freeze({outcome:'rejected',code:'package_mismatch'}));}
|
|
695
730
|
try{const record=persist('effect-intent',{effect:v});
|
|
@@ -790,7 +825,7 @@ export function createTaskRunner(options) {
|
|
|
790
825
|
need(state==='fixture_completed','qa_attach_not_completed');
|
|
791
826
|
persist('qa-attached',{record});qaAttachment=record;return json(record);
|
|
792
827
|
};
|
|
793
|
-
const api={executeEffect,status,cancel,run,inspectFixAssociation,acceptCompletedFix,attachQa};
|
|
828
|
+
const api={executeEffect,status,cancel,run,inspectFixAssociation,acceptCompletedFix,attachQa,verificationBlocks};
|
|
794
829
|
if(bootstrap!==null)api.inspectBootstrapAdmission=()=>bootstrap.inspectAdmission(original);
|
|
795
830
|
if(taskLearning!==null)api.attachLearningEvidence=attachLearningEvidence;
|
|
796
831
|
return Object.freeze(api);
|
|
@@ -13,7 +13,7 @@ import {serveCmAiHost} from '../runtime/js/cm-ai/host-session.mjs';
|
|
|
13
13
|
import {validateHostWorkflowConfiguration,featureHasBrowserCases,readBrowserCapability} from '../runtime/js/cm-ai/host-workflow-capabilities.mjs';
|
|
14
14
|
import {digest,json,need,shape} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
15
15
|
|
|
16
|
-
const usage='cm-ai-batch-host.mjs serve --config PATH --host-context ID --allow-development [--runtime codex|claude] [--review-config PATH] [--allow-review FEATURE/TASK:1|2]... [--allow-qa] [--browser-qa available|unavailable] [--protected-conversation-config PATH | --protected-config PATH] [--allow-provider-development FEATURE/TASK:1|2]...';
|
|
16
|
+
const usage='cm-ai-batch-host.mjs serve --config PATH --host-context ID --allow-development [--runtime codex|claude] [--review-config PATH] [--allow-review FEATURE/TASK:1|2]... [--allow-qa] [--rerun-unknown-qa | --rerun-blocked-qa] [--verification-precheck] [--browser-qa available|unavailable] [--protected-conversation-config PATH | --protected-config PATH] [--allow-provider-development FEATURE/TASK:1|2]...';
|
|
17
17
|
const safeCode=error=>typeof error?.code==='string'&&/^[a-z][a-z0-9_]{0,63}$/.test(error.code)?error.code:'batch_host_failed';
|
|
18
18
|
|
|
19
19
|
async function memberReviewConfiguration(batch,definition,review,runtime){
|
|
@@ -26,9 +26,12 @@ async function memberReviewConfiguration(batch,definition,review,runtime){
|
|
|
26
26
|
fs.mkdirSync(directory,{recursive:true,mode:0o700});
|
|
27
27
|
need(fs.realpathSync(directory)===directory,'invalid_preflight_cache');
|
|
28
28
|
const file=path.join(directory,`preflight-${definition.identity.taskId}.json`);
|
|
29
|
+
// The cached file stays a pure preflight diagnostic. The reviewer budget is a
|
|
30
|
+
// launch argument, so it is applied on return and never written to the cache.
|
|
31
|
+
const withTimeout=config=>review.timeoutMs==null?config:{...config,timeoutMs:review.timeoutMs};
|
|
29
32
|
if(fs.existsSync(file)){
|
|
30
33
|
const info=fs.lstatSync(file);need(info.isFile()&&!info.isSymbolicLink(),'invalid_preflight_cache');
|
|
31
|
-
try{const cached=readConversationReviewConfiguration(file);if(matches(cached))return cached;}
|
|
34
|
+
try{const cached=readConversationReviewConfiguration(file);if(matches(cached))return withTimeout(cached);}
|
|
32
35
|
catch{/* Invalid or obsolete diagnostics require a fresh loopback, never a rewritten fingerprint. */}
|
|
33
36
|
}
|
|
34
37
|
const config=await runReviewPreflight(definition,{model:review.model,runtime,disabledSkills:review.disabledSkills});
|
|
@@ -36,12 +39,12 @@ async function memberReviewConfiguration(batch,definition,review,runtime){
|
|
|
36
39
|
const temporary=`${file}.${process.pid}.tmp`;
|
|
37
40
|
fs.writeFileSync(temporary,JSON.stringify(config)+'\n',{flag:'wx',mode:0o600});
|
|
38
41
|
try{fs.renameSync(temporary,file);}finally{if(fs.existsSync(temporary))fs.unlinkSync(temporary);}
|
|
39
|
-
return config;
|
|
42
|
+
return withTimeout(config);
|
|
40
43
|
}catch{need(false,'review_preflight_failed');}
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
export async function main(argv=process.argv.slice(2),{input=process.stdin,output=process.stdout,error=process.stderr}={}){
|
|
44
|
-
if(argv.length===1&&['--help','-h'].includes(argv[0])){output.write(usage+'\nOptional --protected-conversation-config PATH uses the shared current-host scoped text proposals and native sandbox checks; {checkCommands,timeoutMs}. No extra model call, same Codex/Claude runtime and per-task Review permissions. Optional --protected-config PATH {model,checkCommands,timeoutMs} enables CLI development only for per-task --allow-provider-development FEATURE/TASK:1|2 grants; mutually exclusive with --protected-conversation-config. Optional bundle.bootstraps maps approved bootstrap task keys to {selection}; --allow-bootstrap-write grants only those fixed instruction/scaffold steps. Optional batch.codeProjects uses prefixed paths and checks with codeProject per command; one task remains one completion gate.\nBatch entry requires a clean Git main checkout (including untracked files); batch_main_dirty lists dirty files before any task or worktree starts. Serial tasks are committed automatically before batch_handoff, with task_commit recording the SHA (null if unchanged). Terminal parallel members preserve WIP on their retained branches and fall back once to serial generation 2 after ready members merge.\n');return 0;}
|
|
47
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0])){output.write(usage+'\nOptional --protected-conversation-config PATH uses the shared current-host scoped text proposals and native sandbox checks; {checkCommands,timeoutMs}. No extra model call, same Codex/Claude runtime and per-task Review permissions. Optional --protected-config PATH {model,checkCommands,timeoutMs} enables CLI development only for per-task --allow-provider-development FEATURE/TASK:1|2 grants; mutually exclusive with --protected-conversation-config. Optional bundle.bootstraps maps approved bootstrap task keys to {selection}; --allow-bootstrap-write grants only those fixed instruction/scaffold steps. Optional batch.codeProjects uses prefixed paths and checks with codeProject per command; one task remains one completion gate.\nOptional --review-config PATH is {model,preflight[,disabledSkills][,timeoutMs]}; timeoutMs is the reviewer transport budget in milliseconds (integer 1-3600000, default 60000). It is independent of --protected-conversation-config/--protected-config and wins over their timeoutMs for the reviewer, so a review that exceeds the default can be raised without switching development mode. It is not part of the authorized configuration digest, so a resumed run may raise it after review_transport_timeout.\nOptional --rerun-unknown-qa / --rerun-blocked-qa carry the same single-task QA recovery into a batch and require --allow-qa; they are mutually exclusive. A batch has no --mode, so each task applies the flag only when it resumes an existing run and has a QA executor; a created run or a task without QA ignores it rather than failing the whole batch. Semantics, limits and the qaRound cap are the single-task ones, unchanged.\nOptional --verification-precheck sends the written verification of the task and the collected checks back as a verification_precheck request before any handoff or review package is built. It may only block: a requirement reported unsatisfied stops the task at blocked / verification_precheck_failed with pendingAction resume and spends no review round. Passing it is not an approval, writes no receipt and does not replace the independent review. A task with no written verification is unaffected.\nBatch entry requires a clean Git main checkout (including untracked files); batch_main_dirty lists dirty files before any task or worktree starts. Serial tasks are committed automatically before batch_handoff, with task_commit recording the SHA (null if unchanged). Terminal parallel members preserve WIP on their retained branches and fall back once to serial generation 2 after ready members merge.\n');return 0;}
|
|
45
48
|
let bridge;
|
|
46
49
|
try{
|
|
47
50
|
need(argv.length>=6&&argv[0]==='serve'&&argv[1]==='--config'&&argv[3]==='--host-context'
|
|
@@ -59,10 +62,14 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
59
62
|
}
|
|
60
63
|
need(keys.length===Object.keys(workflows).length&&keys.every(key=>Object.hasOwn(workflows,key)),'workflow_task_mismatch');
|
|
61
64
|
for(const key of keys)if(workflows[key]!==null)validateHostWorkflowConfiguration(workflows[key]);
|
|
62
|
-
let review=null,allowQa=false,allowBootstrap=false,runtime=null,protection=null,providerConfig=null,browserQaFlag;
|
|
65
|
+
let review=null,allowQa=false,allowBootstrap=false,runtime=null,protection=null,providerConfig=null,browserQaFlag;
|
|
66
|
+
let rerunUnknownQa=false,rerunBlockedQa=false,verificationPrecheck=false;const approvals=new Set(),developments=new Map();
|
|
63
67
|
for(let index=6;index<argv.length;index++){
|
|
64
68
|
const name=argv[index];
|
|
65
69
|
if(name==='--allow-qa'){need(!allowQa,'invalid_arguments');allowQa=true;}
|
|
70
|
+
else if(name==='--rerun-unknown-qa'){need(!rerunUnknownQa,'invalid_arguments');rerunUnknownQa=true;}
|
|
71
|
+
else if(name==='--rerun-blocked-qa'){need(!rerunBlockedQa,'invalid_arguments');rerunBlockedQa=true;}
|
|
72
|
+
else if(name==='--verification-precheck'){need(!verificationPrecheck,'invalid_arguments');verificationPrecheck=true;}
|
|
66
73
|
else if(name==='--browser-qa'){
|
|
67
74
|
need(browserQaFlag===undefined&&typeof argv[index+1]==='string','invalid_arguments');browserQaFlag=argv[++index];
|
|
68
75
|
}
|
|
@@ -98,6 +105,10 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
98
105
|
readBrowserCapability(browserQaFlag,keys.some(key=>workflows[key]?.qa!=null
|
|
99
106
|
&&featureHasBrowserCases(batch.specsDir,key.slice(0,key.lastIndexOf('/')),batch.codeProject)));
|
|
100
107
|
need(!approvals.size||review!==null,'review_configuration_required');
|
|
108
|
+
// Same two guards as the single-task host. A batch has no --mode, so the
|
|
109
|
+
// per-task resume check lives in createCmAiBatch rather than here.
|
|
110
|
+
need(!(rerunUnknownQa&&rerunBlockedQa),'qa_recovery_authorization_required');
|
|
111
|
+
need(!(rerunUnknownQa||rerunBlockedQa)||allowQa,'qa_recovery_authorization_required');
|
|
101
112
|
need(allowQa||!Object.values(workflows).some(item=>item?.qa!=null),'qa_authorization_required');
|
|
102
113
|
bridge=createHostToolBridge();
|
|
103
114
|
// The current conversation transport accepts one outstanding host call.
|
|
@@ -109,12 +120,13 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
109
120
|
}};
|
|
110
121
|
const driver=createCmAiBatch({configuration:batch,logHome:path.join(batch.specsDir,'.reviews','host-log-mirror'),
|
|
111
122
|
runtime:runtime??'codex',checkCommands:(providerConfig??protection)?.checkCommands??null,checkTimeoutMs:(providerConfig??protection)?.timeoutMs??60000,
|
|
123
|
+
rerunUnknownQa,rerunBlockedQa,
|
|
112
124
|
executionFor:async(definition,{parallelMember=false}={})=>{
|
|
113
125
|
const key=`${definition.feature}/${definition.identity.taskId}`;
|
|
114
126
|
const attempts=[1,2].filter(attempt=>approvals.has(`${key}:${attempt}`));
|
|
115
127
|
const memberReview=parallelMember?await memberReviewConfiguration(batch,definition,review,runtime??'codex'):review;
|
|
116
128
|
const execution=createConversationExecution(definition,argv[4],parallelMember?memberBridge:bridge,memberReview,attempts,workflows[key],allowQa,runtime??'codex',
|
|
117
|
-
{parallelMember,batchWorkflowsDigest:digest(bootstraps?{workflows,bootstraps}:workflows),qaLogHome:path.join(batch.specsDir,'.reviews','host-log-mirror'),
|
|
129
|
+
{parallelMember,...(verificationPrecheck?{verificationPrecheck:true}:{}),batchWorkflowsDigest:digest(bootstraps?{workflows,bootstraps}:workflows),qaLogHome:path.join(batch.specsDir,'.reviews','host-log-mirror'),
|
|
118
130
|
// A protected CLI config also protects unauthorized tasks: they stay on the
|
|
119
131
|
// current-session transport but with the same sandbox checks (protected-text edits).
|
|
120
132
|
...(protection?{protection}:providerConfig?{protection:{checkCommands:providerConfig.checkCommands,timeoutMs:providerConfig.timeoutMs}}:{}),
|
|
@@ -5,6 +5,7 @@ import path from 'node:path';
|
|
|
5
5
|
import {spawnSync} from 'node:child_process';
|
|
6
6
|
import {fileURLToPath} from 'node:url';
|
|
7
7
|
import {openControlRun,validateRunDefinition} from './cm-ai-run.mjs';
|
|
8
|
+
import {developmentRetryable} from '../runtime/js/cm-ai/cm-ai-conversation-entry.mjs';
|
|
8
9
|
import {digest,json,shape,need,id,hex} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
9
10
|
import {scanRows,findCmAiQaDecision,latestCmAiQaRun} from '../runtime/js/cm-ai/cm-ai-qa-log.mjs';
|
|
10
11
|
import {checkParallelWrite} from './cm-task-gate.mjs';
|
|
@@ -14,7 +15,8 @@ import {inspectRunClosure} from './cm-log-event.mjs';
|
|
|
14
15
|
|
|
15
16
|
const writer=fileURLToPath(new URL('./cm-log-event.py',import.meta.url));
|
|
16
17
|
const key=task=>`${task.feature}/${task.taskId}`;
|
|
17
|
-
export function createCmAiBatch({configuration,executionFor,logHome,runtime='codex',checkCommands=null,checkTimeoutMs=60000
|
|
18
|
+
export function createCmAiBatch({configuration,executionFor,logHome,runtime='codex',checkCommands=null,checkTimeoutMs=60000,
|
|
19
|
+
rerunUnknownQa=false,rerunBlockedQa=false}){
|
|
18
20
|
const config=json(configuration);
|
|
19
21
|
shape(config,['version','repositoryId','batchId','specsDir','codeProject','tasks',...['codeProjects','parallel'].filter(name=>Object.hasOwn(config,name))]);
|
|
20
22
|
need(config.version===1);id(config.repositoryId);id(config.batchId);need(config.batchId.length>=8);
|
|
@@ -83,8 +85,14 @@ export function createCmAiBatch({configuration,executionFor,logHome,runtime='cod
|
|
|
83
85
|
}
|
|
84
86
|
async function open(taskKey){
|
|
85
87
|
const definition=plans.get(taskKey),state=path.join(config.specsDir,'.reviews','.execution',definition.identity.runId,'state.json');
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
const mode=fs.existsSync(state)?'resume':'create',execution=await executionForKey(taskKey);
|
|
89
|
+
// QA recovery is rejected outright for a created run or one without a QA
|
|
90
|
+
// executor. Passing it to every task would take down the unrelated ones, so
|
|
91
|
+
// only the tasks the flag can legally apply to receive it.
|
|
92
|
+
const recovery=mode==='resume'&&execution?.qaExecutor&&(rerunUnknownQa||rerunBlockedQa)
|
|
93
|
+
? {rerunUnknownQa,rerunBlockedQa} : {};
|
|
94
|
+
return openControlRun(definition,mode,execution,{...recovery,
|
|
95
|
+
...(membership.has(taskKey)?{parallelSelection:{version:1,group:membership.get(taskKey).map(key=>plans.get(key).identity.taskId)}}:{})});
|
|
88
96
|
}
|
|
89
97
|
function parallelProgress(rows){
|
|
90
98
|
const done=new Set(),ready=new Map(),merging=new Map(),blocked=new Map();let stopped=false,code=null;
|
|
@@ -188,7 +196,7 @@ export function createCmAiBatch({configuration,executionFor,logHome,runtime='cod
|
|
|
188
196
|
};
|
|
189
197
|
for(let round=status.identity.attempt;round<=2;round++){
|
|
190
198
|
if(status.code===null&&['ready','changes_requested'].includes(status.state)
|
|
191
|
-
||status
|
|
199
|
+
||developmentRetryable(status))await call('start');
|
|
192
200
|
if(['reported','advanced'].includes(status.outcome)&&(status.code===null&&status.state==='awaiting_review'
|
|
193
201
|
||status.state==='pending_review'&&status.code==='review_transport_timeout'))await call('decision');
|
|
194
202
|
if(status.outcome==='advanced'&&status.code===null&&status.state==='changes_requested'&&status.identity.attempt===round+1)continue;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
|
|
4
|
+
import {executionDiagnostic,failureCode,reportExecutionCollapse} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
5
|
+
|
|
6
|
+
const collapse=error=>{let out='';reportExecutionCollapse(error,value=>{out+=value;});return out;};
|
|
7
|
+
const named=(message,fields)=>Object.assign(new Error(message),fields);
|
|
8
|
+
|
|
9
|
+
test('a filesystem collapse names the syscall and both paths', () => {
|
|
10
|
+
const line=collapse(named('EEXIST: file already exists, link a -> b',
|
|
11
|
+
{code:'EEXIST',syscall:'link',path:'/specs/.reviews/.cm-initial-handoff-1',dest:'/specs/.reviews/x-a1-handoff.json'}));
|
|
12
|
+
assert.equal(line.endsWith('\n'),true);
|
|
13
|
+
assert.deepEqual(JSON.parse(line),{diagnostic:'execution_error',code:'EEXIST',syscall:'link',
|
|
14
|
+
path:'/specs/.reviews/.cm-initial-handoff-1',dest:'/specs/.reviews/x-a1-handoff.json'});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('an internal contract collapse carries its code alone', () => {
|
|
18
|
+
assert.deepEqual(JSON.parse(collapse(named('store_missing',{code:'store_missing'}))),
|
|
19
|
+
{diagnostic:'execution_error',code:'store_missing'});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('the raw message is never emitted', () => {
|
|
23
|
+
const line=collapse(named('secret token sk-live-0123456789 leaked from provider output',{code:'EPERM'}));
|
|
24
|
+
assert.equal(line.includes('sk-live'),false);
|
|
25
|
+
assert.equal(line.includes('secret'),false);
|
|
26
|
+
assert.deepEqual(JSON.parse(line),{diagnostic:'execution_error',code:'EPERM'});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('fields that are absent, oversized or control-bearing are dropped', () => {
|
|
30
|
+
assert.equal(executionDiagnostic(named('x',{code:'EBADF',path:'a'.repeat(1025)})).path,undefined);
|
|
31
|
+
assert.equal(executionDiagnostic(named('x',{code:'EBADF',syscall:`open${String.fromCharCode(0)}rm`})).syscall,undefined);
|
|
32
|
+
assert.equal(executionDiagnostic(named('x',{code:'EBADF',dest:''})).dest,undefined);
|
|
33
|
+
assert.deepEqual(executionDiagnostic(named('x',{code:'EBADF'})),{code:'EBADF'});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('an error with no usable field still produces a line', () => {
|
|
37
|
+
assert.deepEqual(JSON.parse(collapse(new Error('no code at all'))),
|
|
38
|
+
{diagnostic:'execution_error',detail:'unavailable'});
|
|
39
|
+
assert.equal(executionDiagnostic(new Error('no code at all')),null);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('an allowlisted code returns unchanged and emits nothing', () => {
|
|
43
|
+
let emitted=false;
|
|
44
|
+
const original=process.stderr.write;
|
|
45
|
+
process.stderr.write=(...args)=>{emitted=true;return original.apply(process.stderr,args);};
|
|
46
|
+
try{assert.equal(failureCode(named('invalid_input',{code:'invalid_input'})),'invalid_input');}
|
|
47
|
+
finally{process.stderr.write=original;}
|
|
48
|
+
assert.equal(emitted,false);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('an unlisted code collapses and emits exactly one line', () => {
|
|
52
|
+
const lines=[];
|
|
53
|
+
const original=process.stderr.write;
|
|
54
|
+
process.stderr.write=value=>{lines.push(String(value));return true;};
|
|
55
|
+
try{assert.equal(failureCode(named('EEXIST: x',{code:'EEXIST',syscall:'link'})),'execution_error');}
|
|
56
|
+
finally{process.stderr.write=original;}
|
|
57
|
+
assert.equal(lines.length,1);
|
|
58
|
+
assert.deepEqual(JSON.parse(lines[0]),{diagnostic:'execution_error',code:'EEXIST',syscall:'link'});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('an error whose code cannot be read still collapses without throwing', () => {
|
|
62
|
+
const hostile={};
|
|
63
|
+
Object.defineProperty(hostile,'code',{get(){throw new Error('trap');}});
|
|
64
|
+
const original=process.stderr.write;
|
|
65
|
+
process.stderr.write=()=>true;
|
|
66
|
+
try{assert.equal(failureCode(hostile),'execution_error');}
|
|
67
|
+
finally{process.stderr.write=original;}
|
|
68
|
+
});
|
package/scripts/cm-ai-host.mjs
CHANGED
|
@@ -29,17 +29,22 @@ const fixLocalPermissions=new Map(['red-test','baseline','regression','learning-
|
|
|
29
29
|
'test-author','repair','cause-review','final-review']
|
|
30
30
|
.map(name=>[`--allow-qa-fix-${name}`,`--allow-${name}`]));
|
|
31
31
|
|
|
32
|
-
const usage='cm-ai-host.mjs serve --config RUN_DEFINITION.json --mode create|resume --host-context ID --allow-development [--runtime codex|claude] [--failover] [--review-config PATH] [--allow-review-attempt 1|2] [--workflow-config PATH] [--allow-qa] [--browser-qa available|unavailable]\ncm-ai-host.mjs preflight --config RUN_DEFINITION.json --review-model MODEL [--runtime codex|claude] (synthetic loopback only)';
|
|
32
|
+
const usage='cm-ai-host.mjs serve --config RUN_DEFINITION.json --mode create|resume --host-context ID --allow-development [--runtime codex|claude] [--failover] [--review-config PATH] [--allow-review-attempt 1|2] [--workflow-config PATH] [--allow-qa] [--browser-qa available|unavailable]\nReview config is {model,preflight[,disabledSkills][,timeoutMs]}; timeoutMs is the reviewer transport budget in milliseconds (integer 1-3600000, default 60000), independent of protected mode and outside the authorized configuration digest.\ncm-ai-host.mjs preflight --config RUN_DEFINITION.json --review-model MODEL [--runtime codex|claude] (synthetic loopback only)';
|
|
33
33
|
|
|
34
34
|
function reviewConfiguration(file){
|
|
35
35
|
const info=fs.lstatSync(file);
|
|
36
36
|
need(info.isFile()&&!info.isSymbolicLink()&&info.size<=64*1024,'invalid_review_config');
|
|
37
37
|
const config=json(JSON.parse(fs.readFileSync(file,'utf8')));
|
|
38
|
-
shape(config,['model','preflight',...(Object.hasOwn(config,'disabledSkills')?['disabledSkills']:[])
|
|
38
|
+
shape(config,['model','preflight',...(Object.hasOwn(config,'disabledSkills')?['disabledSkills']:[]),
|
|
39
|
+
...(Object.hasOwn(config,'timeoutMs')?['timeoutMs']:[])]);
|
|
39
40
|
need(typeof config.model==='string'&&/^[a-zA-Z0-9._-]+$/.test(config.model),'invalid_review_config');
|
|
40
41
|
const disabledSkills=config.disabledSkills??[];
|
|
41
42
|
need(Array.isArray(disabledSkills)&&disabledSkills.length<=4096
|
|
42
43
|
&&disabledSkills.every(item=>typeof item==='string'&&path.isAbsolute(item)&&!/[\n\r\0]/.test(item)),'invalid_review_config');
|
|
44
|
+
// Reviewer transport budget only. It is not part of the authorized configuration
|
|
45
|
+
// digest, so a resumed run may raise it after a transport timeout.
|
|
46
|
+
if(Object.hasOwn(config,'timeoutMs'))need(Number.isInteger(config.timeoutMs)
|
|
47
|
+
&&config.timeoutMs>=1&&config.timeoutMs<=3600000,'invalid_review_config');
|
|
43
48
|
return json({...config,disabledSkills});
|
|
44
49
|
}
|
|
45
50
|
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import test from 'node:test';
|
|
6
|
+
import {spawnSync} from 'node:child_process';
|
|
7
|
+
import {fileURLToPath} from 'node:url';
|
|
8
|
+
|
|
9
|
+
import {validateHostWorkflowConfiguration} from '../runtime/js/cm-ai/host-workflow-capabilities.mjs';
|
|
10
|
+
|
|
11
|
+
const cli=fileURLToPath(new URL('./cm-ai-batch-host.mjs',import.meta.url));
|
|
12
|
+
|
|
13
|
+
const qa=timeoutMs=>({commands:[{id:'unit',command:['npm','test'],caseIds:[]}],
|
|
14
|
+
environment:{kind:'web',carrier:'browser',target:'fixture-command-only',scope:'local'},
|
|
15
|
+
...(timeoutMs===undefined?{}:{timeoutMs})});
|
|
16
|
+
const workflow=timeoutMs=>({qa:qa(timeoutMs),documentationPaths:[],applicableAgentFiles:[]});
|
|
17
|
+
|
|
18
|
+
test('a QA budget beyond one minute is accepted up to the shared call-timeout range', () => {
|
|
19
|
+
// A real browser walkthrough of one blocking case runs for minutes; the old
|
|
20
|
+
// 60000 cap made every such case time out with no way to raise it.
|
|
21
|
+
for(const timeoutMs of [1,60000,900000,3600000]){
|
|
22
|
+
assert.equal(validateHostWorkflowConfiguration(workflow(timeoutMs)).qa.timeoutMs,timeoutMs);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('a QA budget outside that range is still rejected', () => {
|
|
27
|
+
for(const timeoutMs of [0,-1,3600001,1.5,'900000',null]){
|
|
28
|
+
assert.throws(()=>validateHostWorkflowConfiguration(workflow(timeoutMs)),
|
|
29
|
+
error=>error.code==='invalid_workflow_config',`expected rejection for ${String(timeoutMs)}`);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('omitting the budget stays valid and plants no key', () => {
|
|
34
|
+
const config=validateHostWorkflowConfiguration(workflow(undefined));
|
|
35
|
+
assert.equal(Object.hasOwn(config.qa,'timeoutMs'),false);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
function batchFixture(fn){
|
|
39
|
+
const temp=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-qa-recovery-')));
|
|
40
|
+
const specs=path.join(temp,'specs'),code=path.join(temp,'code');
|
|
41
|
+
fs.mkdirSync(path.join(specs,'.reviews'),{recursive:true});fs.mkdirSync(code,{recursive:true});
|
|
42
|
+
const config=path.join(temp,'batch.json');
|
|
43
|
+
fs.writeFileSync(config,JSON.stringify({batch:{version:1,repositoryId:'fixture',batchId:'recovery-fixture',
|
|
44
|
+
specsDir:specs,codeProject:code,tasks:[{feature:'9.demo',taskId:'T-001',scope:['a.mjs'],requirements:[]}]},
|
|
45
|
+
workflows:{'9.demo/T-001':workflow(900000)}}));
|
|
46
|
+
const run=args=>spawnSync(process.execPath,[cli,'serve','--config',config,'--host-context','author',
|
|
47
|
+
'--allow-development',...args],{encoding:'utf8',timeout:15000,input:''});
|
|
48
|
+
try{fn(run);}finally{fs.rmSync(temp,{recursive:true,force:true});}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
test('the two QA recovery flags are mutually exclusive', () => batchFixture(run => {
|
|
52
|
+
const result=run(['--allow-qa','--rerun-unknown-qa','--rerun-blocked-qa']);
|
|
53
|
+
assert.equal(result.status,1);
|
|
54
|
+
assert.match(result.stderr,/qa_recovery_authorization_required/);
|
|
55
|
+
}));
|
|
56
|
+
|
|
57
|
+
test('a QA recovery flag without --allow-qa is refused', () => batchFixture(run => {
|
|
58
|
+
const result=run(['--rerun-blocked-qa']);
|
|
59
|
+
assert.equal(result.status,1);
|
|
60
|
+
assert.match(result.stderr,/qa_recovery_authorization_required/);
|
|
61
|
+
}));
|
|
62
|
+
|
|
63
|
+
test('the same flag twice is refused', () => batchFixture(run => {
|
|
64
|
+
const result=run(['--allow-qa','--rerun-blocked-qa','--rerun-blocked-qa']);
|
|
65
|
+
assert.equal(result.status,1);
|
|
66
|
+
assert.match(result.stderr,/invalid_arguments/);
|
|
67
|
+
}));
|
|
68
|
+
|
|
69
|
+
test('a single recovery flag with --allow-qa passes the launch guards', () => batchFixture(run => {
|
|
70
|
+
// The batch has no --mode: whether the flag applies is decided per task at
|
|
71
|
+
// open time, so the launch guards must not reject it the way the single-task
|
|
72
|
+
// host does. The fixture batch is otherwise minimal and still fails later for
|
|
73
|
+
// unrelated reasons, so this asserts only that the recovery guard stayed quiet.
|
|
74
|
+
const line=result=>result.stderr.split('\n').find(item=>item.startsWith('{'))??'';
|
|
75
|
+
const withFlag=run(['--allow-qa','--rerun-blocked-qa']);
|
|
76
|
+
const without=run(['--allow-qa']);
|
|
77
|
+
assert.equal(/qa_recovery_authorization_required/.test(withFlag.stderr),false,withFlag.stderr);
|
|
78
|
+
assert.equal(line(withFlag),line(without));
|
|
79
|
+
assert.equal(withFlag.status,without.status);
|
|
80
|
+
}));
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import test from 'node:test';
|
|
6
|
+
|
|
7
|
+
import {readConversationReviewConfiguration} from './cm-ai-host.mjs';
|
|
8
|
+
import {resolveReviewTimeout} from '../runtime/js/cm-ai/host-conversation-execution.mjs';
|
|
9
|
+
|
|
10
|
+
const preflight={passed:true,provider:'claude',prompt_transport:'stdin',config_fingerprint:'x'};
|
|
11
|
+
|
|
12
|
+
function configFile(value){
|
|
13
|
+
const root=fs.mkdtempSync(path.join(os.tmpdir(),'cm-review-timeout-'));
|
|
14
|
+
const file=path.join(root,'review.json');
|
|
15
|
+
fs.writeFileSync(file,JSON.stringify(value));
|
|
16
|
+
return file;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
test('review config accepts an explicit reviewer transport budget', () => {
|
|
20
|
+
const config=readConversationReviewConfiguration(configFile({model:'fixture',preflight,timeoutMs:600000}));
|
|
21
|
+
assert.equal(config.timeoutMs,600000);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('review config stays valid without a budget', () => {
|
|
25
|
+
const config=readConversationReviewConfiguration(configFile({model:'fixture',preflight}));
|
|
26
|
+
assert.equal(Object.hasOwn(config,'timeoutMs'),false);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('review config rejects budgets outside the shared call-timeout range', () => {
|
|
30
|
+
for(const timeoutMs of [0,-1,3600001,1.5,'600000',null]){
|
|
31
|
+
assert.throws(()=>readConversationReviewConfiguration(configFile({model:'fixture',preflight,timeoutMs})),
|
|
32
|
+
error=>error.code==='invalid_review_config',`expected rejection for ${String(timeoutMs)}`);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('review config accepts both range boundaries', () => {
|
|
37
|
+
for(const timeoutMs of [1,3600000]){
|
|
38
|
+
assert.equal(readConversationReviewConfiguration(configFile({model:'fixture',preflight,timeoutMs})).timeoutMs,timeoutMs);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('an explicit reviewer budget wins over the protected-mode budget', () => {
|
|
43
|
+
assert.deepEqual(resolveReviewTimeout({timeoutMs:600000},{timeoutMs:90000}),{timeoutMs:600000});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('protected mode still supplies the budget when review config omits one', () => {
|
|
47
|
+
assert.deepEqual(resolveReviewTimeout({model:'fixture'},{timeoutMs:90000}),{timeoutMs:90000});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('no budget anywhere leaves the worker default untouched', () => {
|
|
51
|
+
assert.deepEqual(resolveReviewTimeout(null,null),{});
|
|
52
|
+
assert.deepEqual(resolveReviewTimeout({model:'fixture'},null),{});
|
|
53
|
+
});
|
package/scripts/cm-ai-run.mjs
CHANGED
|
@@ -181,7 +181,7 @@ export async function openControlRun(definition,mode,execution=null,{rerunUnknow
|
|
|
181
181
|
if(execution!==null){
|
|
182
182
|
const {shape,json,validCallTimeout}=await import('../runtime/js/cm-ai/effect-contract.mjs');
|
|
183
183
|
shape(execution,['configuration','developer','reviewers','reviewInvocation','check','hostDecision','excludedContexts','timeoutMs',
|
|
184
|
-
...['bootstrap','developmentAttempt','hostDecisionProvider','qaDecisionProvider','qaLogHome','qaExecutor','applicableAgentFiles','documentationProvider','documentationResult','documentationSync'].filter(key=>Object.hasOwn(execution,key))]);
|
|
184
|
+
...['bootstrap','developmentAttempt','hostDecisionProvider','qaDecisionProvider','qaLogHome','qaExecutor','applicableAgentFiles','documentationProvider','documentationResult','documentationSync','verificationGate'].filter(key=>Object.hasOwn(execution,key))]);
|
|
185
185
|
json(execution.configuration);validCallTimeout(execution.timeoutMs);
|
|
186
186
|
if(Object.hasOwn(execution.configuration,'codeProject'))
|
|
187
187
|
if(execution.configuration.codeProject!==definition.codeProject)fail('execution_root_mismatch');
|
|
@@ -287,6 +287,7 @@ export async function openControlRun(definition,mode,execution=null,{rerunUnknow
|
|
|
287
287
|
...(execution.bootstrap?{bootstrap:execution.bootstrap}:{}),
|
|
288
288
|
reviewInvocation:execution.reviewInvocation,check:execution.check,
|
|
289
289
|
excludedContexts:execution.excludedContexts,timeoutMs:execution.timeoutMs,
|
|
290
|
+
...(Object.hasOwn(execution,'verificationGate')?{verificationGate:execution.verificationGate}:{}),
|
|
290
291
|
taskLearning:{feature,hostHandoff:true}})},
|
|
291
292
|
entry:{specsDir,codeProject,feature,identity,rerunUnknownQa,rerunBlockedQa,...(parallelSelection===null?{}:{parallelSelection}),...(execution===null?{}:{hostDecision:execution.hostDecision,
|
|
292
293
|
...Object.fromEntries(['developmentAttempt','hostDecisionProvider','qaDecisionProvider','qaLogHome','qaExecutor','applicableAgentFiles','documentationProvider','documentationResult'].filter(key=>Object.hasOwn(execution,key)).map(key=>[key,execution[key]]))})},
|