@aibyzero/cm-workflow 0.16.9 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/.codex-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +12 -0
  3. package/README.md +9 -1
  4. package/VERSION +1 -1
  5. package/docs/cm-control-policy-v2.md +331 -0
  6. package/docs/execution-optimizations.md +1 -1
  7. package/docs/external-models.md +3 -3
  8. package/docs/human-correction.md +5 -5
  9. package/docs/installation.md +1 -1
  10. package/docs/js-workflow-control.md +101 -84
  11. package/docs/next-steps.md +11 -0
  12. package/docs/untested-branches.md +2 -3
  13. package/docs/user-guide.md +3 -3
  14. package/package.json +1 -1
  15. package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +13 -69
  16. package/runtime/js/cm-ai/cm-ai-qa-log.mjs +10 -5
  17. package/runtime/js/cm-ai/control-policy.mjs +111 -0
  18. package/runtime/js/cm-ai/drive-bootstrap.mjs +11 -8
  19. package/runtime/js/cm-ai/durable-runner-state.mjs +32 -126
  20. package/runtime/js/cm-ai/gate-bridge.mjs +4 -4
  21. package/runtime/js/cm-ai/host-conversation-execution.mjs +22 -20
  22. package/runtime/js/cm-ai/host-qa-fix-owner.mjs +11 -2
  23. package/runtime/js/cm-ai/host-qa-policy.mjs +63 -21
  24. package/runtime/js/cm-ai/host-review-authority.mjs +2 -2
  25. package/runtime/js/cm-ai/host-review-file.mjs +1 -1
  26. package/runtime/js/cm-ai/host-tool-bridge.mjs +3 -0
  27. package/runtime/js/cm-ai/host-workflow-capabilities.mjs +21 -10
  28. package/runtime/js/cm-ai/host.mjs +1 -2
  29. package/runtime/js/cm-ai/operator-guidance.mjs +1 -24
  30. package/runtime/js/cm-ai/review-package.mjs +16 -4
  31. package/runtime/js/cm-ai/reviewed-deliveries.mjs +1 -1
  32. package/runtime/js/cm-ai/task-runner.mjs +36 -99
  33. package/runtime/js/cm-init/review-evidence.mjs +3 -1
  34. package/runtime/js/cm-prd/review-host.mjs +1 -1
  35. package/runtime/js/cm-prd/review-publication.mjs +5 -3
  36. package/runtime/js/cm-refactor/workflow.mjs +1 -1
  37. package/runtime/js/notify-send.mjs +15 -14
  38. package/runtime/js/notify.mjs +27 -4
  39. package/runtime/js/policy-binding-compat.mjs +2 -1
  40. package/runtime/review.md +52 -7
  41. package/runtime/task-gates.md +107 -9
  42. package/scripts/cm-ai-abandon-effect-position.test.mjs +1 -8
  43. package/scripts/cm-ai-answer-gap-driver.test.mjs +12 -12
  44. package/scripts/cm-ai-answer-gap-fixture.mjs +1 -8
  45. package/scripts/cm-ai-batch-drive.mjs +50 -31
  46. package/scripts/cm-ai-batch-drive.test.mjs +62 -19
  47. package/scripts/cm-ai-batch-host.mjs +39 -20
  48. package/scripts/cm-ai-batch-host.test.mjs +62 -38
  49. package/scripts/cm-ai-batch-run-fixture.mjs +6 -53
  50. package/scripts/cm-ai-batch-run-member-stops.test.mjs +0 -12
  51. package/scripts/cm-ai-batch-run.mjs +34 -8
  52. package/scripts/cm-ai-bootstrap-flow.test.mjs +1 -7
  53. package/scripts/cm-ai-bootstrap.test.mjs +2 -3
  54. package/scripts/cm-ai-control-launch.test.mjs +219 -0
  55. package/scripts/cm-ai-control-policy.test.mjs +124 -0
  56. package/scripts/cm-ai-control-v2-drive.test.mjs +270 -0
  57. package/scripts/cm-ai-develop-answer-invalid.test.mjs +1 -8
  58. package/scripts/cm-ai-develop-call-timeout.test.mjs +1 -8
  59. package/scripts/cm-ai-develop-driver-gaps.test.mjs +33 -20
  60. package/scripts/cm-ai-direct-review.test.mjs +348 -0
  61. package/scripts/cm-ai-documentation-sync-gap.test.mjs +3 -3
  62. package/scripts/cm-ai-drive-bootstrap-rules.test.mjs +54 -25
  63. package/scripts/cm-ai-drive.mjs +96 -54
  64. package/scripts/cm-ai-drive.test.mjs +43 -84
  65. package/scripts/cm-ai-fix-integration.test.mjs +3 -5
  66. package/scripts/cm-ai-fix-later-delivery.test.mjs +3 -6
  67. package/scripts/cm-ai-fix-run-delivery.test.mjs +3 -6
  68. package/scripts/cm-ai-host-cli-workflow.test.mjs +6 -10
  69. package/scripts/cm-ai-host-fixture.mjs +38 -10
  70. package/scripts/cm-ai-host-protected.test.mjs +35 -33
  71. package/scripts/cm-ai-host.mjs +103 -93
  72. package/scripts/cm-ai-host.test.mjs +19 -18
  73. package/scripts/cm-ai-launch-diagnostics.test.mjs +5 -3
  74. package/scripts/cm-ai-legacy-history.test.mjs +53 -0
  75. package/scripts/cm-ai-light-modules.test.mjs +4 -7
  76. package/scripts/cm-ai-multi-root.test.mjs +4 -4
  77. package/scripts/cm-ai-nested-execution.test.mjs +16 -19
  78. package/scripts/cm-ai-progress.test.mjs +10 -8
  79. package/scripts/cm-ai-project-qa-gate.test.mjs +37 -10
  80. package/scripts/cm-ai-protected-scope.test.mjs +1 -2
  81. package/scripts/cm-ai-qa-config-revision.test.mjs +1 -9
  82. package/scripts/cm-ai-qa-fingerprint-config.test.mjs +12 -9
  83. package/scripts/cm-ai-qa-fix-cross-session.test.mjs +18 -3
  84. package/scripts/cm-ai-qa-fixed-log.test.mjs +41 -0
  85. package/scripts/cm-ai-qa-recovery-args.test.mjs +7 -0
  86. package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +3 -4
  87. package/scripts/cm-ai-review-drift-precedence.test.mjs +1 -1
  88. package/scripts/cm-ai-review-failure.test.mjs +13 -19
  89. package/scripts/cm-ai-review-timeout-config.test.mjs +3 -1
  90. package/scripts/cm-ai-review-timeout.test.mjs +15 -128
  91. package/scripts/cm-ai-run.mjs +78 -24
  92. package/scripts/cm-ai-run.test.mjs +11 -38
  93. package/scripts/cm-ai-selection-guard.test.mjs +2 -2
  94. package/scripts/cm-ai-session-chain.test.mjs +18 -15
  95. package/scripts/cm-ai-spec-rebind.test.mjs +14 -18
  96. package/scripts/cm-ai-supersede.test.mjs +3 -10
  97. package/scripts/cm-blocked-reason.test.mjs +2 -3
  98. package/scripts/cm-capability-gate.test.mjs +33 -1
  99. package/scripts/cm-check-drive-files.mjs +1 -1
  100. package/scripts/cm-check-runtime.sh +1 -1
  101. package/scripts/cm-claude-worker.test.mjs +5 -3
  102. package/scripts/cm-controlled-correction.test.mjs +469 -0
  103. package/scripts/cm-external-batch-host.test.mjs +30 -11
  104. package/scripts/cm-external-model-host.test.mjs +1 -1
  105. package/scripts/cm-external-model-recovery.test.mjs +3 -9
  106. package/scripts/cm-external-qa-fix.test.mjs +1 -1
  107. package/scripts/cm-external-review-reconciliation.test.mjs +6 -24
  108. package/scripts/cm-fix-review-recovery.test.mjs +1 -1
  109. package/scripts/cm-host-qa-executor.test.mjs +1 -2
  110. package/scripts/cm-host-qa-policy.test.mjs +43 -16
  111. package/scripts/cm-host-review-authority.test.mjs +0 -31
  112. package/scripts/cm-knowledge-closeout.test.mjs +3 -3
  113. package/scripts/cm-notify-command.test.mjs +54 -18
  114. package/scripts/cm-notify-read-drift.test.mjs +69 -4
  115. package/scripts/cm-notify.mjs +16 -4
  116. package/scripts/cm-notify.test.mjs +91 -19
  117. package/scripts/cm-patrol.test.mjs +3 -2
  118. package/scripts/cm-task-gate-correction.test.mjs +69 -16
  119. package/scripts/cm-task-gate.mjs +368 -34
  120. package/scripts/cm-task-gate.py +2 -0
  121. package/scripts/cm-task-gate.test.mjs +252 -4
  122. package/scripts/fixtures/bootstrap-review-runner.mjs +1 -7
  123. package/scripts/fixtures/native-gate-fixture.mjs +18 -0
  124. package/scripts/policy-binding-compat.test.mjs +4 -0
  125. package/skills/cm-ai/SKILL.md +8 -6
  126. package/skills/cm-ai/references/N3-execute-task.md +17 -2
  127. package/skills/cm-ai/references/N4-review.md +11 -21
  128. package/skills/cm-ai/references/N5-mark-done.md +1 -1
  129. package/skills/cm-ai/references/N6-qa-eval.md +49 -21
  130. package/skills/cm-ai/references/js-host-modes.md +35 -14
  131. package/skills/cm-ai/references/js-host-qa-recovery.md +60 -12
  132. package/skills/cm-ai/references/js-host-recovery.md +95 -47
  133. package/skills/cm-ai/references/js-host.md +65 -28
  134. package/skills/cm-fix/SKILL.md +12 -0
  135. package/skills/cm-init/references/js-host.md +1 -1
  136. package/skills/cm-prd/references/js-host.md +1 -1
  137. package/skills/cm-refactor/SKILL.md +12 -0
  138. package/runtime/js/cm-ai/review-dispatch-limits.mjs +0 -18
  139. package/scripts/cm-ai-review-dispatch-exit.test.mjs +0 -475
