@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 {batchDevelopAttempts} from './cm-ai-batch-drive.mjs';
11
12
  import {runLiveDriver} from './fixtures/live-evidence-driver.mjs';
12
13
 
@@ -41,6 +42,8 @@ function fixture(t,count=1){
41
42
  fs.writeFileSync(path.join(root,'review.json'),JSON.stringify({model:'fixture',preflight:{passed:true,
42
43
  cli_model:'fixture',prompt_transport:'stdin',config_fingerprint:configFingerprint({cwd:codeProject,model:'fixture'})}}));
43
44
  fs.copyFileSync(reviewer,path.join(bin,'codex'));fs.chmodSync(path.join(bin,'codex'),0o700);
45
+ const claudeReviewer=fileURLToPath(new URL('./fixtures/claude-review-process.mjs',import.meta.url));
46
+ fs.copyFileSync(claudeReviewer,path.join(bin,'claude'));fs.chmodSync(path.join(bin,'claude'),0o700);
44
47
  const answers=path.join(root,'answers','1.work','T-001');fs.mkdirSync(answers,{recursive:true});
45
48
  fs.writeFileSync(path.join(answers,'target.txt'),'export const value = 42;\n');
46
49
  const write=(name,value)=>fs.writeFileSync(path.join(answers,name),JSON.stringify(value));
@@ -49,7 +52,7 @@ function fixture(t,count=1){
49
52
  const value={config:'batch.json',mode:'create',hostContext:'batch-host-a',
50
53
  permissions:['--allow-qa'],answers:'answers',checks:Object.fromEntries(batch.tasks.map(task=>
51
54
  [`1.work/${task.taskId}`,[{id:'syntax',command:[process.execPath,'--check',task.taskId==='T-001'?'target.mjs':'target2.mjs']}]])),...extra};
52
- // A new batch requires a bound review configuration (it grants no review).
55
+ // A new batch requires bound review configuration for automatic review execution.
53
56
  if(!value.permissions.includes('--review-config'))value.permissions=[...value.permissions,'--review-config','review.json'];
54
57
  fs.writeFileSync(file,JSON.stringify(value));
55
58
  return file;
@@ -62,8 +65,7 @@ function fixture(t,count=1){
62
65
  }
63
66
  function prepared(f){
64
67
  f.write('develop.json',develop);
65
- f.write('qa-assess.json',{scores:{scope:2,risk:2,accumulation:2,boundary:2},
66
- changes:{api:false,migration:false,authentication:false,authorization:false,payment:false}});
68
+ f.write('qa-assess.json',{confirmed:true});
67
69
  f.write('documentation-inspect.json',{status:'completed',reason:'README and task artifacts inspected'});
68
70
  }
69
71
  function noStore(f){assert.equal(fs.existsSync(f.store),false);assert.equal(fs.existsSync(path.join(f.specsDir,'运行日志.jsonl')),false);}
@@ -73,7 +75,7 @@ test('batch reaches live logic and browser QA through the real member host',asyn
73
75
  acIds:[],taskIds:['T-001'],title:'Fixture observation',preconditions:[],steps:['Observe fixture'],expected:['value is 42'],cleanup:[]}));
74
76
  fs.writeFileSync(path.join(f.specsDir,'1.work/test-cases.json'),JSON.stringify({schemaVersion:'1.0',feature:'work',cases}));
75
77
  fs.writeFileSync(path.join(f.specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:['1.work'],specFiles:buildManifest(f.specsDir)}));
76
- const plan=f.plan({permissions:['--allow-qa','--allow-review',`${key}:1`,'--browser-qa','available'],
78
+ const plan=f.plan({permissions:['--allow-qa','--browser-qa','available'],
77
79
  liveEvidence:{directory:'exchange',kinds:['qa_logic','qa_browser'],timeoutMs:1000}});
78
80
  const out=await runLiveDriver(DRIVER,plan,'advance',row=>row.kind==='qa_logic'
79
81
  ?{verdict:'SUPPORTED',evidence:['Fixture target.mjs exports 42']}
@@ -93,7 +95,7 @@ test('batch live verification request can reject a written requirement without r
93
95
  assert.equal(row.kind,'verification_precheck');
94
96
  assert.match(fs.readFileSync(path.join(f.codeProject,'target.mjs'),'utf8'),/42/);
95
97
  return {items:[{requirement:'value is 43',satisfied:false,evidence:'Fixture source exports 42'}]};
96
- },{timeoutMs:60000,env:{...process.env,CM_WORKFLOW_HOME:path.join(f.root,'home'),CM_WORKFLOW_LOG_HOME:path.join(f.root,'logs')}});
98
+ },{timeoutMs:60000,env:{...process.env,PATH:path.join(f.root,'bin')+path.delimiter+process.env.PATH,CM_WORKFLOW_HOME:path.join(f.root,'home'),CM_WORKFLOW_LOG_HOME:path.join(f.root,'logs')}});
97
99
  assert.equal(out.status,0,out.stderr);assert.equal(out.requests.length,1);
98
100
  assert.match(out.stdout,/verification_precheck_failed/);
99
101
  });
@@ -125,10 +127,10 @@ test('real batch host advances with authored edit and actual check, then resumes
125
127
  const again=f.drive(f.plan({mode:'resume',originalHostContext:'batch-host-a'}),'advance');
126
128
  assert.equal(again.status,0,again.stderr);
127
129
  });
