@aibyzero/cm-workflow 0.16.9 → 0.17.1
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 +4 -0
- package/CHANGELOG.md +18 -1
- package/CONTRIBUTING.md +47 -0
- package/README.md +16 -1
- package/VERSION +1 -1
- package/docs/architecture.md +29 -13
- package/docs/cm-control-policy-v2.md +331 -0
- package/docs/execution-optimizations.md +1 -1
- package/docs/external-models.md +3 -3
- package/docs/fixes/20261013-claude-preinit-ui-invalidate.md +48 -0
- package/docs/human-correction.md +5 -5
- package/docs/installation.md +1 -1
- package/docs/js-workflow-control.md +104 -85
- package/docs/next-steps.md +11 -0
- package/docs/untested-branches.md +2 -3
- package/docs/user-guide.md +3 -3
- package/package.json +1 -1
- package/runtime/js/cm-ai/claude-review-stream.mjs +12 -8
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +13 -69
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +10 -5
- package/runtime/js/cm-ai/control-policy.mjs +112 -0
- package/runtime/js/cm-ai/drive-bootstrap.mjs +11 -8
- package/runtime/js/cm-ai/drive-core.mjs +124 -25
- package/runtime/js/cm-ai/durable-runner-state.mjs +32 -126
- package/runtime/js/cm-ai/gate-bridge.mjs +4 -4
- package/runtime/js/cm-ai/host-check.mjs +3 -1
- package/runtime/js/cm-ai/host-conversation-execution.mjs +22 -20
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +11 -2
- package/runtime/js/cm-ai/host-qa-policy.mjs +63 -21
- package/runtime/js/cm-ai/host-review-authority.mjs +2 -2
- package/runtime/js/cm-ai/host-review-file.mjs +1 -1
- package/runtime/js/cm-ai/host-session.mjs +41 -8
- package/runtime/js/cm-ai/host-stage-observer.mjs +26 -0
- package/runtime/js/cm-ai/host-tool-bridge.mjs +25 -9
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +21 -10
- package/runtime/js/cm-ai/host.mjs +1 -2
- package/runtime/js/cm-ai/operator-guidance.mjs +57 -54
- package/runtime/js/cm-ai/review-package.mjs +16 -4
- package/runtime/js/cm-ai/reviewed-deliveries.mjs +1 -1
- package/runtime/js/cm-ai/task-runner.mjs +41 -101
- package/runtime/js/cm-init/review-evidence.mjs +3 -1
- package/runtime/js/cm-prd/review-host.mjs +1 -1
- package/runtime/js/cm-prd/review-publication.mjs +5 -3
- package/runtime/js/cm-prd/summary.mjs +27 -12
- package/runtime/js/cm-refactor/workflow.mjs +1 -1
- package/runtime/js/notify-send.mjs +15 -14
- package/runtime/js/notify.mjs +27 -4
- package/runtime/js/policy-binding-compat.mjs +2 -1
- package/runtime/review.md +61 -7
- package/runtime/task-gates.md +107 -9
- package/scripts/cm-ai-abandon-effect-position.test.mjs +1 -8
- package/scripts/cm-ai-answer-gap-driver.test.mjs +12 -12
- package/scripts/cm-ai-answer-gap-fixture.mjs +1 -8
- package/scripts/cm-ai-batch-drive.mjs +50 -31
- package/scripts/cm-ai-batch-drive.test.mjs +62 -19
- package/scripts/cm-ai-batch-host.mjs +39 -20
- package/scripts/cm-ai-batch-host.test.mjs +83 -47
- package/scripts/cm-ai-batch-run-fixture.mjs +6 -53
- package/scripts/cm-ai-batch-run-member-stops.test.mjs +0 -12
- package/scripts/cm-ai-batch-run.mjs +46 -14
- package/scripts/cm-ai-bootstrap-flow.test.mjs +1 -7
- package/scripts/cm-ai-bootstrap.test.mjs +2 -3
- package/scripts/cm-ai-control-launch.test.mjs +219 -0
- package/scripts/cm-ai-control-policy.test.mjs +192 -0
- package/scripts/cm-ai-control-v2-drive.test.mjs +270 -0
- package/scripts/cm-ai-develop-answer-invalid.test.mjs +1 -8
- package/scripts/cm-ai-develop-call-timeout.test.mjs +1 -8
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +33 -20
- package/scripts/cm-ai-direct-review.test.mjs +348 -0
- package/scripts/cm-ai-documentation-sync-gap.test.mjs +3 -3
- package/scripts/cm-ai-drive-bootstrap-rules.test.mjs +57 -27
- package/scripts/cm-ai-drive.mjs +96 -54
- package/scripts/cm-ai-drive.test.mjs +46 -87
- package/scripts/cm-ai-fix-integration.test.mjs +3 -5
- package/scripts/cm-ai-fix-later-delivery.test.mjs +3 -6
- package/scripts/cm-ai-fix-run-delivery.test.mjs +3 -6
- package/scripts/cm-ai-host-cli-workflow.test.mjs +6 -10
- package/scripts/cm-ai-host-fixture.mjs +47 -16
- package/scripts/cm-ai-host-protected.test.mjs +35 -33
- package/scripts/cm-ai-host.mjs +103 -93
- package/scripts/cm-ai-host.test.mjs +34 -18
- package/scripts/cm-ai-launch-diagnostics.test.mjs +5 -3
- package/scripts/cm-ai-legacy-history.test.mjs +53 -0
- package/scripts/cm-ai-light-modules.test.mjs +4 -7
- package/scripts/cm-ai-multi-root.test.mjs +4 -4
- package/scripts/cm-ai-nested-execution.test.mjs +16 -19
- package/scripts/cm-ai-operator-guidance.test.mjs +56 -0
- package/scripts/cm-ai-progress.test.mjs +10 -8
- package/scripts/cm-ai-project-qa-gate.test.mjs +37 -10
- package/scripts/cm-ai-protected-scope.test.mjs +1 -2
- package/scripts/cm-ai-qa-config-revision.test.mjs +1 -9
- package/scripts/cm-ai-qa-fingerprint-config.test.mjs +12 -9
- package/scripts/cm-ai-qa-fix-cross-session.test.mjs +18 -3
- package/scripts/cm-ai-qa-fixed-log.test.mjs +41 -0
- package/scripts/cm-ai-qa-recovery-args.test.mjs +7 -0
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +3 -4
- package/scripts/cm-ai-review-drift-precedence.test.mjs +1 -1
- package/scripts/cm-ai-review-failure.test.mjs +13 -19
- package/scripts/cm-ai-review-timeout-config.test.mjs +3 -1
- package/scripts/cm-ai-review-timeout.test.mjs +35 -128
- package/scripts/cm-ai-run.mjs +78 -24
- package/scripts/cm-ai-run.test.mjs +11 -38
- package/scripts/cm-ai-selection-guard.test.mjs +2 -2
- package/scripts/cm-ai-session-chain.test.mjs +18 -15
- package/scripts/cm-ai-spec-rebind.test.mjs +14 -18
- package/scripts/cm-ai-supersede.test.mjs +3 -10
- package/scripts/cm-blocked-reason.test.mjs +2 -3
- package/scripts/cm-capability-gate.test.mjs +33 -1
- package/scripts/cm-check-drive-files.mjs +1 -1
- package/scripts/cm-check-host.test.mjs +1 -1
- package/scripts/cm-check-runtime.sh +1 -1
- package/scripts/cm-claude-probe.test.mjs +26 -0
- package/scripts/cm-claude-review-stream.test.mjs +36 -0
- package/scripts/cm-claude-worker.test.mjs +21 -3
- package/scripts/cm-controlled-correction.test.mjs +469 -0
- package/scripts/cm-drive-liveness.test.mjs +83 -0
- package/scripts/cm-external-batch-host.test.mjs +38 -17
- package/scripts/cm-external-model-host.test.mjs +1 -1
- package/scripts/cm-external-model-recovery.test.mjs +3 -9
- package/scripts/cm-external-qa-fix.test.mjs +1 -1
- package/scripts/cm-external-review-reconciliation.test.mjs +6 -24
- package/scripts/cm-fix-review-recovery.test.mjs +1 -1
- package/scripts/cm-host-diagnostic.test.mjs +33 -0
- package/scripts/cm-host-liveness.test.mjs +150 -0
- package/scripts/cm-host-qa-executor.test.mjs +1 -2
- package/scripts/cm-host-qa-policy.test.mjs +43 -16
- package/scripts/cm-host-review-authority.test.mjs +0 -31
- package/scripts/cm-host-stage-observer.test.mjs +41 -0
- package/scripts/cm-knowledge-closeout.test.mjs +3 -3
- package/scripts/cm-notify-command.test.mjs +54 -18
- package/scripts/cm-notify-read-drift.test.mjs +69 -4
- package/scripts/cm-notify.mjs +16 -4
- package/scripts/cm-notify.test.mjs +135 -29
- package/scripts/cm-patrol.test.mjs +3 -2
- package/scripts/cm-prd-drive.test.mjs +1 -1
- package/scripts/cm-prd-self-check-revision.test.mjs +15 -0
- package/scripts/cm-prd-session-recovery.test.mjs +5 -3
- package/scripts/cm-prd-summary.test.mjs +31 -0
- package/scripts/cm-release-smoke.sh +2 -14
- package/scripts/cm-task-gate-correction.test.mjs +69 -16
- package/scripts/cm-task-gate.mjs +368 -34
- package/scripts/cm-task-gate.py +2 -0
- package/scripts/cm-task-gate.test.mjs +252 -4
- package/scripts/cm-test-suite.mjs +109 -0
- package/scripts/cm-test-suite.test.mjs +162 -0
- package/scripts/fixtures/bootstrap-review-runner.mjs +1 -7
- package/scripts/fixtures/host-diagnostic.mjs +33 -0
- package/scripts/fixtures/native-gate-fixture.mjs +18 -0
- package/scripts/policy-binding-compat.test.mjs +4 -0
- package/skills/cm-ai/SKILL.md +8 -6
- package/skills/cm-ai/references/N3-execute-task.md +17 -2
- package/skills/cm-ai/references/N4-review.md +11 -21
- package/skills/cm-ai/references/N5-mark-done.md +1 -1
- package/skills/cm-ai/references/N6-qa-eval.md +49 -21
- package/skills/cm-ai/references/js-host-modes.md +35 -14
- package/skills/cm-ai/references/js-host-qa-recovery.md +60 -12
- package/skills/cm-ai/references/js-host-recovery.md +95 -47
- package/skills/cm-ai/references/js-host.md +98 -29
- package/skills/cm-fix/SKILL.md +12 -0
- package/skills/cm-init/references/js-host.md +1 -1
- package/skills/cm-prd/references/js-host.md +1 -1
- package/skills/cm-refactor/SKILL.md +12 -0
- package/runtime/js/cm-ai/review-dispatch-limits.mjs +0 -18
- package/scripts/cm-ai-review-dispatch-exit.test.mjs +0 -475
package/scripts/cm-ai-drive.mjs
CHANGED
|
@@ -38,7 +38,7 @@ import path from 'node:path';
|
|
|
38
38
|
import {createHash} from 'node:crypto';
|
|
39
39
|
import {fileURLToPath} from 'node:url';
|
|
40
40
|
import {createHostCheck,reportHostCheckProgress} from '../runtime/js/cm-ai/host-check.mjs';
|
|
41
|
-
import {
|
|
41
|
+
import {readQaAssessment} from '../runtime/js/cm-ai/host-qa-policy.mjs';
|
|
42
42
|
import {createHostQaExecutor} from '../runtime/js/cm-ai/host-qa-executor.mjs';
|
|
43
43
|
import {inspectCmAiQaTaskContext} from '../runtime/js/cm-ai/cm-ai-admission.mjs';
|
|
44
44
|
import {readLearningRetrospectiveContent} from '../runtime/js/cm-ai/cm-ai-context-refresh.mjs';
|
|
@@ -61,6 +61,7 @@ import {developmentRetryable} from '../runtime/js/cm-ai/cm-ai-conversation-entry
|
|
|
61
61
|
import {stderr,stop,readJson,loadPlanFile,requireFields,preflightAnswers,driveHost,planCheckTimeout} from '../runtime/js/cm-ai/drive-core.mjs';
|
|
62
62
|
import {attemptAnswerName,inspectDriverBootstrap,readBootstrapRulesAnswers,createBootstrapRulesResponder} from '../runtime/js/cm-ai/drive-bootstrap.mjs';
|
|
63
63
|
import {driverLiveEvidence} from '../runtime/js/cm-ai/live-evidence.mjs';
|
|
64
|
+
import {readControlPolicyFile,isControlRecovery as controlRecoveryRequest} from '../runtime/js/cm-ai/control-policy.mjs';
|
|
64
65
|
|
|
65
66
|
// PLAN.liveEvidence: fresh current-session evidence; see docs/live-evidence-drivers.md.
|
|
66
67
|
const HOST=fileURLToPath(new URL('./cm-ai-host.mjs',import.meta.url));
|
|
@@ -86,7 +87,7 @@ const FIX_REASONED=['abandon_step','abandon_review','rediagnose','rerun_blocked_
|
|
|
86
87
|
const FILES={develop:'develop.json',qa_assess:'qa-assess.json',documentation_inspect:'documentation-inspect.json',
|
|
87
88
|
documentation_sync:'documentation-sync.json',fix_learning:'learning.json',fix_diagnose:'diagnosis.json',
|
|
88
89
|
fix_test_author:'test-edits.json',fix_repair:'repair-edits.json',fix_retrospective:'retrospective.json'};
|
|
89
|
-
const PAIR_FLAGS=new Set(['--external-models-config','--
|
|
90
|
+
const PAIR_FLAGS=new Set(['--external-models-config','--review-config','--workflow-config',
|
|
90
91
|
'--input-limit',
|
|
91
92
|
'--protected-conversation-config','--protected-config','--revise-qa-config','--qa-config-revision-reason','--qa-environment-failure',
|
|
92
93
|
'--qa-fix-owner-config','--qa-fix-template-config','--qa-fix-review-config','--browser-qa',
|
|
@@ -100,6 +101,47 @@ const FLAG_FLAGS=new Set(['--execution-optimizations','--external-models','--all
|
|
|
100
101
|
'test-author','repair','cause-review','final-review','rediagnosis','rerun-blocked-step','final-review-recovery'].map(name=>`--allow-qa-fix-${name}`)]);
|
|
101
102
|
const object=value=>value!==null&&typeof value==='object'&&!Array.isArray(value);
|
|
102
103
|
const nonempty=value=>typeof value==='string'&&value.trim().length>0;
|
|
104
|
+
// V2 control is explicit configuration. Never derive a fresh recovery target
|
|
105
|
+
// from the journal or status here: the caller must carry its earlier preview.
|
|
106
|
+
export function readDriverControl(plan,base,operation,recovery=null){
|
|
107
|
+
if(!Object.hasOwn(plan,'controlConfig'))return null;
|
|
108
|
+
if(!nonempty(plan.controlConfig)||path.isAbsolute(plan.controlConfig))
|
|
109
|
+
throw Error('PLAN.controlConfig 必须是相对 PLAN 的配置文件路径');
|
|
110
|
+
if(!Array.isArray(plan.permissions)||plan.permissions.some(flag=>typeof flag!=='string'))
|
|
111
|
+
throw Error('permissions 必须是宿主参数数组');
|
|
112
|
+
if(plan.permissions.some(flag=>flag.startsWith('--allow-')))
|
|
113
|
+
throw Error('control v2 迁移错误:permissions 禁止 --allow-*;请改用 controlConfig 的明确模式和 expectedControl');
|
|
114
|
+
const recovering=recovery??isControlRecovery(operation,plan);
|
|
115
|
+
if(plan.mode==='create'&&Object.hasOwn(plan,'expectedControl'))
|
|
116
|
+
throw Error('control v2 create 禁止 expectedControl');
|
|
117
|
+
if(!recovering&&Object.hasOwn(plan,'expectedControl'))
|
|
118
|
+
throw Error('control v2 expectedControl 只用于显式恢复操作');
|
|
119
|
+
if(recovering&&(plan.mode!=='resume'||!object(plan.expectedControl)))
|
|
120
|
+
throw Error('control v2 恢复需要 PLAN.expectedControl;请携带此前 status 返回的 controlTarget');
|
|
121
|
+
const file=path.resolve(base,plan.controlConfig);
|
|
122
|
+
const policy=readControlPolicyFile(file);
|
|
123
|
+
if((policy.development==='provider')!==plan.permissions.includes('--protected-config'))
|
|
124
|
+
throw Error('invalid_arguments: development provider 需要 --protected-config;conversation 禁止 provider 配置');
|
|
125
|
+
if(policy.bootstrap==='disabled'&&plan.permissions.includes('--bootstrap-config'))
|
|
126
|
+
throw Error('invalid_arguments: bootstrap disabled 禁止 --bootstrap-config;未读取该配置');
|
|
127
|
+
if(policy.qaFix==='disabled'&&['--qa-fix-owner-config','--qa-fix-template-config'].some(flag=>plan.permissions.includes(flag)))
|
|
128
|
+
throw Error('invalid_arguments: qaFix disabled 禁止 QA Fix 配置;未读取该配置');
|
|
129
|
+
return {file,policy};
|
|
130
|
+
}
|
|
131
|
+
export const isControlRecovery=(operation,plan)=>controlRecoveryRequest({operation,fixOperation:plan.fixOperation});
|
|
132
|
+
export function controlDevelopAttempts(status,operation){
|
|
133
|
+
const {state,attempt,reviewPackage}=status;
|
|
134
|
+
const reviewAfterDevelop=operation==='advance'&&attempt===1;
|
|
135
|
+
if(state==='blocked'&&(RECHECK_CODES.includes(status.code)||DOCUMENTATION_SYNC_CODES.includes(status.code)))
|
|
136
|
+
return {attempts:reviewAfterDevelop?[2]:[],reviewFirst:false,reviewAfterDevelop,holdable:true,packageDigest:null};
|
|
137
|
+
if(developmentRetryable(status))
|
|
138
|
+
return {attempts:reviewAfterDevelop?[1,2]:[attempt],reviewFirst:false,reviewAfterDevelop,holdable:true,packageDigest:null};
|
|
139
|
+
if(state==='ready')return {attempts:reviewAfterDevelop?[1,2]:[attempt],reviewFirst:false,reviewAfterDevelop,holdable:true,packageDigest:null};
|
|
140
|
+
if(state==='changes_requested')return {attempts:[attempt],reviewFirst:false,packageDigest:null};
|
|
141
|
+
if(operation==='advance'&&['awaiting_review','pending_review'].includes(state)&&attempt<2)
|
|
142
|
+
return {attempts:[attempt+1],reviewFirst:true,reviewAfterDevelop:true,holdable:true,packageDigest:reviewPackage?.packageDigest??null};
|
|
143
|
+
return {attempts:[],reviewFirst:false,packageDigest:null};
|
|
144
|
+
}
|
|
103
145
|
// Needs the resolved --bootstrap-config path in permissions.
|
|
104
146
|
export const bootstrapDriverGap=(operation,definition,permissions)=>
|
|
105
147
|
inspectDriverBootstrap({advance:ADVANCE.has(operation),definition,permissions}).gap;
|
|
@@ -428,41 +470,23 @@ export function readRunJournal(definition){
|
|
|
428
470
|
return {history:readRunnerHistory(snapshot.records,first.payload.config,3),config:first.payload.config,baseline:first.payload.baseline,
|
|
429
471
|
frame:journalRestBytes(snapshot.records)};
|
|
430
472
|
}
|
|
431
|
-
function reachableDevelopAttempts({plan,operation,journal,permissions}){
|
|
473
|
+
function reachableDevelopAttempts({plan,operation,journal,permissions,controlPolicy=null}){
|
|
432
474
|
if(plan.mode==='create'){
|
|
433
|
-
const reviewAfterDevelop=operation==='advance'
|
|
434
|
-
|
|
435
|
-
|
|
475
|
+
const reviewAfterDevelop=operation==='advance';
|
|
476
|
+
return {attempts:reviewAfterDevelop?[1,2]:[1],reviewFirst:false,reviewAfterDevelop,
|
|
477
|
+
holdable:true,packageDigest:null,learning:null};
|
|
436
478
|
}
|
|
437
479
|
if(journal.error)stop(2,`无法只读检查恢复存档: ${journal.error.code??journal.error.message}`);
|
|
438
480
|
// learning is the journal's Learning result the next develop effect starts from
|
|
439
481
|
// (bootstrap rules bind their on-disk files to its recorded evidence).
|
|
440
482
|
// Q28: decide from what the host will show (projected answer-gap blocks), not the raw replay state.
|
|
441
|
-
|
|
483
|
+
const status=projectedRunnerStatus(journal.history,journal.config);
|
|
484
|
+
return {...(controlPolicy?controlDevelopAttempts(status,operation):projectDevelopAttempts(status,operation,permissions)),
|
|
442
485
|
learning:journal.history.state.learningResult??null};
|
|
443
486
|
}
|
|
444
|
-
export function projectDevelopAttempts(status,operation
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
// --allow-review-attempt 1 (Codex round 1 on Q28): preflight that round too.
|
|
448
|
-
const reviewAfterDevelop=operation==='advance'&&attempt===1
|
|
449
|
-
&&permissions.some((flag,index)=>flag==='--allow-review-attempt'&&permissions[index+1]==='1');
|
|
450
|
-
// A re-check (check_answer_*) re-runs only the checks: no developer answer for
|
|
451
|
-
// this round, only for the round its review may lead to.
|
|
452
|
-
// Q16/Q17: a documentation-only redo reuses the journaled developer answer.
|
|
453
|
-
if(state==='blocked'&&(RECHECK_CODES.includes(status.code)||DOCUMENTATION_SYNC_CODES.includes(status.code)))
|
|
454
|
-
return {attempts:reviewAfterDevelop?[2]:[],reviewFirst:false,reviewAfterDevelop,holdable:true,packageDigest:null};
|
|
455
|
-
if(developmentRetryable(status))
|
|
456
|
-
return {attempts:reviewAfterDevelop?[1,2]:[attempt],reviewFirst:false,reviewAfterDevelop,holdable:true,packageDigest:null};
|
|
457
|
-
if(state==='ready'&&attempt===1&&operation==='advance'
|
|
458
|
-
&&permissions.some((flag,index)=>flag==='--allow-review-attempt'&&permissions[index+1]==='1'))
|
|
459
|
-
return {attempts:[1,2],reviewFirst:false,reviewAfterDevelop:true,packageDigest:null};
|
|
460
|
-
if(['ready','changes_requested'].includes(state))return {attempts:[attempt],reviewFirst:false,packageDigest:null};
|
|
461
|
-
if(operation==='advance'&&['awaiting_review','pending_review'].includes(state)
|
|
462
|
-
&&permissions.some((flag,index)=>flag==='--allow-review-attempt'&&Number(permissions[index+1])===attempt)
|
|
463
|
-
&&attempt<2)return {attempts:[attempt+1],reviewFirst:true,
|
|
464
|
-
packageDigest:reviewPackage?.packageDigest??null};
|
|
465
|
-
return {attempts:[],reviewFirst:false,packageDigest:null};
|
|
487
|
+
export function projectDevelopAttempts(status,operation){
|
|
488
|
+
// Review dispatch is direct; both attempts follow the same reachable-state rules.
|
|
489
|
+
return controlDevelopAttempts(status,operation);
|
|
466
490
|
}
|
|
467
491
|
function predictedQaAsks(definition,qa){
|
|
468
492
|
// Reuse the executor's validated initial plan for policy applicability.
|
|
@@ -523,7 +547,7 @@ export function validateCmAiAnswer(kind,value,root){
|
|
|
523
547
|
try{developEntries(value.edits,root,'develop.json.edits');}catch(error){stop(2,`答案格式错误:${error.message}`);}
|
|
524
548
|
}else {exact(value,['status','code'],'develop.json');requireShape(nonempty(value.code),'develop.json.code');}
|
|
525
549
|
}else if(kind==='qa_assess'){
|
|
526
|
-
try{
|
|
550
|
+
try{readQaAssessment(value);}
|
|
527
551
|
catch{stop(2,'答案格式错误:qa-assess.json');}
|
|
528
552
|
}else if(kind==='documentation_inspect'){
|
|
529
553
|
exact(value,['status','reason','at','closeout'],'documentation-inspect.json');
|
|
@@ -560,7 +584,8 @@ export function validateCmAiAnswer(kind,value,root){
|
|
|
560
584
|
}
|
|
561
585
|
function load(){
|
|
562
586
|
if(process.argv.length===3&&['--help','-h'].includes(process.argv[2])){
|
|
563
|
-
process.stdout.write('
|
|
587
|
+
process.stdout.write('新版 PLAN.controlConfig 为相对 PLAN 的 v2 控制配置路径;development、bootstrap、qa、qaFix 使用明确模式,permissions 禁止所有 --allow-*。普通 advance 自动独立审查;缺少 develop-a2.json 时保持 revision_answer_required。显式恢复需要 resume 与此前 status 返回的 PLAN.expectedControl,驾驶员不会读取新目标覆盖它。\n');
|
|
588
|
+
process.stdout.write('用法: cm-ai-drive.mjs --plan PLAN.json <operation>\nPLAN: config, mode, hostContext, originalHostContext (换会话 resume 必填), runtime, permissions, answers, checks, checkTimeoutMs。\nchecks 每项为 {id,command,timeoutMs?};checkTimeoutMs 与每项 timeoutMs 为 1..3600000 整数,默认 900000 ms(15 分钟)。\nabandon_review 需要 mode:resume、permissions:["--allow-abandon-review"] 与 PLAN.reason;abandon_effect 需要 mode:resume、permissions:["--allow-abandon-effect"] 与 PLAN.reason(均为单行、最多 500 UTF-8 字节)。develop_redo 需要 mode:resume、permissions:["--allow-develop-redo"] 与 PLAN.reason,先确认会话已停止修改代码。 bootstrap_review_recover 需要 mode:resume、permissions:["--allow-bootstrap-review-recovery"] 与 PLAN.reason;只核对原运行的已写规则与 handoff,不需要答案文件。\n人工答案放 answers/;check 只运行 PLAN.checks,不读取静态执行证据。bootstrap T-001 骨架可用;T-002 规范任务(纯规范 scope、单代码根、非 --protected-config)读 answers/init-generate.json({status:"generated",documents:[{path,contentFile}]},覆盖全部 targets)与 answers/init-verify.json(commands 为驾驶员实跑的草稿命令 {id,command,timeoutMs?},可选 commandsNotRun;checks 只含 globs/file_references/constraint_preservation/rule_applicability;constraintChanges:[];application/retrospective 沿原 Learning);第 1 轮也可用 *-a1.json,第 2 轮只读 init-generate-a2.json 与 init-verify-a2.json,审查自动派发;缺少第2轮草稿时先停在 changes_requested,读取首轮 findings 后再写草稿。commands 在宿主接受启动后、发送操作前由驾驶员实跑(须先带 --allow-bootstrap-write 等宿主授权;受保护模式在 specs 沙箱内),失败或改动了预检核对的文件即退出 2 且不发送操作(create 时改用 resume 重跑);结果只来自实跑,答案文件不能提供。\n'
|
|
564
589
|
+'develop.json.edits 每项是 scope 路径到下列之一:"内容文件"(写入;已有文件保留权限,新文件 0644)、{"file":"内容文件","mode":"0755"|"0644"}、{"mode":"0755"|"0644"}(只改已有文件权限)、{"delete":true}(删除已有文件)。改名 = 删旧路径 + 写新路径,两者都要在 scope 内;同时列在 requirements 里的路径不能删除。\n'
|
|
565
590
|
+'启动前拒绝:单个 scope 文件超过 1 MiB、审查材料(按审查包快照:scope、requirements 与树中全部 AGENTS.md 正文)合计超过 2 MiB 或超过 256 个文件、交付后与任务基线完全相同(edits 为空或内容和权限都没变)、开发检查点(含 handoff 与 AGENTS.md 回写,按宿主同一套构建代码计)装不进运行存档单条 1 MiB 记录减去为有界审查与完成记录推出的预留,或任务基线装不进一条记录。受保护模式(--protected-conversation-config)只收合法 UTF-8 文本,应答大于 --input-limit(默认 65536)时提示应加的值。\n'
|
|
566
591
|
+'runId 需 8–128 个字符(运行日志要求),create 前检查。resume 时按存档里的当前轮次发送 identity,第 2 轮的 decision/complete/qa 等无需手改。\n');
|
|
@@ -569,6 +594,12 @@ function load(){
|
|
|
569
594
|
const loaded=loadPlanFile({name:'cm-ai-drive.mjs',known:OPERATIONS});
|
|
570
595
|
const {plan,operation,base}=loaded;
|
|
571
596
|
requireFields(plan,['config','mode','hostContext','permissions']);
|
|
597
|
+
let control;
|
|
598
|
+
try{control=readDriverControl(plan,base,operation);}catch(error){stop(2,error.message);}
|
|
599
|
+
if(control?.policy.bootstrap==='write'&&!plan.permissions.includes('--bootstrap-config'))
|
|
600
|
+
stop(2,'invalid_arguments: bootstrap write 需要 --bootstrap-config');
|
|
601
|
+
if(control?.policy.qaFix==='disabled'&&['fix_advance','fix_run','fix_action'].includes(operation))
|
|
602
|
+
stop(2,'invalid_arguments: qaFix disabled 不执行 QA Fix 操作');
|
|
572
603
|
if(Object.hasOwn(plan,'verificationPrecheck')&&typeof plan.verificationPrecheck!=='boolean')stop(2,'verificationPrecheck 需要 boolean');
|
|
573
604
|
try{planCheckTimeout(plan);}catch(error){stop(2,error.message);}
|
|
574
605
|
if(!['create','resume'].includes(plan.mode))stop(2,'mode 只能是 create 或 resume');
|
|
@@ -592,13 +623,18 @@ function load(){
|
|
|
592
623
|
if(permissions.includes('--rebind-spec-material')!==permissions.includes('--spec-rebind-reason')
|
|
593
624
|
||permissions.includes('--rebind-spec-material')&&plan.mode!=='resume')
|
|
594
625
|
stop(2,'--rebind-spec-material 只用于 mode resume,并须同时提供 --spec-rebind-reason 原因');
|
|
595
|
-
|
|
626
|
+
// V2 recovery operations are gated by the original expectedControl in the
|
|
627
|
+
// host, while the driver still validates the explicit operation and reason.
|
|
628
|
+
if(control&&['abandon_review','abandon_effect','bootstrap_review_recover','develop_redo'].includes(operation)
|
|
629
|
+
&&(plan.mode!=='resume'||!nonempty(plan.reason)||Buffer.byteLength(plan.reason,'utf8')>500||/[\r\n\0]/.test(plan.reason)))
|
|
630
|
+
stop(2,`${operation} 需要 resume、expectedControl 与单行 reason(最多 500 UTF-8 字节)`);
|
|
631
|
+
const abandonError=control?null:abandonReviewPlanError(operation,plan,permissions);
|
|
596
632
|
if(abandonError)stop(2,abandonError);
|
|
597
|
-
const abandonEffectError=abandonEffectPlanError(operation,plan,permissions);
|
|
633
|
+
const abandonEffectError=control?null:abandonEffectPlanError(operation,plan,permissions);
|
|
598
634
|
if(abandonEffectError)stop(2,abandonEffectError);
|
|
599
|
-
const developRedoError=developRedoPlanError(operation,plan,permissions);
|
|
635
|
+
const developRedoError=control?null:developRedoPlanError(operation,plan,permissions);
|
|
600
636
|
if(developRedoError)stop(2,developRedoError);
|
|
601
|
-
const bootstrapRecoveryError=bootstrapReviewRecoveryPlanError(operation,plan,permissions);
|
|
637
|
+
const bootstrapRecoveryError=control?null:bootstrapReviewRecoveryPlanError(operation,plan,permissions);
|
|
602
638
|
if(bootstrapRecoveryError)stop(2,bootstrapRecoveryError);
|
|
603
639
|
const config=path.resolve(base,plan.config),answers=plan.answers?path.resolve(base,plan.answers):null;
|
|
604
640
|
if(!fs.existsSync(config))stop(2,`运行定义不存在: ${config}`);
|
|
@@ -631,18 +667,18 @@ function load(){
|
|
|
631
667
|
}
|
|
632
668
|
const permissionFiles=[];
|
|
633
669
|
for(let i=0;i<permissions.length;i++)if(PAIR_FLAGS.has(permissions[i])
|
|
634
|
-
&&permissions[i]!=='--
|
|
670
|
+
&&permissions[i]!=='--browser-qa'
|
|
635
671
|
&&permissions[i]!=='--qa-config-revision-reason'&&permissions[i]!=='--qa-environment-failure'&&permissions[i]!=='--allow-provider-development-attempt'
|
|
636
672
|
&&permissions[i]!=='--supersede-reason'&&permissions[i]!=='--spec-rebind-reason'&&permissions[i]!=='--input-limit'
|
|
637
673
|
&&permissions[i]!=='--review-runtime'&&permissions[i]!=='--feature'&&permissions[i]!=='--qa-fix-final-review-recovery-invocation'){
|
|
638
674
|
const file=path.resolve(base,permissions[i+1]);if(!fs.existsSync(file))stop(2,`${permissions[i]} 文件不存在: ${file}`);
|
|
639
675
|
permissions[i+1]=file;permissionFiles.push(file);i++;
|
|
640
676
|
}
|
|
641
|
-
const bootstrap=inspectDriverBootstrap({advance:ADVANCE.has(operation),definition,permissions});
|
|
677
|
+
const bootstrap=inspectDriverBootstrap({advance:ADVANCE.has(operation),definition,permissions,controlPolicy:control?.policy??null});
|
|
642
678
|
if(bootstrap.gap)stop(2,bootstrap.gap);
|
|
643
679
|
const rules=bootstrap.mode==='instructions';
|
|
644
|
-
const providerMode=permissions.includes('--protected-config');
|
|
645
|
-
const protectedMode=
|
|
680
|
+
const providerMode=control?control.policy.development==='provider':permissions.includes('--protected-config');
|
|
681
|
+
const protectedMode=permissions.includes('--protected-config')||permissions.includes('--protected-conversation-config');
|
|
646
682
|
const asks=[];
|
|
647
683
|
if(ADVANCE.has(operation)){
|
|
648
684
|
// A pure rules scope never reaches develop: host-bootstrap.mjs asks the session instead.
|
|
@@ -652,15 +688,15 @@ function load(){
|
|
|
652
688
|
}
|
|
653
689
|
if((plan.verificationPrecheck===true||permissions.includes('--verification-precheck'))&&(ADVANCE.has(operation)||operation==='complete'))asks.push('verification_precheck');
|
|
654
690
|
if(operation==='complete'&&!protectedMode)asks.push('check');
|
|
655
|
-
if((operation==='advance'||operation==='qa')&&workflow
|
|
691
|
+
if((operation==='advance'||operation==='qa')&&workflow&&(control||workflow.qa)){asks.push('qa_assess');
|
|
656
692
|
}
|
|
657
|
-
if((operation==='advance'||operation==='qa')&&workflow?.qa){
|
|
693
|
+
if((operation==='advance'||operation==='qa')&&workflow?.qa&&(!control||control.policy.qa==='run')){
|
|
658
694
|
try{asks.push(...predictedQaAsks(definition,workflow.qa));}
|
|
659
695
|
catch(error){stop(2,`QA 请求预测失败: ${error.code??error.message}`);}
|
|
660
696
|
}
|
|
661
697
|
if(operation==='advance'&&workflow?.documentationPaths?.length&&!protectedMode)asks.push('documentation_sync');
|
|
662
698
|
if(['advance','finish','run_finalize'].includes(operation)&&workflow)asks.push('documentation_inspect');
|
|
663
|
-
if(operation==='advance'&&permissions.includes('--auto-qa-fix')){
|
|
699
|
+
if(operation==='advance'&&(control?control.policy.qaFix==='auto':permissions.includes('--auto-qa-fix'))){
|
|
664
700
|
asks.push(...new Set(Object.values(FIX_ASKS).flat()));
|
|
665
701
|
}
|
|
666
702
|
if(['fix_advance','fix_run'].includes(operation))asks.push(...new Set(Object.values(FIX_ASKS).flat()));
|
|
@@ -668,7 +704,7 @@ function load(){
|
|
|
668
704
|
if(plan.fixOperation==='reconcile_review'&&(plan.mode!=='resume'||!nonempty(plan.invocationId)))stop(2,'fix reconciliation requires resume and original invocationId');
|
|
669
705
|
if(!FIX_ACTIONS.has(plan.fixOperation))stop(2,'fix_action 需要宿主支持的 fixOperation');
|
|
670
706
|
const actionFlag=FIX_ACTION_FLAGS[plan.fixOperation];
|
|
671
|
-
if(actionFlag&&!permissions.includes(actionFlag))stop(2,`${plan.fixOperation} 需要 ${actionFlag}`);
|
|
707
|
+
if(actionFlag&&!control&&!permissions.includes(actionFlag))stop(2,`${plan.fixOperation} 需要 ${actionFlag}`);
|
|
672
708
|
if(FIX_REASONED.includes(plan.fixOperation)&&!(nonempty(plan.reason)&&Buffer.byteLength(plan.reason,'utf8')<=1000
|
|
673
709
|
&&!/[\r\n\0\u0085\u2028\u2029]/.test(plan.reason)))stop(2,`${plan.fixOperation} 需要单行 reason(最多 1000 UTF-8 字节)`);
|
|
674
710
|
if(plan.fixOperation==='rediagnose'&&plan.mode!=='resume')stop(2,'rediagnose 需要 mode:resume');
|
|
@@ -696,12 +732,16 @@ function load(){
|
|
|
696
732
|
}
|
|
697
733
|
catch(error){stop(2,`PLAN.checks 格式错误: ${error.code??error.message}`);}
|
|
698
734
|
}
|
|
699
|
-
|
|
700
|
-
?reachableDevelopAttempts({plan,operation,journal,permissions})
|
|
735
|
+
let reachable=(asks.includes('develop')||rules)&&!providerMode
|
|
736
|
+
?reachableDevelopAttempts({plan,operation,journal,permissions,controlPolicy:control?.policy??null})
|
|
701
737
|
:{attempts:[],reviewFirst:false,packageDigest:null};
|
|
738
|
+
// Rules answers are authored after reading the review findings. V2 can run
|
|
739
|
+
// that review automatically, but it must stop before asking for a new draft.
|
|
740
|
+
const holdBootstrapRevision=Boolean(rules&&reachable.reviewAfterDevelop);
|
|
741
|
+
if(holdBootstrapRevision)reachable={...reachable,attempts:reachable.attempts.filter(attempt=>attempt<2),reviewAfterDevelop:false,reviewFirst:false};
|
|
702
742
|
const bootstrapAnswers=rules
|
|
703
|
-
?readBootstrapRulesAnswers({answers,operation,definition,plan,permissions,bootstrap,reachable}):null;
|
|
704
|
-
const developAnswers=new Map(),deliveries=[];let holdRevision=
|
|
743
|
+
?readBootstrapRulesAnswers({answers,operation,definition,plan,permissions,bootstrap,reachable,controlPolicy:control?.policy??null}):null;
|
|
744
|
+
const developAnswers=new Map(),deliveries=[];let holdRevision=holdBootstrapRevision;
|
|
705
745
|
if(asks.includes('develop'))for(const attempt of reachable.attempts){
|
|
706
746
|
const file=answerPath(answers??'',developFilename(answers??'',attempt));
|
|
707
747
|
if(!answers||!fs.existsSync(file)){
|
|
@@ -714,8 +754,6 @@ function load(){
|
|
|
714
754
|
stderr(`没有 ${path.basename(file)}:本次 advance 的首轮审查若要求修改,任务会停在 changes_requested(revision_answer_required),不会发起第 2 轮开发;读取 ${reviewFile} 的 findings,写 answers/develop-a2.json 后再 advance`);
|
|
715
755
|
continue;
|
|
716
756
|
}
|
|
717
|
-
if(reachable.reviewAfterDevelop&&attempt===2)
|
|
718
|
-
stop(2,`缺少 ${file};本次 advance 带 --allow-review-attempt 1,宿主完成首轮审查后可能直接进入第 2 轮 develop。可选:1) 从 PLAN.permissions 移除 --allow-review-attempt 1,先 advance 到 awaiting_review;再用该运行返回的 packageDigest 执行 decision,读取 ${reviewFile} 的 findings;若要求修改,写 answers/develop-a2.json 后 advance。2) 若有意一次跑完,预先写 answers/develop-a2.json 后重试 advance。develop-a2.json 必须针对首轮 findings 修改;与第 1 轮被要求修改的代码逐字节相同时,第 2 轮停在 blocked/develop_unchanged_after_review,不送审,改好后再 advance。`);
|
|
719
757
|
if(reachable.reviewFirst)stop(2,`缺少 ${path.basename(file)};请先以 decision 和当前 packageDigest ${reachable.packageDigest} 单独运行审查,读取 .reviews/${definition.feature.replace(/^\d+\./,'')}-${definition.identity.taskId}-r${attempt-1}.md 中的 findings,写 answers/develop-a${attempt}.json 后再 advance`);
|
|
720
758
|
stop(2,`步骤 ${operation} 会反问 develop,但答案文件不存在: ${file}`);
|
|
721
759
|
}
|
|
@@ -740,7 +778,7 @@ function load(){
|
|
|
740
778
|
});
|
|
741
779
|
if(answer.documentation_sync)for(const target of Object.keys(answer.documentation_sync.edits))
|
|
742
780
|
if(!workflow.documentationPaths.includes(target))stop(2,`documentation-sync.json.edits 越过文档 scope: ${target}`);
|
|
743
|
-
return {...loaded,definition,identity,permissions,config,answers,answer,developAnswers,live,executionPolicy,holdRevision,
|
|
781
|
+
return {...loaded,control,definition,identity,permissions,config,answers,answer,developAnswers,live,executionPolicy,holdRevision,
|
|
744
782
|
bootstrapRules:bootstrapAnswers&&createBootstrapRulesResponder({definition,plan,bootstrap,answers:bootstrapAnswers,
|
|
745
783
|
// Same execution as the task checks: the host's specs sandbox in protected mode, else the driver's own.
|
|
746
784
|
specsRoot:protectedMode?definition.specsDir:null,watch:[config,...permissionFiles]})};
|
|
@@ -815,7 +853,11 @@ async function answerFor(row,answer,paths,control){
|
|
|
815
853
|
return value??null;
|
|
816
854
|
}
|
|
817
855
|
export function buildCmAiDriveRequest(operation,plan,definition,identity=definition.identity){
|
|
818
|
-
|
|
856
|
+
// Recovery is bound to the caller's earlier preview, including its attempt.
|
|
857
|
+
// The host compares that whole target before dispatching anything.
|
|
858
|
+
if(Object.hasOwn(plan,'controlConfig')&&isControlRecovery(operation,plan))identity=plan.expectedControl?.identity??identity;
|
|
859
|
+
return {version:Object.hasOwn(plan,'controlConfig')?2:1,identity,
|
|
860
|
+
...(Object.hasOwn(plan,'controlConfig')&&isControlRecovery(operation,plan)?{expectedControl:plan.expectedControl}:{}),
|
|
819
861
|
...(operation==='reconcile_review'?{invocationId:plan.invocationId}:{}),
|
|
820
862
|
...(['abandon_review','abandon_effect','bootstrap_review_recover','develop_redo'].includes(operation)?{reason:plan.reason}:{}),
|
|
821
863
|
...(PACKAGE_OPERATIONS.has(operation)?{packageDigest:plan.packageDigest}:{}),
|
|
@@ -827,9 +869,9 @@ export function buildCmAiDriveRequest(operation,plan,definition,identity=definit
|
|
|
827
869
|
...(plan.fixOperation==='recover_final_review'?{invocationId:plan.invocationId,reviewPackageDigest:plan.reviewPackageDigest,
|
|
828
870
|
previousInvocationStopped:plan.previousInvocationStopped}:{})}: {})}: {})};
|
|
829
871
|
}
|
|
830
|
-
export function buildCmAiDriveHostArgs(plan,permissions,config){
|
|
872
|
+
export function buildCmAiDriveHostArgs(plan,permissions,config,controlConfig=null){
|
|
831
873
|
return ['serve','--config',config,'--mode',plan.mode,'--host-context',plan.hostContext,
|
|
832
|
-
'--allow-development',
|
|
874
|
+
...(Object.hasOwn(plan,'controlConfig')?['--control-config',controlConfig??plan.controlConfig]:['--allow-development']),
|
|
833
875
|
...(plan.verificationPrecheck===true&&!permissions.includes('--verification-precheck')?['--verification-precheck']:[]),
|
|
834
876
|
...(plan.originalHostContext?['--original-host-context',plan.originalHostContext]:[]),
|
|
835
877
|
'--runtime',plan.runtime??'codex',...permissions.filter(flag=>flag!=='--allow-development')];
|
|
@@ -849,7 +891,7 @@ async function main(){
|
|
|
849
891
|
// Rules init_verify commands really run once the host has accepted the launch
|
|
850
892
|
// (host_ready) and before the operation is sent: a failure never becomes an
|
|
851
893
|
// unknown develop effect, and the host's own launch validation came first.
|
|
852
|
-
driveHost({host:HOST,args:[...buildCmAiDriveHostArgs(plan,permissions,config),...(loaded.holdRevision?['--hold-revision']:[])],cwd:definition.codeProject,operation,request,
|
|
894
|
+
driveHost({host:HOST,args:[...buildCmAiDriveHostArgs(plan,permissions,config,loaded.control?.file),...(loaded.holdRevision?['--hold-revision']:[])],cwd:definition.codeProject,operation,request,
|
|
853
895
|
answers:answer,paths:{answers:loaded.answers},answerFor,
|
|
854
896
|
...(loaded.bootstrapRules?{beforeRequest:()=>loaded.bootstrapRules.prepare(plan.mode)}:{})});
|
|
855
897
|
}
|
|
@@ -7,6 +7,7 @@ import {spawnSync} from 'node:child_process';
|
|
|
7
7
|
import {fileURLToPath} from 'node:url';
|
|
8
8
|
import {buildManifest} from './cm-spec-manifest.mjs';
|
|
9
9
|
import {configFingerprint} from '../runtime/js/cm-ai/codex-config.mjs';
|
|
10
|
+
import {claudeReviewFingerprint} from '../runtime/js/cm-ai/worker-claude.mjs';
|
|
10
11
|
import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
11
12
|
import {cmInitRuleTargets} from '../runtime/js/cm-init/draft-generation.mjs';
|
|
12
13
|
import {qaFixAnswerFor,projectDevelopAttempts,bootstrapReviewRecoveryPlanError,buildCmAiDriveRequest} from './cm-ai-drive.mjs';
|
|
@@ -31,12 +32,19 @@ function fixture(t){
|
|
|
31
32
|
const answers=path.join(root,'answers');fs.mkdirSync(answers);
|
|
32
33
|
const bin=path.join(root,'bin');fs.mkdirSync(bin);
|
|
33
34
|
const write=(name,value)=>fs.writeFileSync(path.join(answers,name),JSON.stringify(value));
|
|
34
|
-
//
|
|
35
|
-
|
|
35
|
+
// Isolated executable reviewers and matching synthetic preflights; no model service.
|
|
36
|
+
for(const provider of ['codex','claude']){
|
|
37
|
+
const executable=path.join(bin,provider);
|
|
38
|
+
fs.copyFileSync(fileURLToPath(new URL(`./fixtures/${provider}-review-process.mjs`,import.meta.url)),executable);
|
|
39
|
+
fs.chmodSync(executable,0o700);
|
|
40
|
+
fs.writeFileSync(path.join(root,`${provider}-review.json`),JSON.stringify({model:'fixture',disabledSkills:[],preflight:{passed:true,
|
|
41
|
+
provider,prompt_transport:'stdin',...(provider==='codex'?{cli_model:'fixture'}:{}),
|
|
42
|
+
config_fingerprint:provider==='codex'?configFingerprint({cwd:codeProject,model:'fixture'}):claudeReviewFingerprint({cwd:codeProject,model:'fixture'})}}));
|
|
43
|
+
}
|
|
36
44
|
const plan=(extra={})=>{const file=path.join(root,`plan-${Math.random().toString(36).slice(2)}.json`);
|
|
37
45
|
const value={config:'run.json',mode:'create',hostContext:'drive-host-a',
|
|
38
46
|
permissions:[],answers:'answers',checks:[{id:'syntax',command:[process.execPath,'--check','target.mjs']}],...extra};
|
|
39
|
-
if(!value.permissions.includes('--review-config'))value.permissions=[...value.permissions,'--review-config'
|
|
47
|
+
if(!value.permissions.includes('--review-config'))value.permissions=[...value.permissions,'--review-config',`${value.runtime==='claude'||value.permissions.includes('--review-runtime')?'claude':'codex'}-review.json`];
|
|
40
48
|
fs.writeFileSync(file,JSON.stringify(value));
|
|
41
49
|
return file;};
|
|
42
50
|
const drive=(file,operation,timeout=30000)=>spawnSync(process.execPath,[DRIVER,'--plan',file,operation],
|
|
@@ -57,29 +65,18 @@ function changesRequestedReview(f){
|
|
|
57
65
|
const cli=path.join(f.bin,'codex');fs.writeFileSync(cli,fake,{mode:0o700});
|
|
58
66
|
fs.writeFileSync(path.join(f.root,'review.json'),JSON.stringify({model:'fixture',preflight:{passed:true,
|
|
59
67
|
cli_model:'fixture',prompt_transport:'stdin',config_fingerprint:configFingerprint({cwd:f.codeProject,model:'fixture'})}}));
|
|
60
|
-
return ['--review-config','review.json'
|
|
68
|
+
return ['--review-config','review.json'];
|
|
61
69
|
}
|
|
62
70
|
function reviewPending(f){
|
|
63
71
|
prepared(f);const permissions=changesRequestedReview(f);
|
|
64
72
|
const first=f.drive(f.plan({permissions:permissions.slice(0,2)}),'advance');assert.equal(first.status,0,first.stderr);
|
|
65
73
|
return {permissions,packageDigest:JSON.parse(first.stdout).result.packageDigest};
|
|
66
74
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
assert.
|
|
70
|
-
assert.match(stderr,/移除 --allow-review-attempt 1/);
|
|
71
|
-
assert.match(stderr,/awaiting_review/);
|
|
72
|
-
assert.match(stderr,/packageDigest.*decision/);
|
|
73
|
-
assert.match(stderr,/\.reviews\/work-T-001-r1\.md/);
|
|
74
|
-
assert.match(stderr,/预先写.*develop-a2\.json/);
|
|
75
|
-
assert.match(stderr,/逐字节相同时.*develop_unchanged_after_review/);
|
|
76
|
-
}
|
|
77
|
-
test('review-enabled advance refuses missing second-round answer before host launch',t=>{
|
|
78
|
-
const f=fixture(t),{permissions,packageDigest}=reviewPending(f),before=fs.readFileSync(f.store);
|
|
75
|
+
test('direct advance holds at changes_requested before the missing second-round answer',t=>{
|
|
76
|
+
const f=fixture(t),{permissions}=reviewPending(f),before=fs.readFileSync(f.store);
|
|
77
|
+
assert.equal(JSON.parse(before).records.filter(row=>row.payload.type==='review-invocation-started').length,1);
|
|
79
78
|
const run=f.drive(f.plan({mode:'resume',originalHostContext:'drive-host-a',permissions}),'advance');
|
|
80
79
|
assert.equal(run.status,2,run.stderr);assert.match(run.stderr,/develop-a2\.json/);
|
|
81
|
-
assert.match(run.stderr,/decision/);assert.match(run.stderr,new RegExp(packageDigest));
|
|
82
|
-
assert.match(run.stderr,/\.reviews\/work-T-001-r1\.md/);
|
|
83
80
|
assert.deepEqual(fs.readFileSync(f.store),before);
|
|
84
81
|
});
|
|
85
82
|
test('retryable blocked state projects the same develop attempt',()=>{
|
|
@@ -101,19 +98,20 @@ test('D1 real host retries a check-output-blocked develop with a fresh effect id
|
|
|
101
98
|
const clean=[{id:'build',command:[process.execPath,'-e','0']}];
|
|
102
99
|
const second=f.drive(f.plan({mode:'resume',originalHostContext:'drive-host-a',runtime:'claude',checks:clean}),'advance');
|
|
103
100
|
assert.equal(second.status,0,second.stderr);
|
|
104
|
-
assert.equal(JSON.parse(second.stdout).result.state,'
|
|
101
|
+
assert.equal(JSON.parse(second.stdout).result.state,'fixture_completed');
|
|
105
102
|
assert.match(second.stderr,/应答 develop/);
|
|
106
103
|
const intents=JSON.parse(fs.readFileSync(f.store)).records.filter(r=>r.payload.type==='effect-intent').map(r=>r.payload.effect.id);
|
|
107
|
-
assert.deepEqual(intents,['develop-1','develop-1-retry-1']);
|
|
104
|
+
assert.deepEqual(intents.slice(0,2),['develop-1','develop-1-retry-1']);
|
|
105
|
+
assert.equal(intents.filter(id=>id.startsWith('develop')).length,2);
|
|
108
106
|
assert.match(fs.readFileSync(path.join(f.codeProject,'App','ContentView.swift'),'utf8'),/import SwiftUI/);
|
|
109
107
|
});
|
|
110
108
|
|
|
111
109
|
test('D1 per-check timeout lets a 61 second check finish under a 65 second limit',t=>{
|
|
112
|
-
const f=fixture(t);prepared(f);
|
|
110
|
+
const f=fixture(t);prepared(f);changesRequestedReview(f);
|
|
113
111
|
const checks=[{id:'slow',command:[process.execPath,'-e','setTimeout(()=>{},61000)'],timeoutMs:65000}];
|
|
114
|
-
const run=f.drive(f.plan({checkTimeoutMs:1000,checks}),'advance',80000);
|
|
112
|
+
const run=f.drive(f.plan({checkTimeoutMs:1000,checks,permissions:['--review-config','review.json']}),'advance',80000);
|
|
115
113
|
assert.equal(run.status,0,run.stderr);
|
|
116
|
-
assert.equal(JSON.parse(run.stdout).result.state,'
|
|
114
|
+
assert.equal(JSON.parse(run.stdout).result.state,'changes_requested');
|
|
117
115
|
});
|
|
118
116
|
|
|
119
117
|
for(const plan of [{checkTimeoutMs:0},{checks:[{id:'syntax',command:[process.execPath,'--check','target.mjs'],timeoutMs:3600001}]}])
|
|
@@ -122,35 +120,14 @@ test(`D1 single driver rejects invalid timeout before host launch ${Object.keys(
|
|
|
122
120
|
const run=f.drive(f.plan(plan),'advance');
|
|
123
121
|
assert.equal(run.status,2);assert.match(run.stderr,/[tT]imeoutMs/);assert.equal(fs.existsSync(f.store),false);
|
|
124
122
|
});
|
|
125
|
-
test('review
|
|
126
|
-
const f=fixture(t);prepared(f);const permissions=changesRequestedReview(f);
|
|
127
|
-
const run=f.drive(f.plan({permissions}),'advance');
|
|
128
|
-
assert.equal(run.status,2,run.stderr);assertActionableFirstReviewHint(run.stderr);
|
|
129
|
-
assert.equal(fs.existsSync(f.store),false);
|
|
130
|
-
});
|
|
131
|
-
test('review-authorized resume from ready gives the same two paths before launch',t=>{
|
|
123
|
+
test('create direct review holds for an authored revision when only develop.json exists',t=>{
|
|
132
124
|
const f=fixture(t);prepared(f);const permissions=changesRequestedReview(f);
|
|
133
|
-
const status=f.drive(f.plan({permissions:permissions.slice(0,2),answers:undefined,checks:undefined}),'status');
|
|
134
|
-
assert.equal(status.status,0,status.stderr);assert.equal(JSON.parse(status.stdout).result.state,'ready');
|
|
135
|
-
const before=fs.readFileSync(f.store);
|
|
136
|
-
const run=f.drive(f.plan({mode:'resume',originalHostContext:'drive-host-a',permissions}),'advance');
|
|
137
|
-
assert.equal(run.status,2,run.stderr);assertActionableFirstReviewHint(run.stderr);
|
|
138
|
-
assert.deepEqual(fs.readFileSync(f.store),before);
|
|
139
|
-
});
|
|
140
|
-
test('create advance without review authorization accepts only develop.json',t=>{
|
|
141
|
-
const f=fixture(t);prepared(f);const permissions=changesRequestedReview(f).slice(0,2);
|
|
142
125
|
assert.equal(fs.existsSync(path.join(f.answers,'develop-a2.json')),false);
|
|
143
126
|
const run=f.drive(f.plan({permissions}),'advance');assert.equal(run.status,0,run.stderr);
|
|
144
|
-
assert.equal(JSON.parse(run.stdout).result.state,'awaiting_review');
|
|
145
|
-
});
|
|
146
|
-
test('decision dispatches only review and leaves changes_requested for authored revision',t=>{
|
|
147
|
-
const f=fixture(t),{permissions,packageDigest}=reviewPending(f);
|
|
148
|
-
const run=f.drive(f.plan({mode:'resume',originalHostContext:'drive-host-a',permissions,
|
|
149
|
-
packageDigest,answers:undefined,checks:undefined}),'decision');
|
|
150
|
-
assert.equal(run.status,0,run.stderr);
|
|
151
127
|
assert.equal(JSON.parse(run.stdout).result.state,'changes_requested');
|
|
152
|
-
assert.equal(JSON.parse(run.stdout).result.
|
|
153
|
-
|
|
128
|
+
assert.equal(JSON.parse(run.stdout).result.code,'revision_answer_required');
|
|
129
|
+
const intents=JSON.parse(fs.readFileSync(f.store)).records.filter(row=>row.payload.type==='effect-intent');
|
|
130
|
+
assert.equal(intents.filter(row=>row.payload.effect.kind==='develop').length,1);
|
|
154
131
|
});
|
|
155
132
|
test('advance applies develop-a2 content after changes_requested review',t=>{
|
|
156
133
|
const f=fixture(t),{permissions}=reviewPending(f);
|
|
@@ -190,8 +167,7 @@ function qaFixture(f,kinds,caseIds=[]){
|
|
|
190
167
|
fs.writeFileSync(path.join(f.root,'workflow.json'),JSON.stringify({documentationPaths:[],applicableAgentFiles:[],
|
|
191
168
|
qa:{commands:[{id:'unit',command:[process.execPath,'--check','target.mjs'],caseIds}],
|
|
192
169
|
environment:{kind:'web',carrier:'browser',target:'fixture-local',scope:'local'}}}));
|
|
193
|
-
f.write('qa-assess.json',{
|
|
194
|
-
changes:{api:false,migration:false,authentication:false,authorization:false,payment:false}});
|
|
170
|
+
f.write('qa-assess.json',{confirmed:true});
|
|
195
171
|
f.write('documentation-inspect.json',{status:'blocked',reason:'Fixture stops before documentation review'});
|
|
196
172
|
return f.plan({permissions:['--workflow-config','workflow.json','--allow-qa',
|
|
197
173
|
...(kinds.some(item=>item.kind==='browser')?['--browser-qa','available']:[])]});
|
|
@@ -243,8 +219,7 @@ test('progress R1: single driver forwards quiet QA command boundaries',t=>{
|
|
|
243
219
|
const permissions=changesRequestedReview(f);
|
|
244
220
|
fs.copyFileSync(fileURLToPath(new URL('./fixtures/codex-review-process.mjs',import.meta.url)),path.join(f.bin,'codex'));
|
|
245
221
|
fs.chmodSync(path.join(f.bin,'codex'),0o700);
|
|
246
|
-
f.write('qa-assess.json',{
|
|
247
|
-
changes:{api:false,migration:false,authentication:false,authorization:false,payment:false}});
|
|
222
|
+
f.write('qa-assess.json',{confirmed:true});
|
|
248
223
|
const workflowPath=path.join(f.root,'workflow.json'),workflow=JSON.parse(fs.readFileSync(workflowPath,'utf8'));
|
|
249
224
|
workflow.qa.commands=[{id:'quiet-qa',command:[process.execPath,'-e','setTimeout(()=>process.exit(0),400)'],caseIds:[]}];
|
|
250
225
|
fs.writeFileSync(workflowPath,JSON.stringify(workflow));
|
|
@@ -264,17 +239,17 @@ test('create and advance run authored edits and actual check, then resume with o
|
|
|
264
239
|
const f=fixture(t);prepared(f);
|
|
265
240
|
const first=f.drive(f.plan(),'advance');assert.equal(first.status,0,first.stderr);
|
|
266
241
|
const result=JSON.parse(first.stdout).result;
|
|
267
|
-
assert.equal(result.state,'
|
|
242
|
+
assert.equal(result.state,'fixture_completed');assert.equal(result.code,'qa_decision_required');
|
|
268
243
|
assert.match(first.stderr,/应答 develop/);assert.match(first.stderr,/应答 check/);
|
|
269
244
|
assert.equal(fs.readFileSync(path.join(f.codeProject,'target.mjs'),'utf8'),'export const value = 42;\n');
|
|
270
245
|
assert(fs.existsSync(f.store));
|
|
271
246
|
const resumed=f.drive(f.plan({mode:'resume',hostContext:'drive-host-b',originalHostContext:'drive-host-a'}),'advance');
|
|
272
|
-
assert.equal(resumed.status,0,resumed.stderr);assert.equal(JSON.parse(resumed.stdout).result.code,'
|
|
247
|
+
assert.equal(resumed.status,0,resumed.stderr);assert.equal(JSON.parse(resumed.stdout).result.code,'qa_decision_required');
|
|
273
248
|
});
|
|
274
249
|
|
|
275
250
|
test('driver resumes an interrupted develop and sends the bound abandon_effect request',t=>{
|
|
276
251
|
const f=fixture(t);prepared(f);
|
|
277
|
-
const first=f.drive(f.plan(),'advance');assert.equal(first.status,0,first.stderr);
|
|
252
|
+
const first=f.drive(f.plan({checks:[{id:'stop-before-review',command:[process.execPath,'-e','process.exit(7)']}]}),'advance');assert.equal(first.status,0,first.stderr);
|
|
278
253
|
const current=JSON.parse(fs.readFileSync(f.store,'utf8'));
|
|
279
254
|
const index=current.records.findIndex(row=>row.payload.type==='effect-intent'
|
|
280
255
|
&&row.payload.effect.kind==='develop');assert(index>=0);
|
|
@@ -325,15 +300,8 @@ test('real host drives split-root bootstrap scaffold, then refuses rules without
|
|
|
325
300
|
fs.writeFileSync(path.join(root,'review.json'),preview.stdout);
|
|
326
301
|
writePlan('create',['--bootstrap-config','bootstrap.json','--allow-bootstrap-write','--review-config','review.json']);
|
|
327
302
|
const scaffold=drive('advance');assert.equal(scaffold.status,0,scaffold.stderr);
|
|
328
|
-
const first=JSON.parse(scaffold.stdout).result;assert.equal(first.state,'
|
|
303
|
+
const first=JSON.parse(scaffold.stdout).result;assert.equal(first.state,'fixture_completed');
|
|
329
304
|
assert.equal(fs.readFileSync(path.join(codeProject,'app.mjs'),'utf8'),'export const app = true;\n');
|
|
330
|
-
writePlan('resume',['--bootstrap-config','bootstrap.json','--allow-bootstrap-write','--review-config','review.json',
|
|
331
|
-
'--allow-review-attempt','1'],{packageDigest:first.packageDigest});
|
|
332
|
-
const review=drive('decision');
|
|
333
|
-
assert.equal(review.status,0,review.stderr);assert.equal(JSON.parse(review.stdout).result.state,'approved');
|
|
334
|
-
writePlan('resume',['--bootstrap-config','bootstrap.json','--allow-bootstrap-write','--review-config','review.json']);
|
|
335
|
-
const completed=drive('advance');assert.equal(completed.status,0,completed.stderr);
|
|
336
|
-
assert.equal(JSON.parse(completed.stdout).result.state,'fixture_completed');
|
|
337
305
|
assert.match(fs.readFileSync(path.join(specsDir,feature,'tasks.md'),'utf8'),/\[x\] T-001/);
|
|
338
306
|
writeRun('T-002',cmInitRuleTargets(selection,codeProject));
|
|
339
307
|
fs.writeFileSync(bootstrap,JSON.stringify({selection}));
|
|
@@ -479,19 +447,19 @@ test('same-session resume may omit originalHostContext and cross-session omissio
|
|
|
479
447
|
const before=fs.readFileSync(f.store);
|
|
480
448
|
const same=f.drive(f.plan({mode:'resume',answers:undefined,checks:undefined}),'status');
|
|
481
449
|
assert.equal(same.status,0,same.stderr);
|
|
482
|
-
assert.equal(JSON.parse(same.stdout).result.state,'
|
|
450
|
+
assert.equal(JSON.parse(same.stdout).result.state,'fixture_completed');
|
|
483
451
|
const cross=f.drive(f.plan({mode:'resume',hostContext:'drive-host-b',answers:undefined,checks:undefined}),'status');
|
|
484
|
-
assert.equal(cross.status,
|
|
452
|
+
assert.equal(cross.status,71,cross.stderr);assert.match(cross.stderr,/host_exited/);assert.match(cross.stderr,/fingerprint_mismatch/);
|
|
485
453
|
assert.deepEqual(fs.readFileSync(f.store),before);
|
|
486
454
|
});
|
|
487
455
|
test('supersession flags reach create and incomplete or resume pairs stop before host launch',t=>{
|
|
488
456
|
const f=fixture(t);prepared(f);
|
|
489
457
|
const both=['--supersede-reviewed-evidence','--supersede-reason','operator restart'];
|
|
490
458
|
const create=f.drive(f.plan({permissions:both}),'advance');
|
|
491
|
-
assert.equal(create.status,
|
|
459
|
+
assert.equal(create.status,71,create.stderr);assert.match(create.stderr,/host_exited/);
|
|
492
460
|
assert.match(create.stderr,/supersede_unavailable/);
|
|
493
461
|
const accepted=f.drive(f.plan({permissions:[...both,'--accept-superseded-code-drift']}),'advance');
|
|
494
|
-
assert.equal(accepted.status,
|
|
462
|
+
assert.equal(accepted.status,71,accepted.stderr);assert.match(accepted.stderr,/host_exited/);
|
|
495
463
|
assert.match(accepted.stderr,/supersede_unavailable/);
|
|
496
464
|
for(const permissions of [['--supersede-reviewed-evidence'],['--supersede-reason','operator restart']]){
|
|
497
465
|
const refused=f.drive(f.plan({permissions}),'advance');
|
|
@@ -509,26 +477,17 @@ test('status reads the existing run without answer files or checks',t=>{
|
|
|
509
477
|
const f=fixture(t);prepared(f);assert.equal(f.drive(f.plan(),'advance').status,0);
|
|
510
478
|
const before=fs.readFileSync(f.store);
|
|
511
479
|
const status=f.drive(f.plan({mode:'resume',originalHostContext:'drive-host-a',answers:undefined,checks:undefined}),'status');
|
|
512
|
-
assert.equal(status.status,0,status.stderr);assert.equal(JSON.parse(status.stdout).result.state,'
|
|
480
|
+
assert.equal(status.status,0,status.stderr);assert.equal(JSON.parse(status.stdout).result.state,'fixture_completed');
|
|
513
481
|
assert.deepEqual(fs.readFileSync(f.store),before);
|
|
514
482
|
});
|
|
515
|
-
test('decision sends the package binding and needs no answer files',t=>{
|
|
516
|
-
const f=fixture(t);prepared(f);
|
|
517
|
-
const first=f.drive(f.plan(),'advance');assert.equal(first.status,0,first.stderr);
|
|
518
|
-
const packageDigest=JSON.parse(first.stdout).result.packageDigest;
|
|
519
|
-
const decision=f.drive(f.plan({mode:'resume',originalHostContext:'drive-host-a',
|
|
520
|
-
packageDigest,answers:undefined,checks:undefined}),'decision');
|
|
521
|
-
assert.equal(decision.status,0,decision.stderr);
|
|
522
|
-
assert.equal(JSON.parse(decision.stdout).result.code,'decision_required');
|
|
523
|
-
});
|
|
524
483
|
test('explicit allow-development permission reaches the host once',t=>{
|
|
525
484
|
const f=fixture(t);prepared(f);
|
|
526
485
|
const run=f.drive(f.plan({permissions:['--allow-development']}),'advance');
|
|
527
|
-
assert.equal(run.status,0,run.stderr);assert.equal(JSON.parse(run.stdout).result.code,'
|
|
486
|
+
assert.equal(run.status,0,run.stderr);assert.equal(JSON.parse(run.stdout).result.code,'qa_decision_required');
|
|
528
487
|
});
|
|
529
488
|
test('QA-fix child operation forwards its binding and returns parent gate result',t=>{
|
|
530
|
-
const f=fixture(t);prepared(f);assert.equal(f.drive(f.plan(),'advance').status,0);
|
|
531
|
-
const binding={feature:'1.work',identity,packageDigest:'a'.repeat(64),testRunId:'qa-child'};
|
|
489
|
+
const f=fixture(t);prepared(f);changesRequestedReview(f);assert.equal(f.drive(f.plan({permissions:['--review-config','review.json']}),'advance').status,0);
|
|
490
|
+
const binding={feature:'1.work',identity:{...identity,attempt:2},packageDigest:'a'.repeat(64),testRunId:'qa-child'};
|
|
532
491
|
fs.writeFileSync(path.join(f.root,'fix-owner.json'),JSON.stringify({specsRoot:f.specsDir,identity:{...identity,runId:'fix-run'},
|
|
533
492
|
configuration:{hostContextId:'drive-host-a',reproduction:{cwd:f.codeProject},qaSource:binding}}));
|
|
534
493
|
const attempt=f.drive(f.plan({mode:'resume',originalHostContext:'drive-host-a',
|
|
@@ -537,8 +496,8 @@ test('QA-fix child operation forwards its binding and returns parent gate result
|
|
|
537
496
|
assert.match(attempt.stderr,/qa_fix_parent_not_completed/);
|
|
538
497
|
});
|
|
539
498
|
test('QA-fix child action requires its own answer before any host request',t=>{
|
|
540
|
-
const f=fixture(t);prepared(f);assert.equal(f.drive(f.plan(),'advance').status,0);
|
|
541
|
-
const binding={feature:'1.work',identity,packageDigest:'a'.repeat(64),testRunId:'qa-child'};
|
|
499
|
+
const f=fixture(t);prepared(f);changesRequestedReview(f);assert.equal(f.drive(f.plan({permissions:['--review-config','review.json']}),'advance').status,0);
|
|
500
|
+
const binding={feature:'1.work',identity:{...identity,attempt:2},packageDigest:'a'.repeat(64),testRunId:'qa-child'};
|
|
542
501
|
fs.writeFileSync(path.join(f.root,'fix-owner.json'),JSON.stringify({specsRoot:f.specsDir,identity:{...identity,runId:'fix-run'},
|
|
543
502
|
configuration:{hostContextId:'drive-host-a',reproduction:{cwd:f.codeProject},qaSource:binding}}));
|
|
544
503
|
const options={mode:'resume',originalHostContext:'drive-host-a',packageDigest:'a'.repeat(64),
|
|
@@ -557,8 +516,8 @@ test('QA-fix child action requires its own answer before any host request',t=>{
|
|
|
557
516
|
{outcome:'repaired',edits:[{path:'target.mjs',beforeSha256:'old-hash',content:'export const value = 43;\n'}]});
|
|
558
517
|
});
|
|
559
518
|
test('Q23 QA-fix recovery fixOperations need their parent flag and fields before any host request',t=>{
|
|
560
|
-
const f=fixture(t);prepared(f);assert.equal(f.drive(f.plan(),'advance').status,0);
|
|
561
|
-
const binding={feature:'1.work',identity,packageDigest:'a'.repeat(64),testRunId:'qa-child'};
|
|
519
|
+
const f=fixture(t);prepared(f);changesRequestedReview(f);assert.equal(f.drive(f.plan({permissions:['--review-config','review.json']}),'advance').status,0);
|
|
520
|
+
const binding={feature:'1.work',identity:{...identity,attempt:2},packageDigest:'a'.repeat(64),testRunId:'qa-child'};
|
|
562
521
|
fs.writeFileSync(path.join(f.root,'fix-owner.json'),JSON.stringify({specsRoot:f.specsDir,identity:{...identity,runId:'fix-run'},
|
|
563
522
|
configuration:{hostContextId:'drive-host-a',reproduction:{cwd:f.codeProject},qaSource:binding}}));
|
|
564
523
|
const base={mode:'resume',originalHostContext:'drive-host-a',packageDigest:'a'.repeat(64),testRunId:'qa-child',
|
|
@@ -606,11 +565,11 @@ test('new policy real driver reuses only declared checks and frozen resume keeps
|
|
|
606
565
|
const command=[process.execPath,'-e',"require('node:fs').appendFileSync("+JSON.stringify(path.join(f.root,'execution-count'))+",'x');console.log('tests 1\\npass 1')"];
|
|
607
566
|
const checks=[{id:'tests',command},{id:'ui',command,sameExecutionAs:'tests'}];
|
|
608
567
|
const plan=f.plan({permissions:['--execution-optimizations'],checks});
|
|
609
|
-
const first=f.drive(plan,'advance');assert.equal(first.status,0,first.stderr);assert.equal(JSON.parse(first.stdout).result.state,'
|
|
610
|
-
assert.equal(fs.readFileSync(path.join(f.root,'execution-count'),'utf8'),'
|
|
568
|
+
const first=f.drive(plan,'advance');assert.equal(first.status,0,first.stderr);assert.equal(JSON.parse(first.stdout).result.state,'fixture_completed',first.stdout+first.stderr);
|
|
569
|
+
assert.equal(fs.readFileSync(path.join(f.root,'execution-count'),'utf8'),'xx');
|
|
611
570
|
const before=fs.readFileSync(f.store),snapshot=JSON.parse(before);assert.equal(snapshot.records[0].payload.config.executionPolicy.checkReuse,'declared-adjacent-v1');
|
|
612
571
|
const resume=f.plan({mode:'resume',checks});const status=f.drive(resume,'status');assert.equal(status.status,0,status.stderr);
|
|
613
|
-
assert.equal(fs.readFileSync(path.join(f.root,'execution-count'),'utf8'),'
|
|
572
|
+
assert.equal(fs.readFileSync(path.join(f.root,'execution-count'),'utf8'),'xx');assert.deepEqual(fs.readFileSync(f.store),before);
|
|
614
573
|
});
|
|
615
574
|
test('legacy real driver rejects optimization aliases before any host or command starts',t=>{
|
|
616
575
|
const f=fixture(t);prepared(f);const command=[process.execPath,'-e',"require('node:fs').writeFileSync('marker','bad')"];
|