@aibyzero/cm-workflow 0.21.6 → 0.25.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 (212) hide show
  1. package/.codex-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +58 -0
  3. package/README.md +18 -3
  4. package/VERSION +1 -1
  5. package/docs/architecture.md +9 -0
  6. package/docs/cm-acceptance-completion.md +3 -1
  7. package/docs/cm-control-policy-v2.md +35 -3
  8. package/docs/execution-optimizations.md +1 -1
  9. package/docs/external-models.md +1 -0
  10. package/docs/human-correction.md +1 -1
  11. package/docs/installation.md +42 -16
  12. package/docs/js-workflow-control.md +65 -30
  13. package/docs/next-steps.md +10 -0
  14. package/docs/runtime-failover.md +5 -3
  15. package/docs/user-guide.md +6 -6
  16. package/package.json +1 -1
  17. package/runtime/js/cm-ai/batch-location.mjs +14 -0
  18. package/runtime/js/cm-ai/batch-plan.mjs +6 -2
  19. package/runtime/js/cm-ai/checkpoint-package-material.mjs +9 -2
  20. package/runtime/js/cm-ai/cm-ai-admission.mjs +9 -3
  21. package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +51 -8
  22. package/runtime/js/cm-ai/cm-ai-qa-log.mjs +30 -4
  23. package/runtime/js/cm-ai/codex-review-adapter.mjs +2 -4
  24. package/runtime/js/cm-ai/delivery-evidence.mjs +3 -1
  25. package/runtime/js/cm-ai/developer-adapter.mjs +15 -1
  26. package/runtime/js/cm-ai/drive-core.mjs +50 -6
  27. package/runtime/js/cm-ai/drive-next-step.mjs +61 -0
  28. package/runtime/js/cm-ai/durable-runner-state.mjs +85 -23
  29. package/runtime/js/cm-ai/execution-snapshot.mjs +5 -2
  30. package/runtime/js/cm-ai/execution-store.mjs +21 -3
  31. package/runtime/js/cm-ai/external-run-guard.mjs +9 -1
  32. package/runtime/js/cm-ai/host-check.mjs +4 -2
  33. package/runtime/js/cm-ai/host-conversation-execution.mjs +23 -2
  34. package/runtime/js/cm-ai/host-handoff.mjs +7 -0
  35. package/runtime/js/cm-ai/host-progress.mjs +18 -0
  36. package/runtime/js/cm-ai/host-qa-executor.mjs +47 -15
  37. package/runtime/js/cm-ai/host-qa-fix-owner.mjs +11 -2
  38. package/runtime/js/cm-ai/host-qa-policy.mjs +24 -14
  39. package/runtime/js/cm-ai/host-session.mjs +1 -1
  40. package/runtime/js/cm-ai/host-workflow-capabilities.mjs +1 -1
  41. package/runtime/js/cm-ai/host.mjs +1 -1
  42. package/runtime/js/cm-ai/operator-guidance.mjs +126 -2
  43. package/runtime/js/cm-ai/project-qa-gate.mjs +13 -2
  44. package/runtime/js/cm-ai/provider-review-observation.mjs +7 -3
  45. package/runtime/js/cm-ai/qa-plan-notes.mjs +106 -0
  46. package/runtime/js/cm-ai/review-continuation.mjs +102 -0
  47. package/runtime/js/cm-ai/review-evidence-file.mjs +11 -0
  48. package/runtime/js/cm-ai/review-package.mjs +25 -4
  49. package/runtime/js/cm-ai/review-presentation.mjs +31 -14
  50. package/runtime/js/cm-ai/review-runner.mjs +5 -4
  51. package/runtime/js/cm-ai/review-verdict-rules.mjs +7 -0
  52. package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +30 -1
  53. package/runtime/js/cm-ai/task-commit-codec.mjs +11 -1
  54. package/runtime/js/cm-ai/task-commit.mjs +7 -4
  55. package/runtime/js/cm-ai/task-owner.mjs +5 -2
  56. package/runtime/js/cm-ai/task-runner.mjs +343 -52
  57. package/runtime/js/cm-ai/tool-preview.mjs +6 -0
  58. package/runtime/js/cm-fix/diagnosis.mjs +16 -3
  59. package/runtime/js/cm-fix/execution.mjs +47 -9
  60. package/runtime/js/cm-fix/finish.mjs +9 -1
  61. package/runtime/js/cm-fix/step-timing.mjs +222 -0
  62. package/runtime/js/cm-idea/session.mjs +22 -3
  63. package/runtime/js/cm-init/review-evidence.mjs +20 -7
  64. package/runtime/js/cm-prd/ai-draft.mjs +260 -0
  65. package/runtime/js/cm-prd/analysis.mjs +27 -9
  66. package/runtime/js/cm-prd/change.mjs +29 -8
  67. package/runtime/js/cm-prd/failed-correction.mjs +24 -4
  68. package/runtime/js/cm-prd/narrow-review.mjs +63 -3
  69. package/runtime/js/cm-prd/review-correction.mjs +65 -5
  70. package/runtime/js/cm-prd/review-disposition.mjs +10 -1
  71. package/runtime/js/cm-prd/self-check.mjs +121 -9
  72. package/runtime/js/cm-prd/session.mjs +55 -13
  73. package/runtime/js/cm-prd/summary.mjs +34 -6
  74. package/runtime/js/cm-prd/task-scope-record.mjs +40 -15
  75. package/runtime/js/cm-refactor/records.mjs +82 -11
  76. package/runtime/js/cm-refactor/workflow.mjs +3 -1
  77. package/runtime/js/executor-version.mjs +81 -0
  78. package/runtime/js/python-log-writer.mjs +15 -0
  79. package/runtime/js/run-analysis.mjs +136 -11
  80. package/runtime/logging.md +6 -0
  81. package/runtime/review.md +3 -1
  82. package/runtime/workflow-config.md +1 -1
  83. package/scripts/ci-test-weights.json +1 -0
  84. package/scripts/cm-ai-admission.mjs +27 -1
  85. package/scripts/cm-ai-admission.test.mjs +34 -2
  86. package/scripts/cm-ai-answer-gap-recheck.test.mjs +3 -2
  87. package/scripts/cm-ai-batch-drive.mjs +54 -17
  88. package/scripts/cm-ai-batch-drive.test.mjs +123 -6
  89. package/scripts/cm-ai-batch-host.mjs +55 -9
  90. package/scripts/cm-ai-batch-host.test.mjs +22 -3
  91. package/scripts/cm-ai-batch-location.test.mjs +22 -1
  92. package/scripts/cm-ai-batch-merge.mjs +102 -0
  93. package/scripts/cm-ai-batch-plan.mjs +55 -2
  94. package/scripts/cm-ai-batch-plan.test.mjs +228 -6
  95. package/scripts/cm-ai-batch-run-fixture.mjs +239 -15
  96. package/scripts/cm-ai-batch-run-parallel.test.mjs +23 -1
  97. package/scripts/cm-ai-batch-run.mjs +435 -33
  98. package/scripts/cm-ai-batch-session-member.test.mjs +85 -0
  99. package/scripts/cm-ai-check-recheck-cancellation.test.mjs +23 -2
  100. package/scripts/cm-ai-checkpoint-package-material.test.mjs +28 -0
  101. package/scripts/cm-ai-completion-summary.test.mjs +2 -1
  102. package/scripts/cm-ai-control-v2-drive.test.mjs +39 -9
  103. package/scripts/cm-ai-direct-review.test.mjs +1 -1
  104. package/scripts/cm-ai-disk-edits.test.mjs +229 -0
  105. package/scripts/cm-ai-drive-next-step.test.mjs +191 -0
  106. package/scripts/cm-ai-drive.mjs +66 -14
  107. package/scripts/cm-ai-drive.test.mjs +13 -3
  108. package/scripts/cm-ai-host-cli-workflow.test.mjs +4 -2
  109. package/scripts/cm-ai-host.mjs +16 -8
  110. package/scripts/cm-ai-host.test.mjs +12 -0
  111. package/scripts/cm-ai-operator-guidance.test.mjs +132 -1
  112. package/scripts/cm-ai-project-qa-gate.test.mjs +26 -0
  113. package/scripts/cm-ai-qa-fix-cross-session.test.mjs +18 -0
  114. package/scripts/cm-ai-review-continuation.test.mjs +335 -0
  115. package/scripts/cm-ai-review-failure.test.mjs +13 -10
  116. package/scripts/cm-ai-review-timeout.test.mjs +1 -1
  117. package/scripts/cm-ai-run.mjs +42 -11
  118. package/scripts/cm-ai-run.test.mjs +26 -0
  119. package/scripts/cm-ai-supersede.test.mjs +10 -2
  120. package/scripts/cm-capability-gate.test.mjs +1 -1
  121. package/scripts/cm-check-runtime.sh +9 -0
  122. package/scripts/cm-codex-clean-env.test.mjs +40 -0
  123. package/scripts/cm-codex-prompt-input.test.mjs +2 -1
  124. package/scripts/cm-developer-self-review.test.mjs +27 -0
  125. package/scripts/cm-efficiency-presentation-delta.test.mjs +4 -3
  126. package/scripts/cm-efficiency-response.test.mjs +2 -1
  127. package/scripts/cm-executor-version-draft.test.mjs +251 -0
  128. package/scripts/cm-executor-version-entries.test.mjs +93 -0
  129. package/scripts/cm-executor-version-prd.test.mjs +154 -0
  130. package/scripts/cm-executor-version-records.test.mjs +256 -0
  131. package/scripts/cm-executor-version.test.mjs +250 -0
  132. package/scripts/cm-external-model-host.test.mjs +6 -1
  133. package/scripts/cm-external-review-reconciliation.test.mjs +1 -1
  134. package/scripts/cm-fix-closeout-preflight.test.mjs +123 -0
  135. package/scripts/cm-fix-diagnosis-module-correction.test.mjs +5 -1
  136. package/scripts/cm-fix-drive.mjs +7 -2
  137. package/scripts/cm-fix-drive.test.mjs +45 -0
  138. package/scripts/cm-fix-entry.mjs +5 -2
  139. package/scripts/cm-fix-frozen-baseline.test.mjs +50 -0
  140. package/scripts/cm-fix-host.mjs +9 -2
  141. package/scripts/cm-fix-test-extension.test.mjs +30 -2
  142. package/scripts/cm-host-check.test.mjs +12 -0
  143. package/scripts/cm-host-qa-executor.test.mjs +172 -1
  144. package/scripts/cm-host-qa-policy.test.mjs +55 -1
  145. package/scripts/cm-idea-drive.mjs +5 -2
  146. package/scripts/cm-idea-entry.mjs +5 -2
  147. package/scripts/cm-idea-host.mjs +3 -1
  148. package/scripts/cm-init-drive.mjs +8 -5
  149. package/scripts/cm-init-entry.mjs +5 -2
  150. package/scripts/cm-init-host.mjs +6 -2
  151. package/scripts/cm-log-event.mjs +10 -2
  152. package/scripts/cm-log-event.test.mjs +29 -0
  153. package/scripts/cm-prd-ai-draft-fixture.mjs +18 -0
  154. package/scripts/cm-prd-ai-draft.test.mjs +505 -0
  155. package/scripts/cm-prd-answer-gaps.test.mjs +110 -5
  156. package/scripts/cm-prd-completion.test.mjs +67 -4
  157. package/scripts/cm-prd-design-phase.test.mjs +48 -13
  158. package/scripts/cm-prd-drive.mjs +89 -20
  159. package/scripts/cm-prd-drive.test.mjs +109 -4
  160. package/scripts/cm-prd-entry.mjs +5 -2
  161. package/scripts/cm-prd-host.mjs +89 -20
  162. package/scripts/cm-prd-host.test.mjs +17 -8
  163. package/scripts/cm-prd-narrow-review.test.mjs +49 -1
  164. package/scripts/cm-prd-review-disposition.test.mjs +94 -1
  165. package/scripts/cm-prd-review-gate.mjs +11 -4
  166. package/scripts/cm-prd-self-check-rules.test.mjs +175 -10
  167. package/scripts/cm-prd-self-check.test.mjs +1 -1
  168. package/scripts/cm-refactor-drive.mjs +10 -4
  169. package/scripts/cm-refactor-entry.mjs +5 -2
  170. package/scripts/cm-refactor-host.mjs +3 -1
  171. package/scripts/cm-run-analysis.test.mjs +373 -1
  172. package/scripts/cm-runtime-i18n.mjs +3 -3
  173. package/scripts/cm-runtime-install.mjs +19 -10
  174. package/scripts/cm-runtime.mjs +2 -4
  175. package/scripts/cm-runtime.test.mjs +55 -13
  176. package/scripts/cm-skill-hints-autowire.test.mjs +1 -1
  177. package/scripts/cm-skill-hints-exam.mjs +3 -1
  178. package/scripts/cm-skill-hints-install.test.mjs +1 -1
  179. package/scripts/cm-skill-hints.mjs +106 -10
  180. package/scripts/cm-skill-hints.test.mjs +162 -6
  181. package/scripts/cm-skill-judge.mjs +2 -1
  182. package/scripts/cm-statusline.test.mjs +54 -0
  183. package/scripts/cm-task-gate.mjs +88 -18
  184. package/scripts/cm-task-scope.test.mjs +1 -1
  185. package/scripts/cm-test-drive.mjs +13 -8
  186. package/scripts/cm-test-entry.mjs +5 -2
  187. package/scripts/cm-test-host.mjs +3 -1
  188. package/scripts/cm-upgrade-compat-batch.test.mjs +62 -9
  189. package/scripts/fixtures/fresh-completion-checks.mjs +8 -0
  190. package/scripts/fixtures/prd-review-gate-python-oracle.py +9 -0
  191. package/scripts/policy-binding-compat.test.mjs +3 -2
  192. package/scripts/test-cm-prd-review-gate.py +25 -0
  193. package/skills/cm-ai/SKILL.md +1 -1
  194. package/skills/cm-ai/references/N1-init.md +4 -3
  195. package/skills/cm-ai/references/N4-review.md +6 -3
  196. package/skills/cm-ai/references/N6-qa-eval.md +3 -1
  197. package/skills/cm-ai/references/js-host-recovery.md +4 -1
  198. package/skills/cm-ai/references/js-host.md +25 -5
  199. package/skills/cm-fix/references/js-host.md +20 -0
  200. package/skills/cm-fix/references/test-extension.md +1 -1
  201. package/skills/cm-prd/SKILL.md +8 -6
  202. package/skills/cm-prd/references/ai-draft.md +81 -0
  203. package/skills/cm-prd/references/change-mode.md +2 -0
  204. package/skills/cm-prd/references/greenfield.md +2 -0
  205. package/skills/cm-prd/references/js-change-recovery.md +2 -2
  206. package/skills/cm-prd/references/js-host.md +9 -6
  207. package/skills/cm-prd/references/light-mode.md +19 -0
  208. package/skills/cm-prd/references/requirement-grilling.md +2 -0
  209. package/skills/cm-prd/references/spec-self-check.md +1 -0
  210. package/skills/cm-prd/references/summary-card.md +1 -0
  211. package/skills/cm-runtime/SKILL.md +6 -6
  212. package/templates/statusline/cm-statusline.sh +63 -1