128
- test('real batch reaches completion with an independently dispatched fixture review',t=>{
130
+ test('real batch reaches completion with automatic configured fixture review',t=>{
129
131
  const f=fixture(t);prepared(f);
130
132
  f.write('develop-a2.json',develop);
131
- const permissions=['--allow-qa','--review-config','review.json','--allow-review',`${key}:1`];
133
+ const permissions=['--allow-qa','--review-config','review.json'];
132
134
  const first=f.drive(f.plan({permissions}),'advance');
133
135
  assert.equal(first.status,0,first.stderr);assert.match(first.stderr,/应答 check/);
134
136
  let result=JSON.parse(first.stdout).result,stderr=first.stderr;
@@ -156,7 +158,7 @@ const developIntents=f=>{
156
158
  };
157
159
  test('batch review without a second-round answer stops at changes_requested after the first review',t=>{
158
160
  const f=fixture(t);prepared(f);changesRequested(f);
159
- const permissions=['--allow-qa','--review-config','review.json','--allow-review',`${key}:1`];
161
+ const permissions=['--allow-qa','--review-config','review.json'];
160
162
  const run=f.drive(f.plan({permissions}),'advance');
161
163
  assert.equal(run.status,0,run.stderr);
162
164
  assert.match(run.stderr,/没有 develop-a2\.json/);assert.match(run.stderr,/\.reviews\/work-T-001-r1\.md/);
@@ -182,16 +184,19 @@ test('batch resume holds a later task that has no run yet when its second-round
182
184
  for(const name of ['qa-assess.json','documentation-inspect.json'])
183
185
  fs.copyFileSync(path.join(f.answers,name),path.join(later,name));
184
186
  fs.writeFileSync(path.join(later,'develop.json'),JSON.stringify({...develop,edits:{'target2.mjs':'target2.txt'}}));
185
- // T-001 stops at awaiting_review first, so T-002 has no run when the batch resumes.
187
+ // T-001 holds after declared changes, so T-002 has no run when the batch resumes.
188
+ changesRequested(f);
186
189
  const first=f.drive(f.plan({permissions:['--allow-qa','--review-config','review.json']}),'advance');
187
- assert.equal(first.status,0,first.stderr);assert.equal(JSON.parse(first.stdout).result.state,'awaiting_review');
190
+ assert.equal(first.status,0,first.stderr);assert.equal(JSON.parse(first.stdout).result.state,'changes_requested');
191
+ fs.writeFileSync(path.join(f.answers,'target-a2.txt'),'export const value = 42; // revised\n');
192
+ f.write('develop-a2.json',{...develop,edits:{'target.mjs':'target-a2.txt'}});
188
193
  // The reviewer approves T-001 and asks for changes on T-002.
189
194
  const cli=path.join(f.root,'bin','codex');
190
195
  fs.writeFileSync(cli,fs.readFileSync(reviewer,'utf8').replace("verdict:'approved'",
191
196
  "verdict:prompt.includes('target2.mjs')?'changes_requested':'approved'")
192
197
  .replace('findings:[]',"findings:prompt.includes('target2.mjs')?[{id:'F1',severity:'P2',path:'target2.mjs',message:'Revise',evidence:'Fixture finding'}]:[]"));
193
198
  fs.chmodSync(cli,0o700);
194
- const permissions=['--allow-qa','--review-config','review.json','--allow-review',`${key}:1`,'--allow-review','1.work/T-002:1'];
199
+ const permissions=['--allow-qa','--review-config','review.json'];
195
200
  let result;
196
201
  for(let n=0;n<4;n++){
197
202
  const next=f.drive(f.plan({mode:'resume',originalHostContext:'batch-host-a',permissions}),'advance');
@@ -203,7 +208,7 @@ test('batch resume holds a later task that has no run yet when its second-round
203
208
  });
204
209
  test('batch hold without a second-round answer does not interfere with an approving review',t=>{
205
210
  const f=fixture(t);prepared(f);
206
- const permissions=['--allow-qa','--review-config','review.json','--allow-review',`${key}:1`];
211
+ const permissions=['--allow-qa','--review-config','review.json'];
207
212
  const first=f.drive(f.plan({permissions}),'advance');assert.equal(first.status,0,first.stderr);
208
213
  let result=JSON.parse(first.stdout).result;
209
214
  for(let n=0;n<4&&result.state!=='run_done';n++){
@@ -243,7 +248,7 @@ test('batch driver lets a later task\'s second-round delete bring its delivered
243
248
  const later=path.join(f.root,'answers','1.work','T-002');
244
249
  fs.writeFileSync(path.join(later,'gen_c.bin.txt'),Buffer.alloc(100*1024,0x61));
245
250
  fs.writeFileSync(path.join(later,'develop-a2.json'),JSON.stringify({...develop,edits:{'gen/b.bin':{delete:true},'gen/c.bin':'gen_c.bin.txt'}}));
246
- const run=f.drive(f.plan({permissions:['--allow-qa','--review-config','review.json','--allow-review','1.work/T-002:1']}),'advance');
251
+ const run=f.drive(f.plan({permissions:['--allow-qa','--review-config','review.json']}),'advance');
247
252
  assert.equal(run.status,0,run.stderr);assert.doesNotMatch(run.stderr,/仅答案写入/);assert.equal(fs.existsSync(f.store),true);
248
253
  });
249
254
  test('batch driver refuses a no-op or non-UTF-8 protected develop answer before launch',t=>{
@@ -264,7 +269,7 @@ test('batch review revision applies the second-round develop content',t=>{
264
269
  .replace('findings:[]',"findings:[{id:'F1',severity:'P2',path:'target.mjs',message:'Revise value',evidence:'Fixture finding'}]"));
265
270
  fs.writeFileSync(path.join(f.answers,'target-a2.txt'),'export const value = 43;\n');
266
271
  f.write('develop-a2.json',{...develop,edits:{'target.mjs':'target-a2.txt'}});
267
- const permissions=['--allow-qa','--review-config','review.json','--allow-review',`${key}:1`];
272
+ const permissions=['--allow-qa','--review-config','review.json'];
268
273
  const run=f.drive(f.plan({permissions}),'advance');assert.equal(run.status,0,run.stderr);
269
274
  assert.equal(fs.readFileSync(path.join(f.codeProject,'target.mjs'),'utf8'),'export const value = 43;\n');
270
275
  });
@@ -288,6 +293,8 @@ test('D1 batch rejects invalid check timeout before opening a host',t=>{
288
293
 
289
294
  test('D1 batch retries failed checks before review in the same attempt',t=>{
290
295
  const f=fixture(t);prepared(f);
296
+ fs.writeFileSync(path.join(f.root,'review.json'),JSON.stringify({model:'fixture',preflight:{passed:true,provider:'claude',
297
+ prompt_transport:'stdin',config_fingerprint:claudeReviewFingerprint({cwd:f.codeProject,model:'fixture'})}}));
291
298
  const failed={[key]:[{id:'test',command:[process.execPath,'-e','process.exit(1)']}]};
292
299
  const first=f.drive(f.plan({permissions:['--allow-qa','--runtime','claude'],checks:failed}),'advance');assert.equal(first.status,0,first.stderr);
293
300
  const result=JSON.parse(first.stdout).result;
@@ -360,8 +367,9 @@ test('optimized real batch driver shares only a declared same-plan check and rej
360
367
  const checks={[key]:[{id:'first',command},{id:'same',command,sameExecutionAs:'first'}]};
361
368
  const denied=f.drive(f.plan({checks}), 'advance');assert.equal(denied.status,2);noStore(f);assert(!fs.existsSync(counter));
362
369
  const out=f.drive(f.plan({permissions:['--allow-qa','--execution-optimizations'],checks}), 'advance');
363
- assert.equal(out.status,0,out.stderr);assert.equal(JSON.parse(out.stdout).result.state,'awaiting_review',out.stdout+out.stderr);
364
- assert.equal(fs.readFileSync(counter,'utf8'),'x');
370
+ assert.equal(out.status,0,out.stderr);assert.equal(JSON.parse(out.stdout).result.state,'run_done',out.stdout+out.stderr);
371
+ // One physical command per phase: development and the required completion recheck.
372
+ assert.equal(fs.readFileSync(counter,'utf8'),'xx');
365
373
  });
366
374
 
367
375
  // Q24 driver: develop_redo goes through the batch host to the stopped member; the
@@ -404,8 +412,7 @@ test(`${label} batch driver preflights a rescheduled second generation before it
404
412
  fs.writeFileSync(path.join(dir(id),`${file}.txt`),content);
405
413
  fs.writeFileSync(path.join(dir(id),'develop.json'),JSON.stringify({...develop,
406
414
  value:outcome==='implemented'?develop.value:{outcome:'blocked',reason:'Synthetic dependency is missing'},edits:{[`${file}.mjs`]:`${file}.txt`}}));
407
- for(const [name,value] of [['qa-assess.json',{scores:{scope:2,risk:2,accumulation:2,boundary:2},
408
- changes:{api:false,migration:false,authentication:false,authorization:false,payment:false}}],
415
+ for(const [name,value] of [['qa-assess.json',{confirmed:true}],
409
416
  ['documentation-inspect.json',{status:'completed',reason:'README and task artifacts inspected'}]])
410
417
  fs.writeFileSync(path.join(dir(id),name),JSON.stringify(value));
411
418
  };
@@ -414,7 +421,7 @@ test(`${label} batch driver preflights a rescheduled second generation before it
414
421
  answer('T-003','target3','export const value = 3;\n');
415
422
  const checks=Object.fromEntries(['T-001','T-002','T-003'].map((id,n)=>[`1.work/${id}`,
416
423
  [{id:'syntax',command:[process.execPath,'--check',n===0?'target.mjs':`target${n+1}.mjs`]}]]));
417
- const permissions=['--allow-qa',...(strict?['--execution-optimizations']:[]),...['T-001','T-002','T-003'].flatMap(id=>['--allow-review',`1.work/${id}:1`])];
424
+ const permissions=['--allow-qa',...(strict?['--execution-optimizations']:[])];
418
425
  const first=f.drive(f.plan({permissions,checks}),'advance');assert.equal(first.status,0,first.stderr);
419
426
  const stopped=JSON.parse(first.stdout).result;
420
427
  assert.equal(stopped.code,'batch_member_rescheduled',first.stdout+first.stderr);assert.deepEqual(stopped.rescheduled,['1.work/T-002']);
@@ -428,3 +435,39 @@ test(`${label} batch driver preflights a rescheduled second generation before it
428
435
  assert.equal(done.state,'run_done',resumed.stdout+resumed.stderr);
429
436
  assert.equal(fs.readFileSync(path.join(f.codeProject,'target2.mjs'),'utf8'),'export const value = 2;\n');
430
437
  });
438
+
439
+
440
+ test('batch ordinary advance preflights reachable revision answers without review grants',()=>{
441
+ assert.deepEqual(batchDevelopAttempts({state:'ready',attempt:1},key,[]),[1,2]);
442
+ assert.deepEqual(batchDevelopAttempts({state:'awaiting_review',attempt:1},key,[]),[2]);
443
+ assert.deepEqual(batchDevelopAttempts({state:'pending_review',attempt:1},key,[]),[2]);
444
+ assert.deepEqual(batchDevelopAttempts({state:'blocked',code:'develop_checks_not_passed',attempt:1},key,[]),[1,2]);
445
+ assert.deepEqual(batchDevelopAttempts({state:'blocked',code:'check_answer_missing',attempt:1},key,[]),[2]);
446
+ assert.deepEqual(batchDevelopAttempts({state:'changes_requested',attempt:2},key,[]),[2]);
447
+ });
448
+ test('batch driver rejects removed review grant before starting a batch',t=>{
449
+ const f=fixture(t);prepared(f);
450
+ const out=f.drive(f.plan({permissions:['--allow-qa','--allow-review',key+':1']}),'advance');
451
+ assert.equal(out.status,2,out.stderr);assert.match(out.stderr,/permissions 无效.*--allow-review/);noStore(f);
452
+ });
453
+
454
+ test('batch configured review reaches both rounds and completes without a review grant',t=>{
455
+ const f=fixture(t);prepared(f);
456
+ fs.writeFileSync(path.join(f.answers,'revised.txt'),'export const value = 42; // revised after findings\n');
457
+ f.write('develop-a2.json',{...develop,edits:{'target.mjs':'revised.txt'}});
458
+ const cli=path.join(f.root,'bin','codex');
459
+ fs.writeFileSync(cli,fs.readFileSync(reviewer,'utf8')
460
+ .replace("verdict:'approved'","verdict:data.reviewPackage.identity.attempt===1?'changes_requested':'approved'")
461
+ .replace('findings:[]',"findings:data.reviewPackage.identity.attempt===1?[{id:'F1',severity:'P2',path:'target.mjs',message:'Revise',evidence:'Fixture finding'}]:[]"));
462
+ fs.chmodSync(cli,0o700);
463
+ let out=f.drive(f.plan(),'advance');assert.equal(out.status,0,out.stderr);
464
+ let result=JSON.parse(out.stdout).result;
465
+ for(let n=0;n<4&&result.state!=='run_done';n++){
466
+ out=f.drive(f.plan({mode:'resume',originalHostContext:'batch-host-a'}),'advance');
467
+ assert.equal(out.status,0,out.stderr);result=JSON.parse(out.stdout).result;
468
+ }
469
+ assert.equal(result.state,'run_done',JSON.stringify(result));
470
+ assert.deepEqual(developIntents(f),['develop-1','develop-2']);
471
+ assert.match(fs.readFileSync(path.join(f.specsDir,'.reviews','work-T-001-r1.md'),'utf8'),/verdict: changes_requested/);
472
+ assert.match(fs.readFileSync(path.join(f.specsDir,'.reviews','work-T-001-r2.md'),'utf8'),/verdict: approved/);
473
+ });
@@ -17,8 +17,9 @@ import {serveCmAiHost,parseHostInputLimit,inputLimitReason} from '../runtime/js/
17
17
  import {validateHostWorkflowConfiguration,featureHasBrowserCases,readBrowserCapability} from '../runtime/js/cm-ai/host-workflow-capabilities.mjs';
18
18
  import {digest,json,need,shape} from '../runtime/js/cm-ai/effect-contract.mjs';
19
19
  import {identifyApprovedBootstrapFeature} from '../runtime/js/cm-ai/bootstrap-feature.mjs';
20
+ import {readControlPolicyFile} from '../runtime/js/cm-ai/control-policy.mjs';
20
21
 
21
- const usage='cm-ai-batch-host.mjs serve --config PATH --host-context ID --allow-development --review-config PATH (required for a new batch; later launches pass the same file) [--execution-optimizations] [--external-models [--external-models-config PATH]] [--runtime codex|claude] [--input-limit BYTES] [--allow-review FEATURE/TASK:1|2]... [--allow-qa] [--rerun-unknown-qa | --rerun-blocked-qa [--qa-environment-failure REASON]] [--allow-develop-redo FEATURE/TASK]... [--allow-abandon-effect FEATURE/TASK]... [--allow-abandon-review FEATURE/TASK]... [--allow-bootstrap-review-recovery FEATURE/TASK]... [--verification-precheck] [--browser-qa available|unavailable] [--protected-conversation-config PATH | --protected-config PATH] [--allow-provider-development FEATURE/TASK:1|2]... [--hold-revision FEATURE/TASK]...';
22
+ const usage='cm-ai-batch-host.mjs serve --config PATH --host-context ID --allow-development --review-config PATH (required for a new batch; later launches pass the same file) [--execution-optimizations] [--external-models [--external-models-config PATH]] [--runtime codex|claude] [--input-limit BYTES] [--allow-qa] [--rerun-unknown-qa | --rerun-blocked-qa [--qa-environment-failure REASON]] [--allow-develop-redo FEATURE/TASK]... [--allow-abandon-effect FEATURE/TASK]... [--allow-abandon-review FEATURE/TASK]... [--allow-bootstrap-review-recovery FEATURE/TASK]... [--verification-precheck] [--browser-qa available|unavailable] [--protected-conversation-config PATH | --protected-config PATH] [--allow-provider-development FEATURE/TASK:1|2]... [--hold-revision FEATURE/TASK]...';
22
23
  const safeCode=error=>typeof error?.code==='string'&&/^[a-z][a-z0-9_]{0,63}$/.test(error.code)?error.code:'batch_host_failed';
23
24
  // Operator-facing reasons the batch owner writes itself (R4); others stay redacted.
24
25
  const REASONED=new Set(['batch_resources_open','legacy_preflight_cache_invalid']);
@@ -155,13 +156,24 @@ async function memberReviewConfiguration(batch,definition,review,runtime,pair=nu
155
156
  }
156
157
 
157
158
  export async function main(argv=process.argv.slice(2),{input=process.stdin,output=process.stdout,error=process.stderr}={}){
159
+ if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('Control v2: serve --config BUNDLE --host-context ID --control-config POLICY --review-config REVIEW; no --allow-*. Batch qaFix must be disabled. See docs/cm-control-policy-v2.md.\n');
158
160
  if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('Optional --execution-optimizations freezes policy v1 for new runs only; recovery retains the original policy and legacy runs reject retrofit. See docs/execution-optimizations.md.\n');
159
161
  if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('成员恢复(Q24):--allow-develop-redo / --allow-abandon-effect / --allow-abandon-review / --allow-bootstrap-review-recovery FEATURE/TASK 各授权一次同名批次操作 {operation, requestId, taskKey, reason},只转给批次当前停住的那个成员运行(同一 cm-ai 入口、只带这一项权限,不跨成员),之后 advance 继续本批次;缺授权返回 batch_member_action_authorization_required,非当前成员返回 batch_member_action_not_current。批次 cancel 后永久停止不变。--qa-environment-failure REASON 随 --rerun-blocked-qa / --rerun-unknown-qa 使用。--revise-qa-config 与 --rebind-spec-material 不支持(batch_qa_revision_unavailable / batch_spec_rebind_unavailable,原因里写明出口)。并行成员停在可在原运行内恢复的状态时返回 batch_parallel_member_recovery_required;结果未确认时返回 batch_parallel_member_unresolved 并留在原运行;只有原始存档为已 checkpoint 的 blocked 才改排串行第二代,且先停在 batch_member_rescheduled,下一次 advance 才开发第二代(普通批次与外部模型、执行策略批次相同)。\n');
160
- if(argv.length===1&&['--help','-h'].includes(argv[0])){output.write(usage+'\nOptional --input-limit BYTES sets the host input transport limit to an integer from 65536 to 4194304 (default 65536); it may change on resume.\nOptional --protected-conversation-config PATH uses the shared current-host scoped text proposals and native sandbox checks; {checkCommands,timeoutMs}. No extra model call, same Codex/Claude runtime and per-task Review permissions. Optional --protected-config PATH {model,checkCommands,timeoutMs} enables CLI development only for per-task --allow-provider-development FEATURE/TASK:1|2 grants; mutually exclusive with --protected-conversation-config. Optional bundle.bootstraps maps approved bootstrap task keys to {selection}; --allow-bootstrap-write grants only those fixed instruction/scaffold steps. Optional batch.codeProjects uses prefixed paths and checks with codeProject per command; one task remains one completion gate.\n--review-config PATH is required when no member run of the batch exists yet (like single-task create): it is bound into every member fingerprint and cannot be added on resume. It is {model,preflight[,disabledSkills][,timeoutMs]}; timeoutMs is the reviewer transport budget in milliseconds (integer 1-3600000, default 900000). It is independent of --protected-conversation-config/--protected-config and wins over their timeoutMs for the reviewer. It is not part of the authorized configuration digest, so a resumed run may raise it after review_transport_timeout.\n--browser-qa available|unavailable declares interactive QA capability for applicable feature carriers including browser and ios-simulator; the flag name is retained for compatibility.\nOptional --rerun-unknown-qa / --rerun-blocked-qa carry the same single-task QA recovery into a batch and require --allow-qa; they are mutually exclusive. A batch has no --mode, so each task applies the flag only when it resumes an existing run and has a QA executor; a created run or a task without QA ignores it rather than failing the whole batch. Semantics, limits and the qaRound cap are the single-task ones, unchanged.\nOptional --verification-precheck sends the written verification of the task and the collected checks back as a verification_precheck request before any handoff or review package is built. It may only block: a requirement reported unsatisfied stops the task at blocked / verification_precheck_failed with pendingAction resume and spends no review round. Passing it is not an approval, writes no receipt and does not replace the independent review. A task with no written verification is unaffected.\nOptional --hold-revision FEATURE/TASK (repeatable, launch-only, never persisted) stops that task after a changes_requested review with code revision_answer_required, before any second-round develop intent; the next launch without it resumes the revision. It only narrows what this launch does.\nBatch entry requires a clean Git main checkout (including untracked files); batch_main_dirty lists dirty files before any task or worktree starts. Serial tasks are committed automatically before batch_handoff, with task_commit recording the SHA (null if unchanged). A parallel member whose raw journal is a checkpointed blocked terminal preserves WIP on its retained branch and falls back once to serial generation 2 after ready members merge; that advance stops at batch_member_rescheduled and the next one develops generation 2. Unconfirmed members stay in their original run.\n');return 0;}
162
+ if(argv.length===1&&['--help','-h'].includes(argv[0])){output.write(usage+'\nOptional --input-limit BYTES sets the host input transport limit to an integer from 65536 to 4194304 (default 65536); it may change on resume.\nOptional --protected-conversation-config PATH uses the shared current-host scoped text proposals and native sandbox checks; {checkCommands,timeoutMs}. No extra model call, same Codex/Claude runtime and configured per-task review execution. Optional --protected-config PATH {model,checkCommands,timeoutMs} enables CLI development only for per-task --allow-provider-development FEATURE/TASK:1|2 grants; mutually exclusive with --protected-conversation-config. Optional bundle.bootstraps maps approved bootstrap task keys to {selection}; --allow-bootstrap-write grants only those fixed instruction/scaffold steps. Optional batch.codeProjects uses prefixed paths and checks with codeProject per command; one task remains one completion gate.\n--review-config PATH is required when no member run of the batch exists yet (like single-task create): it is bound into every member fingerprint and cannot be added on resume. It is {model,preflight[,disabledSkills][,timeoutMs]}; timeoutMs is the reviewer transport budget in milliseconds (integer 1-3600000, default 900000). It is independent of --protected-conversation-config/--protected-config and wins over their timeoutMs for the reviewer. It is not part of the authorized configuration digest, so a resumed run may raise it after review_transport_timeout.\n--browser-qa available|unavailable declares interactive QA capability for applicable feature carriers including browser and ios-simulator; the flag name is retained for compatibility.\nOptional --rerun-unknown-qa / --rerun-blocked-qa carry the same single-task QA recovery into a batch and require --allow-qa; they are mutually exclusive. A batch has no --mode, so each task applies the flag only when it resumes an existing run and has a QA executor; a created run or a task without QA ignores it rather than failing the whole batch. Semantics, limits and the qaRound cap are the single-task ones, unchanged.\nOptional --verification-precheck sends the written verification of the task and the collected checks back as a verification_precheck request before any handoff or review package is built. It may only block: a requirement reported unsatisfied stops the task at blocked / verification_precheck_failed with pendingAction resume and spends no review round. Passing it is not an approval, writes no receipt and does not replace the independent review. A task with no written verification is unaffected.\nOptional --hold-revision FEATURE/TASK (repeatable, launch-only, never persisted) stops that task after a changes_requested review with code revision_answer_required, before any second-round develop intent; the next launch without it resumes the revision. It only narrows what this launch does.\nBatch entry requires a clean Git main checkout (including untracked files); batch_main_dirty lists dirty files before any task or worktree starts. Serial tasks are committed automatically before batch_handoff, with task_commit recording the SHA (null if unchanged). A parallel member whose raw journal is a checkpointed blocked terminal preserves WIP on its retained branch and falls back once to serial generation 2 after ready members merge; that advance stops at batch_member_rescheduled and the next one develops generation 2. Unconfirmed members stay in their original run.\n');return 0;}
161
163
  let bridge;
162
164
  try{
163
- need(argv.length>=6&&argv[0]==='serve'&&argv[1]==='--config'&&argv[3]==='--host-context'
164
- &&argv[5]==='--allow-development','host_launch_authorization_required');
165
+ let controlPolicy=null;
166
+ const withMode=argv[0]==='serve'&&argv[3]==='--mode'&&argv[5]==='--host-context'&&argv[7]==='--control-config';
167
+ if(withMode)need(['create','resume'].includes(argv[4]),'invalid_mode');
168
+ const contextOffset=withMode?5:3,controlOffset=withMode?7:5;
169
+ if(argv[0]==='serve'&&argv[controlOffset]==='--control-config'){
170
+ if(argv.some(value=>value.startsWith('--allow-')))throw Object.assign(new Error('invalid_arguments'),
171
+ {code:'invalid_arguments',reason:'新版批次不接受 --allow-*;旧批次请用原入口和参数。'});
172
+ controlPolicy=readControlPolicyFile(argv[controlOffset+1]);need(controlPolicy.qaFix==='disabled','invalid_arguments');
173
+ }
174
+ need(argv.length>=6&&argv[0]==='serve'&&argv[1]==='--config'&&argv[contextOffset]==='--host-context'
175
+ &&(controlPolicy!==null||argv[5]==='--allow-development'),'host_launch_authorization_required');
176
+ const hostContextId=argv[contextOffset+1];
165
177
  const stat=fs.lstatSync(argv[2]);need(stat.isFile()&&!stat.isSymbolicLink()&&stat.size<=64*1024,'invalid_batch_config');
166
178
  const bundle=json(JSON.parse(fs.readFileSync(argv[2],'utf8')));shape(bundle,['batch','workflows',...(Object.hasOwn(bundle,'bootstraps')?['bootstraps']:[])]);
167
179
  const {batch,workflows,bootstraps=null}=bundle;need(Array.isArray(batch.tasks),'invalid_batch_config');
@@ -176,10 +188,10 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
176
188
  need(keys.length===Object.keys(workflows).length&&keys.every(key=>Object.hasOwn(workflows,key)),'workflow_task_mismatch');
177
189
  for(const key of keys)if(workflows[key]!==null)validateHostWorkflowConfiguration(workflows[key]);
178
190
  let review=null,allowQa=false,allowBootstrap=false,runtime=null,protection=null,providerConfig=null,browserQaFlag,inputLimitRaw;
179
- let rerunUnknownQa=false,rerunBlockedQa=false,verificationPrecheck=false,qaEnvironmentFailure=null;const approvals=new Set(),developments=new Map(),holds=new Set();
191
+ let rerunUnknownQa=false,rerunBlockedQa=false,verificationPrecheck=false,qaEnvironmentFailure=null;const developments=new Map(),holds=new Set();
180
192
  const memberActions=Object.fromEntries(Object.keys(BATCH_MEMBER_ACTIONS).map(name=>[name,[]]));
181
193
  let externalEnabled=false,externalFile,executionPolicyEnabled=false;
182
- for(let index=6;index<argv.length;index++){
194
+ for(let index=controlPolicy?controlOffset+2:6;index<argv.length;index++){
183
195
  const name=argv[index];
184
196
  if(name==='--execution-optimizations'){need(!executionPolicyEnabled,'invalid_arguments');executionPolicyEnabled=true;}
185
197
  else if(name==='--allow-qa'){need(!allowQa,'invalid_arguments');allowQa=true;}
@@ -231,11 +243,15 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
231
243
  else if(name==='--hold-revision'){
232
244
  const held=argv[++index];need(typeof held==='string'&&keys.includes(held)&&!holds.has(held),'invalid_arguments');holds.add(held);
233
245
  }
234
- else if(name==='--allow-review'){
235
- const approval=argv[++index];need(typeof approval==='string'&&!approvals.has(approval),'invalid_arguments');
236
- const split=approval.lastIndexOf(':'),key=approval.slice(0,split),attempt=approval.slice(split+1);
237
- need(keys.includes(key)&&['1','2'].includes(attempt),'review_task_mismatch');approvals.add(approval);
238
- }else need(false,'invalid_arguments');
246
+ else need(false,'invalid_arguments');
247
+ }
248
+ if(controlPolicy){
249
+ allowQa=controlPolicy.qa==='run';allowBootstrap=controlPolicy.bootstrap==='write';
250
+ need((controlPolicy.development==='provider')===Boolean(providerConfig),'invalid_arguments');
251
+ need(controlPolicy.bootstrap!=='write'||bootstraps!==null,'invalid_arguments');
252
+ need(bootstraps===null||controlPolicy.bootstrap==='write','invalid_arguments');
253
+ if(providerConfig)for(const key of keys)developments.set(key,1);
254
+ need(!rerunUnknownQa&&!rerunBlockedQa,'supersede_unavailable');
239
255
  }
240
256
  const started=keys.some(key=>fs.existsSync(path.join(batch.specsDir,'.reviews','.execution',batchTaskRunId(batch.batchId,key),'state.json')));
241
257
  // Same read-only create gate as the batch owner, before any model or policy configuration is read or frozen.
@@ -256,16 +272,15 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
256
272
  need(!developments.size||providerConfig!==null,'protected_configuration_required');
257
273
  // Same launch-time assertion as the single-task host, evaluated across every
258
274
  // task whose approved contract can select a browser case.
259
- readBrowserCapability(browserQaFlag,keys.flatMap(key=>workflows[key]?.qa!=null
275
+ readBrowserCapability(browserQaFlag,keys.flatMap(key=>(!controlPolicy||allowQa)&&workflows[key]?.qa!=null
260
276
  &&featureHasBrowserCases(batch.specsDir,key.slice(0,key.lastIndexOf('/')),batch.codeProject)
261
277
  ?[workflows[key].qa.environment?.carrier??'browser']:[]));
262
- need(!approvals.size||review!==null,'review_configuration_required');
263
278
  // Same two guards as the single-task host. A batch has no --mode, so the
264
279
  // per-task resume check lives in createCmAiBatch rather than here.
265
280
  need(!(rerunUnknownQa&&rerunBlockedQa),'qa_recovery_authorization_required');
266
281
  need(!(rerunUnknownQa||rerunBlockedQa)||allowQa,'qa_recovery_authorization_required');
267
282
  need(qaEnvironmentFailure===null||rerunUnknownQa||rerunBlockedQa,'qa_recovery_authorization_required');
268
- need(allowQa||!Object.values(workflows).some(item=>item?.qa!=null),'qa_authorization_required');
283
+ need(controlPolicy||allowQa||!Object.values(workflows).some(item=>item?.qa!=null),'qa_authorization_required');
269
284
  // Same rule as single-task create: the reviewer binding is part of every
270
285
  // member's durable fingerprint and cannot be added on resume. A batch none
271
286
  // of whose member runs exist yet is being created. Batches that already
@@ -274,7 +289,7 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
274
289
  batchTaskRunId(batch.batchId,key),'state.json')));
275
290
  if(!created&&review===null)throw Object.assign(new Error('review_configuration_required'),{code:'review_configuration_required',
276
291
  reason:'新批次必须带 --review-config:审查配置写进每个任务运行的指纹,恢复时不能再补。先用 cm-ai-host.mjs preflight 生成 review.json;'
277
- +'是否真正派发审查仍由 --allow-review 单独授权'});
292
+ +'普通 advance 按已有审查配置派发第 1、2 轮;来源声明不证明人工批准'});
278
293
  // Tool replies travel on the same input lines, so they share the one limit.
279
294
  bridge=createHostToolBridge({responseLimit:parseHostInputLimit(inputLimitRaw),answerTimeoutMs:HOST_ANSWER_BACKSTOP_MS});
280
295
  // The current conversation transport accepts one outstanding host call.
@@ -285,17 +300,16 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
285
300
  hostCallTail=pending.then(()=>{},()=>{});return pending;
286
301
  }};
287
302
  let reconciling=false;
288
- const driver=createCmAiBatch({configuration:{...batch,...(externalModels?{externalModels}:{}),...(executionPolicy?{executionPolicy}:{})},logHome:path.join(batch.specsDir,'.reviews','host-log-mirror'),
303
+ const driver=createCmAiBatch({configuration:{...batch,...(controlPolicy?{controlPolicy}:{}),...(externalModels?{externalModels}:{}),...(executionPolicy?{executionPolicy}:{})},logHome:path.join(batch.specsDir,'.reviews','host-log-mirror'),
289
304
  runtime:runtime??'codex',checkCommands:(providerConfig??protection)?.checkCommands??null,checkTimeoutMs:(providerConfig??protection)?.timeoutMs??60000,
290
305
  rerunUnknownQa,rerunBlockedQa,qaEnvironmentFailure,memberActions,holdRevisions:[...holds],bootstrapKeys:Object.keys(bootstraps??{}),
291
306
  executionFor:async(definition,{parallelMember=false}={})=>{
292
307
  await freezeBatchExecutionPolicy(batch,executionPolicy);
293
308
  freezeBatchExternalModels(batch,externalModels);
294
309
  const key=`${definition.feature}/${definition.identity.taskId}`;
295
- const attempts=[1,2].filter(attempt=>approvals.has(`${key}:${attempt}`));
296
310
  const memberReview=parallelMember?await memberReviewConfiguration(batch,definition,review,externalModels?routes.reviewerRuntime:runtime??'codex',externalModels?.providers[routes.reviewerRuntime]??null,!reconciling,Boolean(executionPolicy)):review;
297
- const execution=createConversationExecution(definition,argv[4],parallelMember?memberBridge:bridge,memberReview,attempts,workflows[key],allowQa,runtime??'codex',
298
- {parallelMember,...(executionPolicy?{executionPolicy}:{}),...(externalModels?{externalModels,...(providerConfig?{reviewerRuntime:routes.reviewerRuntime}:{})}:{}),...(verificationPrecheck?{verificationPrecheck:true}:{}),batchWorkflowsDigest:digest(executionPolicy?{workflows,bootstraps,externalModels,executionPolicy}:externalModels?{workflows,bootstraps,externalModels}:bootstraps?{workflows,bootstraps}:workflows),qaLogHome:path.join(batch.specsDir,'.reviews','host-log-mirror'),
311
+ const execution=createConversationExecution(definition,hostContextId,parallelMember?memberBridge:bridge,memberReview,null,workflows[key],allowQa,runtime??'codex',
312
+ {parallelMember,...(controlPolicy?{controlPolicy}:{}),...(executionPolicy?{executionPolicy}:{}),...(externalModels?{externalModels,...(providerConfig?{reviewerRuntime:routes.reviewerRuntime}:{})}:{}),...(verificationPrecheck?{verificationPrecheck:true}:{}),batchWorkflowsDigest:digest(executionPolicy?{workflows,bootstraps,externalModels,executionPolicy}:externalModels?{workflows,bootstraps,externalModels}:bootstraps?{workflows,bootstraps}:workflows),qaLogHome:path.join(batch.specsDir,'.reviews','host-log-mirror'),
299
313
  // A protected CLI config also protects unauthorized tasks: they stay on the
300
314
  // current-session transport but with the same sandbox checks (protected-text edits).
301
315
  ...(protection?{protection}:providerConfig?{protection:{checkCommands:providerConfig.checkCommands,timeoutMs:providerConfig.timeoutMs}}:{}),
@@ -308,7 +322,12 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
308
322
  return execution;
309
323
  }});
310
324
  const host={async handle(request){
311
- try{reconciling=request.operation==='reconcile_review';return await driver.handle(request);}
325
+ try{
326
+ reconciling=request.operation==='reconcile_review';const result=await driver.handle(request);
327
+ if(controlPolicy&&request.operation==='status'&&result.state!=='running')
328
+ return {...result,controlTarget:await driver.controlTarget()};
329
+ return result;
330
+ }
312
331
  catch(cause){const reason=boundedReason(cause);return {outcome:'blocked',code:safeCode(cause),...(reason?{reason}:{})};}
313
332
  }};
314
333
  const rawMode=input.isTTY&&typeof input.setRawMode==='function';if(rawMode)input.setRawMode(true);