@aibyzero/cm-workflow 0.16.8 → 0.16.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/CHANGELOG.md +19 -0
- package/README.md +14 -3
- package/VERSION +1 -1
- package/compat/claude-commands/cm-notify.md +3 -0
- package/docs/installation.md +1 -1
- package/docs/js-workflow-control.md +25 -1
- package/docs/next-steps.md +8 -2
- package/docs/user-guide.md +105 -5
- package/package.json +2 -1
- package/runtime/js/cm-ai/claude-review-stream.mjs +49 -13
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +111 -20
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +69 -22
- package/runtime/js/cm-ai/code-projects.mjs +4 -1
- package/runtime/js/cm-ai/developer-adapter.mjs +7 -0
- package/runtime/js/cm-ai/drive-core.mjs +9 -0
- package/runtime/js/cm-ai/durable-runner-state.mjs +951 -43
- package/runtime/js/cm-ai/effect-abandon-log.mjs +5 -2
- package/runtime/js/cm-ai/effect-contract.mjs +6 -1
- package/runtime/js/cm-ai/external-run-guard.mjs +18 -7
- package/runtime/js/cm-ai/host-check.mjs +4 -1
- package/runtime/js/cm-ai/host-conversation-execution.mjs +11 -4
- package/runtime/js/cm-ai/host-documentation.mjs +53 -12
- package/runtime/js/cm-ai/host-project-execution.mjs +2 -2
- package/runtime/js/cm-ai/host-qa-executor.mjs +49 -4
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +44 -9
- package/runtime/js/cm-ai/host-session.mjs +1 -1
- package/runtime/js/cm-ai/host-tool-bridge.mjs +40 -3
- package/runtime/js/cm-ai/operator-guidance.mjs +112 -3
- package/runtime/js/cm-ai/provider-review-observation.mjs +50 -0
- package/runtime/js/cm-ai/qa-resource-release.mjs +46 -0
- package/runtime/js/cm-ai/qa-round-budget.mjs +13 -0
- package/runtime/js/cm-ai/review-dispatch-limits.mjs +18 -0
- package/runtime/js/cm-ai/review-package.mjs +10 -1
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +1 -1
- package/runtime/js/cm-ai/task-commit.mjs +39 -0
- package/runtime/js/cm-ai/task-runner.mjs +636 -65
- package/runtime/js/cm-ai/worker-claude-developer.mjs +9 -0
- package/runtime/js/cm-ai/worker-claude.mjs +10 -3
- package/runtime/js/cm-ai/worker-process-identity.mjs +43 -0
- package/runtime/js/cm-fix/execution.mjs +176 -48
- package/runtime/js/cm-fix/host.mjs +2 -1
- package/runtime/js/cm-fix/pinned-baseline.mjs +24 -0
- package/runtime/js/cm-fix/progress.mjs +13 -3
- package/runtime/js/cm-fix/protected-edits.mjs +10 -3
- package/runtime/js/cm-fix/repair.mjs +11 -3
- package/runtime/js/cm-fix/test-author.mjs +10 -3
- package/runtime/js/cm-idea/session.mjs +67 -4
- package/runtime/js/cm-prd/review-correction.mjs +10 -4
- package/runtime/js/cm-prd/session.mjs +43 -0
- package/runtime/js/cm-refactor/records.mjs +98 -8
- package/runtime/js/cm-refactor/workflow.mjs +79 -9
- package/runtime/js/cm-test/host.mjs +10 -3
- package/runtime/js/cm-test/session.mjs +45 -6
- package/runtime/js/notify-safe-read.mjs +49 -0
- package/runtime/js/notify-send.mjs +312 -0
- package/runtime/js/notify.mjs +137 -33
- package/runtime/js/policy-binding-compat.mjs +54 -0
- package/scripts/ci-test-shards.mjs +67 -0
- package/scripts/ci-test-shards.test.mjs +64 -0
- package/scripts/ci-test-weights.json +222 -0
- package/scripts/cm-ai-abandon-effect-position.test.mjs +70 -2
- package/scripts/cm-ai-answer-gap-dispatch.test.mjs +86 -0
- package/scripts/cm-ai-answer-gap-driver.test.mjs +51 -0
- package/scripts/cm-ai-answer-gap-fixture.mjs +96 -0
- package/scripts/cm-ai-answer-gap-recheck.test.mjs +70 -0
- package/scripts/cm-ai-answer-gap-redo.test.mjs +103 -0
- package/scripts/cm-ai-batch-drive.mjs +55 -10
- package/scripts/cm-ai-batch-drive.test.mjs +65 -0
- package/scripts/cm-ai-batch-host.mjs +132 -13
- package/scripts/cm-ai-batch-host.test.mjs +255 -7
- package/scripts/cm-ai-batch-run-fixture.mjs +499 -0
- package/scripts/cm-ai-batch-run-member-stops.test.mjs +38 -0
- package/scripts/cm-ai-batch-run-parallel.test.mjs +7 -0
- package/scripts/cm-ai-batch-run-reschedule.test.mjs +17 -0
- package/scripts/cm-ai-batch-run.mjs +184 -22
- package/scripts/cm-ai-batch-run.test.mjs +21 -341
- package/scripts/cm-ai-develop-answer-invalid.test.mjs +104 -0
- package/scripts/cm-ai-develop-call-timeout.test.mjs +153 -0
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +4 -3
- package/scripts/cm-ai-documentation-sync-gap.test.mjs +424 -0
- package/scripts/cm-ai-drive.mjs +64 -22
- package/scripts/cm-ai-drive.test.mjs +29 -2
- package/scripts/cm-ai-host-cli-workflow.test.mjs +271 -0
- package/scripts/cm-ai-host-fixture.mjs +268 -0
- package/scripts/cm-ai-host-protected.test.mjs +251 -0
- package/scripts/cm-ai-host.mjs +27 -15
- package/scripts/cm-ai-host.test.mjs +17 -759
- package/scripts/cm-ai-light-modules.test.mjs +57 -0
- package/scripts/cm-ai-operator-guidance.test.mjs +30 -5
- package/scripts/cm-ai-protected-scope.test.mjs +7 -3
- package/scripts/cm-ai-qa-answer-gaps.test.mjs +99 -0
- package/scripts/cm-ai-qa-fix-cross-session.test.mjs +78 -11
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +56 -10
- package/scripts/cm-ai-review-dispatch-exit.test.mjs +475 -0
- package/scripts/cm-ai-review-failure.test.mjs +124 -13
- package/scripts/cm-ai-review-timeout.test.mjs +188 -10
- package/scripts/cm-ai-run.mjs +15 -6
- package/scripts/cm-ai-supersede.test.mjs +486 -41
- package/scripts/cm-check-drive-files.mjs +8 -0
- package/scripts/cm-check-drive.test.mjs +2 -5
- package/scripts/cm-check-runtime.sh +4 -2
- package/scripts/cm-claude-developer-worker.test.mjs +15 -0
- package/scripts/cm-claude-review-stream.test.mjs +21 -16
- package/scripts/cm-claude-review-synthetic.test.mjs +155 -0
- package/scripts/cm-claude-worker.test.mjs +18 -2
- package/scripts/cm-external-model-recovery.test.mjs +29 -3
- package/scripts/cm-fix-abandon.test.mjs +163 -10
- package/scripts/cm-fix-drive-unprotected.test.mjs +37 -0
- package/scripts/cm-fix-drive.mjs +25 -7
- package/scripts/cm-fix-host.mjs +8 -7
- package/scripts/cm-fix-review-budget.test.mjs +13 -0
- package/scripts/cm-fix-review-recovery.test.mjs +35 -0
- package/scripts/cm-host-answer-timeout.test.mjs +65 -0
- package/scripts/cm-host-call-kinds.test.mjs +28 -0
- package/scripts/cm-host-documentation.test.mjs +49 -0
- package/scripts/cm-host-qa-executor.test.mjs +22 -10
- package/scripts/cm-idea-answer-gaps.test.mjs +164 -0
- package/scripts/cm-idea-drive.mjs +49 -11
- package/scripts/cm-idea-drive.test.mjs +66 -0
- package/scripts/cm-idea-host.mjs +106 -16
- package/scripts/cm-init-answer-gaps.test.mjs +258 -0
- package/scripts/cm-init-drive.mjs +41 -7
- package/scripts/cm-init-host.mjs +61 -12
- package/scripts/cm-log-event.mjs +21 -10
- package/scripts/cm-notify-command.test.mjs +900 -0
- package/scripts/cm-notify-read-drift.test.mjs +205 -0
- package/scripts/cm-notify.mjs +469 -0
- package/scripts/cm-notify.test.mjs +221 -4
- package/scripts/cm-prd-answer-gaps.test.mjs +216 -0
- package/scripts/cm-prd-drive.mjs +18 -5
- package/scripts/cm-prd-drive.test.mjs +15 -0
- package/scripts/cm-prd-host.mjs +37 -4
- package/scripts/cm-prd-review-disposition.test.mjs +6 -1
- package/scripts/cm-prd-review-gate.mjs +56 -0
- package/scripts/cm-refactor-answer-gaps.test.mjs +206 -0
- package/scripts/cm-refactor-drive.mjs +52 -8
- package/scripts/cm-refactor-drive.test.mjs +44 -0
- package/scripts/cm-refactor-host.test.mjs +10 -6
- package/scripts/cm-release-smoke.sh +2 -0
- package/scripts/cm-test-answer-gaps.test.mjs +151 -0
- package/scripts/cm-test-drive.mjs +21 -5
- package/scripts/fixtures/claude-review-process.mjs +1 -1
- package/scripts/policy-binding-compat.test.mjs +99 -0
- package/scripts/scan-public-safety.py +4 -0
- package/scripts/validate-public-repo.py +4 -0
- package/skills/cm-ai/references/js-host-qa-recovery.md +27 -1
- package/skills/cm-ai/references/js-host-recovery.md +120 -8
- package/skills/cm-ai/references/js-host.md +14 -7
- package/skills/cm-check/SKILL.md +3 -3
- package/skills/cm-fix/references/js-host.md +44 -5
- package/skills/cm-idea/references/js-host.md +27 -2
- package/skills/cm-init/references/js-host.md +16 -3
- package/skills/cm-notify/SKILL.md +34 -0
- package/skills/cm-prd/references/js-change-recovery.md +35 -1
- package/skills/cm-refactor/references/js-host.md +17 -0
- package/skills/cm-test/references/js-host.md +14 -1
|
@@ -26,7 +26,7 @@ after(()=>{
|
|
|
26
26
|
const diagnosis={status:'diagnosed',rootCause:'Wrong value',affectedPaths:['value.mjs'],
|
|
27
27
|
affectedModules:['value'],plan:'Correct value',crossLayer:false};
|
|
28
28
|
|
|
29
|
-
async function fixture(t,{observation=false,reviewMode=null,crossLayer=false,lesson=false}={}){
|
|
29
|
+
async function fixture(t,{observation=false,reviewMode=null,crossLayer=false,lesson=false,repairContent=null}={}){
|
|
30
30
|
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'fix-abandon-')));
|
|
31
31
|
t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
|
|
32
32
|
const cwd=path.join(root,'code'),specsRoot=path.join(root,'specs');
|
|
@@ -52,13 +52,15 @@ async function fixture(t,{observation=false,reviewMode=null,crossLayer=false,les
|
|
|
52
52
|
const data=JSON.parse(prompt.split('<cm-review-data-json>\n')[1]);
|
|
53
53
|
onEvent({event:'thread.started',provider_thread:`fixture-review-${reviewMode==='first_lost_same_thread'?1:reviews}`});
|
|
54
54
|
if(reviewMode==='lost'||['second_lost','second_lost_retry'].includes(reviewMode)&&reviews===2
|
|
55
|
+
||reviewMode==='second_lost_twice'&&[2,3].includes(reviews)
|
|
55
56
|
||['first_lost','first_lost_same_thread'].includes(reviewMode)&&reviews===1
|
|
56
|
-
||['rediagnosis_lost','rediagnosis_twice','rediagnosis_context'].includes(reviewMode)
|
|
57
|
+
||['rediagnosis_lost','rediagnosis_twice','rediagnosis_thrice','rediagnosis_context'].includes(reviewMode)
|
|
58
|
+
&&(reviews===2||['rediagnosis_twice','rediagnosis_thrice'].includes(reviewMode)&&reviews===3||reviewMode==='rediagnosis_thrice'&&reviews===4))
|
|
57
59
|
throw Error('Synthetic lost review result');
|
|
58
60
|
for(const event of [{event:'turn.started',item_type:null},{event:'item.completed',item_type:'agent_message'},
|
|
59
61
|
{event:'turn.completed',item_type:null},{event:'process_closed',exit_code:0,signal:null,timed_out:false}])onEvent(event);
|
|
60
62
|
const outsidePath=reviewMode==='rediagnosis_invalid'&&reviews===2;
|
|
61
|
-
const verdict=['changes_requested','second_lost'].includes(reviewMode)||
|
|
63
|
+
const verdict=['changes_requested','second_lost'].includes(reviewMode)||['second_lost_retry','second_lost_twice'].includes(reviewMode)&&reviews===1
|
|
62
64
|
||reviewMode?.startsWith('rediagnosis_')&&reviews===1||outsidePath?'changes_requested':'approved';
|
|
63
65
|
return {status:'succeeded',value:{verdict,packageDigest:data.reviewPackage.packageDigest,
|
|
64
66
|
examinedPaths:data.examinedPaths,
|
|
@@ -77,10 +79,10 @@ async function fixture(t,{observation=false,reviewMode=null,crossLayer=false,les
|
|
|
77
79
|
return crossLayer?{...diagnosis,crossLayer:true}:diagnosis;
|
|
78
80
|
}
|
|
79
81
|
if(kind==='fix_repair'){
|
|
80
|
-
if(['changes_requested','second_lost','second_lost_retry'].includes(reviewMode)&&payload.identity.attempt===2&&loseRevisionRepair){
|
|
82
|
+
if(['changes_requested','second_lost','second_lost_retry','second_lost_twice'].includes(reviewMode)&&payload.identity.attempt===2&&loseRevisionRepair){
|
|
81
83
|
loseRevisionRepair=false;throw Error('Lost revision repair answer');
|
|
82
84
|
}
|
|
83
|
-
fs.writeFileSync(path.join(cwd,'value.mjs'),payload.identity.attempt===2?'export const value=2; // revised\n':'export const value=2;\n');
|
|
85
|
+
fs.writeFileSync(path.join(cwd,'value.mjs'),repairContent??(payload.identity.attempt===2?'export const value=2; // revised\n':'export const value=2;\n'));
|
|
84
86
|
return {outcome:'repaired'};
|
|
85
87
|
}
|
|
86
88
|
if(kind==='fix_retrospective')return (lesson===true||lesson==='revision'&&payload.identity.attempt===2)?{status:'lesson_candidate',candidates:[{classification:'memory_only',
|
|
@@ -103,7 +105,9 @@ async function fixture(t,{observation=false,reviewMode=null,crossLayer=false,les
|
|
|
103
105
|
owner=openFixExecution({...options,create:false},dependencies);
|
|
104
106
|
};
|
|
105
107
|
const reopen=()=>{owner.close();owner=openFixExecution({...options,create:false},dependencies);return owner;};
|
|
106
|
-
|
|
108
|
+
// After a refused append left no open owner: restore the saved bytes and reopen.
|
|
109
|
+
const restore=bytes=>{owner?.close();fs.writeFileSync(statePath,bytes);owner=openFixExecution({...options,create:false},dependencies);return owner;};
|
|
110
|
+
return {cwd,specsRoot,identity,configuration,options,statePath,records,append,reopen,restore,owner:()=>owner,reviewHost,reviews:()=>reviews};
|
|
107
111
|
}
|
|
108
112
|
|
|
109
113
|
test('an unknown red test needs explicit authorization and reason, then redoes with distinct records and evidence',async t=>{
|
|
@@ -435,16 +439,25 @@ test('#15 a no-result cause review is abandoned once, audited, and retried on a
|
|
|
435
439
|
assert.equal(f.owner().status().causeReview.providerThreadId,'fixture-review-2');
|
|
436
440
|
});
|
|
437
441
|
|
|
438
|
-
test('#15 a
|
|
442
|
+
test('#15 a third no-result cause review exhausts the round\'s two abandonments without changing the store',async t=>{
|
|
439
443
|
const f=await fixture(t,{reviewMode:'lost',crossLayer:true});
|
|
440
444
|
await f.owner().advance({authorized:true});await causeDecide(f);
|
|
441
445
|
assert.equal((await f.owner().reviewCause()).stage,'unknown');
|
|
442
446
|
f.owner().abandonReview({authorized:true,reason:'First reviewer stopped'});
|
|
443
447
|
await causeDecide(f);
|
|
448
|
+
// V5: the round keeps a second abandonment, redispatched under fix-cause-retry-2-*.
|
|
449
|
+
const second=await f.owner().reviewCause();
|
|
450
|
+
assert.equal(second.stage,'unknown');assert.equal(second.reviewAbandonable,'cause_review');
|
|
451
|
+
const abandoned=f.owner().abandonReview({authorized:true,reason:'Second reviewer stopped'});
|
|
452
|
+
assert.equal(abandoned.stage,'cause_review_required');assert.equal(abandoned.causeReviewAbandonment2.providerThreadId,'fixture-review-2');
|
|
453
|
+
assert.deepEqual(f.records().filter(row=>/^fix-cause-abandoned/.test(row.id)).map(row=>row.id),['fix-cause-abandoned','fix-cause-abandoned-2']);
|
|
454
|
+
await causeDecide(f);
|
|
444
455
|
const again=await f.owner().reviewCause();
|
|
456
|
+
assert(f.records().some(row=>row.id==='fix-cause-retry-2-registered'));
|
|
445
457
|
assert.equal(again.stage,'unknown');assert.equal(again.reviewAbandonBudgetExhausted,true);assert.equal(again.reviewAbandonable,undefined);
|
|
446
458
|
const before=fs.readFileSync(f.statePath);
|
|
447
|
-
assert.throws(()=>f.owner().abandonReview({authorized:true,reason:'
|
|
459
|
+
assert.throws(()=>f.owner().abandonReview({authorized:true,reason:'Third reviewer stopped'}),{code:'fix_review_abandon_budget_exhausted'});
|
|
460
|
+
assert.equal(f.reopen().status().reviewAbandonBudgetExhausted,true);
|
|
448
461
|
assert.deepEqual(fs.readFileSync(f.statePath),before);
|
|
449
462
|
});
|
|
450
463
|
|
|
@@ -496,6 +509,46 @@ test('#15 a no-result second-round final review is abandoned once and retried on
|
|
|
496
509
|
assert.equal(f.reopen().status().stage,'revision_completion_gate_required');
|
|
497
510
|
});
|
|
498
511
|
|
|
512
|
+
// V5 (F26): the second-round final review keeps two no-result abandonments;
|
|
513
|
+
// the second cycle runs under fix-revision-final-retry-2-* on a third thread.
|
|
514
|
+
test('V5 a twice-lost second-round final review is abandoned twice and retried on fresh threads',async t=>{
|
|
515
|
+
const f=await fixture(t,{reviewMode:'second_lost_twice'});
|
|
516
|
+
await toRevision(f);await completeRevisionRepair(f);
|
|
517
|
+
await f.owner().runRegression({authorized:true});await f.owner().retrospect();
|
|
518
|
+
assert.equal(f.owner().createHandoff().stage,'revision_final_review_required');
|
|
519
|
+
const decide=async()=>{const pkg=f.owner().finalReviewPackage();
|
|
520
|
+
await f.reviewHost.finalAuthority.hostDecisionProvider.decide({identity:f.owner().status().revision.nextIdentity,
|
|
521
|
+
packageDigest:pkg.packageDigest},new AbortController().signal);};
|
|
522
|
+
let beforeSecond=null,afterSecond=null;
|
|
523
|
+
for(const reason of ['First stopped','Second stopped']){
|
|
524
|
+
await decide();
|
|
525
|
+
const lost=await f.owner().reviewFinal();
|
|
526
|
+
assert.equal(lost.stage,'unknown');assert.equal(lost.reviewAbandonable,'revision_final_review');
|
|
527
|
+
if(reason==='Second stopped')beforeSecond=fs.readFileSync(f.statePath);
|
|
528
|
+
assert.equal(f.owner().abandonReview({authorized:true,reason}).stage,'revision_final_review_required');
|
|
529
|
+
}
|
|
530
|
+
afterSecond=fs.readFileSync(f.statePath);
|
|
531
|
+
// Replay refuses a second abandonment bound to the first cycle, and a duplicate one.
|
|
532
|
+
const second=f.records().find(row=>row.id==='fix-revision-final-abandoned-2').payload;
|
|
533
|
+
f.restore(beforeSecond);
|
|
534
|
+
const firstRegistration=f.records().find(row=>row.id==='fix-revision-final-registered').payload;
|
|
535
|
+
assert.throws(()=>f.append('fix-revision-final-abandoned-2','result',{...second,registrationDigest:digest(firstRegistration),
|
|
536
|
+
invocationId:firstRegistration.request.invocationId}),{code:'fix_review_abandon_mismatch'});
|
|
537
|
+
f.restore(afterSecond);
|
|
538
|
+
assert.throws(()=>f.append('fix-revision-final-abandoned-2','result',{...second,reason:'Again'}));
|
|
539
|
+
assert.equal(f.records().filter(row=>row.id==='fix-revision-final-abandoned-2').length,1);
|
|
540
|
+
f.restore(afterSecond);
|
|
541
|
+
assert.equal(f.reopen().status().revisionFinalReviewAbandonment2.providerThreadId,'fixture-review-3');
|
|
542
|
+
await decide();
|
|
543
|
+
assert.equal((await f.owner().reviewFinal()).stage,'revision_final_review_evidence_required');
|
|
544
|
+
const records=f.records(),ids=records.map(row=>row.id).filter(id=>id.startsWith('fix-revision-final'));
|
|
545
|
+
assert.deepEqual(ids,['fix-revision-final-registered','fix-revision-final-started','fix-revision-final-abandoned',
|
|
546
|
+
'fix-revision-final-retry-registered','fix-revision-final-retry-started','fix-revision-final-abandoned-2',
|
|
547
|
+
'fix-revision-final-retry-2-registered','fix-revision-final-retry-2-started','fix-revision-final-retry-2-result']);
|
|
548
|
+
assert.equal(f.owner().publishReview().stage,'revision_completion_gate_required');
|
|
549
|
+
assert.equal(f.reopen().status().stage,'revision_completion_gate_required');
|
|
550
|
+
});
|
|
551
|
+
|
|
499
552
|
test('#15 the retried cause review refuses the abandoned reviewer thread',async t=>{
|
|
500
553
|
const f=await fixture(t,{reviewMode:'first_lost_same_thread',crossLayer:true});
|
|
501
554
|
await f.owner().advance({authorized:true});await causeDecide(f);await f.owner().reviewCause();
|
|
@@ -554,12 +607,16 @@ test(`regression: a no-result round-2 cause review (${reviewMode}) is abandoned
|
|
|
554
607
|
assert.equal(reopened.stage,'red_test_required');assert.equal(reopened.causeReview.providerThreadId,'fixture-review-3');
|
|
555
608
|
});
|
|
556
609
|
|
|
557
|
-
test('regression: a
|
|
558
|
-
const f=await fixture(t,{reviewMode:'
|
|
610
|
+
test('regression: a third no-result round-2 cause review exhausts that round\'s two abandonments without changing the store',async t=>{
|
|
611
|
+
const f=await fixture(t,{reviewMode:'rediagnosis_thrice',crossLayer:true});
|
|
559
612
|
await toRediagnosisReview(f);
|
|
560
613
|
const host=()=>hostFor(f,['--allow-reproduction','--allow-abandon-review']);
|
|
561
614
|
assert.equal((await host().handle({requestId:'a',operation:'abandon_review',reason:'First round-2 reviewer stopped'})).stage,'cause_review_required');
|
|
562
615
|
await causeDecide(f);
|
|
616
|
+
assert.equal((await f.owner().reviewCause()).reviewAbandonable,'cause_review');
|
|
617
|
+
assert.equal((await host().handle({requestId:'a2',operation:'abandon_review',reason:'Second round-2 reviewer stopped'})).stage,'cause_review_required');
|
|
618
|
+
assert(f.records().some(row=>row.id==='fix-cause-rediagnosis-abandoned-2'));
|
|
619
|
+
await causeDecide(f);
|
|
563
620
|
const again=await f.owner().reviewCause();
|
|
564
621
|
assert.equal(again.stage,'unknown');assert.equal(again.reviewAbandonBudgetExhausted,true);assert.equal(again.reviewAbandonable,undefined);
|
|
565
622
|
const before=fs.readFileSync(f.statePath);
|
|
@@ -585,3 +642,99 @@ test('regression: the round-2 cause package carries the prior review\'s examined
|
|
|
585
642
|
assert.equal(review.verdict,'approved');assert.deepEqual(review.findings.map(row=>row.path),['existing.mjs']);
|
|
586
643
|
assert.equal(f.owner().status().stage,'red_test_required');
|
|
587
644
|
});
|
|
645
|
+
|
|
646
|
+
// V2 (F14): a repair abandoned after it left residue is redone on the baseline
|
|
647
|
+
// its first intent pinned. The residue is reviewed, not absorbed, and an
|
|
648
|
+
// approved cause review does not turn it into cause_review_drift.
|
|
649
|
+
test('abandoned repair with residue keeps its pinned baseline and stays out of cause_review_drift',async t=>{
|
|
650
|
+
const f=await fixture(t,{reviewMode:'approved_pinned',crossLayer:true});
|
|
651
|
+
assert.equal((await f.owner().advance({authorized:true})).stage,'cause_review_required');
|
|
652
|
+
await causeDecide(f);await f.owner().reviewCause();
|
|
653
|
+
if(f.owner().status().stage==='cause_review_evidence_required')await f.owner().reviewCause();
|
|
654
|
+
await f.owner().runRedTest({authorized:true});
|
|
655
|
+
assert.equal((await f.owner().captureBaseline({authorized:true})).stage,'repair_required');
|
|
656
|
+
const atRepair=f.owner().status();
|
|
657
|
+
const baseline=captureReviewBaseline({root:f.cwd,specsRoot:f.specsRoot,identity:f.identity,
|
|
658
|
+
scope:f.configuration.repair.scope,requirements:f.configuration.repair.requirements});
|
|
659
|
+
f.append('fix-repair-intent','intent',{baseline,redDigest:digest(atRepair.redTest),testBaselineDigest:digest(atRepair.baseline)});
|
|
660
|
+
// The lost attempt wrote half a repair before the host lost its answer.
|
|
661
|
+
fs.writeFileSync(path.join(f.cwd,'value.mjs'),'export const value=7; // half\n');
|
|
662
|
+
const abandoned=f.owner().abandonStep({authorized:true,reason:'Repair answer lost after a partial write'});
|
|
663
|
+
assert.equal(abandoned.stage,'repair_required');assert.equal(abandoned.pinnedBaselines.repair,baseline.baselineDigest);
|
|
664
|
+
assert.equal(f.reopen().status().stage,'repair_required');
|
|
665
|
+
// A redo intent that re-captured the residue as its "before" image is refused on replay.
|
|
666
|
+
const forged=captureReviewBaseline({root:f.cwd,specsRoot:f.specsRoot,identity:f.identity,
|
|
667
|
+
scope:f.configuration.repair.scope,requirements:f.configuration.repair.requirements});
|
|
668
|
+
const saved=fs.readFileSync(f.statePath);
|
|
669
|
+
assert.throws(()=>f.append('fix-repair-retry-1-intent','intent',{baseline:forged,redDigest:digest(atRepair.redTest),
|
|
670
|
+
testBaselineDigest:digest(atRepair.baseline)}),{code:'fix_history_invalid'});
|
|
671
|
+
f.restore(saved);
|
|
672
|
+
assert.equal((await f.owner().repair({authorized:true})).stage,'regression_required');
|
|
673
|
+
const retry=f.records().find(row=>row.id==='fix-repair-retry-1-intent');
|
|
674
|
+
assert.equal(retry.payload.baseline.baselineDigest,baseline.baselineDigest,'the redo registers the pinned baseline');
|
|
675
|
+
assert.equal(f.records().find(row=>row.id==='fix-abandoned-1').payload.baselinePinned,true);
|
|
676
|
+
});
|
|
677
|
+
|
|
678
|
+
// V10 (F18): an inconclusive regression (the red test could not run) is a
|
|
679
|
+
// legitimate blocked verdict; with a reason it is rerun at most twice.
|
|
680
|
+
test('a blocked regression is rerun with a reason through the host, keeping the blocked result',async t=>{
|
|
681
|
+
const marker=path.join(fs.realpathSync(os.tmpdir()),`cm-fix-hang-${process.pid}-${Date.now()}`);t.after(()=>fs.rmSync(marker,{force:true}));
|
|
682
|
+
const f=await fixture(t,{repairContent:`import fs from 'node:fs';if(fs.existsSync(${JSON.stringify(marker)}))await new Promise(()=>{});export const value=2;\n`});
|
|
683
|
+
await toRepair(f);
|
|
684
|
+
assert.equal((await f.owner().repair({authorized:true})).stage,'regression_required');
|
|
685
|
+
fs.writeFileSync(marker,'');
|
|
686
|
+
const blocked=await f.owner().runRegression({authorized:true});
|
|
687
|
+
assert.equal(blocked.stage,'regression_blocked',JSON.stringify(blocked.regression?.status));
|
|
688
|
+
assert.deepEqual(blocked.blockedRerun,{pending:'regression',used:0,limit:2});
|
|
689
|
+
const host=createFixHost({owner:f.owner(),config:{...f.configuration,specsRoot:f.specsRoot,identity:f.identity},permissions:[]});
|
|
690
|
+
await assert.rejects(host.handle({requestId:'r',operation:'rerun_blocked_step',reason:'environment fixed'}),{code:'fix_blocked_rerun_authorization_required'});
|
|
691
|
+
const allowed=createFixHost({owner:f.owner(),config:{...f.configuration,specsRoot:f.specsRoot,identity:f.identity},permissions:['--allow-rerun-blocked-step']});
|
|
692
|
+
await assert.rejects(allowed.handle({requestId:'r',operation:'rerun_blocked_step',reason:'two\nlines'}),{code:'fix_blocked_rerun_reason_required'});
|
|
693
|
+
fs.rmSync(marker);
|
|
694
|
+
const rerun=await allowed.handle({requestId:'r',operation:'rerun_blocked_step',reason:'Stale hang marker removed'});
|
|
695
|
+
assert.equal(rerun.stage,'regression_required');assert.deepEqual(rerun.blockedReruns,{regression:1});
|
|
696
|
+
assert.equal(f.reopen().status().stage,'regression_required');
|
|
697
|
+
assert.equal((await f.owner().runRegression({authorized:true})).stage,'handoff_required');
|
|
698
|
+
const ids=f.records().map(row=>row.id);
|
|
699
|
+
assert(ids.includes('fix-regression-result')&&ids.includes('fix-blocked-rerun-1')&&ids.includes('fix-regression-retry-1-result'));
|
|
700
|
+
// A forged second rerun record at a non-blocked stage is refused on replay.
|
|
701
|
+
const saved=fs.readFileSync(f.statePath);
|
|
702
|
+
assert.throws(()=>f.append('fix-blocked-rerun-2','result',{stage:'regression_blocked',pending:'regression',reason:'x',rerunAt:1,
|
|
703
|
+
intentDigest:'0'.repeat(64),resultDigest:'0'.repeat(64)}),{code:'fix_history_invalid'});
|
|
704
|
+
f.restore(saved);
|
|
705
|
+
});
|
|
706
|
+
|
|
707
|
+
// V6 (F13): in protected mode a redo refuses while the scope still holds a
|
|
708
|
+
// partial write of the abandoned attempt; elsewhere only out-of-scope residue refuses.
|
|
709
|
+
test('pinned residue: out-of-scope always refuses, in-scope refuses only in protected mode',async()=>{
|
|
710
|
+
const {pinnedResidue}=await import('../runtime/js/cm-fix/pinned-baseline.mjs');
|
|
711
|
+
const file=(p,sha)=>({path:p,type:'file',mode:420,size:1,sha256:sha.repeat(64)});
|
|
712
|
+
const baseline={files:[file('value.mjs','a'),file('requirements.md','b')]};
|
|
713
|
+
const now={files:[file('value.mjs','c'),file('requirements.md','b')]};
|
|
714
|
+
assert.deepEqual(pinnedResidue(baseline,now,['value.mjs'],false),['value.mjs']);
|
|
715
|
+
assert.throws(()=>pinnedResidue(baseline,now,['value.mjs'],true),error=>error.code==='fix_protected_residue'&&error.paths[0]==='value.mjs');
|
|
716
|
+
assert.throws(()=>pinnedResidue(baseline,{files:[file('value.mjs','a'),file('requirements.md','d')]},['value.mjs'],false),{code:'fix_pinned_residue'});
|
|
717
|
+
});
|
|
718
|
+
|
|
719
|
+
// P2 (Codex round 1): a rerun record is checked against the replay parser
|
|
720
|
+
// before it is appended. Here the regression step already used its eight retry
|
|
721
|
+
// ids, so a rerun record could not replay: it is refused and nothing is written.
|
|
722
|
+
test('a blocked rerun that could not replay is refused before append',async t=>{
|
|
723
|
+
const marker=path.join(fs.realpathSync(os.tmpdir()),`cm-fix-hang-cap-${process.pid}-${Date.now()}`);t.after(()=>fs.rmSync(marker,{force:true}));
|
|
724
|
+
const f=await fixture(t,{repairContent:`import fs from 'node:fs';if(fs.existsSync(${JSON.stringify(marker)}))await new Promise(()=>{});export const value=2;\n`});
|
|
725
|
+
await toRepair(f);
|
|
726
|
+
assert.equal((await f.owner().repair({authorized:true})).stage,'regression_required');
|
|
727
|
+
for(let n=0;n<8;n++){
|
|
728
|
+
const at=f.owner().status();
|
|
729
|
+
f.append(n?`fix-regression-retry-${n}-intent`:'fix-regression-intent','intent',
|
|
730
|
+
{repairDigest:digest(at.repair),redDigest:digest(at.redTest),baselineDigest:digest(at.baseline)});
|
|
731
|
+
assert.equal(f.owner().abandonStep({authorized:true,reason:`Regression process crashed ${n+1}`}).stage,'regression_required');
|
|
732
|
+
}
|
|
733
|
+
fs.writeFileSync(marker,'');
|
|
734
|
+
assert.equal((await f.owner().runRegression({authorized:true})).stage,'regression_blocked');
|
|
735
|
+
assert(f.records().some(row=>row.id==='fix-regression-retry-8-result'));
|
|
736
|
+
const before=fs.readFileSync(f.statePath);
|
|
737
|
+
assert.throws(()=>f.owner().rerunBlockedStep({authorized:true,reason:'environment fixed'}),{code:'fix_blocked_rerun_unavailable'});
|
|
738
|
+
assert.deepEqual(fs.readFileSync(f.statePath),before);
|
|
739
|
+
assert.equal(f.reopen().status().stage,'regression_blocked');
|
|
740
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// F11: outside protected mode the fix driver must answer like a session: write
|
|
2
|
+
// the planned files inside the supplied scope and return only {outcome}. It used
|
|
3
|
+
// to return the protected {outcome,edits} proposal, which the host always
|
|
4
|
+
// refused (shape), so the step went unknown and abandon_step was spent each time.
|
|
5
|
+
import test from 'node:test';
|
|
6
|
+
import assert from 'node:assert/strict';
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import os from 'node:os';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import {prepareFixTestAuthor} from '../runtime/js/cm-fix/test-author.mjs';
|
|
11
|
+
import {answerFor} from './cm-fix-drive.mjs';
|
|
12
|
+
|
|
13
|
+
test('fix driver answers a non-protected fix_test_author through the real test-author step',async t=>{
|
|
14
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'fix-drive-unprotected-')));
|
|
15
|
+
t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
|
|
16
|
+
const cwd=path.join(root,'code'),specsRoot=path.join(root,'specs'),answers=path.join(root,'answers');
|
|
17
|
+
for(const dir of [cwd,specsRoot,answers])fs.mkdirSync(dir);
|
|
18
|
+
fs.writeFileSync(path.join(cwd,'value.mjs'),'export const value=1;');fs.writeFileSync(path.join(cwd,'requirements.md'),'fixture');
|
|
19
|
+
fs.writeFileSync(path.join(answers,'red.mjs'),"import {value} from './value.mjs';if(value!==2)process.exit(1)\n");
|
|
20
|
+
const identity={repositoryId:'fixture',runId:'driver-unprotected',taskId:'T-FIX-demo',attempt:1};
|
|
21
|
+
const options={codeProject:cwd,specsRoot,identity,testFiles:['red.mjs'],requirements:['requirements.md'],defect:'Constant bug',diagnosis:{},reproduction:{}};
|
|
22
|
+
const driverAnswers={'test-edits':{'red.mjs':'red.mjs'}},paths={answers,round:1};
|
|
23
|
+
let asked=null;
|
|
24
|
+
const author=prepareFixTestAuthor(options,{assertReviewReady(){},bridge:{async call(kind,payload){
|
|
25
|
+
asked=payload;return answerFor({kind,payload},driverAnswers,paths);}}});
|
|
26
|
+
const result=await author.execute({authorized:true,signal:new AbortController().signal,register(){}});
|
|
27
|
+
assert.equal(asked.editMode,undefined,'non-protected request');
|
|
28
|
+
assert.deepEqual([result.outcome,result.changedFiles],['authored',['red.mjs']]);
|
|
29
|
+
assert.equal(fs.readFileSync(path.join(cwd,'red.mjs'),'utf8'),fs.readFileSync(path.join(answers,'red.mjs'),'utf8'));
|
|
30
|
+
// A planned file outside the supplied scope is a legal blocked answer, nothing written.
|
|
31
|
+
assert.deepEqual(answerFor({kind:'fix_repair',payload:{identity,codeProject:cwd,scope:['value.mjs']}},
|
|
32
|
+
{'repair-edits':{'other.mjs':'red.mjs'}},paths),{outcome:'blocked'});
|
|
33
|
+
assert.equal(fs.existsSync(path.join(cwd,'other.mjs')),false);
|
|
34
|
+
// Protected mode keeps the proposal shape.
|
|
35
|
+
const proposal=answerFor({kind:'fix_test_author',payload:{identity,editMode:'protected-text-v1',expected:{'red.mjs':null}}},driverAnswers,paths);
|
|
36
|
+
assert.deepEqual(Object.keys(proposal),['outcome','edits']);assert.equal(proposal.edits[0].path,'red.mjs');
|
|
37
|
+
});
|
package/scripts/cm-fix-drive.mjs
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
// "reviewConfig": "review.json", 可选
|
|
23
23
|
// "permissions": ["--allow-red-test", ...], 原样传给宿主,不另造一套词
|
|
24
24
|
// "answers": "answers", 答案目录;abandon_step / abandon_review 可省略
|
|
25
|
-
// "reason": "旧本地步骤结果丢失" abandon_step 必填并需 --allow-abandon;abandon_review 必填并需 --allow-abandon-review
|
|
25
|
+
// "reason": "旧本地步骤结果丢失" abandon_step 必填并需 --allow-abandon;abandon_review 必填并需 --allow-abandon-review;rerun_blocked_step 必填并需 --allow-rerun-blocked-step
|
|
26
26
|
// "inputLimit": 1048576 可选;宿主输入与应答上限(65536–4194304,默认 65536)
|
|
27
27
|
// }
|
|
28
28
|
//
|
|
@@ -60,11 +60,11 @@ const ASKS={
|
|
|
60
60
|
const READ_ONLY=new Set(['status','final_review_package','completion_evidence','cause_review_package']);
|
|
61
61
|
const KNOWN=new Set([...Object.keys(ASKS),...READ_ONLY,'cancel','handoff','publish_review','check_n5',
|
|
62
62
|
'publish_dossier','learning_writeback','walkthrough','finish','final_review','cause_review',
|
|
63
|
-
'reconcile_review','recover_final_review','abandon_step','abandon_review','resume','revision_test_check']);
|
|
63
|
+
'reconcile_review','recover_final_review','abandon_step','abandon_review','rerun_blocked_step','resume','revision_test_check']);
|
|
64
64
|
|
|
65
65
|
function loadPlan(){
|
|
66
66
|
const {operation,plan,base}=loadPlanFile({name:'cm-fix-drive.mjs',known:KNOWN});
|
|
67
|
-
const abandoning=['abandon_step','abandon_review'].includes(operation);
|
|
67
|
+
const abandoning=['abandon_step','abandon_review','rerun_blocked_step'].includes(operation);
|
|
68
68
|
requireFields(plan,['config','cwd','mode','hostContext','permissions',...(abandoning||operation==='reconcile_review'?[]:['answers'])]);
|
|
69
69
|
if(!['create','resume'].includes(plan.mode))stop(2,'mode 只能是 create 或 resume');
|
|
70
70
|
if(!Array.isArray(plan.permissions))stop(2,'permissions must be an array');
|
|
@@ -76,7 +76,7 @@ function loadPlan(){
|
|
|
76
76
|
}else if(!['--execution-optimizations','--external-models'].includes(flag)&&!/^--allow-[a-z-]+$/.test(flag))stop(2,'invalid permissions');
|
|
77
77
|
}
|
|
78
78
|
if(operation==='reconcile_review'&&(plan.mode!=='resume'||typeof plan.invocationId!=='string'||!plan.invocationId))stop(2,'reconcile_review requires resume and original invocationId');
|
|
79
|
-
const abandonFlag=operation==='abandon_review'?'--allow-abandon-review':'--allow-abandon';
|
|
79
|
+
const abandonFlag=operation==='abandon_review'?'--allow-abandon-review':operation==='rerun_blocked_step'?'--allow-rerun-blocked-step':'--allow-abandon';
|
|
80
80
|
if(abandoning&&(!plan.permissions.includes(abandonFlag)||typeof plan.reason!=='string'
|
|
81
81
|
||!plan.reason.trim().length||Buffer.byteLength(plan.reason,'utf8')>1000||/[\r\n\0\u0085\u2028\u2029]/.test(plan.reason)))
|
|
82
82
|
stop(2,`${operation} 需要 PLAN.reason(单行,最多 1000 字节)和 ${abandonFlag}`);
|
|
@@ -188,7 +188,7 @@ function hostArgs({plan,paths}){
|
|
|
188
188
|
...plan.permissions];
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
function answerFor(row,answers,paths){
|
|
191
|
+
export function answerFor(row,answers,paths){
|
|
192
192
|
const {kind,payload}=row;
|
|
193
193
|
if(kind==='fix_learning')return {contextDigest:payload.contextDigest,status:answers.learning.status,summary:answers.learning.summary};
|
|
194
194
|
if(kind==='fix_diagnose')return answers.diagnosis;
|
|
@@ -198,6 +198,24 @@ function answerFor(row,answers,paths){
|
|
|
198
198
|
if(requestAttempt!==undefined&&requestAttempt!==paths.round)
|
|
199
199
|
throw Error(`修订轮次 ${requestAttempt} 与已预检答案轮次 ${paths.round} 不一致`);
|
|
200
200
|
const map=answers[kind==='fix_repair'?'repair-edits':'test-edits'],expected=payload.expected??{};
|
|
201
|
+
const done=kind==='fix_repair'?'repaired':'authored';
|
|
202
|
+
// F11: outside protected mode the session itself writes inside the supplied
|
|
203
|
+
// scope and answers only {outcome} (test-author.mjs / repair.mjs); a
|
|
204
|
+
// {outcome,edits} proposal there always failed its shape check. The driver,
|
|
205
|
+
// standing in for the session, writes the planned files the same way.
|
|
206
|
+
if(payload.editMode!=='protected-text-v1'){
|
|
207
|
+
const scope=Array.isArray(payload.scope)?payload.scope:[];
|
|
208
|
+
if(typeof payload.codeProject!=='string'||!path.isAbsolute(payload.codeProject))throw Error('宿主没有给出代码根,无法写入');
|
|
209
|
+
const outside=Object.keys(map).filter(target=>!scope.includes(target));
|
|
210
|
+
if(outside.length){stderr(`${outside.join(', ')} 不在宿主本次允许的范围内,回 blocked`);return {outcome:'blocked'};}
|
|
211
|
+
for(const [target,local] of Object.entries(map)){
|
|
212
|
+
const file=path.join(payload.codeProject,target);
|
|
213
|
+
if(path.relative(payload.codeProject,file).startsWith('..'))throw Error(`${target} 越出代码根`);
|
|
214
|
+
fs.mkdirSync(path.dirname(file),{recursive:true});
|
|
215
|
+
fs.writeFileSync(file,fs.readFileSync(path.join(paths.answers,local),'utf8'));
|
|
216
|
+
}
|
|
217
|
+
return {outcome:done};
|
|
218
|
+
}
|
|
201
219
|
const edits=[];
|
|
202
220
|
for(const [target,local] of Object.entries(map)){
|
|
203
221
|
// 路径不在宿主给的范围里:不能硬塞,也不能断线(断线会把运行做死)。
|
|
@@ -205,7 +223,7 @@ function answerFor(row,answers,paths){
|
|
|
205
223
|
if(!Object.hasOwn(expected,target)){stderr(`${target} 不在宿主本次允许的范围内,回 blocked`);return {outcome:'blocked',edits:[]};}
|
|
206
224
|
edits.push({path:target,beforeSha256:expected[target],content:fs.readFileSync(path.join(paths.answers,local),'utf8')});
|
|
207
225
|
}
|
|
208
|
-
return {outcome:
|
|
226
|
+
return {outcome:done,edits};
|
|
209
227
|
}
|
|
210
228
|
return null;
|
|
211
229
|
}
|
|
@@ -215,7 +233,7 @@ function main(){
|
|
|
215
233
|
const {answers,round}=preflight(loaded);
|
|
216
234
|
const {operation,plan,paths}=loaded;
|
|
217
235
|
driveHost({host:HOST,args:hostArgs(loaded).slice(1),cwd:path.resolve(plan.cwd),operation,
|
|
218
|
-
request:{...(operation==='reconcile_review'?{invocationId:plan.invocationId}:{}),...(['abandon_step','abandon_review','rediagnose'].includes(operation)?{reason:plan.reason}:{}),
|
|
236
|
+
request:{...(operation==='reconcile_review'?{invocationId:plan.invocationId}:{}),...(['abandon_step','abandon_review','rediagnose','rerun_blocked_step'].includes(operation)?{reason:plan.reason}:{}),
|
|
219
237
|
...(operation==='prepare_revision'&&Object.hasOwn(plan,'revisionTests')?{tests:plan.revisionTests}:{})},
|
|
220
238
|
answers,paths:{...paths,round},answerFor});
|
|
221
239
|
}
|
package/scripts/cm-fix-host.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import {fileURLToPath} from 'node:url';
|
|
|
7
7
|
import {openFixExecution} from '../runtime/js/cm-fix/execution.mjs';
|
|
8
8
|
import {createFixHost} from '../runtime/js/cm-fix/host.mjs';
|
|
9
9
|
import {createFixLearningPreparation} from '../runtime/js/cm-fix/learning.mjs';
|
|
10
|
-
import {createHostToolBridge} from '../runtime/js/cm-ai/host-tool-bridge.mjs';
|
|
10
|
+
import {createHostToolBridge,HOST_ANSWER_BACKSTOP_MS} from '../runtime/js/cm-ai/host-tool-bridge.mjs';
|
|
11
11
|
import {serveCmAiHost,parseHostInputLimit,inputLimitReason} from '../runtime/js/cm-ai/host-session.mjs';
|
|
12
12
|
import {id,json,need,shape,digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
13
13
|
import {readConversationReviewConfiguration} from './cm-ai-host.mjs';
|
|
@@ -21,10 +21,11 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
21
21
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('Omit specsRoot or use null for a bare project: the same owner stores archives in docs/fixes and reviews in docs/fixes/.reviews, uses the original no-specs log mode, and skips METRICS. No specs skeleton is created. Visual-only reproduction/redTest may use kind:visual with cwd, timeoutMs, before:{path,sha256,kind:screenshot|video,description}, reason explaining why automated red cannot be written, environment, steps and expected; redTest also has testFiles:[]. No testAuthor or fake red/green command. Repair/regression/review/finish permissions remain mandatory. qa_browser returns actual after carrier metadata; missing evidence blocks.\n');
|
|
22
22
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('Optional startup configuration protectSpecs:true uses the existing Codex native sandbox for reproduction, red/baseline/regression/walkthrough commands and fixed text edits, without a model call. Requires the local sandbox executable; it does not change the current Codex/Claude host or reviewer identity. Original action permissions remain required. fix_test_author/fix_repair with editMode=protected-text-v1 require {outcome,edits:[{path,beforeSha256,content}]} using the supplied scope/expected hashes; never write directly. Content is full UTF-8 text or null for deletion, blocked requires edits:[]. Default 64KiB response limit applies; --input-limit may explicitly raise transport to 4MiB, while protected text proposal limits remain 1MiB. Drift or failed writes retain the original unknown boundary; no automatic retry/rollback or protection-mode switching on resume.\n');
|
|
23
23
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('completion_evidence is read-only and available only after the original finish has completed and current evidence still validates. It returns the selected attempt, original reviewed package, handoff/review digests, completion event IDs and optional qaSource from the original owner. It does not complete or resume a parent task; JSON evidence alone is not authority.\n');
|
|
24
|
-
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('recover_final_review requires --allow-final-review-recovery and exact latest invocationId/packageDigest, previousInvocationStopped:true, and a nonempty reason. The legacy first continuation remains once-only. A further continuation additionally requires a fresh startup --final-review-recovery-invocation ID matching the latest unknown invocation, authorizing exactly one new call. Confirm the previous process stopped; this is a trusted host acknowledgment, not an automatic liveness check. Preparation dispatches nothing. Later final_review requires recovery permission and --allow-final-review; additional cycles require the same invocation binding after restart. Old records, task attempt, reviewed package and the original Review/N5/finish remain unchanged. No automatic retry, cancelled/complete-verdict recovery,
|
|
25
|
-
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('rediagnose requires --allow-rediagnosis, the original resumed run at rediagnosis_required and a nonempty single-line reason up to 1000 UTF-8 bytes. It appends one history-bound diagnosis without repeating reproduction or overwriting cause-r1. A fresh cause review must publish cause-r2 even for a revised single-layer cause. Second rejection reaches rediagnosis_review_limit_reached. Interrupted rediagnosis or its review is not automatically retried or abandoned.
|
|
26
|
-
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('abandon_step requires --allow-abandon, stage unknown, an eligible local pending kind, and a nonempty single-line reason up to 1000 UTF-8 bytes. It records the abandoned intent and returns to the required stage; a later separate action redoes the step. At most eight abandonments per run. Review, Learning writeback and handoff remain unavailable.\n');
|
|
27
|
-
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('
|
|
24
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('recover_final_review requires --allow-final-review-recovery and exact latest invocationId/packageDigest, previousInvocationStopped:true, and a nonempty reason. The legacy first continuation remains once-only. A further continuation additionally requires a fresh startup --final-review-recovery-invocation ID matching the latest unknown invocation, authorizing exactly one new call. Confirm the previous process stopped; this is a trusted host acknowledgment, not an automatic liveness check. Preparation dispatches nothing. Later final_review requires recovery permission and --allow-final-review; additional cycles require the same invocation binding after restart. Old records, task attempt, reviewed package and the original Review/N5/finish remain unchanged. A first final review whose worker never opened a thread may be recovered at most twice in total. No automatic retry, cancelled/complete-verdict recovery, business-revision recovery or source-drift bypass. status adds a read-only progress projection, not authorization or current-source verification.\n');
|
|
25
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('rediagnose requires --allow-rediagnosis, the original resumed run at rediagnosis_required and a nonempty single-line reason up to 1000 UTF-8 bytes. It appends one history-bound diagnosis without repeating reproduction or overwriting cause-r1. A fresh cause review must publish cause-r2 even for a revised single-layer cause. Second rejection reaches rediagnosis_review_limit_reached. Interrupted rediagnosis or its review is not automatically retried or abandoned. A QA-fix child reaches the same operation through the parent cm-ai-host fix_action with --allow-qa-fix-rediagnosis.\n');
|
|
26
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('abandon_step requires --allow-abandon, stage unknown, an eligible local pending kind, and a nonempty single-line reason up to 1000 UTF-8 bytes. It records the abandoned intent and returns to the required stage; a later separate action redoes the step. At most eight abandonments per run. Review, Learning writeback and handoff remain unavailable. A redone test author or repair keeps the baseline its first intent captured (baselinePinned), so the residue of the abandoned attempt is reviewed; in protected mode the scope must first be restored to that baseline (fix_protected_residue lists the paths).\n');
|
|
27
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('rerun_blocked_step requires --allow-rerun-blocked-step and a nonempty single-line reason up to 1000 UTF-8 bytes. Only for a legitimate blocked verdict of test_author, repair, regression (including visual BLOCKED/inconclusive), post-review regression or walkthrough (and their revision_ forms): it records fix-blocked-rerun-N, keeps the blocked result as history and returns to the required stage; at most two reruns per step kind.\n');
|
|
28
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('abandon_review requires its own --allow-abandon-review flag (not --allow-abandon) and the same reason rules. Each run may abandon each cause review round twice (the first round and the post-rediagnosis round 2 separately) and the second-round final review twice, only while that registered review has no review result (interrupted, timed out, disconnected or cancelled); confirm the old reviewer stopped first. It records the abandoned invocation and returns to the review stage; the retry needs the original review flag, a fresh grant and a new reviewer thread. Reviews wait for the review configuration timeoutMs (default 900000), not the reproduction timeout.\n');
|
|
28
29
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('N6 child configuration may include qaSource {feature, identity, packageDigest, testRunId, handoffDigest}; derive the separate fixed child identity with qaFixIdentity. It requires --allow-qa-fix in addition to existing action flags. Close the parent host first: the original specs-wide owner lock is shared. Creation/resume rechecks the current failed round, project, report and policy; the source is bound to the original fix configuration. This does not resume the parent or automatically rerun QA, and does not authorize provider calls, installation or Git.\n');
|
|
29
30
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('Second-round retrospective uses the cumulative original baseline, including previously authored tests and Learning scope. It persists the current round reflection and reaches revision_handoff_ready or revision_learning_writeback_required; neither state completes the task or publishes a new handoff. From revision_handoff_ready, handoff publishes a separate a2 handoff containing cumulative changes, current reflection, original red evidence and prior review/Learning history; final_review_package then reads that bound package. Pending Learning blocks publication. final_review requires --allow-final-review, uses fresh-thread exclusions and carries prior findings; publish_review writes the original r2 evidence and review log, and check_n5 runs the original Learning-aware gate. Approval reaches revision_post_review_regression_required, not completion.\n');
|
|
30
31
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('prepare_revision requires --allow-repair and either a published first-round changes_requested review or an approved first-round review followed by a package-bound walkthrough result of failed. The latter preserves the approved verdict and carries separate walkthrough failure evidence; passed, blocked, unknown, or drifted evidence cannot authorize this repair. An approved first-round review followed by package-bound post-review regression defect_remaining or regressed can also prepare the second repair when all baseline commands produced complete results. The regression commands must match the first reviewed handoff; passed, inconclusive, unavailable or partial evidence is refused. Regression and walkthrough failure feedback are mutually exclusive and neither replaces the next independent review. It rereads project Learning and persists the second-round preparation in the original store, preserving first-round evidence. repair then uses the original business scope and findings with separate second-round records. regression requires --allow-regression and reruns the original test commands against the second repair, preserving the original red evidence. Success reaches revision_handoff_required, not completion; handoff and final_review use the second-round package; review evidence publication and N5 are connected; post_review_regression requires --allow-regression and reaches revision_closeout_required after the original checks; walkthrough requires --allow-walkthrough and binds the second-round package and identity; finish reuses the original closeout with --allow-finish, preserving first-round history and recording completion for attempt 2. Second-round learning_writeback requires --allow-learning-writeback, includes the resulting AGENTS.md in the cumulative review package and preserves prior Learning history; pending or unknown writeback cannot advance to handoff. A lost repair or regression result stays unknown and is not redispatched.\n');
|
|
@@ -36,7 +37,7 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
36
37
|
need(['create','resume'].includes(argv[4]),'invalid_arguments');id(argv[6]);
|
|
37
38
|
const extra=new Map();
|
|
38
39
|
for(let index=8;index<argv.length;index++){
|
|
39
|
-
const flag=argv[index];need(!extra.has(flag)&&['--execution-optimizations','--external-models','--external-models-config','--runtime','--input-limit','--review-config','--original-host-context','--final-review-recovery-invocation','--allow-qa-fix','--allow-rediagnosis','--allow-cause-review','--allow-final-review','--allow-final-review-recovery','--allow-abandon','--allow-abandon-review','--allow-red-test','--allow-baseline','--allow-test-author','--allow-repair','--allow-regression','--allow-learning-writeback','--allow-walkthrough','--allow-finish'].includes(flag),'invalid_arguments');
|
|
40
|
+
const flag=argv[index];need(!extra.has(flag)&&['--execution-optimizations','--external-models','--external-models-config','--runtime','--input-limit','--review-config','--original-host-context','--final-review-recovery-invocation','--allow-qa-fix','--allow-rediagnosis','--allow-cause-review','--allow-final-review','--allow-final-review-recovery','--allow-abandon','--allow-abandon-review','--allow-rerun-blocked-step','--allow-red-test','--allow-baseline','--allow-test-author','--allow-repair','--allow-regression','--allow-learning-writeback','--allow-walkthrough','--allow-finish'].includes(flag),'invalid_arguments');
|
|
40
41
|
if(flag.startsWith('--allow-')||flag==='--external-models'||flag==='--execution-optimizations')extra.set(flag,true);
|
|
41
42
|
else{need(typeof argv[index+1]==='string'&&!argv[index+1].startsWith('--'),'invalid_arguments');extra.set(flag,argv[++index]);}
|
|
42
43
|
}
|
|
@@ -76,7 +77,7 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
76
77
|
const {reviewer,authority,finalAuthority,execution:reviewExecution}=createFixReviewHost({
|
|
77
78
|
codeProject:config.reproduction.cwd,hostContextId:argv[6],runtime,review,
|
|
78
79
|
permissions:[...extra.keys()],workerFactory:reviewWorkerFactory,externalModels,executionPolicy,specsDir:config.specsRoot??null});
|
|
79
|
-
bridge=createHostToolBridge({responseLimit:inputLimit});
|
|
80
|
+
bridge=createHostToolBridge({responseLimit:inputLimit,answerTimeoutMs:HOST_ANSWER_BACKSTOP_MS});
|
|
80
81
|
owner=openFixExecution({specsRoot:config.specsRoot??null,identity:config.identity,create:argv[4]==='create',
|
|
81
82
|
hostContextId:argv[6],
|
|
82
83
|
configuration:{...(executionPolicy?{executionPolicy}:{}),...(externalModels?{externalModels}:{}),hostContextId:originalHostContext??argv[6],defect:config.defect,reproduction:config.reproduction,
|
|
@@ -145,3 +145,16 @@ test('#15 the cm-ai driver forwards the QA-fix abandon_review reason inside fix_
|
|
|
145
145
|
assert.deepEqual(buildCmAiDriveRequest('fix_action',plan,{identity}),{version:1,identity,packageDigest:plan.packageDigest,
|
|
146
146
|
testRunId:plan.testRunId,fixOperation:'abandon_review',reason:plan.reason});
|
|
147
147
|
});
|
|
148
|
+
|
|
149
|
+
test('Q23 the cm-ai driver forwards the new QA-fix recovery fields inside fix_action',()=>{
|
|
150
|
+
const identity={repositoryId:'r',runId:'run',taskId:'T-1',attempt:1},base={packageDigest:'a'.repeat(64),testRunId:'qa-run'};
|
|
151
|
+
for(const fixOperation of ['rediagnose','rerun_blocked_step'])
|
|
152
|
+
assert.deepEqual(buildCmAiDriveRequest('fix_action',{...base,fixOperation,reason:'理由'},{identity}),
|
|
153
|
+
{version:1,identity,...base,fixOperation,reason:'理由'});
|
|
154
|
+
const recover={...base,fixOperation:'recover_final_review',invocationId:'final-1',reviewPackageDigest:'b'.repeat(64),
|
|
155
|
+
previousInvocationStopped:true,reason:'旧审查已停'};
|
|
156
|
+
assert.deepEqual(buildCmAiDriveRequest('fix_action',recover,{identity}),{version:1,identity,...base,fixOperation:'recover_final_review',
|
|
157
|
+
reason:'旧审查已停',invocationId:'final-1',reviewPackageDigest:'b'.repeat(64),previousInvocationStopped:true});
|
|
158
|
+
assert.deepEqual(buildCmAiDriveRequest('fix_action',{...base,fixOperation:'revision_test_check'},{identity}),
|
|
159
|
+
{version:1,identity,...base,fixOperation:'revision_test_check'});
|
|
160
|
+
});
|
|
@@ -35,6 +35,7 @@ async function fixture(t,mode){
|
|
|
35
35
|
const workerFactory=()=>async({prompt},{onEvent})=>{
|
|
36
36
|
calls++;const data=JSON.parse(prompt.split('<cm-review-data-json>\n')[1]);
|
|
37
37
|
const thread=calls===1||mode==='reuse-thread'||['reuse-first-thread','revision-reuses-lost-thread'].includes(mode)&&calls===3?'old-thread':`new-thread-${calls}`;
|
|
38
|
+
if(mode==='no-thread-always'||mode==='no-thread'&&calls===1)throw Error('Synthetic loss before any thread');
|
|
38
39
|
onEvent({event:'thread.started',provider_thread:thread});
|
|
39
40
|
if(calls===1&&!['approved','changes_requested'].includes(mode)||mode==='loss-again'
|
|
40
41
|
||['twice-then-success','reuse-first-thread'].includes(mode)&&calls<=2)throw Error('Synthetic lost result');
|
|
@@ -196,3 +197,37 @@ for(const mode of ['loss-again','reuse-thread','approved','changes_requested'])t
|
|
|
196
197
|
assert.equal(f.reopen().status().stage,'unknown');assert.equal((await f.owner().reviewFinal()).stage,'unknown');
|
|
197
198
|
assert.equal(f.calls(),2);assert.equal(f.repairs(),1);
|
|
198
199
|
});
|
|
200
|
+
|
|
201
|
+
// V5 (F24): a worker that never opened a thread leaves nothing to exclude; the
|
|
202
|
+
// first final review is still recoverable, at most twice in total.
|
|
203
|
+
test('F24 a first final review lost before any thread is recovered and approved',{timeout:FIXTURE_TIMEOUT_MS},async t=>{
|
|
204
|
+
const f=await fixture(t,'no-thread');
|
|
205
|
+
const lost=f.reopen().status();assert.equal(lost.stage,'unknown');
|
|
206
|
+
assert(!JSON.parse(fs.readFileSync(f.statePath)).records.some(r=>r.id==='fix-final-started'));
|
|
207
|
+
assert.match((await f.cli([op('status')]))[0].result.progress.nextAction,/recover_final_review/);
|
|
208
|
+
const rows=await f.cli([f.request,op('final_review')],['--allow-final-review','--allow-final-review-recovery']);
|
|
209
|
+
for(const row of rows)assert(!row.error,JSON.stringify(row));
|
|
210
|
+
assert.equal(rows.at(-1).result.stage,'final_review_evidence_required');assert.equal(f.calls(),2);
|
|
211
|
+
const authorized=JSON.parse(fs.readFileSync(f.statePath)).records.find(r=>r.id==='fix-final-recovery-authorized').payload;
|
|
212
|
+
assert.equal(authorized.providerThreadId,null);
|
|
213
|
+
});
|
|
214
|
+
test('F24 thread-less recovery stops after two recoveries without changing the store',{timeout:FIXTURE_TIMEOUT_MS},async t=>{
|
|
215
|
+
const f=await fixture(t,'no-thread-always');
|
|
216
|
+
await f.cli([f.request,op('final_review')],['--allow-final-review','--allow-final-review-recovery']);
|
|
217
|
+
assert.equal(f.calls(),2);
|
|
218
|
+
const bound=()=>{const latest=f.reopen().status().finalReviewInvocation;
|
|
219
|
+
return {request:{...f.request,invocationId:latest.invocationId,packageDigest:latest.packageDigest},
|
|
220
|
+
flags:['--allow-final-review-recovery','--final-review-recovery-invocation',latest.invocationId]};};
|
|
221
|
+
const second=bound();
|
|
222
|
+
const rows=await f.cli([second.request,op('final_review')],[...second.flags,'--allow-final-review']);
|
|
223
|
+
assert(!rows[0].error,JSON.stringify(rows[0]));assert.equal(f.calls(),3);assert.equal(f.reopen().status().stage,'unknown');
|
|
224
|
+
const third=bound(),before=fs.readFileSync(f.statePath);
|
|
225
|
+
const refused=await f.cli([third.request],third.flags);
|
|
226
|
+
assert(refused[0].error);assert.deepEqual(fs.readFileSync(f.statePath),before);assert.equal(f.calls(),3);
|
|
227
|
+
const {requestId,operation,...fields}=third.request;
|
|
228
|
+
assert.throws(()=>f.reopen().recoverFinalReview({authorized:true,recoveryInvocationId:third.request.invocationId,...fields}),
|
|
229
|
+
{code:'fix_review_recovery_limit',reason:/无线程恢复已用满 2 次/});
|
|
230
|
+
const status=(await f.cli([op('status')]))[0].result;
|
|
231
|
+
assert.equal(status.progress.blocker,'fix_review_recovery_limit');assert.match(status.progress.nextAction,/新的 runId/);
|
|
232
|
+
assert.deepEqual(fs.readFileSync(f.statePath),before);
|
|
233
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// R0: every bridge call has a deadline. A call without its own timeoutMs stops
|
|
2
|
+
// at the host answer limit; an answer that arrives after a call was stopped is
|
|
3
|
+
// refused as host_response_late with one diagnostic line.
|
|
4
|
+
import test from 'node:test';
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
import {createHostToolBridge,hostAnswerTimeoutMs,HOST_ANSWER_TIMEOUT_DEFAULT_MS,HOST_ANSWER_TIMEOUT_MAX_MS,
|
|
7
|
+
HOST_ANSWER_BACKSTOP_MS} from '../runtime/js/cm-ai/host-tool-bridge.mjs';
|
|
8
|
+
|
|
9
|
+
test('host answer limit: default 30 minutes, 1-60 minutes from CM_HOST_ANSWER_TIMEOUT_MINUTES, backstop above 60',()=>{
|
|
10
|
+
assert.equal(hostAnswerTimeoutMs({}),HOST_ANSWER_TIMEOUT_DEFAULT_MS);
|
|
11
|
+
assert.equal(HOST_ANSWER_TIMEOUT_DEFAULT_MS,30*60000);
|
|
12
|
+
assert.equal(hostAnswerTimeoutMs({CM_HOST_ANSWER_TIMEOUT_MINUTES:'5'}),5*60000);
|
|
13
|
+
assert.equal(hostAnswerTimeoutMs({CM_HOST_ANSWER_TIMEOUT_MINUTES:'60'}),HOST_ANSWER_TIMEOUT_MAX_MS);
|
|
14
|
+
for(const bad of ['0','61','1.5','x','-1',' 5'])
|
|
15
|
+
assert.throws(()=>hostAnswerTimeoutMs({CM_HOST_ANSWER_TIMEOUT_MINUTES:bad}),{code:'host_answer_timeout_invalid'},bad);
|
|
16
|
+
assert.ok(HOST_ANSWER_BACKSTOP_MS>HOST_ANSWER_TIMEOUT_MAX_MS);
|
|
17
|
+
assert.throws(()=>createHostToolBridge({answerTimeoutMs:HOST_ANSWER_BACKSTOP_MS+1}),{code:'host_answer_timeout_invalid'});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('a call without its own timeout stops at the host answer limit and a late answer is refused with one diagnostic',async()=>{
|
|
21
|
+
const bridge=createHostToolBridge({answerTimeoutMs:1000}),sent=[];
|
|
22
|
+
bridge.attach(value=>{sent.push(value);});
|
|
23
|
+
// The default deadline is unref'd; keep this test process alive while it runs.
|
|
24
|
+
const keep=setInterval(()=>{},100);
|
|
25
|
+
try{
|
|
26
|
+
const started=Date.now();
|
|
27
|
+
await assert.rejects(bridge.call('prd_generate',{fixture:true},new AbortController().signal),{code:'host_request_timeout'});
|
|
28
|
+
assert.ok(Date.now()-started>=900);
|
|
29
|
+
const request=sent.find(row=>row.type==='host_request');assert.ok(request);
|
|
30
|
+
const lines=[],write=process.stderr.write;
|
|
31
|
+
process.stderr.write=(chunk,...rest)=>{lines.push(String(chunk));return true;};
|
|
32
|
+
let late;
|
|
33
|
+
try{late=bridge.accept({type:'host_result',sessionId:request.sessionId,callId:request.callId,
|
|
34
|
+
requestDigest:request.requestDigest,result:{status:'late'}});}
|
|
35
|
+
finally{process.stderr.write=write;}
|
|
36
|
+
assert.deepEqual(late,{accepted:false,code:'host_response_late'});
|
|
37
|
+
const diagnostics=lines.filter(line=>line.includes('host_response_late'));
|
|
38
|
+
assert.equal(diagnostics.length,1);
|
|
39
|
+
assert.deepEqual(JSON.parse(diagnostics[0]),{diagnostic:'host_response_late',kind:'prd_generate',
|
|
40
|
+
callId:request.callId,stoppedBy:'host_request_timeout'});
|
|
41
|
+
// An answer for a call this bridge never issued stays a plain mismatch.
|
|
42
|
+
assert.deepEqual(bridge.accept({type:'host_result',sessionId:request.sessionId,callId:'other',
|
|
43
|
+
requestDigest:request.requestDigest,result:{}}),{accepted:false,code:'host_response_mismatch'});
|
|
44
|
+
}finally{clearInterval(keep);bridge.close();}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('an explicit per-call timeout still wins over the host answer limit',async()=>{
|
|
48
|
+
const bridge=createHostToolBridge({answerTimeoutMs:60000});bridge.attach(()=>{});
|
|
49
|
+
const started=Date.now();
|
|
50
|
+
await assert.rejects(bridge.call('qa_assess',{},new AbortController().signal,{timeoutMs:50}),{code:'host_request_timeout'});
|
|
51
|
+
assert.ok(Date.now()-started<5000);bridge.close();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('a request that first runs project commands waits for the 60-minute maximum, not the general limit',async()=>{
|
|
55
|
+
const bridge=createHostToolBridge({answerTimeoutMs:1000}),sent=[];bridge.attach(value=>{sent.push(value);});
|
|
56
|
+
const keep=setInterval(()=>{},100);
|
|
57
|
+
try{
|
|
58
|
+
const pending=bridge.call('init_verify',{},new AbortController().signal);
|
|
59
|
+
await new Promise(resolve=>setTimeout(resolve,1300));
|
|
60
|
+
const request=sent.find(row=>row.type==='host_request');
|
|
61
|
+
assert.deepEqual(bridge.accept({type:'host_result',sessionId:request.sessionId,callId:request.callId,
|
|
62
|
+
requestDigest:request.requestDigest,result:{ok:true}}),{accepted:true,callId:request.callId});
|
|
63
|
+
assert.deepEqual(await pending,{ok:true});
|
|
64
|
+
}finally{clearInterval(keep);bridge.close();}
|
|
65
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// O20: every kind a workflow host asks through the real bridge must be on its
|
|
2
|
+
// whitelist; refactor_revise_tests (round-2 judge revision) was missing, so the
|
|
3
|
+
// second refactor round threw host_operation_invalid on every attempt.
|
|
4
|
+
import test from 'node:test';
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
import fs from 'node:fs';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import {fileURLToPath} from 'node:url';
|
|
9
|
+
import {createHostToolBridge,HOST_CALL_KINDS} from '../runtime/js/cm-ai/host-tool-bridge.mjs';
|
|
10
|
+
|
|
11
|
+
const root=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..');
|
|
12
|
+
test('the real bridge accepts refactor_revise_tests and answers it',async()=>{
|
|
13
|
+
const bridge=createHostToolBridge(),sent=[];bridge.attach(value=>{sent.push(value);});
|
|
14
|
+
try{
|
|
15
|
+
const pending=bridge.call('refactor_revise_tests',{attempt:2},new AbortController().signal);
|
|
16
|
+
await new Promise(resolve=>setImmediate(resolve));
|
|
17
|
+
const request=sent.find(row=>row.type==='host_request');
|
|
18
|
+
assert.equal(request?.kind,'refactor_revise_tests');
|
|
19
|
+
bridge.accept({type:'host_result',sessionId:request.sessionId,callId:request.callId,requestDigest:request.requestDigest,result:{files:[]}});
|
|
20
|
+
assert.deepEqual(await pending,{files:[]});
|
|
21
|
+
}finally{bridge.close();}
|
|
22
|
+
});
|
|
23
|
+
test('every refactor invoke kind in the workflow is a bridge kind',()=>{
|
|
24
|
+
const source=fs.readFileSync(path.join(root,'runtime/js/cm-refactor/workflow.mjs'),'utf8');
|
|
25
|
+
const kinds=[...new Set([...source.matchAll(/invoke\([^,]+,'([a-z_]+)'/g)].map(match=>match[1]))];
|
|
26
|
+
assert.ok(kinds.includes('refactor_revise_tests'),kinds.join(','));
|
|
27
|
+
assert.deepEqual(kinds.filter(kind=>!HOST_CALL_KINDS.includes(kind)),[]);
|
|
28
|
+
});
|