@@ -0,0 +1,123 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import {spawnSync} from 'node:child_process';
4
+ import fs from 'node:fs';
5
+ import os from 'node:os';
6
+ import path from 'node:path';
7
+ import {fileURLToPath} from 'node:url';
8
+ import {configFingerprint} from '../runtime/js/cm-ai/codex-config.mjs';
9
+ import {openExecutionStore} from '../runtime/js/cm-ai/execution-store.mjs';
10
+ import {inspectFixExecutionHistory,openFixExecution} from '../runtime/js/cm-fix/execution.mjs';
11
+ import {isSupportedExecutionPlatform} from '../runtime/js/cm-ai/execution-platform.mjs';
12
+
13
+ const skip=!isSupportedExecutionPlatform();
14
+ const host=fileURLToPath(new URL('./cm-fix-host.mjs',import.meta.url));
15
+ const driver=fileURLToPath(new URL('./cm-fix-drive.mjs',import.meta.url));
16
+ const diagnosis={status:'diagnosed',rootCause:'Fixture value is stale',affectedPaths:['value.mjs'],
17
+ affectedModules:['value'],crossLayer:false,plan:'Update the value.'};
18
+ const investigation={discardedAlternatives:[],boundaryAnalysis:null};
19
+ const walkthrough={timeoutMs:2000,flows:[{id:'check-value',modules:['value'],kind:'commands',
20
+ steps:['Read the value'],expected:['The value is updated'],command:[process.execPath,'existing.mjs']}]};
21
+
22
+ function fixture(t){
23
+ const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-fix-closeout-preflight-')));
24
+ t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
25
+ const code=path.join(root,'code'),specsRoot=path.join(root,'specs'),answers=path.join(root,'answers');
26
+ for(const dir of [code,specsRoot,answers])fs.mkdirSync(dir);
27
+ fs.writeFileSync(path.join(code,'value.mjs'),'export const value=1;');
28
+ fs.writeFileSync(path.join(code,'red.mjs'),"console.error('BUG');process.exit(1);");
29
+ fs.writeFileSync(path.join(code,'existing.mjs'),'process.exit(0);');
30
+ const command=[process.execPath,'red.mjs'];
31
+ const reproduction={cwd:code,command,expectedFailure:{exitCode:1,outputIncludes:'BUG'},timeoutMs:2000};
32
+ const identity={repositoryId:'fixture',runId:'closeout-check',taskId:'T-FIX-small',attempt:1};
33
+ const config={specsRoot,identity,defect:'Fixture value',reproduction,
34
+ redTest:{...reproduction,testFiles:['red.mjs']},repair:{scope:['value.mjs'],requirements:['existing.mjs']},
35
+ baseline:{cwd:code,testFiles:['existing.mjs'],commands:[{id:'existing',command:[process.execPath,'existing.mjs']}],timeoutMs:2000}};
36
+ const write=(file,value)=>fs.writeFileSync(path.join(root,file),JSON.stringify(value));
37
+ const model='fixture-reviewer';
38
+ write('review.json',{model,disabledSkills:[],preflight:{passed:true,cli_model:model,prompt_transport:'stdin',
39
+ config_fingerprint:configFingerprint({cwd:code,model,disabledSkills:[],promptTransport:'stdin'})}});
40
+ write('plan.json',{config:'config.json',cwd:code,mode:'create',hostContext:'fixture-host',permissions:[],answers:'answers'});
41
+ write('answers/learning.json',{status:'applied',summary:'Use the failing command as the reproduction.'});
42
+ const run=args=>spawnSync(process.execPath,args,{cwd:root,input:'',encoding:'utf8',timeout:Number(process.env.CM_TEST_FIXTURE_TIMEOUT_MS??60000),
43
+ env:{...process.env,CM_WORKFLOW_HOME:path.join(root,'home'),CM_WORKFLOW_LOG_HOME:path.join(root,'logs')}});
44
+ return {config,root,specsRoot,write,run,state:path.join(specsRoot,'.reviews','.execution',identity.runId,'state.json')};
45
+ }
46
+
47
+ test('repair closeout requested at creation requires a walkthrough before the host writes any state',{skip},t=>{
48
+ const f=fixture(t);
49
+ f.write('config.json',f.config);
50
+ const launch=(mode,flags)=>f.run([host,'serve','--config','config.json','--mode',mode,'--host-context','fixture-host',
51
+ '--allow-reproduction','--review-config','review.json','--allow-repair',...flags]);
52
+ const bad=launch('create',['--allow-finish']);
53
+ assert.notEqual(bad.status,0,bad.stdout);
54
+ assert.equal(JSON.parse(bad.stderr).error.code,'walkthrough_configuration_required');
55
+ assert.equal(fs.existsSync(f.state),false);
56
+
57
+ // The same partial configuration is legitimate when repair completion is not requested.
58
+ const partial=launch('create',[]);
59
+ assert.equal(partial.status,0,partial.stderr);assert.match(partial.stdout,/host_ready/);
60
+ const before=fs.readFileSync(f.state);
61
+ const resume=launch('resume',[]);
62
+ assert.equal(resume.status,0,resume.stderr);assert.deepEqual(fs.readFileSync(f.state),before);
63
+ });
64
+
65
+ test('walkthrough can be configured at creation and separately authorized at execution',{skip},t=>{
66
+ const f=fixture(t);
67
+ f.write('config.json',{...f.config,walkthrough});
68
+ const ok=f.run([host,'serve','--config','config.json','--mode','create','--host-context','fixture-host',
69
+ '--allow-reproduction','--review-config','review.json','--allow-repair','--allow-finish']);
70
+ assert.equal(ok.status,0,ok.stderr);assert.match(ok.stdout,/host_ready/);
71
+ });
72
+
73
+ for(const [field,answer] of [
74
+ ['investigation',diagnosis],
75
+ ['investigation.boundaryAnalysis',{...diagnosis,crossLayer:true,investigation}]
76
+ ]){
77
+ test(`a repair diagnosis lacking ${field} stops advance before the host starts`,{skip},t=>{
78
+ const f=fixture(t);f.write('config.json',{...f.config,walkthrough});f.write('answers/diagnosis.json',answer);
79
+ const result=f.run([driver,'--plan','plan.json','advance']);
80
+ assert.notEqual(result.status,0,result.stdout);assert.ok(result.stderr.includes(field),result.stderr);
81
+ assert.equal(fs.existsSync(f.state),false);
82
+ });
83
+ }
84
+
85
+ for(const [answer,expected] of [
86
+ [{...diagnosis,investigation},'red_test_required'],
87
+ [{...diagnosis,status:'needs_evidence'},'observation'],
88
+ [{...diagnosis,status:'design_change'},'cause_review_required']
89
+ ]){
90
+ test(`valid ${answer.status} keeps its normal driver route`,{skip},t=>{
91
+ const f=fixture(t);f.write('config.json',{...f.config,walkthrough});f.write('answers/diagnosis.json',answer);
92
+ const result=f.run([driver,'--plan','plan.json','advance']);
93
+ assert.equal(result.status,0,result.stderr);assert.equal(JSON.parse(result.stdout).result.stage,expected);
94
+ if(answer.status!=='diagnosed')return;
95
+ // Rebuild the exact historical journal shape with a real reproduction result
96
+ // and a diagnosis recorded before investigation was required for repair.
97
+ const snapshot=JSON.parse(fs.readFileSync(f.state));
98
+ const specsRoot=path.join(f.root,'legacy');fs.mkdirSync(specsRoot);
99
+ const store=openExecutionStore({specsRoot,identity:snapshot.identity,fingerprints:snapshot.fingerprints,create:true});
100
+ try{
101
+ for(const {id,kind,payload} of snapshot.records){
102
+ if(id==='fix-diagnose-result')delete payload.value.investigation;
103
+ store.append({id,kind,payload,expectedRevision:store.snapshot().revision});
104
+ }
105
+ }finally{store.close();}
106
+ const history=inspectFixExecutionHistory({specsRoot,identity:snapshot.identity});
107
+ assert.equal(history.stage,'red_test_required');assert.equal(history.diagnosis.investigation,undefined);
108
+ });
109
+ }
110
+
111
+ test('a direct host diagnosis cannot bypass the driver preflight',{skip},async t=>{
112
+ const f=fixture(t);
113
+ const {specsRoot,identity,...config}=f.config;
114
+ const configuration={...config,hostContextId:'fixture-host',walkthrough};
115
+ const bridge={call:async kind=>{assert.equal(kind,'fix_diagnose');return diagnosis;}};
116
+ const owner=openFixExecution({specsRoot,identity,configuration,create:true},{bridge});
117
+ try{
118
+ await assert.rejects(owner.advance({authorized:true}),{code:'invalid_diagnosis'});
119
+ const rows=JSON.parse(fs.readFileSync(f.state)).records;
120
+ assert.ok(rows.some(row=>row.id==='fix-diagnose-intent'));
121
+ assert.ok(!rows.some(row=>row.id==='fix-diagnose-result'));
122
+ }finally{owner.close();}
123
+ });
@@ -39,7 +39,11 @@ async function fixture(t,{aligned=false,outside=false,waitingDiagnosis=false,lif
39
39
  return new Promise(resolve=>{releaseWorker=()=>resolve({status:'failed',code:'owned_stopped'});signal.addEventListener('abort',releaseWorker,{once:true});});
40
40
  }});