@@ -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
- // create requires a bound review configuration; this one grants no review attempt.
35
- fs.writeFileSync(path.join(root,'placeholder-review.json'),JSON.stringify({model:'fixture',preflight:{}}));
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','placeholder-review.json'];
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','--allow-review-attempt','1'];
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
- function assertActionableFirstReviewHint(stderr){
68
- assert.match(stderr,/develop-a2\.json/);
69
- assert.match(stderr,/审查后可能直接进入第 2 轮 develop/);
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,'awaiting_review');
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,'awaiting_review');
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-authorized create preflights a possible second develop round',t=>{
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.identity.attempt,2);
153
- assert.equal(fs.readFileSync(path.join(f.codeProject,'target.mjs'),'utf8'),'export const value = 42;\n');
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',{scores:{scope:1,risk:1,accumulation:1,boundary:1},
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',{scores:{scope:2,risk:2,accumulation:2,boundary:2},
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,'awaiting_review');assert.equal(result.code,'decision_required');
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,'decision_required');
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,'awaiting_review');
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,7 +447,7 @@ 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,'awaiting_review');
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
452
  assert.equal(cross.status,1,cross.stderr);assert.match(cross.stderr,/fingerprint_mismatch/);
485
453
  assert.deepEqual(fs.readFileSync(f.store),before);
