@aibyzero/cm-workflow 0.16.3 → 0.16.5
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/AGENTS.md +8 -0
- package/CHANGELOG.md +59 -0
- package/README.md +55 -3
- package/VERSION +1 -1
- package/docs/installation.md +21 -1
- package/docs/js-workflow-control.md +245 -33
- package/docs/next-steps.md +14 -24
- package/docs/runtime-failover.md +1 -1
- package/package.json +1 -1
- package/runtime/js/cm-ai/accepted-fix.mjs +23 -5
- package/runtime/js/cm-ai/bootstrap-feature.mjs +15 -0
- package/runtime/js/cm-ai/claude-review-stream.mjs +30 -0
- package/runtime/js/cm-ai/cm-ai-admission.mjs +116 -41
- package/runtime/js/cm-ai/cm-ai-context-refresh.mjs +3 -2
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +137 -22
- package/runtime/js/cm-ai/cm-ai-learning-handoff-writer.mjs +11 -9
- package/runtime/js/cm-ai/cm-ai-learning-writer.mjs +22 -5
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +180 -53
- package/runtime/js/cm-ai/cm-ai-run-finalizer.mjs +2 -1
- package/runtime/js/cm-ai/codex-review-adapter.mjs +24 -4
- package/runtime/js/cm-ai/developer-adapter.mjs +6 -2
- package/runtime/js/cm-ai/diagnostic-reason.mjs +10 -0
- package/runtime/js/cm-ai/drive-bootstrap.mjs +305 -0
- package/runtime/js/cm-ai/drive-core.mjs +39 -7
- package/runtime/js/cm-ai/durable-runner-state.mjs +307 -53
- package/runtime/js/cm-ai/effect-abandon-log.mjs +19 -0
- package/runtime/js/cm-ai/effect-contract.mjs +44 -2
- package/runtime/js/cm-ai/execution-store-limits.mjs +18 -0
- package/runtime/js/cm-ai/execution-store.mjs +6 -4
- package/runtime/js/cm-ai/fix-code-association.mjs +171 -18
- package/runtime/js/cm-ai/host-bootstrap.mjs +68 -21
- package/runtime/js/cm-ai/host-conversation-execution.mjs +16 -4
- package/runtime/js/cm-ai/host-handoff.mjs +13 -6
- package/runtime/js/cm-ai/host-qa-executor.mjs +21 -7
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +4 -4
- package/runtime/js/cm-ai/host-qa-policy.mjs +16 -7
- package/runtime/js/cm-ai/host-session.mjs +20 -5
- package/runtime/js/cm-ai/host-tool-bridge.mjs +1 -1
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +13 -4
- package/runtime/js/cm-ai/host.mjs +1 -1
- package/runtime/js/cm-ai/launch-mismatch.mjs +42 -0
- package/runtime/js/cm-ai/log-rows.mjs +21 -0
- package/runtime/js/cm-ai/project-qa-gate.mjs +84 -0
- package/runtime/js/cm-ai/provider-review-observation.mjs +53 -9
- package/runtime/js/cm-ai/qa-config-revision.mjs +44 -10
- package/runtime/js/cm-ai/review-abandon-log.mjs +21 -0
- package/runtime/js/cm-ai/review-package.mjs +427 -31
- package/runtime/js/cm-ai/review-runner.mjs +47 -1
- package/runtime/js/cm-ai/reviewed-deliveries.mjs +97 -0
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +104 -10
- package/runtime/js/cm-ai/reviewed-evidence-supersession-record.mjs +42 -3
- package/runtime/js/cm-ai/specification-material.mjs +154 -12
- package/runtime/js/cm-ai/task-commit.mjs +2 -2
- package/runtime/js/cm-ai/task-runner.mjs +502 -65
- package/runtime/js/cm-ai/worker-claude-developer.mjs +16 -7
- package/runtime/js/cm-fix/execution.mjs +109 -25
- package/runtime/js/cm-fix/host-review.mjs +7 -3
- package/runtime/js/cm-fix/host.mjs +3 -1
- package/runtime/js/cm-fix/progress.mjs +1 -0
- package/runtime/js/cm-fix/protected-edits.mjs +15 -4
- package/runtime/js/cm-fix/qa-source.mjs +6 -4
- package/runtime/js/cm-prd/analysis.mjs +2 -1
- package/runtime/js/cm-prd/change.mjs +28 -10
- package/runtime/js/cm-prd/draft.mjs +5 -2
- package/runtime/js/cm-prd/review-preparation.mjs +10 -3
- package/runtime/js/cm-prd/review-publication.mjs +4 -2
- package/runtime/js/cm-prd/self-check.mjs +6 -3
- package/runtime/js/cm-prd/summary.mjs +6 -2
- package/runtime/js/cm-prd/validation-reason.mjs +20 -0
- package/runtime/js/spec-task-line.mjs +117 -0
- package/runtime/js/specs-status.mjs +14 -3
- package/scripts/cm-ai-abandon-effect-position.test.mjs +201 -0
- package/scripts/cm-ai-admission.mjs +19 -10
- package/scripts/cm-ai-admission.test.mjs +65 -1
- package/scripts/cm-ai-batch-drive.mjs +93 -21
- package/scripts/cm-ai-batch-drive.test.mjs +171 -3
- package/scripts/cm-ai-batch-host.mjs +37 -13
- package/scripts/cm-ai-batch-host.test.mjs +26 -0
- package/scripts/cm-ai-batch-run.mjs +33 -10
- package/scripts/cm-ai-batch-run.test.mjs +56 -5
- package/scripts/cm-ai-bootstrap-driver-preflight.test.mjs +45 -0
- package/scripts/cm-ai-bootstrap-flow.test.mjs +158 -0
- package/scripts/cm-ai-bootstrap-merge.test.mjs +45 -0
- package/scripts/cm-ai-bootstrap.test.mjs +99 -7
- package/scripts/cm-ai-conversation-entry-ops.test.mjs +82 -2
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +822 -0
- package/scripts/cm-ai-drive-bootstrap-rules.test.mjs +468 -0
- package/scripts/cm-ai-drive-timeout.test.mjs +17 -0
- package/scripts/cm-ai-drive.mjs +480 -47
- package/scripts/cm-ai-drive.test.mjs +247 -10
- package/scripts/cm-ai-fix-later-delivery.test.mjs +383 -0
- package/scripts/cm-ai-host.mjs +89 -25
- package/scripts/cm-ai-host.test.mjs +274 -12
- package/scripts/cm-ai-launch-diagnostics.test.mjs +142 -0
- package/scripts/cm-ai-multi-root.test.mjs +9 -3
- package/scripts/cm-ai-project-qa-gate.test.mjs +308 -0
- package/scripts/cm-ai-qa-config-revision.test.mjs +166 -15
- package/scripts/cm-ai-qa-fingerprint-config.test.mjs +157 -0
- package/scripts/cm-ai-qa-fix-cross-session.test.mjs +27 -2
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +400 -0
- package/scripts/cm-ai-review-drift-precedence.test.mjs +90 -0
- package/scripts/cm-ai-review-failure.test.mjs +917 -0
- package/scripts/cm-ai-review-timeout-config.test.mjs +29 -7
- package/scripts/cm-ai-review-timeout.test.mjs +199 -4
- package/scripts/cm-ai-run.mjs +160 -60
- package/scripts/cm-ai-run.test.mjs +4 -3
- package/scripts/cm-ai-runner-error-code-regression.test.mjs +219 -0
- package/scripts/cm-ai-selection-guard.test.mjs +100 -0
- package/scripts/cm-ai-session-chain.test.mjs +7 -3
- package/scripts/cm-ai-spec-rebind.test.mjs +481 -0
- package/scripts/cm-ai-supersede.test.mjs +571 -17
- package/scripts/cm-ai-verification-gate.test.mjs +2 -1
- package/scripts/cm-capability-gate.test.mjs +21 -2
- package/scripts/cm-check-drive.mjs +4 -3
- package/scripts/cm-check-drive.test.mjs +17 -1
- package/scripts/cm-check-entry.mjs +13 -2
- package/scripts/cm-check-host.mjs +2 -2
- package/scripts/cm-check-host.test.mjs +57 -1
- package/scripts/cm-check-runtime.sh +16 -7
- package/scripts/cm-claude-developer-worker.test.mjs +43 -2
- package/scripts/cm-claude-probe.test.mjs +9 -1
- package/scripts/cm-claude-review-stream.test.mjs +68 -0
- package/scripts/cm-claude-worker.test.mjs +11 -4
- package/scripts/cm-codex-developer-worker.test.mjs +4 -2
- package/scripts/cm-failover.mjs +8 -8
- package/scripts/cm-fix-abandon.test.mjs +123 -5
- package/scripts/cm-fix-cause-package.test.mjs +2 -0
- package/scripts/cm-fix-drive.mjs +45 -13
- package/scripts/cm-fix-drive.test.mjs +36 -1
- package/scripts/cm-fix-host.mjs +9 -6
- package/scripts/cm-fix-review-budget.test.mjs +141 -0
- package/scripts/cm-fixture-process-cleanup.test.mjs +95 -0
- package/scripts/cm-host-check.test.mjs +6 -3
- package/scripts/cm-host-qa-executor.test.mjs +192 -17
- package/scripts/cm-host-session-diagnostic.test.mjs +10 -0
- package/scripts/cm-interactive-qa-diagnostic.test.mjs +53 -0
- package/scripts/cm-log-event.mjs +17 -0
- package/scripts/cm-log-event.test.mjs +31 -0
- package/scripts/cm-prd-completion.test.mjs +105 -2
- package/scripts/cm-prd-draft.test.mjs +14 -0
- package/scripts/cm-prd-drive.mjs +13 -7
- package/scripts/cm-prd-drive.test.mjs +10 -0
- package/scripts/cm-prd-gate-diagnostic.test.mjs +100 -0
- package/scripts/cm-prd-review-gate.mjs +126 -81
- package/scripts/cm-prd-review-gate.test.mjs +105 -1
- package/scripts/cm-prd-review-preparation.test.mjs +15 -0
- package/scripts/cm-prd-review-publication.test.mjs +6 -0
- package/scripts/cm-prd-self-check.test.mjs +6 -0
- package/scripts/cm-prd-summary.test.mjs +40 -0
- package/scripts/cm-review-dependency-snapshot.test.mjs +15 -0
- package/scripts/cm-review-inventory.test.mjs +253 -1
- package/scripts/cm-spec-manifest.mjs +28 -10
- package/scripts/cm-spec-manifest.test.mjs +8 -4
- package/scripts/cm-spec-task-line.test.mjs +138 -0
- package/scripts/cm-specs-status.test.mjs +31 -1
- package/scripts/cm-task-gate.mjs +18 -10
- package/scripts/cm-task-gate.py +1 -1
- package/scripts/cm-test-branch-impact.test.mjs +6 -3
- package/scripts/fixtures/claude-review-process.mjs +1 -0
- package/scripts/fixtures/process-cleanup.mjs +99 -0
- package/scripts/test-cm-log-event.py +2 -0
- package/scripts/test-cm-prd-review-gate.py +2 -1
- package/scripts/test-npm-install.py +1 -1
- package/scripts/test-scan-public-safety.py +1 -1
- package/scripts/test-shell-compat.sh +67 -0
- package/scripts/test-spec-manifest.py +16 -8
- package/scripts/test-task-gate.py +2 -2
- package/scripts/test-workflow-config.py +1 -0
- package/scripts/validate-public-repo.py +1 -0
- package/skills/cm-ai/references/N1-init.md +1 -1
- package/skills/cm-ai/references/js-host.md +264 -40
- package/skills/cm-check/SKILL.md +6 -1
- package/skills/cm-check/references/js-host.md +3 -3
- package/skills/cm-fix/references/js-host.md +22 -1
- package/skills/cm-prd/references/js-change-recovery.md +30 -0
- package/skills/cm-prd/references/js-host.md +6 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
1
|
+
import test,{after} from 'node:test';
|
|
2
2
|
import assert from 'node:assert/strict';
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
import os from 'node:os';
|
|
@@ -14,6 +14,15 @@ import {createFixReviewHost} from '../runtime/js/cm-fix/host-review.mjs';
|
|
|
14
14
|
import {configFingerprint} from '../runtime/js/cm-ai/codex-config.mjs';
|
|
15
15
|
import {fixHandoffEvidence,fixDefectHandoffEvidence} from '../runtime/js/cm-fix/handoff.mjs';
|
|
16
16
|
|
|
17
|
+
// Never write the real ~/.cm-workflow home or its global log from this suite.
|
|
18
|
+
const isolatedHome=fs.mkdtempSync(path.join(os.tmpdir(),'cm-fix-abandon-home-'));
|
|
19
|
+
const savedHome={CM_WORKFLOW_HOME:process.env.CM_WORKFLOW_HOME,CM_WORKFLOW_LOG_HOME:process.env.CM_WORKFLOW_LOG_HOME};
|
|
20
|
+
process.env.CM_WORKFLOW_HOME=path.join(isolatedHome,'home');process.env.CM_WORKFLOW_LOG_HOME=path.join(isolatedHome,'logs');
|
|
21
|
+
after(()=>{
|
|
22
|
+
for(const [key,value] of Object.entries(savedHome)){if(value===undefined)delete process.env[key];else process.env[key]=value;}
|
|
23
|
+
fs.rmSync(isolatedHome,{recursive:true,force:true});
|
|
24
|
+
});
|
|
25
|
+
|
|
17
26
|
const diagnosis={status:'diagnosed',rootCause:'Wrong value',affectedPaths:['value.mjs'],
|
|
18
27
|
affectedModules:['value'],plan:'Correct value',crossLayer:false};
|
|
19
28
|
|
|
@@ -41,11 +50,13 @@ async function fixture(t,{observation=false,reviewMode=null,crossLayer=false,les
|
|
|
41
50
|
permissions:['--allow-final-review','--allow-cause-review','--allow-repair'],workerFactory:()=>async({prompt},{onEvent})=>{
|
|
42
51
|
reviews++;
|
|
43
52
|
const data=JSON.parse(prompt.split('<cm-review-data-json>\n')[1]);
|
|
44
|
-
onEvent({event:'thread.started',provider_thread:`fixture-review-${reviews}`});
|
|
45
|
-
if(reviewMode==='lost'||
|
|
53
|
+
onEvent({event:'thread.started',provider_thread:`fixture-review-${reviewMode==='first_lost_same_thread'?1:reviews}`});
|
|
54
|
+
if(reviewMode==='lost'||['second_lost','second_lost_retry'].includes(reviewMode)&&reviews===2
|
|
55
|
+
||['first_lost','first_lost_same_thread'].includes(reviewMode)&&reviews===1)throw Error('Synthetic lost review result');
|
|
46
56
|
for(const event of [{event:'turn.started',item_type:null},{event:'item.completed',item_type:'agent_message'},
|
|
47
57
|
{event:'turn.completed',item_type:null},{event:'process_closed',exit_code:0,signal:null,timed_out:false}])onEvent(event);
|
|
48
|
-
const verdict=['changes_requested','second_lost'].includes(reviewMode)
|
|
58
|
+
const verdict=['changes_requested','second_lost'].includes(reviewMode)||reviewMode==='second_lost_retry'&&reviews===1
|
|
59
|
+
?'changes_requested':'approved';
|
|
49
60
|
return {status:'succeeded',value:{verdict,packageDigest:data.reviewPackage.packageDigest,
|
|
50
61
|
examinedPaths:data.examinedPaths,
|
|
51
62
|
findings:verdict==='changes_requested'?[{id:'F1',severity:'P2',path:'value.mjs',message:'Revise value',evidence:'Fixture'}]:[],
|
|
@@ -60,7 +71,7 @@ async function fixture(t,{observation=false,reviewMode=null,crossLayer=false,les
|
|
|
60
71
|
return crossLayer?{...diagnosis,crossLayer:true}:diagnosis;
|
|
61
72
|
}
|
|
62
73
|
if(kind==='fix_repair'){
|
|
63
|
-
if(['changes_requested','second_lost'].includes(reviewMode)&&payload.identity.attempt===2&&loseRevisionRepair){
|
|
74
|
+
if(['changes_requested','second_lost','second_lost_retry'].includes(reviewMode)&&payload.identity.attempt===2&&loseRevisionRepair){
|
|
64
75
|
loseRevisionRepair=false;throw Error('Lost revision repair answer');
|
|
65
76
|
}
|
|
66
77
|
fs.writeFileSync(path.join(cwd,'value.mjs'),payload.identity.attempt===2?'export const value=2; // revised\n':'export const value=2;\n');
|
|
@@ -381,3 +392,110 @@ test('revision final review cannot use local abandonment',async t=>{
|
|
|
381
392
|
assert.equal(f.owner().status().pending,'revision_final_review');
|
|
382
393
|
assert.throws(()=>f.owner().abandonStep({authorized:true,reason:'Review result lost'}),{code:'fix_abandon_unavailable'});
|
|
383
394
|
});
|
|
395
|
+
|
|
396
|
+
// #15: a registered cause or second-round final review with no review result
|
|
397
|
+
// gets one audited abandonment and a retry on a fresh reviewer thread.
|
|
398
|
+
const causeDecide=async f=>{const pkg=f.owner().causeReviewPackage();
|
|
399
|
+
await f.reviewHost.authority.hostDecisionProvider.decide({identity:f.identity,packageDigest:pkg.packageDigest},new AbortController().signal);};
|
|
400
|
+
const reviewEvents=f=>fs.readFileSync(path.join(f.specsRoot,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse)
|
|
401
|
+
.filter(row=>row.event==='abandon');
|
|
402
|
+
|
|
403
|
+
test('#15 a no-result cause review is abandoned once, audited, and retried on a fresh reviewer thread',async t=>{
|
|
404
|
+
const f=await fixture(t,{reviewMode:'first_lost',crossLayer:true});
|
|
405
|
+
assert.equal((await f.owner().advance({authorized:true})).stage,'cause_review_required');
|
|
406
|
+
await causeDecide(f);
|
|
407
|
+
const lost=await f.owner().reviewCause();
|
|
408
|
+
assert.equal(lost.stage,'unknown');assert.equal(lost.pending,'cause_review');assert.equal(lost.reviewAbandonable,'cause_review');
|
|
409
|
+
const before=fs.readFileSync(f.statePath);
|
|
410
|
+
assert.throws(()=>f.owner().abandonStep({authorized:true,reason:'Review result lost'}),{code:'fix_abandon_unavailable'});
|
|
411
|
+
assert.throws(()=>f.owner().abandonReview({authorized:false,reason:'Review result lost'}),{code:'fix_review_abandon_authorization_required'});
|
|
412
|
+
assert.throws(()=>f.owner().abandonReview({authorized:true,reason:'two\nlines'}),{code:'fix_review_abandon_reason_required'});
|
|
413
|
+
assert.deepEqual(fs.readFileSync(f.statePath),before);
|
|
414
|
+
const abandoned=f.owner().abandonReview({authorized:true,reason:'Reviewer process confirmed stopped'});
|
|
415
|
+
assert.equal(abandoned.stage,'cause_review_required');
|
|
416
|
+
assert.equal(abandoned.causeReviewAbandonment.providerThreadId,'fixture-review-1');
|
|
417
|
+
assert.equal(abandoned.causeReviewAbandonment.resultDigest,null);
|
|
418
|
+
assert.equal(f.reopen().status().stage,'cause_review_required');
|
|
419
|
+
await causeDecide(f);
|
|
420
|
+
assert.equal((await f.owner().reviewCause()).stage,'red_test_required');
|
|
421
|
+
const ids=f.records().map(row=>row.id).filter(id=>id.startsWith('fix-cause'));
|
|
422
|
+
assert.deepEqual(ids,['fix-cause-registered','fix-cause-started','fix-cause-abandoned',
|
|
423
|
+
'fix-cause-retry-registered','fix-cause-retry-started','fix-cause-retry-result']);
|
|
424
|
+
assert.equal(f.records().find(row=>row.id==='fix-cause-retry-started').payload.providerThreadId,'fixture-review-2');
|
|
425
|
+
assert.equal(f.reviews(),2);
|
|
426
|
+
assert(fs.existsSync(path.join(f.specsRoot,'.reviews','fix-abandon-cause-r1.md')));
|
|
427
|
+
assert.deepEqual(reviewEvents(f).map(row=>[row.phase,row.pending,row.reason]),[['cause_review','cause_review','Reviewer process confirmed stopped']]);
|
|
428
|
+
assert.equal(f.reopen().status().stage,'red_test_required');
|
|
429
|
+
assert.equal(f.owner().status().causeReview.providerThreadId,'fixture-review-2');
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
test('#15 a second no-result cause review exhausts the one-time budget without changing the store',async t=>{
|
|
433
|
+
const f=await fixture(t,{reviewMode:'lost',crossLayer:true});
|
|
434
|
+
await f.owner().advance({authorized:true});await causeDecide(f);
|
|
435
|
+
assert.equal((await f.owner().reviewCause()).stage,'unknown');
|
|
436
|
+
f.owner().abandonReview({authorized:true,reason:'First reviewer stopped'});
|
|
437
|
+
await causeDecide(f);
|
|
438
|
+
const again=await f.owner().reviewCause();
|
|
439
|
+
assert.equal(again.stage,'unknown');assert.equal(again.reviewAbandonBudgetExhausted,true);assert.equal(again.reviewAbandonable,undefined);
|
|
440
|
+
const before=fs.readFileSync(f.statePath);
|
|
441
|
+
assert.throws(()=>f.owner().abandonReview({authorized:true,reason:'Second reviewer stopped'}),{code:'fix_review_abandon_budget_exhausted'});
|
|
442
|
+
assert.deepEqual(fs.readFileSync(f.statePath),before);
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
test('#15 an abandonment record must bind the exact registration and thread',async t=>{
|
|
446
|
+
const f=await fixture(t,{reviewMode:'lost',crossLayer:true});
|
|
447
|
+
await f.owner().advance({authorized:true});await causeDecide(f);await f.owner().reviewCause();
|
|
448
|
+
const registration=f.records().find(row=>row.id==='fix-cause-registered');
|
|
449
|
+
const forged={invocationId:registration.payload.request.invocationId,registrationDigest:'0'.repeat(64),
|
|
450
|
+
providerThreadId:'fixture-review-1',resultDigest:null,reason:'Forged',abandonedAt:Date.now()};
|
|
451
|
+
assert.throws(()=>f.append('fix-cause-abandoned','result',forged),{code:'fix_review_abandon_mismatch'});
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
test('#15 the fix host needs the dedicated --allow-abandon-review for abandon_review and its status points to it',async t=>{
|
|
455
|
+
const f=await fixture(t,{reviewMode:'lost',crossLayer:true});
|
|
456
|
+
await f.owner().advance({authorized:true});await causeDecide(f);await f.owner().reviewCause();
|
|
457
|
+
const config={...f.configuration,specsRoot:f.specsRoot,identity:f.identity};
|
|
458
|
+
// Local step abandonment authority does not extend to a reviewer invocation.
|
|
459
|
+
for(const permissions of [['--allow-reproduction'],['--allow-reproduction','--allow-abandon']]){
|
|
460
|
+
const refused=createFixHost({owner:f.owner(),config,permissions});
|
|
461
|
+
await assert.rejects(refused.handle({requestId:'abandon',operation:'abandon_review',reason:'Stopped'}),{code:'fix_review_abandon_authorization_required'});
|
|
462
|
+
}
|
|
463
|
+
const allowed=createFixHost({owner:f.owner(),config,permissions:['--allow-reproduction','--allow-abandon-review']});
|
|
464
|
+
assert.match((await allowed.handle({requestId:'status',operation:'status'})).progress.nextAction,/abandon_review/);
|
|
465
|
+
assert.equal((await allowed.handle({requestId:'abandon',operation:'abandon_review',reason:'Stopped'})).stage,'cause_review_required');
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
test('#15 a no-result second-round final review is abandoned once and retried on a fresh thread',async t=>{
|
|
469
|
+
const f=await fixture(t,{reviewMode:'second_lost_retry'});
|
|
470
|
+
await toRevision(f);await completeRevisionRepair(f);
|
|
471
|
+
await f.owner().runRegression({authorized:true});await f.owner().retrospect();
|
|
472
|
+
assert.equal(f.owner().createHandoff().stage,'revision_final_review_required');
|
|
473
|
+
const decide=async()=>{const pkg=f.owner().finalReviewPackage();
|
|
474
|
+
await f.reviewHost.finalAuthority.hostDecisionProvider.decide({identity:f.owner().status().revision.nextIdentity,
|
|
475
|
+
packageDigest:pkg.packageDigest},new AbortController().signal);};
|
|
476
|
+
await decide();
|
|
477
|
+
const lost=await f.owner().reviewFinal();
|
|
478
|
+
assert.equal(lost.stage,'unknown');assert.equal(lost.pending,'revision_final_review');
|
|
479
|
+
assert.equal(lost.reviewAbandonable,'revision_final_review');
|
|
480
|
+
assert.equal(f.owner().abandonReview({authorized:true,reason:'Second reviewer stopped'}).stage,'revision_final_review_required');
|
|
481
|
+
assert.equal(f.reopen().status().stage,'revision_final_review_required');
|
|
482
|
+
await decide();
|
|
483
|
+
assert.equal((await f.owner().reviewFinal()).stage,'revision_final_review_evidence_required');
|
|
484
|
+
const ids=f.records().map(row=>row.id).filter(id=>id.startsWith('fix-revision-final'));
|
|
485
|
+
assert.deepEqual(ids,['fix-revision-final-registered','fix-revision-final-started','fix-revision-final-abandoned',
|
|
486
|
+
'fix-revision-final-retry-registered','fix-revision-final-retry-started','fix-revision-final-retry-result']);
|
|
487
|
+
assert.notEqual(f.records().find(row=>row.id==='fix-revision-final-retry-started').payload.providerThreadId,
|
|
488
|
+
f.records().find(row=>row.id==='fix-revision-final-started').payload.providerThreadId);
|
|
489
|
+
assert.equal(f.owner().publishReview().stage,'revision_completion_gate_required');
|
|
490
|
+
assert.equal(f.reopen().status().stage,'revision_completion_gate_required');
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
test('#15 the retried cause review refuses the abandoned reviewer thread',async t=>{
|
|
494
|
+
const f=await fixture(t,{reviewMode:'first_lost_same_thread',crossLayer:true});
|
|
495
|
+
await f.owner().advance({authorized:true});await causeDecide(f);await f.owner().reviewCause();
|
|
496
|
+
f.owner().abandonReview({authorized:true,reason:'Reviewer process confirmed stopped'});
|
|
497
|
+
await causeDecide(f);
|
|
498
|
+
const reused=await f.owner().reviewCause();
|
|
499
|
+
assert.equal(reused.stage,'unknown');assert.equal(reused.pending,'cause_review');
|
|
500
|
+
assert(!f.records().some(row=>row.id==='fix-cause-retry-started'));
|
|
501
|
+
});
|
|
@@ -57,6 +57,8 @@ test('cause package binds only selected current source and never advances the fi
|
|
|
57
57
|
requestedModel:'synthetic',contextId:'logical-review',payload:{reviewPackage:first,priorReview:null}});
|
|
58
58
|
assert.match(buildCauseReviewPrompt(request,provider),/pre-implementation review/);
|
|
59
59
|
assert.match(buildCauseReviewPrompt(request,provider),/Rewrite all callers/);
|
|
60
|
+
assert.match(buildCauseReviewPrompt(request,provider),/approved requires zero P0, P1 and P2 findings/);
|
|
61
|
+
assert.match(buildCauseReviewPrompt(request,provider),/changes_requested requires at least one P0, P1 or P2 finding/);
|
|
60
62
|
assert.throws(()=>buildReviewPrompt(request,provider));
|
|
61
63
|
const expectation=JSON.stringify({request,developerThreadId:'author',excludedThreadIds:['fixture-host']});
|
|
62
64
|
const observation={version:1,kind:'cm-provider-review-observation',requestDigest:request.requestDigest,
|
package/scripts/cm-fix-drive.mjs
CHANGED
|
@@ -21,20 +21,22 @@
|
|
|
21
21
|
// "runtime": "codex" | "claude", 缺省 codex
|
|
22
22
|
// "reviewConfig": "review.json", 可选
|
|
23
23
|
// "permissions": ["--allow-red-test", ...], 原样传给宿主,不另造一套词
|
|
24
|
-
// "answers": "answers", 答案目录;abandon_step 可省略
|
|
25
|
-
// "reason": "旧本地步骤结果丢失" abandon_step
|
|
24
|
+
// "answers": "answers", 答案目录;abandon_step / abandon_review 可省略
|
|
25
|
+
// "reason": "旧本地步骤结果丢失" abandon_step 必填并需 --allow-abandon;abandon_review 必填并需 --allow-abandon-review
|
|
26
|
+
// "inputLimit": 1048576 可选;宿主输入与应答上限(65536–4194304,默认 65536)
|
|
26
27
|
// }
|
|
27
28
|
//
|
|
28
29
|
// answers/ 里按反问种类放文件,一种一个:
|
|
29
30
|
// learning.json {status, summary} 恢复时若存档里已有记录会自动复用
|
|
30
31
|
// diagnosis.json 诊断结论对象
|
|
31
32
|
// retrospective.json {status, candidates, reason}
|
|
32
|
-
// test-edits.json {"仓库内路径": "本目录下的内容文件"}
|
|
33
|
-
// repair-edits.json
|
|
33
|
+
// test-edits.json {"仓库内路径": "本目录下的内容文件"};修订轮用 test-edits-a2.json
|
|
34
|
+
// repair-edits.json 同上;修订轮用 repair-edits-a2.json
|
|
34
35
|
import fs from 'node:fs';
|
|
35
36
|
import path from 'node:path';
|
|
36
37
|
import {fileURLToPath} from 'node:url';
|
|
37
38
|
import {fixEvidenceNames} from '../runtime/js/cm-fix/layout.mjs';
|
|
39
|
+
import {readExecutionSnapshot} from '../runtime/js/cm-ai/execution-snapshot.mjs';
|
|
38
40
|
import {stderr,stop,readJson,loadPlanFile,requireFields,preflightAnswers,driveHost} from '../runtime/js/cm-ai/drive-core.mjs';
|
|
39
41
|
|
|
40
42
|
const here=path.dirname(fileURLToPath(import.meta.url));
|
|
@@ -55,18 +57,22 @@ const ASKS={
|
|
|
55
57
|
const READ_ONLY=new Set(['status','final_review_package','completion_evidence','cause_review_package']);
|
|
56
58
|
const KNOWN=new Set([...Object.keys(ASKS),...READ_ONLY,'cancel','handoff','publish_review','check_n5',
|
|
57
59
|
'publish_dossier','learning_writeback','walkthrough','finish','final_review','cause_review',
|
|
58
|
-
'recover_final_review','abandon_step','resume','revision_test_check']);
|
|
60
|
+
'recover_final_review','abandon_step','abandon_review','resume','revision_test_check']);
|
|
59
61
|
|
|
60
62
|
function loadPlan(){
|
|
61
63
|
const {operation,plan,base}=loadPlanFile({name:'cm-fix-drive.mjs',known:KNOWN});
|
|
62
|
-
|
|
64
|
+
const abandoning=['abandon_step','abandon_review'].includes(operation);
|
|
65
|
+
requireFields(plan,['config','cwd','mode','hostContext','permissions',...(abandoning?[]:['answers'])]);
|
|
63
66
|
if(!['create','resume'].includes(plan.mode))stop(2,'mode 只能是 create 或 resume');
|
|
64
67
|
if(!Array.isArray(plan.permissions)||plan.permissions.some(p=>!/^--allow-[a-z-]+$/.test(p)))
|
|
65
68
|
stop(2,'permissions 必须是 --allow-xxx 形式的数组,原样传给宿主');
|
|
66
|
-
|
|
69
|
+
const abandonFlag=operation==='abandon_review'?'--allow-abandon-review':'--allow-abandon';
|
|
70
|
+
if(abandoning&&(!plan.permissions.includes(abandonFlag)||typeof plan.reason!=='string'
|
|
67
71
|
||!plan.reason.trim().length||Buffer.byteLength(plan.reason,'utf8')>1000||/[\r\n\0\u0085\u2028\u2029]/.test(plan.reason)))
|
|
68
|
-
stop(2
|
|
72
|
+
stop(2,`${operation} 需要 PLAN.reason(单行,最多 1000 字节)和 ${abandonFlag}`);
|
|
69
73
|
if(plan.originalHostContext&&plan.mode!=='resume')stop(2,'originalHostContext 只在 resume 时有意义');
|
|
74
|
+
if(Object.hasOwn(plan,'inputLimit')&&!(Number.isSafeInteger(plan.inputLimit)&&plan.inputLimit>=65536&&plan.inputLimit<=4194304))
|
|
75
|
+
stop(2,'inputLimit 需要 65536–4194304 的整数(字节)');
|
|
70
76
|
const resolve=p=>path.resolve(base,p);
|
|
71
77
|
return {operation,plan,paths:{config:resolve(plan.config),answers:plan.answers?resolve(plan.answers):null,
|
|
72
78
|
review:plan.reviewConfig?resolve(plan.reviewConfig):null}};
|
|
@@ -81,12 +87,33 @@ function recordedLearning(config,cwd){
|
|
|
81
87
|
const record=stored?.records?.find(row=>row.kind==='result'&&/^fix-learning-/.test(row.id));
|
|
82
88
|
return record?.payload?.application??null;
|
|
83
89
|
}
|
|
90
|
+
function answerRound(config,operation,cwd){
|
|
91
|
+
if(!['repair','author_tests'].includes(operation))return 1;
|
|
92
|
+
const archive=config.specsRoot??path.join(cwd,'docs','fixes');
|
|
93
|
+
const state=path.join(archive,'.reviews','.execution',config.identity.runId,'state.json');
|
|
94
|
+
if(!fs.existsSync(state))return 1;
|
|
95
|
+
try{
|
|
96
|
+
const snapshot=readExecutionSnapshot({specsRoot:archive,identity:{
|
|
97
|
+
repositoryId:config.identity.repositoryId,runId:config.identity.runId}});
|
|
98
|
+
return snapshot.records.some(row=>row.id==='fix-revision-prepared')?2:1;
|
|
99
|
+
}catch(error){stop(2,`无法只读检查 cm-fix 修订轮次: ${error.code??error.message}`);}
|
|
100
|
+
}
|
|
101
|
+
function roundAnswerName(root,kind,round){
|
|
102
|
+
const legacy=`${kind}.json`,first=`${kind}-a1.json`;
|
|
103
|
+
if(round===1){
|
|
104
|
+
if(fs.existsSync(path.join(root,legacy))&&fs.existsSync(path.join(root,first)))
|
|
105
|
+
stop(2,`${legacy} 与 ${first} 不能同时存在`);
|
|
106
|
+
return fs.existsSync(path.join(root,first))?first:legacy;
|
|
107
|
+
}
|
|
108
|
+
return `${kind}-a${round}.json`;
|
|
109
|
+
}
|
|
84
110
|
|
|
85
111
|
function preflight({operation,plan,paths}){
|
|
86
112
|
const config=readJson(paths.config,'宿主配置');
|
|
87
113
|
if(config===undefined)stop(2,`宿主配置不存在: ${paths.config}`);
|
|
88
114
|
if(path.resolve(plan.cwd)!==path.resolve(config.reproduction?.cwd??''))
|
|
89
115
|
stop(2,`PLAN.cwd 与 config.reproduction.cwd 不一致`);
|
|
116
|
+
const round=answerRound(config,operation,plan.cwd);
|
|
90
117
|
const need=(kind,file)=>{const value=readJson(path.join(paths.answers,file),kind);
|
|
91
118
|
if(value===undefined)stop(2,`步骤 ${operation} 会反问「${kind}」,但答案文件不存在: ${path.join(paths.answers,file)}\n 先把它写好,再来调驾驱员。缺答案而硬发指令,会把这次运行做死。`);
|
|
92
119
|
return value;};
|
|
@@ -98,7 +125,8 @@ function preflight({operation,plan,paths}){
|
|
|
98
125
|
}
|
|
99
126
|
if(kind==='diagnosis')return need('诊断','diagnosis.json');
|
|
100
127
|
if(kind==='retrospective')return need('复盘','retrospective.json');
|
|
101
|
-
const
|
|
128
|
+
const file=roundAnswerName(paths.answers,kind,round);
|
|
129
|
+
const map=need(kind==='test-edits'?'测试内容':'修复内容',file);
|
|
102
130
|
for(const [target,local] of Object.entries(map)){
|
|
103
131
|
const file=path.join(paths.answers,local);
|
|
104
132
|
if(!fs.existsSync(file))stop(2,`${kind}.json 把 ${target} 指向 ${file},但那个文件不存在`);
|
|
@@ -125,13 +153,14 @@ function preflight({operation,plan,paths}){
|
|
|
125
153
|
stderr(`注意:受保护模式的沙箱跑不了 tsx / vitest 这类要开本地 socket 的命令:${command.join(' ')}\n 见 skills/cm-fix/references/js-host.md「同仓 specs 的受保护修复」`);
|
|
126
154
|
}
|
|
127
155
|
}
|
|
128
|
-
return {config,answers};
|
|
156
|
+
return {config,answers,round};
|
|
129
157
|
}
|
|
130
158
|
|
|
131
159
|
function hostArgs({plan,paths}){
|
|
132
160
|
return [HOST,'serve','--config',paths.config,'--mode',plan.mode,'--host-context',plan.hostContext,'--allow-reproduction',
|
|
133
161
|
...(plan.originalHostContext?['--original-host-context',plan.originalHostContext]:[]),
|
|
134
162
|
'--runtime',plan.runtime??'codex',
|
|
163
|
+
...(Object.hasOwn(plan,'inputLimit')?['--input-limit',String(plan.inputLimit)]:[]),
|
|
135
164
|
...(paths.review?['--review-config',paths.review]:[]),
|
|
136
165
|
...plan.permissions];
|
|
137
166
|
}
|
|
@@ -142,6 +171,9 @@ function answerFor(row,answers,paths){
|
|
|
142
171
|
if(kind==='fix_diagnose')return answers.diagnosis;
|
|
143
172
|
if(kind==='fix_retrospective')return answers.retrospective;
|
|
144
173
|
if(kind==='fix_test_author'||kind==='fix_repair'){
|
|
174
|
+
const requestAttempt=payload.identity?.attempt??payload.request?.identity?.attempt;
|
|
175
|
+
if(requestAttempt!==undefined&&requestAttempt!==paths.round)
|
|
176
|
+
throw Error(`修订轮次 ${requestAttempt} 与已预检答案轮次 ${paths.round} 不一致`);
|
|
145
177
|
const map=answers[kind==='fix_repair'?'repair-edits':'test-edits'],expected=payload.expected??{};
|
|
146
178
|
const edits=[];
|
|
147
179
|
for(const [target,local] of Object.entries(map)){
|
|
@@ -157,12 +189,12 @@ function answerFor(row,answers,paths){
|
|
|
157
189
|
|
|
158
190
|
function main(){
|
|
159
191
|
const loaded=loadPlan();
|
|
160
|
-
const {answers}=preflight(loaded);
|
|
192
|
+
const {answers,round}=preflight(loaded);
|
|
161
193
|
const {operation,plan,paths}=loaded;
|
|
162
194
|
driveHost({host:HOST,args:hostArgs(loaded).slice(1),cwd:path.resolve(plan.cwd),operation,
|
|
163
|
-
request:{...(
|
|
195
|
+
request:{...(['abandon_step','abandon_review'].includes(operation)?{reason:plan.reason}:{}),
|
|
164
196
|
...(operation==='prepare_revision'&&Object.hasOwn(plan,'revisionTests')?{tests:plan.revisionTests}:{})},
|
|
165
|
-
answers,paths,answerFor});
|
|
197
|
+
answers,paths:{...paths,round},answerFor});
|
|
166
198
|
}
|
|
167
199
|
|
|
168
200
|
main();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
1
|
+
import test,{after} from 'node:test';
|
|
2
2
|
import assert from 'node:assert/strict';
|
|
3
3
|
import {spawnSync} from 'node:child_process';
|
|
4
4
|
import fs from 'node:fs';
|
|
@@ -10,6 +10,15 @@ import {openFixExecution} from '../runtime/js/cm-fix/execution.mjs';
|
|
|
10
10
|
import {openExecutionStore} from '../runtime/js/cm-ai/execution-store.mjs';
|
|
11
11
|
import {startFixRun} from '../runtime/js/cm-fix/start.mjs';
|
|
12
12
|
|
|
13
|
+
// Never write the real ~/.cm-workflow home or its global log from this suite.
|
|
14
|
+
const isolatedHome=fs.mkdtempSync(path.join(os.tmpdir(),'cm-fix-drive-home-'));
|
|
15
|
+
const savedHome={CM_WORKFLOW_HOME:process.env.CM_WORKFLOW_HOME,CM_WORKFLOW_LOG_HOME:process.env.CM_WORKFLOW_LOG_HOME};
|
|
16
|
+
process.env.CM_WORKFLOW_HOME=path.join(isolatedHome,'home');process.env.CM_WORKFLOW_LOG_HOME=path.join(isolatedHome,'logs');
|
|
17
|
+
after(()=>{
|
|
18
|
+
for(const [key,value] of Object.entries(savedHome)){if(value===undefined)delete process.env[key];else process.env[key]=value;}
|
|
19
|
+
fs.rmSync(isolatedHome,{recursive:true,force:true});
|
|
20
|
+
});
|
|
21
|
+
|
|
13
22
|
// 驾驭员是宿主的中间人:开进程、发一条指令、代答反问、打结果。它的价值有两条要
|
|
14
23
|
// 拿真宿主验:确实能把一轮开起来并走下去;答案没备齐时停在发指令之前,不把运行做死。
|
|
15
24
|
const DRIVER=fileURLToPath(new URL('./cm-fix-drive.mjs',import.meta.url));
|
|
@@ -115,3 +124,29 @@ test('the driver abandons a local unknown step using only plan reason and flag',
|
|
|
115
124
|
assert.equal(JSON.parse(result.stdout).result.stage,'reproduce');
|
|
116
125
|
assert(JSON.parse(fs.readFileSync(statePath)).records.some(row=>row.id==='fix-abandoned-1'));
|
|
117
126
|
});
|
|
127
|
+
test('#15 the driver refuses abandon_review without plan reason and --allow-abandon-review before launching the host',{skip},t=>{
|
|
128
|
+
const f=fixture(t);
|
|
129
|
+
for(const plan of [f.plan({mode:'resume',permissions:[],reason:'Reviewer stopped',answers:undefined}),
|
|
130
|
+
f.plan({mode:'resume',permissions:['--allow-abandon'],reason:'Reviewer stopped',answers:undefined}),
|
|
131
|
+
f.plan({mode:'resume',permissions:['--allow-abandon-review'],answers:undefined})]){
|
|
132
|
+
const refused=drive(plan,'abandon_review');
|
|
133
|
+
assert.equal(refused.status,2);assert.match(refused.stderr,/abandon_review 需要 PLAN\.reason/);
|
|
134
|
+
}
|
|
135
|
+
assert.equal(fs.existsSync(path.join(f.archive,'.reviews')),false);
|
|
136
|
+
});
|
|
137
|
+
test('revision repair requires its own answer before launching the host',{skip},t=>{
|
|
138
|
+
const f=fixture(t);
|
|
139
|
+
fs.writeFileSync(path.join(f.answers,'learning.json'),JSON.stringify(learning));
|
|
140
|
+
fs.writeFileSync(path.join(f.answers,'diagnosis.json'),JSON.stringify(diagnosis));
|
|
141
|
+
assert.equal(drive(f.plan(),'advance').status,0);
|
|
142
|
+
const statePath=path.join(f.archive,'.reviews','.execution','drive-demo','state.json');
|
|
143
|
+
const state=JSON.parse(fs.readFileSync(statePath));
|
|
144
|
+
const store=openExecutionStore({specsRoot:f.archive,identity:state.identity,fingerprints:state.fingerprints,create:false});
|
|
145
|
+
store.append({id:'fix-revision-prepared',kind:'result',payload:{nextIdentity:{...state.identity,attempt:2}},
|
|
146
|
+
expectedRevision:store.snapshot().revision});store.close();
|
|
147
|
+
fs.writeFileSync(path.join(f.answers,'repair-edits.json'),JSON.stringify({'value.mjs':'repair.txt'}));
|
|
148
|
+
const before=fs.readFileSync(statePath);
|
|
149
|
+
const run=drive(f.plan({mode:'resume',permissions:['--allow-repair']}),'repair');
|
|
150
|
+
assert.equal(run.status,2,run.stderr);assert.match(run.stderr,/repair-edits-a2\.json/);
|
|
151
|
+
assert.deepEqual(fs.readFileSync(statePath),before);
|
|
152
|
+
});
|
package/scripts/cm-fix-host.mjs
CHANGED
|
@@ -6,12 +6,12 @@ import {openFixExecution} from '../runtime/js/cm-fix/execution.mjs';
|
|
|
6
6
|
import {createFixHost} from '../runtime/js/cm-fix/host.mjs';
|
|
7
7
|
import {createFixLearningPreparation} from '../runtime/js/cm-fix/learning.mjs';
|
|
8
8
|
import {createHostToolBridge} from '../runtime/js/cm-ai/host-tool-bridge.mjs';
|
|
9
|
-
import {serveCmAiHost} from '../runtime/js/cm-ai/host-session.mjs';
|
|
9
|
+
import {serveCmAiHost,parseHostInputLimit,inputLimitReason} from '../runtime/js/cm-ai/host-session.mjs';
|
|
10
10
|
import {id,json,need,shape,digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
11
11
|
import {readConversationReviewConfiguration} from './cm-ai-host.mjs';
|
|
12
12
|
import {createFixReviewHost} from '../runtime/js/cm-fix/host-review.mjs';
|
|
13
13
|
|
|
14
|
-
const usage='cm-fix-host.mjs serve --config PATH --mode create|resume --host-context ID --allow-reproduction [--original-host-context ID] [--runtime codex|claude] [--review-config PATH] [--allow-cause-review] [--allow-final-review] [--allow-test-author] [--allow-red-test] [--allow-baseline] [--allow-repair] [--allow-regression] [--allow-learning-writeback]\nCodex or Claude current-host operations: prepare_revision, revision_test_check, advance, cause_review_package, cause_review, author_tests, red_test, baseline, repair, regression, retrospective, learning_writeback, handoff, final_review_package, final_review, publish_review, check_n5, post_review_regression, status, cancel. Runtime defaults to codex; claude uses its own matching diagnostic receipt and cannot reuse Codex preflight or disabledSkills settings. Runtime selection is bound to recovery; switching providers requires a separate run. This selects existing adapters, not permission to call them. Each write/check needs its respective launch flag and configuration. Test authoring, repair, cause and final review dispatch require matching existing stdin diagnostics; diagnostic alone is not authorization. Passing regression stops at handoff_required. The read-only retrospective operation yields handoff_ready or learning_writeback_required. learning_writeback requires its own flag, preserves project instructions and includes AGENTS.md in the review scope; it does not authorize provider calls. handoff publishes the fixed specs-local handoff with Learning evidence and moves to final_review_required; no provider is called and no task is completed. final_review_package is read-only and returns the final content-bound review package. final_review requires its own flag and matching diagnostics; observations do not complete the task. publish_review projects the registered result into the existing review file; it does not dispatch or complete tasks. check_n5 runs the original Learning-aware gate; post_review_regression requires --allow-regression and reaches closeout_required, not completion.';
|
|
14
|
+
const usage='cm-fix-host.mjs serve --config PATH --mode create|resume --host-context ID --allow-reproduction [--original-host-context ID] [--runtime codex|claude] [--input-limit BYTES] [--review-config PATH] [--allow-cause-review] [--allow-final-review] [--allow-test-author] [--allow-red-test] [--allow-baseline] [--allow-repair] [--allow-regression] [--allow-learning-writeback]\nCodex or Claude current-host operations: prepare_revision, revision_test_check, advance, cause_review_package, cause_review, author_tests, red_test, baseline, repair, regression, retrospective, learning_writeback, handoff, final_review_package, final_review, publish_review, check_n5, post_review_regression, status, cancel. Runtime defaults to codex; claude uses its own matching diagnostic receipt and cannot reuse Codex preflight or disabledSkills settings. Runtime selection is bound to recovery; switching providers requires a separate run. This selects existing adapters, not permission to call them. Each write/check needs its respective launch flag and configuration. Test authoring, repair, cause and final review dispatch require matching existing stdin diagnostics; diagnostic alone is not authorization. Passing regression stops at handoff_required. The read-only retrospective operation yields handoff_ready or learning_writeback_required. learning_writeback requires its own flag, preserves project instructions and includes AGENTS.md in the review scope; it does not authorize provider calls. handoff publishes the fixed specs-local handoff with Learning evidence and moves to final_review_required; no provider is called and no task is completed. final_review_package is read-only and returns the final content-bound review package. final_review requires its own flag and matching diagnostics; observations do not complete the task. publish_review projects the registered result into the existing review file; it does not dispatch or complete tasks. check_n5 runs the original Learning-aware gate; post_review_regression requires --allow-regression and reaches closeout_required, not completion.';
|
|
15
15
|
|
|
16
16
|
export async function main(argv=process.argv.slice(2),{input=process.stdin,output=process.stdout,error=process.stderr,reviewWorkerFactory=null}={}){
|
|
17
17
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('Design-change escalation: approved cause_review reaches design_change_required when redTest is configured (test_author_required first if needed); author_tests/red_test keep their original flags and evidence checks. Confirmed red reaches escalation_required, never baseline/repair/regression. Non-visual runs without redTest reach escalation_required directly after approval and record why no failing test exists. Visual runs require a matching visual redTest with testFiles:[] and must complete the visual red step before escalation; opening without it fails with fix_visual_configuration_required. publish_dossier saves an 升级立项 dossier; finish requires --allow-finish, records run_done phase escalation/result escalated and closes the owner with escalationRunEnded:true. Retained tests become acceptance checks for the suggested $cm-prd --change. Resume the same run after a crash; conflicting exits fail with fix_escalation_exit_conflict. Terminal escalated is not completed: no task_done, metrics, repair or parent QA completion.\n');
|
|
@@ -20,6 +20,7 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
20
20
|
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');
|
|
21
21
|
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, missing-thread recovery, business-revision recovery or source-drift bypass. status adds a read-only progress projection, not authorization or current-source verification.\n');
|
|
22
22
|
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');
|
|
23
|
+
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 the cause review once and the second-round final review once, 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');
|
|
23
24
|
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');
|
|
24
25
|
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');
|
|
25
26
|
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');
|
|
@@ -31,7 +32,7 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
31
32
|
need(['create','resume'].includes(argv[4]),'invalid_arguments');id(argv[6]);
|
|
32
33
|
const extra=new Map();
|
|
33
34
|
for(let index=8;index<argv.length;index++){
|
|
34
|
-
const flag=argv[index];need(!extra.has(flag)&&['--runtime','--review-config','--original-host-context','--final-review-recovery-invocation','--allow-qa-fix','--allow-cause-review','--allow-final-review','--allow-final-review-recovery','--allow-abandon','--allow-red-test','--allow-baseline','--allow-test-author','--allow-repair','--allow-regression','--allow-learning-writeback','--allow-walkthrough','--allow-finish'].includes(flag),'invalid_arguments');
|
|
35
|
+
const flag=argv[index];need(!extra.has(flag)&&['--runtime','--input-limit','--review-config','--original-host-context','--final-review-recovery-invocation','--allow-qa-fix','--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');
|
|
35
36
|
if(flag.startsWith('--allow-'))extra.set(flag,true);
|
|
36
37
|
else{need(typeof argv[index+1]==='string'&&!argv[index+1].startsWith('--'),'invalid_arguments');extra.set(flag,argv[++index]);}
|
|
37
38
|
}
|
|
@@ -43,6 +44,8 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
43
44
|
const recoveryInvocationId=extra.get('--final-review-recovery-invocation')??null;
|
|
44
45
|
if(recoveryInvocationId!==null){id(recoveryInvocationId);need(extra.has('--allow-final-review-recovery'),'fix_review_recovery_authorization_required');}
|
|
45
46
|
const runtime=extra.get('--runtime')??'codex';need(['codex','claude'].includes(runtime),'invalid_runtime');
|
|
47
|
+
// Transport only, like the cm-ai hosts: lines and tool replies share one limit.
|
|
48
|
+
const inputLimit=parseHostInputLimit(extra.get('--input-limit'));
|
|
46
49
|
const review=extra.has('--review-config')?readConversationReviewConfiguration(extra.get('--review-config')):null;
|
|
47
50
|
need(runtime!=='claude'||!review||review.disabledSkills.length===0,'invalid_review_config');
|
|
48
51
|
need(!extra.has('--allow-cause-review')||review!==null,'review_configuration_required');
|
|
@@ -66,7 +69,7 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
66
69
|
const {reviewer,authority,finalAuthority,execution:reviewExecution}=createFixReviewHost({
|
|
67
70
|
codeProject:config.reproduction.cwd,hostContextId:argv[6],runtime,review,
|
|
68
71
|
permissions:[...extra.keys()],workerFactory:reviewWorkerFactory});
|
|
69
|
-
bridge=createHostToolBridge();
|
|
72
|
+
bridge=createHostToolBridge({responseLimit:inputLimit});
|
|
70
73
|
owner=openFixExecution({specsRoot:config.specsRoot??null,identity:config.identity,create:argv[4]==='create',
|
|
71
74
|
hostContextId:argv[6],
|
|
72
75
|
configuration:{hostContextId:originalHostContext??argv[6],defect:config.defect,reproduction:config.reproduction,
|
|
@@ -86,12 +89,12 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
86
89
|
const host=createFixHost({owner,config,runtime,permissions:[...extra.keys(),'--allow-reproduction'],authority,finalAuthority,recoveryInvocationId});
|
|
87
90
|
const rawMode=input.isTTY&&typeof input.setRawMode==='function';
|
|
88
91
|
if(rawMode)input.setRawMode(true);
|
|
89
|
-
try{await serveCmAiHost({host,input,output,toolBridge:bridge});}
|
|
92
|
+
try{await serveCmAiHost({host,input,output,toolBridge:bridge,inputLimit});}
|
|
90
93
|
finally{if(rawMode)input.setRawMode(false);}
|
|
91
94
|
return 0;
|
|
92
95
|
}catch(cause){
|
|
93
96
|
const code=typeof cause?.code==='string'&&/^[a-z][a-z0-9_]{0,63}$/.test(cause.code)?cause.code:'fix_host_failed';
|
|
94
|
-
error.write(JSON.stringify({error:{code}})+'\n');return 1;
|
|
97
|
+
error.write(JSON.stringify({error:{code,...(code==='request_too_large'?{reason:inputLimitReason(cause.limit)}:{})}})+'\n');return 1;
|
|
95
98
|
}finally{bridge?.close();owner?.close();}
|
|
96
99
|
}
|
|
97
100
|
if(process.argv[1]&&fs.realpathSync(process.argv[1])===fileURLToPath(import.meta.url))process.exitCode=await main();
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// #15: cm-fix reviews wait for their own budget, record a timeout, and survive a
|
|
2
|
+
// host killed mid-review through one audited abandonment.
|
|
3
|
+
import test,{after} from 'node:test';
|
|
4
|
+
import assert from 'node:assert/strict';
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import os from 'node:os';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import {spawn} from 'node:child_process';
|
|
9
|
+
import {fileURLToPath} from 'node:url';
|
|
10
|
+
import {openFixExecution} from '../runtime/js/cm-fix/execution.mjs';
|
|
11
|
+
import {createHostReviewAuthority} from '../runtime/js/cm-ai/host-review-authority.mjs';
|
|
12
|
+
import {createCauseReviewRun} from '../runtime/js/cm-ai/codex-review-adapter.mjs';
|
|
13
|
+
import {createFixReviewHost} from '../runtime/js/cm-fix/host-review.mjs';
|
|
14
|
+
import {configFingerprint} from '../runtime/js/cm-ai/codex-config.mjs';
|
|
15
|
+
import {buildCmAiDriveRequest} from './cm-ai-drive.mjs';
|
|
16
|
+
|
|
17
|
+
const isolated=fs.mkdtempSync(path.join(os.tmpdir(),'cm-fix-review-budget-'));
|
|
18
|
+
const saved={CM_WORKFLOW_HOME:process.env.CM_WORKFLOW_HOME,CM_WORKFLOW_LOG_HOME:process.env.CM_WORKFLOW_LOG_HOME};
|
|
19
|
+
process.env.CM_WORKFLOW_HOME=path.join(isolated,'home');process.env.CM_WORKFLOW_LOG_HOME=path.join(isolated,'logs');
|
|
20
|
+
after(()=>{
|
|
21
|
+
for(const [key,value] of Object.entries(saved)){if(value===undefined)delete process.env[key];else process.env[key]=value;}
|
|
22
|
+
fs.rmSync(isolated,{recursive:true,force:true});
|
|
23
|
+
});
|
|
24
|
+
const moduleUrl=relative=>new URL(relative,import.meta.url).href;
|
|
25
|
+
const identity={repositoryId:'fixture',runId:'cause-budget-run',taskId:'T-FIX-cause',attempt:1};
|
|
26
|
+
const reviewer={reviewerId:'cause-reviewer',adapterId:'codex-review-adapter',provider:'codex',requestedModel:'synthetic',
|
|
27
|
+
contextId:'logical-review',excludedThreadIds:['other-author']};
|
|
28
|
+
const diagnosis={status:'diagnosed',rootCause:'Cross-layer constant',plan:'Correct after red test',affectedPaths:['value.mjs'],
|
|
29
|
+
affectedModules:['value'],crossLayer:true};
|
|
30
|
+
|
|
31
|
+
function fixture(){
|
|
32
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(isolated,'run-')));
|
|
33
|
+
const cwd=path.join(root,'code'),specsRoot=path.join(root,'specs');fs.mkdirSync(cwd);fs.mkdirSync(specsRoot);
|
|
34
|
+
fs.writeFileSync(path.join(cwd,'value.mjs'),'export const value=1;');
|
|
35
|
+
// The reproduction budget deliberately differs from the review budget below.
|
|
36
|
+
const options={specsRoot,identity,create:true,configuration:{hostContextId:'fixture-host',defect:'Synthetic value mismatch',causeReview:reviewer,
|
|
37
|
+
reproduction:{cwd,command:[process.execPath,'-e',"process.stderr.write('BUG');process.exit(3)"],
|
|
38
|
+
expectedFailure:{exitCode:3,outputIncludes:'BUG'},timeoutMs:3000}}};
|
|
39
|
+
const authority=createHostReviewAuthority({hostContextId:'fixture-host',reviewerId:reviewer.reviewerId,adapterId:reviewer.adapterId,
|
|
40
|
+
decide:async()=>({status:'approved'})});
|
|
41
|
+
const state={calls:0,hang:true};
|
|
42
|
+
const run=createCauseReviewRun(async({prompt},{onEvent})=>{
|
|
43
|
+
state.calls++;const data=JSON.parse(prompt.split('<cm-review-data-json>\n')[1]);
|
|
44
|
+
onEvent({event:'thread.started',provider_thread:`fresh-review-${state.calls}`});
|
|
45
|
+
if(state.hang)return new Promise(()=>{});
|
|
46
|
+
for(const event of [{event:'turn.started',item_type:null},{event:'item.completed',item_type:'agent_message'},
|
|
47
|
+
{event:'turn.completed',item_type:null},{event:'process_closed',exit_code:0,signal:null,timed_out:false}])onEvent(event);
|
|
48
|
+
return {status:'succeeded',value:{verdict:'approved',packageDigest:data.reviewPackage.packageDigest,
|
|
49
|
+
examinedPaths:['value.mjs'],findings:[],summary:'No finding in synthetic package'}};
|
|
50
|
+
},'codex');
|
|
51
|
+
const statePath=path.join(specsRoot,'.reviews','.execution',identity.runId,'state.json');
|
|
52
|
+
return {root,cwd,specsRoot,options,authority,state,run,statePath,records:()=>JSON.parse(fs.readFileSync(statePath)).records,
|
|
53
|
+
bridge:{async call(){return diagnosis;}}};
|
|
54
|
+
}
|
|
55
|
+
async function decide(f,owner){
|
|
56
|
+
const pkg=owner.causeReviewPackage();
|
|
57
|
+
await f.authority.hostDecisionProvider.decide({identity,packageDigest:pkg.packageDigest},new AbortController().signal);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
test('#15 the cause review waits for its own budget, then records the timeout instead of stopping at unknown forever',async()=>{
|
|
61
|
+
const f=fixture(),causeReview={authorize:f.authority.authorize,run:f.run,timeoutMs:1000};
|
|
62
|
+
let owner=openFixExecution(f.options,{causeReview,bridge:f.bridge});
|
|
63
|
+
try{
|
|
64
|
+
assert.equal((await owner.advance({authorized:true})).stage,'cause_review_required');
|
|
65
|
+
await decide(f,owner);const started=Date.now();
|
|
66
|
+
const timedOut=await owner.reviewCause();
|
|
67
|
+
const elapsed=Date.now()-started;
|
|
68
|
+
assert(elapsed>=950&&elapsed<2500,`the review budget (1000 ms), not the reproduction budget (3000 ms), applies: ${elapsed}`);
|
|
69
|
+
assert.equal(timedOut.stage,'unknown');assert.equal(timedOut.pending,null);
|
|
70
|
+
assert.equal(timedOut.causeReview.code,'transport_timeout');assert.equal(timedOut.reviewAbandonable,'cause_review');
|
|
71
|
+
assert.deepEqual(f.records().map(row=>row.id).filter(id=>id.startsWith('fix-cause')),
|
|
72
|
+
['fix-cause-registered','fix-cause-started','fix-cause-result']);
|
|
73
|
+
owner.close();owner=openFixExecution({...f.options,create:false},{causeReview,bridge:f.bridge});
|
|
74
|
+
const result=f.records().find(row=>row.id==='fix-cause-result');
|
|
75
|
+
const abandoned=owner.abandonReview({authorized:true,reason:'Reviewer exceeded its budget and was stopped'});
|
|
76
|
+
assert.equal(abandoned.stage,'cause_review_required');
|
|
77
|
+
assert.equal(abandoned.causeReviewAbandonment.resultDigest.length,64);
|
|
78
|
+
assert.equal(abandoned.causeReviewAbandonment.providerThreadId,'fresh-review-1');
|
|
79
|
+
assert.notEqual(result,undefined);
|
|
80
|
+
f.state.hang=false;await decide(f,owner);
|
|
81
|
+
assert.equal((await owner.reviewCause()).stage,'red_test_required');assert.equal(f.state.calls,2);
|
|
82
|
+
}finally{owner.close();}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('#15 a host killed during the cause review leaves an abandonable registration, and the retry completes',async()=>{
|
|
86
|
+
const f=fixture();
|
|
87
|
+
// The child is a real separate host process: it registers and starts the
|
|
88
|
+
// review, then is killed before any result is written.
|
|
89
|
+
const child=spawn(process.execPath,['--input-type=module','-e',`
|
|
90
|
+
const {openFixExecution}=await import(${JSON.stringify(moduleUrl('../runtime/js/cm-fix/execution.mjs'))});
|
|
91
|
+
const {createHostReviewAuthority}=await import(${JSON.stringify(moduleUrl('../runtime/js/cm-ai/host-review-authority.mjs'))});
|
|
92
|
+
const {createCauseReviewRun}=await import(${JSON.stringify(moduleUrl('../runtime/js/cm-ai/codex-review-adapter.mjs'))});
|
|
93
|
+
const options=${JSON.stringify(f.options)},reviewer=options.configuration.causeReview;
|
|
94
|
+
const authority=createHostReviewAuthority({hostContextId:'fixture-host',reviewerId:reviewer.reviewerId,adapterId:reviewer.adapterId,decide:async()=>({status:'approved'})});
|
|
95
|
+
const run=createCauseReviewRun(async(request,{onEvent})=>{onEvent({event:'thread.started',provider_thread:'killed-review'});
|
|
96
|
+
process.stdout.write('STARTED\\n');return new Promise(()=>{});},'codex');
|
|
97
|
+
const owner=openFixExecution(options,{causeReview:{authorize:authority.authorize,run,timeoutMs:600000},
|
|
98
|
+
bridge:{async call(){return ${JSON.stringify(diagnosis)};}}});
|
|
99
|
+
await owner.advance({authorized:true});const pkg=owner.causeReviewPackage();
|
|
100
|
+
await authority.hostDecisionProvider.decide({identity:options.identity,packageDigest:pkg.packageDigest},new AbortController().signal);
|
|
101
|
+
await owner.reviewCause();`],{env:process.env,stdio:['ignore','pipe','inherit']});
|
|
102
|
+
await new Promise((resolve,reject)=>{
|
|
103
|
+
child.stdout.on('data',chunk=>{if(String(chunk).includes('STARTED'))resolve();});
|
|
104
|
+
child.on('exit',code=>reject(new Error(`child exited early: ${code}`)));
|
|
105
|
+
});
|
|
106
|
+
const exited=new Promise(resolve=>child.on('exit',resolve));child.kill('SIGKILL');await exited;
|
|
107
|
+
assert.deepEqual(f.records().map(row=>row.id).filter(id=>id.startsWith('fix-cause')),['fix-cause-registered','fix-cause-started']);
|
|
108
|
+
f.state.hang=false;
|
|
109
|
+
const owner=openFixExecution({...f.options,create:false},{causeReview:{authorize:f.authority.authorize,run:f.run,timeoutMs:5000},bridge:f.bridge});
|
|
110
|
+
try{
|
|
111
|
+
const stuck=owner.status();
|
|
112
|
+
assert.equal(stuck.stage,'unknown');assert.equal(stuck.pending,'cause_review');assert.equal(stuck.reviewAbandonable,'cause_review');
|
|
113
|
+
assert.equal(owner.abandonReview({authorized:true,reason:'Host process was killed; reviewer confirmed gone'}).stage,'cause_review_required');
|
|
114
|
+
await decide(f,owner);
|
|
115
|
+
assert.equal((await owner.reviewCause()).stage,'red_test_required');
|
|
116
|
+
assert.equal(f.records().find(row=>row.id==='fix-cause-retry-started').payload.providerThreadId,'fresh-review-1');
|
|
117
|
+
}finally{owner.close();}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test('#15 the shipped review host hands its review budget to the owner and the reviewer worker',()=>{
|
|
121
|
+
const codeProject=fs.realpathSync(fs.mkdtempSync(path.join(isolated,'host-')));
|
|
122
|
+
const review=timeoutMs=>({model:'synthetic',disabledSkills:[],...(timeoutMs?{timeoutMs}:{}),preflight:{passed:true,cli_model:'synthetic',prompt_transport:'stdin',
|
|
123
|
+
config_fingerprint:configFingerprint({cwd:codeProject,model:'synthetic',disabledSkills:[],promptTransport:'stdin'})}});
|
|
124
|
+
const seen=[];
|
|
125
|
+
const host=timeoutMs=>createFixReviewHost({codeProject,hostContextId:'host',review:review(timeoutMs),permissions:['--allow-cause-review'],
|
|
126
|
+
workerFactory:options=>{seen.push(options.timeoutMs);return async()=>({status:'failed',code:'unused'});}});
|
|
127
|
+
const configured=host(1234).execution;
|
|
128
|
+
assert.equal(configured.causeReview.timeoutMs,1234);assert.equal(configured.finalReview.timeoutMs,1234);
|
|
129
|
+
const defaulted=host(null).execution;
|
|
130
|
+
assert.equal(defaulted.causeReview.timeoutMs,900000);assert.equal(defaulted.finalReview.timeoutMs,900000);
|
|
131
|
+
// The worker is built with the budget before the adapter validates the request.
|
|
132
|
+
assert.throws(()=>configured.causeReview.run({},{signal:new AbortController().signal,onEvent:()=>true}),{code:'invalid_input'});
|
|
133
|
+
assert.deepEqual(seen,[1234]);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
test('#15 the cm-ai driver forwards the QA-fix abandon_review reason inside fix_action',()=>{
|
|
137
|
+
const plan={packageDigest:'a'.repeat(64),testRunId:'qa-run',fixOperation:'abandon_review',reason:'Child reviewer stopped'};
|
|
138
|
+
const identity={repositoryId:'r',runId:'run',taskId:'T-1',attempt:1};
|
|
139
|
+
assert.deepEqual(buildCmAiDriveRequest('fix_action',plan,{identity}),{version:1,identity,packageDigest:plan.packageDigest,
|
|
140
|
+
testRunId:plan.testRunId,fixOperation:'abandon_review',reason:plan.reason});
|
|
141
|
+
});
|