41
41
  const diagnosis={status:'diagnosed',rootCause:'The owned constant is wrong',affectedPaths:['one/value.mjs'],plan:'Set the owned constant to two',crossLayer:true,
42
- affectedModules:outside?['one','foreign']:aligned?['one','two']:['one'],investigation:{discardedAlternatives:[],boundaryAnalysis:null}};
42
+ affectedModules:outside?['one','foreign']:aligned?['one','two']:['one'],investigation:{discardedAlternatives:[],boundaryAnalysis:{
43
+ callChain:'test.mjs imports one/value.mjs',edgeEvidence:'test.mjs checks the exported value against two',
44
+ lastNormalEdge:'The named import resolved',firstFailingEdge:'The imported constant is one',
45
+ hypotheses:[{hypothesis:'The constant has the wrong value',support:'one/value.mjs exports one',
46
+ counterTest:'Compare the import against two',result:'The fixture reports OWNED MODULE BUG'}]}}};
43
47
  const configuration={hostContextId:'owned-host',defect:'Owned wrong value',causeReview:host.reviewer,
44
48
  reproduction:{cwd,command:[process.execPath,'test.mjs'],expectedFailure:{exitCode:1,outputIncludes:'OWNED MODULE BUG'},timeoutMs:5000},
45
49
  redTest:{cwd,command:[process.execPath,lifecycle?'regression.test.mjs':'test.mjs'],testFiles:[lifecycle?'regression.test.mjs':'test.mjs'],expectedFailure:{exitCode:1,outputIncludes:'OWNED MODULE BUG'},timeoutMs:5000},
@@ -52,6 +52,7 @@ import {readExecutionSnapshot} from '../runtime/js/cm-ai/execution-snapshot.mjs'
52
52
  import {stderr,stop,readJson,loadPlanFile,requireFields,preflightAnswers,driveHost} from '../runtime/js/cm-ai/drive-core.mjs';
53
53
  import {cmFixSessionBoundary} from '../runtime/js/session-boundary.mjs';
54
54
  import {printHandoff} from '../runtime/js/session-handoff.mjs';
55
+ import {recordFixStepTiming,fixTimingSpecsRoot} from '../runtime/js/cm-fix/step-timing.mjs';
55
56
 
56
57
  const here=path.dirname(fileURLToPath(import.meta.url));
57
58
  const HOST=path.join(here,'cm-fix-host.mjs');
@@ -163,7 +164,7 @@ export function preflight({operation,plan,paths}){
163
164
  // 用宿主同一个校验器:不合格的答案在开宿主前就拦下,免得登记了却交不出结论。
164
165
  const file=operation==='rediagnose'?'diagnosis-rediagnosis.json':'diagnosis.json';
165
166
  const value=need('诊断',file);
166
- try{inspectFixDiagnosis(value);}catch(error){stop(2,`${path.join(paths.answers,file)}:${describeFixDiagnosisError(error)};改好再来,宿主未启动`);}
167
+ try{inspectFixDiagnosis(value,config);}catch(error){stop(2,`${path.join(paths.answers,file)}:${describeFixDiagnosisError(error)};改好再来,宿主未启动`);}
167
168
  return value;
168
169
  }
169
170
  if(kind==='retrospective')return need('复盘','retrospective.json');
@@ -257,13 +258,17 @@ function main(){
257
258
  const {operation,plan,paths}=loaded;
258
259
  const archive=config.specsRoot??path.join(path.resolve(plan.cwd),'docs','fixes');
259
260
  if(plan.mode==='create')printHandoff(archive);
261
+ // Step timing target, fixed before the host starts (null: bare project or unresolvable, not timed).
262
+ let timingRoot=null;try{timingRoot=fixTimingSpecsRoot(config,plan.cwd);}catch{stderr('[drive] 步骤计时目录无法确定,本步不计时;修复结果不受影响');}
260
263
  driveHost({host:HOST,args:hostArgs(loaded).slice(1),cwd:path.resolve(plan.cwd),operation,
261
264
  request:{...(operation==='prepare_diagnosis_module_correction'?{expected:plan.expected,previousInvocationStopped:plan.previousInvocationStopped,reason:plan.reason}:{}),...(operation==='prepare_test_type_correction'?{expected:plan.expected,testTypeCorrection:plan.testTypeCorrection,previousInvocationStopped:plan.previousInvocationStopped,reason:plan.reason}:{}),...(operation==='prepare_command_correction'?{expected:plan.expected,commandCorrection:plan.commandCorrection,previousInvocationStopped:plan.previousInvocationStopped,reason:plan.reason}:{}),...(operation==='prepare_verification_recovery'?{expected:plan.expected,...(Object.hasOwn(plan,'sourceCorrection')?{sourceCorrection:plan.sourceCorrection}:{}),previousInvocationStopped:plan.previousInvocationStopped,reason:plan.reason}:{}),
262
265
  ...(operation==='recover_final_review'?{invocationId:plan.invocationId,packageDigest:plan.packageDigest,previousInvocationStopped:plan.previousInvocationStopped,reason:plan.reason}:{}),
263
266
  ...(operation==='reconcile_review'?{invocationId:plan.invocationId}:{}),...(['abandon_step','abandon_review','rediagnose','rerun_blocked_step'].includes(operation)?{reason:plan.reason}:{}),
264
267
  ...(operation==='prepare_revision'&&Object.hasOwn(plan,'revisionTests')?{tests:plan.revisionTests}:{})},
265
268
  answers,paths:{...paths,round},answerFor,
266
- sessionBoundary:(result,op)=>cmFixSessionBoundary(result,op,{archive,runId:config.identity?.runId})});
269
+ sessionBoundary:(result,op)=>cmFixSessionBoundary(result,op,{archive,runId:config.identity?.runId}),
270
+ // After the host has closed: one diagnostic timing row for this step (never changes the result).
271
+ onStepTiming:timing=>recordFixStepTiming({config,specsRoot:timingRoot,planCwd:plan.cwd,timing,stderr})});
267
272
  }