@@ -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,'awaiting_review');
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,'decision_required');
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,'awaiting_review',first.stdout+first.stderr);
610
- assert.equal(fs.readFileSync(path.join(f.root,'execution-count'),'utf8'),'x');
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'),'x');assert.deepEqual(fs.readFileSync(f.store),before);
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')"];
@@ -7,7 +7,6 @@ import path from 'node:path';
7
7
  import {openControlRun} from './cm-ai-run.mjs';
8
8
  import {createCodexDeveloperRun} from '../runtime/js/cm-ai/codex-developer-adapter.mjs';
9
9
  import {createHostCheck} from '../runtime/js/cm-ai/host-check.mjs';
10
- import {createHostReviewAuthority} from '../runtime/js/cm-ai/host-review-authority.mjs';
11
10
  import {createQaFixOwnerHost} from '../runtime/js/cm-ai/host-qa-fix-owner.mjs';
12
11
  import {createFixReviewHost} from '../runtime/js/cm-fix/host-review.mjs';
13
12
  import {qaFixIdentity} from '../runtime/js/cm-fix/qa-source.mjs';
@@ -42,9 +41,8 @@ for(const mode of ['history','retest','unknown','failed-retest','double-pass','d
42
41
  {event:'item.completed',item_type:'agent_message'},{event:'turn.completed',item_type:null},
43
42
  {event:'process_closed',exit_code:0,signal:null,timed_out:false}])onEvent(event);
44
43
  };
45
- const authority=createHostReviewAuthority({hostContextId:'parent-host',reviewerId:'reviewer',adapterId:'codex-review-adapter',decide:async()=>({status:'approved'})});
46
- const execution={configuration:{kind:'synthetic-parent-fix'},timeoutMs:2000,excludedContexts:['parent-host'],hostDecision:null,
47
- hostDecisionProvider:authority.hostDecisionProvider,
44
+
45
+ const execution={configuration:{kind:'synthetic-parent-fix'},timeoutMs:2000,excludedContexts:['parent-host'],
48
46
  developer:{provider:'codex',requestedModel:'synthetic',contextId:'author',run:createCodexDeveloperRun({requestedModel:'synthetic',worker:async()=>{
49
47
  developers++;fs.writeFileSync(path.join(codeProject,'value.mjs'),'export const value=1;');
50
48
  return {status:'succeeded',value:{outcome:'implemented',application:{status:'no_relevant_lesson',note:null},
@@ -56,7 +54,7 @@ for(const mode of ['history','retest','unknown','failed-retest','double-pass','d
56
54
  return {status:'succeeded',value:{verdict:'approved',packageDigest:request.payload.reviewPackage.packageDigest,
57
55
  examinedPaths:reviewPaths(request.payload.reviewPackage),findings:[],summary:'Synthetic parent review; QA exposes remaining defect'}};
58
56
  }}],
59
- reviewInvocation:{developerThreadId:'author',excludedThreadIds:['parent-host'],authorize:authority.authorize},
57
+ reviewInvocation:{developerThreadId:'author',excludedThreadIds:['parent-host']},
60
58
  check:createHostCheck({cwd:codeProject,commands:[{id:'existing',command:[process.execPath,'existing.mjs']}]}),
61
59
  qaLogHome:path.join(root,'logs'),qaDecisionProvider:{timeoutMs:1000,decide:async binding=>({decisionId:'qa-parent',identity:binding.identity,packageDigest:binding.packageDigest,
62
60
  status:'triggered',reason:'feature_complete',score:null,at:'2026-09-08T01:00:00Z'})},
@@ -9,7 +9,6 @@ import {buildManifest} from './cm-spec-manifest.mjs';
9
9
  import {openControlRun} from './cm-ai-run.mjs';
10
10
  import {createCodexDeveloperRun} from '../runtime/js/cm-ai/codex-developer-adapter.mjs';
11
11
  import {createHostCheck} from '../runtime/js/cm-ai/host-check.mjs';
12
- import {createHostReviewAuthority} from '../runtime/js/cm-ai/host-review-authority.mjs';
13
12
  import {createQaFixOwnerHost} from '../runtime/js/cm-ai/host-qa-fix-owner.mjs';
14
13
  import {createFixReviewHost} from '../runtime/js/cm-fix/host-review.mjs';
15
14
  import {qaFixIdentity} from '../runtime/js/cm-fix/qa-source.mjs';
@@ -56,10 +55,8 @@ for(const variant of ['separate','shared'])test(`#18 a QA fix for an earlier fea
56
55
  fs.writeFileSync(path.join(codeProject,'.cm-workflow.json'),JSON.stringify({version:1,policies:{delivery:'diff'}}));
57
56
  let qaRuns=0,childReviews=0,documentation=0;
58
57
  const execution=({feature,write,retrospective={status:'no_new_lesson',candidates:[],reason:null},qa})=>{
59
- const authority=createHostReviewAuthority({hostContextId:'parent-host',reviewerId:'reviewer',adapterId:'codex-review-adapter',
60
- decide:async()=>({status:'approved'})});
61
- return {configuration:{kind:'synthetic-parent-fix'},timeoutMs:2000,excludedContexts:['parent-host'],hostDecision:null,
62
- hostDecisionProvider:authority.hostDecisionProvider,
58
+
59
+ return {configuration:{kind:'synthetic-parent-fix'},timeoutMs:2000,excludedContexts:['parent-host'],
63
60
  developer:{provider:'codex',requestedModel:'synthetic',contextId:'author',run:createCodexDeveloperRun({requestedModel:'synthetic',worker:async()=>{
64
61
  write();return {status:'succeeded',value:{outcome:'implemented',application:{status:'no_relevant_lesson',note:null},retrospective}};}})},
65
62
  reviewers:[{id:'reviewer',adapterId:'codex-review-adapter',provider:'codex',requestedModel:'synthetic',allowed:true,available:true,
@@ -67,7 +64,7 @@ for(const variant of ['separate','shared'])test(`#18 a QA fix for an earlier fea
67
64
  events(onEvent,`synthetic-review-${request.identity.runId}`);
68
65
  return {status:'succeeded',value:{verdict:'approved',packageDigest:request.payload.reviewPackage.packageDigest,
69
66
  examinedPaths:reviewPaths(request.payload.reviewPackage),findings:[],summary:'Synthetic review'}};}}],
70
- reviewInvocation:{developerThreadId:'author',excludedThreadIds:['parent-host'],authorize:authority.authorize},
67
+ reviewInvocation:{developerThreadId:'author',excludedThreadIds:['parent-host']},
71
68
  check:createHostCheck({cwd:codeProject,commands:[{id:'existing',command:[process.execPath,'existing.mjs']}]}),
72
69
  qaLogHome:path.join(root,'logs'),qaDecisionProvider:{timeoutMs:1000,decide:async binding=>({decisionId:`qa-${binding.identity.runId}`,
73
70
  identity:binding.identity,packageDigest:binding.packageDigest,status:'triggered',reason:'feature_complete',score:null,at:'2026-09-28T01:00:00Z'})},
@@ -12,7 +12,6 @@ import {buildManifest} from './cm-spec-manifest.mjs';
12
12
  import {openControlRun} from './cm-ai-run.mjs';
13
13
  import {createCodexDeveloperRun} from '../runtime/js/cm-ai/codex-developer-adapter.mjs';
14
14
  import {createHostCheck} from '../runtime/js/cm-ai/host-check.mjs';
15
- import {createHostReviewAuthority} from '../runtime/js/cm-ai/host-review-authority.mjs';
16
15
  import {reviewPaths} from '../runtime/js/cm-ai/review-runner.mjs';
17
16
  import {openFixExecution} from '../runtime/js/cm-fix/execution.mjs';
18
17
  import {createFixHost} from '../runtime/js/cm-fix/host.mjs';
@@ -49,10 +48,8 @@ async function completedTaskThenFix({finish}){
49
48
  fs.writeFileSync(path.join(codeProject,'red.mjs'),"import {value} from './value.mjs';if(value!==2){console.error('BUG');process.exit(1)}");
50
49
  fs.writeFileSync(path.join(codeProject,'existing.mjs'),"import {value} from './value.mjs';if(typeof value!=='number')process.exit(1)");
51
50
  fs.writeFileSync(path.join(codeProject,'.cm-workflow.json'),JSON.stringify({version:1,policies:{delivery:'diff'}}));
52
- const authority=createHostReviewAuthority({hostContextId:'parent-host',reviewerId:'reviewer',adapterId:'codex-review-adapter',
53
- decide:async()=>({status:'approved'})});
54
- const execution={configuration:{kind:'synthetic-parent'},timeoutMs:2000,excludedContexts:['parent-host'],hostDecision:null,
55
- hostDecisionProvider:authority.hostDecisionProvider,
51
+
52
+ const execution={configuration:{kind:'synthetic-parent'},timeoutMs:2000,excludedContexts:['parent-host'],
56
53
  developer:{provider:'codex',requestedModel:'synthetic',contextId:'author',run:createCodexDeveloperRun({requestedModel:'synthetic',worker:async()=>{
57
54
  fs.writeFileSync(path.join(codeProject,'value.mjs'),'export const value=1;');
58
55
  return {status:'succeeded',value:{outcome:'implemented',application:{status:'no_relevant_lesson',note:null},
@@ -62,7 +59,7 @@ async function completedTaskThenFix({finish}){
62
59
  events(onEvent,`synthetic-review-${request.identity.runId}`);
63
60
  return {status:'succeeded',value:{verdict:'approved',packageDigest:request.payload.reviewPackage.packageDigest,
64
61
  examinedPaths:reviewPaths(request.payload.reviewPackage),findings:[],summary:'Synthetic review'}};}}],
65
- reviewInvocation:{developerThreadId:'author',excludedThreadIds:['parent-host'],authorize:authority.authorize},
62
+ reviewInvocation:{developerThreadId:'author',excludedThreadIds:['parent-host']},
66
63
  check:createHostCheck({cwd:codeProject,commands:[{id:'existing',command:[process.execPath,'existing.mjs']}]}),
67
64
  qaLogHome:path.join(root,'logs'),qaDecisionProvider:{timeoutMs:1000,decide:async binding=>({decisionId:`qa-${binding.identity.runId}`,
68
65
  identity:binding.identity,packageDigest:binding.packageDigest,status:'triggered',reason:'feature_complete',score:null,at:'2026-10-08T01:00:00Z'})},
@@ -67,7 +67,7 @@ let input='';process.stdin.on('data',s=>input+=s);process.stdin.on('end',()=>{
67
67
  repair:{scope:['target.mjs','README.md'],requirements:['requirements.md']},
68
68
  walkthrough:{timeoutMs:2000,flows:[{id:'value',modules:['value'],steps:['Read exported value'],expected:['43'],kind:'commands',command}]}};
69
69
  const template=path.join(f.root,'template.json');fs.writeFileSync(template,JSON.stringify({specsRoot:f.specsDir,feature:'1.work',identity,configuration}));
70
- f.args.push('--runtime',runtime,'--review-config',reviewFile,'--allow-review-attempt','1','--workflow-config',workflowFile,'--allow-qa',
70
+ f.args.push('--runtime',runtime,'--review-config',reviewFile,'--workflow-config',workflowFile,'--allow-qa',
71
71
  '--qa-fix-template-config',template,'--qa-fix-review-config',reviewFile,'--allow-qa-fix-start','--auto-qa-fix',
72
72
  ...permissions.map(name=>`--allow-qa-fix-${name}`));
73
73
  if(f.protected){
@@ -94,7 +94,7 @@ let input='';process.stdin.on('data',s=>input+=s);process.stdin.on('end',()=>{
94
94
  }finally{fs.rmSync(f.root,{recursive:true,force:true});}
95
95
  });
96
96
 
97
- for(const runtime of ['codex','claude'])for(const initialWorkflow of ['absent','qa-null','qa'])test(`configured ${runtime} CLI waits for the authorized attempt and resumes via the original review worker/gate workflow=${initialWorkflow}`,async()=>{
97
+ for(const runtime of ['codex','claude'])for(const initialWorkflow of ['absent','qa-null','qa'])test(`configured ${runtime} CLI starts development and resumes through direct review and resumes via the original review worker/gate workflow=${initialWorkflow}`,async()=>{
98
98
  const workflow=initialWorkflow==='qa';
99
99
  const f=fixture();
100
100
  try{
@@ -121,7 +121,7 @@ for(const runtime of ['codex','claude'])for(const initialWorkflow of ['absent','
121
121
  f.args.push('--review-config',config);
122
122
  if(runtime==='claude'){
123
123
  fs.writeFileSync(config,JSON.stringify({...review,preflight:{...review.preflight,provider:'codex'}}));
124
- const denied=spawnSync(process.execPath,[cli,...f.args,'--allow-review-attempt','1'],{encoding:'utf8',env:f.env,timeout:3000});
124
+ const denied=spawnSync(process.execPath,[cli,...f.args],{encoding:'utf8',env:f.env,timeout:3000});
125
125
  assert.equal(denied.status,1);assert(denied.stderr.includes('tool_preflight_missing'));
126
126
  assert(!fs.existsSync(path.join(f.specsDir,'.reviews')));
127
127
  fs.writeFileSync(config,JSON.stringify(review));
@@ -146,8 +146,8 @@ for(const runtime of ['codex','claude'])for(const initialWorkflow of ['absent','
146
146
  fs.writeFileSync(attachmentFile,JSON.stringify({...attachmentConfig,qa:null}));
147
147
  f.args.push('--workflow-config',attachmentFile);
148
148
  }
149
- const first=await runCli(f,'normal');assert.equal(first.code,0,first.stderr);
150
- assert.equal(first.rows.find(row=>row.requestId==='advance').result.code,'decision_required');
149
+ f.operation='start';const first=await runCli(f,'normal');assert.equal(first.code,0,first.stderr);
150
+ assert.equal(first.rows.find(row=>row.requestId==='advance').result.code,null);
151
151
  const initialArgs=[...f.args];
152
152
  const attemptAttachment=()=>{
153
153
  fs.writeFileSync(attachmentFile,JSON.stringify(attachmentConfig));
@@ -163,11 +163,7 @@ for(const runtime of ['codex','claude'])for(const initialWorkflow of ['absent','
163
163
  }
164
164
 
165
165
  assert(fs.readFileSync(path.join(f.specsDir,'1.work','tasks.md'),'utf8').includes('[ ] T-001'));
166
- // An approved different round cannot authorize this pending round.
167
- f.args.push('--allow-review-attempt','2');
168
- const wrong=await runCli(f,'normal','resume');assert.equal(wrong.code,0,wrong.stderr);
169
- assert.deepEqual(wrong.calls,[]);assert.equal(wrong.rows.find(row=>row.requestId==='advance').result.code,'decision_required');
170
- f.args[f.args.length-1]='1';
166
+ f.operation='advance';
171
167
  const completed=await runCli(f,'authorized-review','resume');assert.equal(completed.code,0,completed.stderr);
172
168
  assert.deepEqual(completed.calls,workflow?['check','qa_assess','documentation_inspect']:['check']);
173
169
  const result=completed.rows.find(row=>row.requestId==='advance').result;
@@ -11,6 +11,8 @@ import os from 'node:os';
11
11
  import path from 'node:path';
12
12
  import {spawn,spawnSync} from 'node:child_process';
13
13
  import {fileURLToPath} from 'node:url';
14
+ import {configFingerprint} from '../runtime/js/cm-ai/codex-config.mjs';
15
+ import {claudeReviewFingerprint} from '../runtime/js/cm-ai/worker-claude.mjs';
14
16
  import {guardFixtureSource,killFixtureProcesses} from './fixtures/process-cleanup.mjs';
15
17
 
16
18
  // Keep runtime declarations and log mirrors independent of the invoking user's home.
@@ -39,13 +41,40 @@ export function fixture(){
39
41
  fs.writeFileSync(path.join(specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:[feature],specFiles:buildManifest(specsDir)}));
40
42
  fs.writeFileSync(path.join(codeProject,'requirements.md'),'# Fixture\n');
41
43
  fs.writeFileSync(config,JSON.stringify({version:1,specsDir,codeProject,feature,identity,scope:['target.mjs'],requirements:['requirements.md']}));
42
- // create requires a bound review configuration; it grants no review attempt.
43
- const reviewFile=path.join(root,'placeholder-review.json');
44
- fs.writeFileSync(reviewFile,JSON.stringify({model:'fixture',preflight:{}}));
45
- return {root,specsDir,codeProject,config,reviewFile,args:['serve','--config',config,'--mode','create','--host-context','native-host-fixture','--allow-development']};
44
+ const reviewFile=path.join(root,'synthetic-review.json');
45
+ const f={root,specsDir,codeProject,config,reviewFile,args:['serve','--config',config,'--mode','create','--host-context','native-host-fixture','--allow-development']};
46
+ installSyntheticReview(f);
47
+ return f;
48
+ }
49
+ export function syntheticReviewConfig(codeProject,runtime='codex',model='fixture'){
50
+ return {model,disabledSkills:[],preflight:{passed:true,provider:runtime,cli_model:model,prompt_transport:'stdin',
51
+ config_fingerprint:(runtime==='claude'?claudeReviewFingerprint:configFingerprint)({cwd:codeProject,model,disabledSkills:[]})}};
52
+ }
53
+ // Only review output is synthetic. Any sandbox request delegates to the actual
54
+ // installed Codex, preserving native write-protection and command checks.
55
+ export function installSyntheticReview(f){
56
+ const bin=path.join(f.root,'synthetic-review-bin');fs.mkdirSync(bin,{recursive:true});
57
+ const real=spawnSync('/usr/bin/which',['codex'],{encoding:'utf8'}).stdout.trim();
58
+ for(const runtime of ['codex','claude']){
59
+ const source=fileURLToPath(new URL(`./fixtures/${runtime}-review-process.mjs`,import.meta.url));
60
+ fs.writeFileSync(path.join(bin,runtime),`#!${process.execPath}\n`
61
+ +`const {spawnSync}=await import('node:child_process');\n`
62
+ +`if(process.argv[2]==='sandbox'){const r=spawnSync(${JSON.stringify(real)},process.argv.slice(2),{stdio:'inherit'});process.exitCode=r.status??1;}\n`
63
+ +`else await import(${JSON.stringify(new URL('file://'+source).href)});\n`,{mode:0o700});
64
+ }
65
+ f.env={...(f.env??process.env),PATH:bin+path.delimiter+(f.env?.PATH??process.env.PATH),
66
+ CM_WORKFLOW_HOME:path.join(f.root,'home'),CM_WORKFLOW_LOG_HOME:path.join(f.root,'logs')};
67
+ if(f.reviewFile)fs.writeFileSync(f.reviewFile,JSON.stringify(syntheticReviewConfig(f.codeProject,f.runtime)));
68
+ return f;
46
69
  }
47
- // A test that supplies its own --review-config keeps it; others use the placeholder.
48
- export const launchArgs=f=>f.args.includes('--review-config')?f.args:[...f.args,'--review-config',f.reviewFile];
70
+ // Explicit review configs retain the case's intended missing/stale preflight.
71
+ export const launchArgs=f=>{
72
+ if(f.args.includes('--review-config'))return f.args;
73
+ const index=f.args.indexOf('--review-runtime'),hostIndex=f.args.indexOf('--runtime');
74
+ const runtime=index>=0?f.args[index+1]:hostIndex>=0?f.args[hostIndex+1]:'codex';
75
+ fs.writeFileSync(f.reviewFile,JSON.stringify(syntheticReviewConfig(f.codeProject,runtime)));
76
+ return [...f.args,'--review-config',f.reviewFile];
77
+ };
49
78
 
50
79
  export function runCli(f,mode,action='create'){
51
80
  return new Promise((resolve,reject)=>{
@@ -128,8 +157,7 @@ export function runCli(f,mode,action='create'){
128
157
  send(response(row,{status:'completed'}));
129
158
  }else if(row.kind==='qa_assess'){
130
159
  assert(f.workflow);assert.equal(row.payload.pending,0);
131
- send(response(row,{scores:{scope:1,risk:1,accumulation:1,boundary:1},
132
- changes:{api:false,migration:false,authentication:false,authorization:false,payment:false}}));
160
+ send(response(row,{confirmed:true}));
133
161
  }else if(row.kind==='qa_browser'&&f.qaBrowser){
134
162
  send(response(row,f.qaBrowser(row.payload)));
135
163
  }else if(row.kind==='documentation_inspect'){
@@ -154,7 +182,7 @@ export function runCli(f,mode,action='create'){
154
182
  }
155
183
  });
156
184
  child.once('close',code=>{disarm();resolve({code,stderr,rows,calls});});
157
- send(f.request??request('advance'));
185
+ send(f.request??{...request(f.operation??'advance'),requestId:'advance'});
158
186
  });
159
187
  }
160
188
 
@@ -220,7 +248,7 @@ export function protectedResultFixture(){
220
248
  fs.writeFileSync(config,JSON.stringify({timeoutMs:5000,
221
249
  checkCommands:[{id:'syntax',command:[process.execPath,'--check','target.mjs']}]}));
222
250
  f.args.push('--protected-conversation-config',config);
223
- f.env={...process.env,CM_WORKFLOW_LOG_HOME:path.join(f.root,'logs')};
251
+ f.env={...f.env,CM_WORKFLOW_LOG_HOME:path.join(f.root,'logs')};
224
252
  return f;
225
253
  }
226
254
  export const implementedValue=()=>({outcome:'implemented',application:{status:'no_relevant_lesson',note:null},