268
273
 
269
274
  if(process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url))main();
@@ -109,6 +109,51 @@ test('the driver refuses unknown operations and malformed plans without touching
109
109
  assert.equal(fs.existsSync(path.join(f.archive,'.reviews')),false);
110
110
  });
111
111
 
112
+ test('an empty or unsafe reference list is refused when the run is created, naming the field, not at its own step',{skip},t=>{
113
+ // Real run: repair.requirements [] passed creation and the frozen run then failed at
114
+ // repair with only repair_preparation_failed; it could never be fixed by editing config.
115
+ for(const [field,patch,code] of [
116
+ ['repair',{repair:{scope:['value.mjs'],requirements:[]}},'repair_requirements_invalid'],
117
+ ['repair',{repair:{scope:['value.mjs'],requirements:['../outside.mjs']}},'repair_requirements_invalid'],
118
+ ['testAuthor',{testAuthor:{requirements:[]}},'test_author_requirements_invalid'],
119
+ ['testAuthor',{testAuthor:{requirements:['.env']}},'test_author_requirements_invalid'],
120
+ // Rules the later review baseline applies are checked now too (dependency trees, specs files, case duplicates).
121
+ ['repair',{repair:{scope:['value.mjs'],requirements:['node_modules/pkg/index.js']}},'repair_requirements_invalid'],
122
+ ['repair',{repair:{scope:['value.mjs'],requirements:['docs/fixes/notes.md']}},'repair_requirements_invalid'],
123
+ ['repair',{repair:{scope:['value.mjs','VALUE.mjs'],requirements:['existing.mjs']}},'repair_scope_invalid'],
124
+ ['repair',{repair:{scope:['value.mjs','value.mjs'],requirements:['existing.mjs']}},'repair_scope_invalid'],
125
+ // With a test author the red test files become that step's baseline scope.
126
+ ['redTest',{redTest:{testFiles:['node_modules/pkg/red.mjs']},testAuthor:{requirements:['existing.mjs']}},'red_test_files_invalid'],
127
+ ['redTest',{redTest:{testFiles:['AGENTS.md']},testAuthor:{requirements:['existing.mjs']}},'red_test_files_invalid'],
128
+ ['redTest',{redTest:{testFiles:[]}},'red_test_files_invalid'],
129
+ ['baseline',{baseline:{testFiles:[]}},'baseline_test_files_invalid']]){
130
+ const f=fixture(t),configFile=path.join(f.root,'fix-config.json'),base=JSON.parse(fs.readFileSync(configFile));
131
+ // A partial patch keeps the fixture's other fields of that section.
132
+ const merged=Object.fromEntries(Object.entries(patch).map(([key,value])=>[key,{...(base[key]??{}),...value}]));
133
+ if(merged.testAuthor)merged.repair={scope:['value.mjs'],requirements:['existing.mjs']};
134
+ fs.writeFileSync(configFile,JSON.stringify({...base,...merged}));
135
+ fs.writeFileSync(path.join(f.answers,'learning.json'),JSON.stringify(learning));
136
+ fs.writeFileSync(path.join(f.answers,'diagnosis.json'),JSON.stringify(diagnosis));
137
+ const run=drive(f.plan(),'advance');
138
+ assert.notEqual(run.status,0,`${field}: ${run.stderr}`);
139
+ assert.match(run.stderr+run.stdout,new RegExp(code),field);
140
+ assert.equal(fs.existsSync(path.join(f.archive,'.reviews','.execution','drive-demo')),false,`${field}: no run is created`);
141
+ }
142
+ // Valid lists are not refused: the run is created and advances as before. Test files
143
+ // only read as evidence may sit under a dependency or specs tree (file-read rules).
144
+ for(const patch of [{},
145
+ {redTest:{testFiles:['node_modules/pkg/red.mjs']}},
146
+ {baseline:{testFiles:['docs/fixes/existing.mjs']}}]){
147
+ const f=fixture(t),configFile=path.join(f.root,'fix-config.json'),base=JSON.parse(fs.readFileSync(configFile));
148
+ const merged=Object.fromEntries(Object.entries(patch).map(([key,value])=>[key,{...base[key],...value}]));
149
+ fs.writeFileSync(configFile,JSON.stringify({...base,...merged,repair:{scope:['value.mjs'],requirements:['existing.mjs']}}));
150
+ fs.writeFileSync(path.join(f.answers,'learning.json'),JSON.stringify(learning));
151
+ fs.writeFileSync(path.join(f.answers,'diagnosis.json'),JSON.stringify(diagnosis));
152
+ const ok=drive(f.plan(),'advance');assert.equal(ok.status,0,`${JSON.stringify(patch)}: ${ok.stderr}`);
153
+ assert.equal(JSON.parse(ok.stdout).result.stage,'red_test_required',JSON.stringify(patch));
154
+ }
155
+ });
156
+
112
157
  test('the driver abandons a local unknown step using only plan reason and flag',{skip},t=>{
113
158
  const f=fixture(t),config=JSON.parse(fs.readFileSync(path.join(f.root,'fix-config.json')));
114
159
  const {identity,...definition}=config;
@@ -2,6 +2,8 @@
2
2
  import fs from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import {fileURLToPath} from 'node:url';
5
+ import {executorRelease} from '../runtime/js/executor-version.mjs';
6
+ import {diagnosticReason} from '../runtime/js/cm-ai/diagnostic-reason.mjs';
5
7
 
6
8
  function reject(code) {
7
9
  const error=new Error(code);
@@ -55,7 +57,8 @@ function workflowRoot(skillDir) {
55
57
  ownedFile(root,'VERSION','skill_path_invalid');layout='plugin';
56
58
  }else if(fs.existsSync(path.join(root,'templates','cm-VERSION'))){
57
59
  ownedFile(root,'templates/cm-VERSION','skill_path_invalid');layout='claude-compat';
58
- }else reject('skill_path_invalid');
60
+ // No release marker at all: a broken install, reported with its reinstall hint.
61
+ }else{executorRelease(root);reject('skill_path_invalid');}
59
62
  if(realDirectory(path.join(root,'templates'),'skill_path_invalid')!==path.join(root,'templates'))
60
63
  reject('skill_path_invalid');
61
64
  for(const file of ['skills/cm-fix/SKILL.md','skills/cm-fix/references/cross-boundary-debugging.md',
@@ -126,7 +129,7 @@ if(isMainModule(process.argv[1])){
126
129
  else { process.stderr.write(output);process.exitCode=2; }
127
130
  } catch(error) {
128
131
  process.stderr.write(`${JSON.stringify({schemaVersion:1,workflow:'cm-fix',status:'error',
129
- reason:error?.code??'admission_failed',executionAuthorized:false,writeAuthorized:false})}\n`);
132
+ reason:error?.code??'admission_failed',...(diagnosticReason(error)?{detail:diagnosticReason(error)}:{}),executionAuthorized:false,writeAuthorized:false})}\n`);
130
133
  process.exitCode=2;
131
134
  }
132
135
  }
@@ -0,0 +1,50 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import fs from 'node:fs';
4
+ import os from 'node:os';
5
+ import path from 'node:path';
6
+ import {captureReviewBaseline} from '../runtime/js/cm-ai/review-package.mjs';
7
+ import {packFixJournalPayload,unpackFixJournalPayload} from '../runtime/js/cm-ai/review-presentation.mjs';
8
+ import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
9
+
10
+ const workflow={workflow:'cm-fix-stages-v1'};
11
+ const MiB=1024*1024;
12
+ const size=value=>Buffer.byteLength(JSON.stringify(value));
13
+
14
+ test('frozen test-author and repair baselines round-trip across the 1 MiB journal boundary',t=>{
15
+ const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-frozen-baseline-')));
16
+ t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
17
+ const identity={repositoryId:'fixture',runId:'baseline',taskId:'T-FIX-baseline',attempt:1};
18
+ fs.writeFileSync(path.join(root,'value.txt'),'x'.repeat(790*1024));
19
+ const baseline=captureReviewBaseline({root,identity,scope:['value.txt'],requirements:['value.txt']});
20
+ const redDigest=digest('red'),testBaselineDigest=digest('tests'),revisionDigest=digest('revision');
21
+ const repair={baseline,redDigest,testBaselineDigest};
22
+ for(const intent of [baseline,{baseline,revisionDigest},repair,{...repair,revisionDigest}]){
23
+ assert.ok(size(intent)>MiB);
24
+ const stored=packFixJournalPayload(intent,workflow);
25
+ assert.ok(size(stored)<=MiB);
26
+ assert.deepEqual(unpackFixJournalPayload(stored,workflow),intent);
27
+ }
28
+ // The storage exception only applies to the owner's known, fully bound forms.
29
+ for(const invalid of [{baseline},{baseline,redDigest},{...repair,extra:true},{...repair,redDigest:'invalid'},
30
+ {...repair,baseline:{...baseline,baselineDigest:digest('wrong')}}]){
31
+ assert.throws(()=>packFixJournalPayload(invalid,workflow));
32
+ }
33
+ const stored=structuredClone(packFixJournalPayload(repair,workflow));
34
+ stored.data.presentation.packageDigest=digest('wrong anchor');
35
+ assert.throws(()=>unpackFixJournalPayload(stored,workflow));
36
+ });
37
+
38
+ test('frozen baselines use shared base64 when JSON escaping would overflow the record',t=>{
39
+ const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-frozen-escaped-')));
40
+ t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
41
+ const identity={repositoryId:'fixture',runId:'escaped',taskId:'T-FIX-escaped',attempt:1};
42
+ const scope=['first.bin','second.bin'];
43
+ for(const file of scope)fs.writeFileSync(path.join(root,file),Buffer.alloc(400*1024));
44
+ const baseline=captureReviewBaseline({root,identity,scope,requirements:scope});
45
+ const intent={baseline,redDigest:digest('red'),testBaselineDigest:digest('tests')};
46
+ assert.ok(size(intent)>MiB);
47
+ const stored=packFixJournalPayload(intent,workflow);
48
+ assert.ok(size(stored)<=MiB);
49
+ assert.deepEqual(unpackFixJournalPayload(stored,workflow),intent);
50
+ });
@@ -6,6 +6,7 @@ import {readFixExternalModels} from '../runtime/js/cm-ai/external-group-models.m
6
6
  import fs from 'node:fs';
7
7
  import {fileURLToPath} from 'node:url';
8
8
  import {openFixExecution} from '../runtime/js/cm-fix/execution.mjs';
9
+ import {checkNewFixCloseoutPlan} from '../runtime/js/cm-fix/finish.mjs';
9
10
  import {createFixHost} from '../runtime/js/cm-fix/host.mjs';
10
11
  import {createFixLearningPreparation} from '../runtime/js/cm-fix/learning.mjs';
11
12
  import {createHostToolBridge,HOST_ANSWER_BACKSTOP_MS} from '../runtime/js/cm-ai/host-tool-bridge.mjs';
@@ -13,6 +14,7 @@ import {serveCmAiHost,parseHostInputLimit,inputLimitReason} from '../runtime/js/
13
14
  import {id,json,need,shape,digest} from '../runtime/js/cm-ai/effect-contract.mjs';
14
15
  import {readConversationReviewConfiguration} from './cm-ai-host.mjs';
15
16
  import {createFixReviewHost} from '../runtime/js/cm-fix/host-review.mjs';
17
+ import {EXECUTOR_REASON_CODES} from '../runtime/js/executor-version.mjs';
16
18
 
17
19
  const usage='cm-fix-host.mjs serve --config PATH --mode create|resume --host-context ID --allow-reproduction [--original-host-context ID] [--execution-optimizations] [--external-models [--external-models-config PATH]] [--runtime codex|claude] [--review-runtime codex|claude] [--input-limit BYTES] [--review-config PATH] [--allow-cause-review] [--allow-rediagnosis] [--allow-final-review] [--allow-test-author] [--allow-red-test] [--allow-baseline] [--allow-repair] [--allow-regression] [--allow-learning-writeback]\nCodex or Claude current-host operations: rediagnose, prepare_revision, revision_test_check, advance, cause_review_package, cause_review, author_tests, red_test, baseline, repair, regression, retrospective, learning_writeback, handoff, final_review_package, final_review, publish_review, check_n5, post_review_regression, status, cancel. Runtime is the actual execution host and defaults to codex. Optional --review-runtime selects the independent reviewer using the declared coder/reviewer roles; omission preserves legacy same-tool routing. Review configuration and diagnostics must match the selected reviewer; Claude cannot reuse Codex preflight or disabledSkills settings. Explicit review runtime is bound to recovery; adding, removing or switching it on an existing run is refused. This selects existing adapters, not permission to call them. Each write/check needs its respective launch flag and configuration. Test authoring, repair, cause and final review dispatch require matching existing stdin diagnostics; diagnostic alone is not authorization. Passing regression stops at handoff_required. The read-only retrospective operation yields handoff_ready or learning_writeback_required. learning_writeback requires its own flag, preserves project instructions and includes AGENTS.md in the review scope; it does not authorize provider calls. handoff publishes the fixed specs-local handoff with Learning evidence and moves to final_review_required; no provider is called and no task is completed. final_review_package is read-only and returns the final content-bound review package. final_review requires its own flag and matching diagnostics; observations do not complete the task. publish_review projects the registered result into the existing review file; it does not dispatch or complete tasks. check_n5 runs the original Learning-aware gate; post_review_regression requires --allow-regression and reaches closeout_required, not completion.';
18
20
 
@@ -75,7 +77,11 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
75
77
  ...(Object.hasOwn(config,'qaSource')?['qaSource']:[]),
76
78
  ...(Object.hasOwn(config,'redTest')?['redTest']:[]),...(Object.hasOwn(config,'baseline')?['baseline']:[]),
77
79
  ...(Object.hasOwn(config,'testAuthor')?['testAuthor']:[]),...(Object.hasOwn(config,'repair')?['repair']:[]),...(Object.hasOwn(config,'walkthrough')?['walkthrough']:[])]);
78
- if(argv[4]==='create')assertJestConfigurationDiscovery(config);
80
+ if(argv[4]==='create'){
81
+ assertJestConfigurationDiscovery(config);
82
+ checkNewFixCloseoutPlan(config,[...extra.keys()]);
83
+ if(config.repair&&!config.walkthrough)error.write('提示:此配置缺少 walkthrough;如计划修复并收尾,请在建运行前配置覆盖受影响模块的走查。\n');
84
+ }
79
85
  const executionPolicy=readFixExecutionPolicy({config,mode:argv[4],enabled:extra.has('--execution-optimizations')});
80
86
  const externalModels=readFixExternalModels({config,mode:argv[4],enabled:extra.has('--external-models'),inputFile:extra.get('--external-models-config'),runtime:selectedReviewRuntime});
81
87
  review=extra.has('--review-config')?readConversationReviewConfiguration(extra.get('--review-config'),externalModels?.providers[selectedReviewRuntime]??null):null;
@@ -120,7 +126,8 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
120
126
  return 0;
121
127
  }catch(cause){
122
128
  const code=typeof cause?.code==='string'&&/^[a-z][a-z0-9_]{0,63}$/.test(cause.code)?cause.code:'fix_host_failed';
123
- error.write(JSON.stringify({error:{code,...(code==='request_too_large'?{reason:inputLimitReason(cause.limit)}:code==='fix_review_runtime_mismatch'?{reason:'执行宿主与审查工具须匹配项目 coder/reviewer 角色;恢复时保留原审查配置。'}:code==='invalid_workflow_config'?{reason:'请检查项目 .cm-workflow 配置及继承的用户默认配置,确认 coder/reviewer 与 runtimes 声明一致。'}:code==='tool_preflight_missing'?{reason:'请为选定审查工具在相同项目、模型与配置下重新运行 preflight;另一工具的诊断不能复用。'}:{})}})+'\n');return 1;
129
+ error.write(JSON.stringify({error:{code,...(code==='request_too_large'?{reason:inputLimitReason(cause.limit)}:code==='fix_review_runtime_mismatch'?{reason:'执行宿主与审查工具须匹配项目 coder/reviewer 角色;恢复时保留原审查配置。'}:code==='invalid_workflow_config'?{reason:'请检查项目 .cm-workflow 配置及继承的用户默认配置,确认 coder/reviewer 与 runtimes 声明一致。'}:code==='walkthrough_configuration_required'?{reason:'新建完整修复运行前,请在宿主配置的 walkthrough.flows 声明覆盖受影响模块的走查。'}:code==='tool_preflight_missing'?{reason:'请为选定审查工具在相同项目、模型与配置下重新运行 preflight;另一工具的诊断不能复用。'}
130
+ :EXECUTOR_REASON_CODES.has(code)&&typeof cause.reason==='string'?{reason:cause.reason}:{})}})+'\n');return 1;
124
131
  }finally{bridge?.close();owner?.close();}
125
132
  }
126
133
  if(process.argv[1]&&fs.realpathSync(process.argv[1])===fileURLToPath(import.meta.url))process.exitCode=await main();
@@ -55,7 +55,8 @@ async function fixture(t,mode='changes_requested',hooks={}){
55
55
  }};
56
56
  if(mode==='cause-tests'){configuration.testAuthor={requirements:['value.mjs']};delete configuration.walkthrough;}
57
57
  const options={identity:config.identity,configuration,create:true};
58
- let owner=openFixExecution(options,{...reviewHost.execution,bridge,prepare:async()=>learning});
58
+ const prepare=async(...args)=>{if(hooks.prepare)await hooks.prepare(cwd,...args);return learning;};
59
+ let owner=openFixExecution(options,{...reviewHost.execution,bridge,prepare});
59
60
  t.after(()=>owner.close());
60
61
  const host=createFixHost({owner,config,permissions,authority:reviewHost.authority,finalAuthority:reviewHost.finalAuthority});
61
62
  if(mode==='cause-tests'){
@@ -70,7 +71,7 @@ async function fixture(t,mode='changes_requested',hooks={}){
70
71
  const bytes=fs.readFileSync(statePath),state=JSON.parse(bytes),registered=state.records.find(r=>r.id==='fix-final-registered').payload;
71
72
  const request={requestId:'recover',operation:'recover_final_review',invocationId:registered.request.invocationId,
72
73
  packageDigest:registered.request.payload.reviewPackage.packageDigest,previousInvocationStopped:true,reason:'Human authorized one continuation; previous process stopped'};
73
- const reopen=()=>{owner.close();owner=openFixExecution({...options,create:false},{...reviewHost.execution,bridge,prepare:async()=>learning});return owner;};
74
+ const reopen=()=>{owner.close();owner=openFixExecution({...options,create:false},{...reviewHost.execution,bridge,prepare});return owner;};
74
75
  return {cwd,statePath,bytes,state,request,reopen,host:()=>createFixHost({owner,config,permissions,authority:reviewHost.authority,finalAuthority:reviewHost.finalAuthority}),owner:()=>owner,calls:()=>calls,repairs:()=>repairs,authors:()=>authors,options};
75
76
  }
76
77
 
@@ -192,6 +193,33 @@ test('F56 rejects missing findings, business scope, permissions, late edits and
192
193
  assert.equal(owner.status().stage,'revision_test_evidence_required');
193
194
  });
194
195
 
196
+ test('F56 a new test plan naming dependency or specs files is refused before it is registered, on both preparation paths',async t=>{
197
+ const f=await fixture(t),owner=f.owner();owner.publishReview();
198
+ const before=JSON.parse(fs.readFileSync(f.statePath)).records;
199
+ for(const file of ['node_modules/pkg/new.test.mjs','docs/fixes/new.test.mjs'])
200
+ await assert.rejects(owner.prepareRevision({authorized:true,tests:{...plan,testFiles:[file]}}),{code:'fix_test_extension_scope'});
201
+ assert.deepEqual(JSON.parse(fs.readFileSync(f.statePath)).records,before);
202
+ await owner.prepareRevision({authorized:true});
203
+ const prepared=JSON.parse(fs.readFileSync(f.statePath)).records;
204
+ for(const file of ['node_modules/pkg/new.test.mjs','docs/fixes/new.test.mjs'])
205
+ await assert.rejects(owner.prepareRevision({authorized:true,tests:{...plan,testFiles:[file]}}),{code:'fix_test_extension_scope'});
206
+ assert.deepEqual(JSON.parse(fs.readFileSync(f.statePath)).records,prepared);
207
+ assert.equal(owner.status().stage,'revision_prepared');
208
+ await owner.prepareRevision({authorized:true,tests:plan});
209
+ assert.equal(owner.status().stage,'revision_test_author_required');
210
+ });
211
+
212
+ test('F56 a new test plan is checked again after preparation: CocoaPods output appearing meanwhile is refused, nothing registered',async t=>{
213
+ const f=await fixture(t,'changes_requested',{prepare(cwd,{identity}){
214
+ // Podfile.lock is there from the start; only the Pods output appears while the second round is prepared.
215
+ if(identity.attempt!==2){fs.mkdirSync(path.join(cwd,'ios'),{recursive:true});fs.writeFileSync(path.join(cwd,'ios/Podfile.lock'),'');return;}
216
+ fs.mkdirSync(path.join(cwd,'ios/Pods/Pods.xcodeproj'),{recursive:true});fs.writeFileSync(path.join(cwd,'ios/Pods/Manifest.lock'),'');}});
217
+ const owner=f.owner();owner.publishReview();
218
+ const before=JSON.parse(fs.readFileSync(f.statePath)).records;
219
+ await assert.rejects(owner.prepareRevision({authorized:true,tests:{...plan,testFiles:['ios/Pods/New.test.mjs']}}),{code:'fix_test_extension_scope'});
220
+ assert.deepEqual(JSON.parse(fs.readFileSync(f.statePath)).records,before);
221
+ });
222
+
195
223
  test('F56 existing prepared revision can append a test plan without rewriting preparation',async t=>{
196
224
  const f=await fixture(t),owner=f.owner();owner.publishReview();await owner.prepareRevision({authorized:true});
197
225
  const before=JSON.parse(fs.readFileSync(f.statePath)).records;
@@ -39,6 +39,18 @@ test('host check evidence excludes credentials paths and timing output',()=>fixt
39
39
  assert.equal(result.outcome,'passed');assert.equal(result.evidence,'host check exited 0');
40
40
  }));
41
41
 
42
+ // Dogfood 2026-12-01: a synchronous callback's return value (stream.write's boolean,
43
+ // Array#push's length) must not turn a passing check into output_capture_failed.
44
+ test('a synchronous output callback may return any value without failing the check',()=>fixture(async cwd=>{
45
+ for(const value of [true,false,0,42,'text',null,{}]){
46
+ const seen=[];
47
+ const check=createHostCheck({cwd,commands:[{id:'loud',command:[process.execPath,'-e',"console.log('loud')"]}],
48
+ onOutput:({chunk})=>{seen.push(chunk.toString('utf8'));return value;}});
49
+ const [result]=await check({identity},control());
50
+ assert.equal(result.outcome,'passed',String(value));assert.match(seen.join(''),/loud/);
51
+ }
52
+ }));
53
+
42
54
  test('async output capture rejects safely and waits for process cleanup',()=>fixture(async cwd=>{
43
55
  const check=createHostCheck({cwd,commands:[hung('capture',
44
56
  "require('node:fs').writeFileSync('pid',String(process.pid));process.on('SIGTERM',()=>{});console.log('fixture');setInterval(()=>{},1000)")],