@aibyzero/cm-workflow 0.16.8 → 0.16.9

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 (157) hide show
  1. package/.codex-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +19 -0
  3. package/README.md +14 -3
  4. package/VERSION +1 -1
  5. package/compat/claude-commands/cm-notify.md +3 -0
  6. package/docs/installation.md +1 -1
  7. package/docs/js-workflow-control.md +25 -1
  8. package/docs/next-steps.md +8 -2
  9. package/docs/user-guide.md +105 -5
  10. package/package.json +2 -1
  11. package/runtime/js/cm-ai/claude-review-stream.mjs +49 -13
  12. package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +111 -20
  13. package/runtime/js/cm-ai/cm-ai-qa-log.mjs +69 -22
  14. package/runtime/js/cm-ai/code-projects.mjs +4 -1
  15. package/runtime/js/cm-ai/developer-adapter.mjs +7 -0
  16. package/runtime/js/cm-ai/drive-core.mjs +9 -0
  17. package/runtime/js/cm-ai/durable-runner-state.mjs +951 -43
  18. package/runtime/js/cm-ai/effect-abandon-log.mjs +5 -2
  19. package/runtime/js/cm-ai/effect-contract.mjs +6 -1
  20. package/runtime/js/cm-ai/external-run-guard.mjs +18 -7
  21. package/runtime/js/cm-ai/host-check.mjs +4 -1
  22. package/runtime/js/cm-ai/host-conversation-execution.mjs +11 -4
  23. package/runtime/js/cm-ai/host-documentation.mjs +53 -12
  24. package/runtime/js/cm-ai/host-project-execution.mjs +2 -2
  25. package/runtime/js/cm-ai/host-qa-executor.mjs +49 -4
  26. package/runtime/js/cm-ai/host-qa-fix-owner.mjs +44 -9
  27. package/runtime/js/cm-ai/host-session.mjs +1 -1
  28. package/runtime/js/cm-ai/host-tool-bridge.mjs +40 -3
  29. package/runtime/js/cm-ai/operator-guidance.mjs +112 -3
  30. package/runtime/js/cm-ai/provider-review-observation.mjs +50 -0
  31. package/runtime/js/cm-ai/qa-resource-release.mjs +46 -0
  32. package/runtime/js/cm-ai/qa-round-budget.mjs +13 -0
  33. package/runtime/js/cm-ai/review-dispatch-limits.mjs +18 -0
  34. package/runtime/js/cm-ai/review-package.mjs +10 -1
  35. package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +1 -1
  36. package/runtime/js/cm-ai/task-commit.mjs +39 -0
  37. package/runtime/js/cm-ai/task-runner.mjs +636 -65
  38. package/runtime/js/cm-ai/worker-claude-developer.mjs +9 -0
  39. package/runtime/js/cm-ai/worker-claude.mjs +10 -3
  40. package/runtime/js/cm-ai/worker-process-identity.mjs +43 -0
  41. package/runtime/js/cm-fix/execution.mjs +176 -48
  42. package/runtime/js/cm-fix/host.mjs +2 -1
  43. package/runtime/js/cm-fix/pinned-baseline.mjs +24 -0
  44. package/runtime/js/cm-fix/progress.mjs +13 -3
  45. package/runtime/js/cm-fix/protected-edits.mjs +10 -3
  46. package/runtime/js/cm-fix/repair.mjs +11 -3
  47. package/runtime/js/cm-fix/test-author.mjs +10 -3
  48. package/runtime/js/cm-idea/session.mjs +67 -4
  49. package/runtime/js/cm-prd/review-correction.mjs +10 -4
  50. package/runtime/js/cm-prd/session.mjs +43 -0
  51. package/runtime/js/cm-refactor/records.mjs +98 -8
  52. package/runtime/js/cm-refactor/workflow.mjs +79 -9
  53. package/runtime/js/cm-test/host.mjs +10 -3
  54. package/runtime/js/cm-test/session.mjs +45 -6
  55. package/runtime/js/notify-safe-read.mjs +49 -0
  56. package/runtime/js/notify-send.mjs +312 -0
  57. package/runtime/js/notify.mjs +137 -33
  58. package/runtime/js/policy-binding-compat.mjs +54 -0
  59. package/scripts/ci-test-shards.mjs +67 -0
  60. package/scripts/ci-test-shards.test.mjs +64 -0
  61. package/scripts/ci-test-weights.json +222 -0
  62. package/scripts/cm-ai-abandon-effect-position.test.mjs +70 -2
  63. package/scripts/cm-ai-answer-gap-dispatch.test.mjs +86 -0
  64. package/scripts/cm-ai-answer-gap-driver.test.mjs +51 -0
  65. package/scripts/cm-ai-answer-gap-fixture.mjs +96 -0
  66. package/scripts/cm-ai-answer-gap-recheck.test.mjs +70 -0
  67. package/scripts/cm-ai-answer-gap-redo.test.mjs +103 -0
  68. package/scripts/cm-ai-batch-drive.mjs +55 -10
  69. package/scripts/cm-ai-batch-drive.test.mjs +65 -0
  70. package/scripts/cm-ai-batch-host.mjs +132 -13
  71. package/scripts/cm-ai-batch-host.test.mjs +255 -7
  72. package/scripts/cm-ai-batch-run-fixture.mjs +499 -0
  73. package/scripts/cm-ai-batch-run-member-stops.test.mjs +38 -0
  74. package/scripts/cm-ai-batch-run-parallel.test.mjs +7 -0
  75. package/scripts/cm-ai-batch-run-reschedule.test.mjs +17 -0
  76. package/scripts/cm-ai-batch-run.mjs +184 -22
  77. package/scripts/cm-ai-batch-run.test.mjs +21 -341
  78. package/scripts/cm-ai-develop-answer-invalid.test.mjs +104 -0
  79. package/scripts/cm-ai-develop-call-timeout.test.mjs +153 -0
  80. package/scripts/cm-ai-develop-driver-gaps.test.mjs +4 -3
  81. package/scripts/cm-ai-documentation-sync-gap.test.mjs +424 -0
  82. package/scripts/cm-ai-drive.mjs +64 -22
  83. package/scripts/cm-ai-drive.test.mjs +29 -2
  84. package/scripts/cm-ai-host-cli-workflow.test.mjs +271 -0
  85. package/scripts/cm-ai-host-fixture.mjs +268 -0
  86. package/scripts/cm-ai-host-protected.test.mjs +251 -0
  87. package/scripts/cm-ai-host.mjs +27 -15
  88. package/scripts/cm-ai-host.test.mjs +17 -759
  89. package/scripts/cm-ai-light-modules.test.mjs +57 -0
  90. package/scripts/cm-ai-operator-guidance.test.mjs +30 -5
  91. package/scripts/cm-ai-protected-scope.test.mjs +7 -3
  92. package/scripts/cm-ai-qa-answer-gaps.test.mjs +99 -0
  93. package/scripts/cm-ai-qa-fix-cross-session.test.mjs +78 -11
  94. package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +56 -10
  95. package/scripts/cm-ai-review-dispatch-exit.test.mjs +475 -0
  96. package/scripts/cm-ai-review-failure.test.mjs +124 -13
  97. package/scripts/cm-ai-review-timeout.test.mjs +188 -10
  98. package/scripts/cm-ai-run.mjs +15 -6
  99. package/scripts/cm-ai-supersede.test.mjs +486 -41
  100. package/scripts/cm-check-drive-files.mjs +8 -0
  101. package/scripts/cm-check-drive.test.mjs +2 -5
  102. package/scripts/cm-check-runtime.sh +4 -2
  103. package/scripts/cm-claude-developer-worker.test.mjs +15 -0
  104. package/scripts/cm-claude-review-stream.test.mjs +21 -16
  105. package/scripts/cm-claude-review-synthetic.test.mjs +155 -0
  106. package/scripts/cm-claude-worker.test.mjs +18 -2
  107. package/scripts/cm-external-model-recovery.test.mjs +29 -3
  108. package/scripts/cm-fix-abandon.test.mjs +163 -10
  109. package/scripts/cm-fix-drive-unprotected.test.mjs +37 -0
  110. package/scripts/cm-fix-drive.mjs +25 -7
  111. package/scripts/cm-fix-host.mjs +8 -7
  112. package/scripts/cm-fix-review-budget.test.mjs +13 -0
  113. package/scripts/cm-fix-review-recovery.test.mjs +35 -0
  114. package/scripts/cm-host-answer-timeout.test.mjs +65 -0
  115. package/scripts/cm-host-call-kinds.test.mjs +28 -0
  116. package/scripts/cm-host-documentation.test.mjs +49 -0
  117. package/scripts/cm-host-qa-executor.test.mjs +22 -10
  118. package/scripts/cm-idea-answer-gaps.test.mjs +164 -0
  119. package/scripts/cm-idea-drive.mjs +49 -11
  120. package/scripts/cm-idea-drive.test.mjs +66 -0
  121. package/scripts/cm-idea-host.mjs +106 -16
  122. package/scripts/cm-init-answer-gaps.test.mjs +258 -0
  123. package/scripts/cm-init-drive.mjs +41 -7
  124. package/scripts/cm-init-host.mjs +61 -12
  125. package/scripts/cm-log-event.mjs +21 -10
  126. package/scripts/cm-notify-command.test.mjs +900 -0
  127. package/scripts/cm-notify-read-drift.test.mjs +205 -0
  128. package/scripts/cm-notify.mjs +469 -0
  129. package/scripts/cm-notify.test.mjs +221 -4
  130. package/scripts/cm-prd-answer-gaps.test.mjs +216 -0
  131. package/scripts/cm-prd-drive.mjs +18 -5
  132. package/scripts/cm-prd-drive.test.mjs +15 -0
  133. package/scripts/cm-prd-host.mjs +37 -4
  134. package/scripts/cm-prd-review-disposition.test.mjs +6 -1
  135. package/scripts/cm-prd-review-gate.mjs +56 -0
  136. package/scripts/cm-refactor-answer-gaps.test.mjs +206 -0
  137. package/scripts/cm-refactor-drive.mjs +52 -8
  138. package/scripts/cm-refactor-drive.test.mjs +44 -0
  139. package/scripts/cm-refactor-host.test.mjs +10 -6
  140. package/scripts/cm-release-smoke.sh +2 -0
  141. package/scripts/cm-test-answer-gaps.test.mjs +151 -0
  142. package/scripts/cm-test-drive.mjs +21 -5
  143. package/scripts/fixtures/claude-review-process.mjs +1 -1
  144. package/scripts/policy-binding-compat.test.mjs +99 -0
  145. package/scripts/scan-public-safety.py +4 -0
  146. package/scripts/validate-public-repo.py +4 -0
  147. package/skills/cm-ai/references/js-host-qa-recovery.md +27 -1
  148. package/skills/cm-ai/references/js-host-recovery.md +120 -8
  149. package/skills/cm-ai/references/js-host.md +14 -7
  150. package/skills/cm-check/SKILL.md +3 -3
  151. package/skills/cm-fix/references/js-host.md +44 -5
  152. package/skills/cm-idea/references/js-host.md +27 -2
  153. package/skills/cm-init/references/js-host.md +16 -3
  154. package/skills/cm-notify/SKILL.md +34 -0
  155. package/skills/cm-prd/references/js-change-recovery.md +35 -1
  156. package/skills/cm-refactor/references/js-host.md +17 -0
  157. package/skills/cm-test/references/js-host.md +14 -1
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env node
2
+ // CI 分片:把测试文件按实测耗时分到 N 份,每个文件恰好落在一份里。
3
+ // 以前按排序后的序号轮流分,最慢的几个文件挤进同一份,那一份比别的慢近一倍。
4
+ // 现在用 ci-test-weights.json 里记的秒数做贪心分配(最重的先放进当前最轻的一份),
5
+ // 表里没有的新文件按表中位数计,所以新增测试不用先改表也会被分到某一份。
6
+ // 只决定哪份跑哪些文件,不跳过、不过滤任何文件。
7
+ // 用法:node scripts/ci-test-shards.mjs --shards 4 --index 0 scripts/a.test.mjs scripts/b.test.mjs ...
8
+ import fs from 'node:fs';
9
+ import path from 'node:path';
10
+ import {fileURLToPath} from 'node:url';
11
+
12
+ const weightsFile=fileURLToPath(new URL('./ci-test-weights.json',import.meta.url));
13
+
14
+ export function readWeights(file=weightsFile){
15
+ const raw=JSON.parse(fs.readFileSync(file,'utf8'));
16
+ const weights=new Map();
17
+ for(const [name,seconds] of Object.entries(raw.seconds??{})){
18
+ if(!Number.isFinite(seconds)||seconds<0)throw new Error(`invalid weight for ${name}`);
19
+ weights.set(name,seconds);
20
+ }
21
+ return weights;
22
+ }
23
+
24
+ export function median(values){
25
+ const sorted=[...values].sort((a,b)=>a-b);
26
+ if(sorted.length===0)return 1;
27
+ const mid=Math.floor(sorted.length/2);
28
+ return sorted.length%2?sorted[mid]:(sorted[mid-1]+sorted[mid])/2;
29
+ }
30
+
31
+ // Deterministic longest-processing-time assignment: heaviest file first, ties by
32
+ // name; each goes to the currently lightest shard, ties by lowest shard index.
33
+ export function assignShards(files,shards,weights){
34
+ if(!Number.isInteger(shards)||shards<1)throw new Error('shards must be a positive integer');
35
+ const unique=[...new Set(files)];
36
+ if(unique.length!==files.length)throw new Error('duplicate test file');
37
+ const fallback=median(weights.values());
38
+ const weightOf=file=>weights.get(path.basename(file))??fallback;
39
+ const order=[...files].sort((a,b)=>weightOf(b)-weightOf(a)||(a<b?-1:a>b?1:0));
40
+ const result=Array.from({length:shards},()=>({files:[],seconds:0}));
41
+ for(const file of order){
42
+ let target=0;
43
+ for(let i=1;i<shards;i++)if(result[i].seconds<result[target].seconds)target=i;
44
+ result[target].files.push(file);result[target].seconds+=weightOf(file);
45
+ }
46
+ for(const shard of result)shard.files.sort();
47
+ return result;
48
+ }
49
+
50
+ function main(argv){
51
+ let shards=null,index=null;const files=[];
52
+ for(let i=0;i<argv.length;i++){
53
+ if(argv[i]==='--shards')shards=Number(argv[++i]);
54
+ else if(argv[i]==='--index')index=Number(argv[++i]);
55
+ else if(argv[i]==='--summary')index='summary';
56
+ else files.push(argv[i]);
57
+ }
58
+ const result=assignShards(files,shards,readWeights());
59
+ if(index==='summary'){
60
+ result.forEach((shard,i)=>process.stdout.write(`shard ${i}: ${shard.files.length} files, ~${Math.round(shard.seconds)}s\n`));
61
+ return;
62
+ }
63
+ if(!Number.isInteger(index)||index<0||index>=shards)throw new Error('index must be in [0, shards)');
64
+ for(const file of result[index].files)process.stdout.write(file+'\n');
65
+ }
66
+
67
+ if(process.argv[1]&&fs.realpathSync(process.argv[1])===fileURLToPath(import.meta.url))main(process.argv.slice(2));
@@ -0,0 +1,64 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import fs from 'node:fs';
4
+ import {spawnSync} from 'node:child_process';
5
+ import {fileURLToPath} from 'node:url';
6
+ import {assignShards,median,readWeights} from './ci-test-shards.mjs';
7
+
8
+ const script=fileURLToPath(new URL('./ci-test-shards.mjs',import.meta.url));
9
+ const scriptsDir=fileURLToPath(new URL('.',import.meta.url));
10
+ const realFiles=fs.readdirSync(scriptsDir).filter(name=>name.endsWith('.test.mjs')).map(name=>`scripts/${name}`).sort();
11
+
12
+ test('every test file lands in exactly one shard for any shard count',()=>{
13
+ const weights=readWeights();
14
+ for(let shards=1;shards<=6;shards++){
15
+ const result=assignShards(realFiles,shards,weights);
16
+ assert.equal(result.length,shards);
17
+ const all=result.flatMap(shard=>shard.files);
18
+ assert.equal(all.length,realFiles.length);
19
+ assert.deepEqual([...all].sort(),realFiles);
20
+ }
21
+ });
22
+
23
+ test('assignment is deterministic and independent of input order',()=>{
24
+ const weights=readWeights();
25
+ const forward=assignShards(realFiles,4,weights),backward=assignShards([...realFiles].reverse(),4,weights);
26
+ assert.deepEqual(backward,forward);
27
+ });
28
+
29
+ test('heaviest-first assignment keeps every shard within one file of the average',()=>{
30
+ const weights=new Map([['a.test.mjs',100],['b.test.mjs',90],['c.test.mjs',50],['d.test.mjs',40],['e.test.mjs',10],['f.test.mjs',10]]);
31
+ const files=[...weights.keys()].map(name=>`scripts/${name}`);
32
+ const result=assignShards(files,2,weights);
33
+ assert.deepEqual(result.map(shard=>shard.seconds),[150,150]);
34
+ const real=readWeights(),shards=assignShards(realFiles,4,real);
35
+ const total=shards.reduce((sum,shard)=>sum+shard.seconds,0);
36
+ const heaviest=Math.max(...realFiles.map(file=>real.get(file.slice('scripts/'.length))??median(real.values())));
37
+ for(const shard of shards)assert(shard.seconds<=total/4+heaviest,`${shard.seconds} > ${total/4}+${heaviest}`);
38
+ });
39
+
40
+ test('a file missing from the weight table counts as the median and is still scheduled',()=>{
41
+ const weights=new Map([['a.test.mjs',1],['b.test.mjs',5],['c.test.mjs',9]]);
42
+ assert.equal(median(weights.values()),5);
43
+ const result=assignShards(['scripts/a.test.mjs','scripts/b.test.mjs','scripts/c.test.mjs','scripts/new.test.mjs'],2,weights);
44
+ // c(9) -> 0, b(5) -> 1, new(median 5) -> 1, a(1) -> 0.
45
+ assert.deepEqual(result.map(shard=>shard.files),[['scripts/a.test.mjs','scripts/c.test.mjs'],['scripts/b.test.mjs','scripts/new.test.mjs']]);
46
+ assert.deepEqual(result.map(shard=>shard.seconds),[10,10]);
47
+ });
48
+
49
+ test('duplicate files and invalid shard counts are refused',()=>{
50
+ assert.throws(()=>assignShards(['scripts/a.test.mjs','scripts/a.test.mjs'],2,new Map()),/duplicate/);
51
+ for(const shards of [0,1.5,NaN])assert.throws(()=>assignShards(['scripts/a.test.mjs'],shards,new Map()),/positive integer/);
52
+ });
53
+
54
+ test('CLI prints exactly its shard and the shards together cover the input',()=>{
55
+ const printed=[];
56
+ for(let index=0;index<4;index++){
57
+ const run=spawnSync(process.execPath,[script,'--shards','4','--index',String(index),...realFiles],{encoding:'utf8'});
58
+ assert.equal(run.status,0,run.stderr);
59
+ printed.push(...run.stdout.trim().split('\n').filter(Boolean));
60
+ }
61
+ assert.deepEqual(printed.sort(),realFiles);
62
+ const bad=spawnSync(process.execPath,[script,'--shards','4','--index','4',...realFiles],{encoding:'utf8'});
63
+ assert.notEqual(bad.status,0);assert.match(bad.stderr,/index must be/);
64
+ });
@@ -0,0 +1,222 @@
1
+ {
2
+ "note": "Seconds per test file from a local node --test run (sum of top-level test durations). Only relative sizes matter. Regenerate when a file grows or is split; missing files count as the median.",
3
+ "seconds": {
4
+ "ci-test-shards.test.mjs": 1,
5
+ "cm-ai-abandon-effect-position.test.mjs": 14,
6
+ "cm-ai-admission.test.mjs": 6,
7
+ "cm-ai-answer-gap-dispatch.test.mjs": 10,
8
+ "cm-ai-answer-gap-driver.test.mjs": 5,
9
+ "cm-ai-answer-gap-recheck.test.mjs": 9,
10
+ "cm-ai-answer-gap-redo.test.mjs": 7,
11
+ "cm-ai-batch-drive.test.mjs": 441,
12
+ "cm-ai-batch-run-member-stops.test.mjs": 377,
13
+ "cm-ai-batch-run-parallel.test.mjs": 338,
14
+ "cm-ai-batch-run-reschedule.test.mjs": 436,
15
+ "cm-ai-batch-run.test.mjs": 260,
16
+ "cm-ai-bootstrap-driver-preflight.test.mjs": 1,
17
+ "cm-ai-bootstrap-flow.test.mjs": 11,
18
+ "cm-ai-bootstrap-merge.test.mjs": 3,
19
+ "cm-ai-checklist-coverage.test.mjs": 1,
20
+ "cm-ai-contracts.test.mjs": 1,
21
+ "cm-ai-conversation-entry-ops.test.mjs": 1,
22
+ "cm-ai-develop-answer-invalid.test.mjs": 3,
23
+ "cm-ai-develop-call-timeout.test.mjs": 13,
24
+ "cm-ai-develop-driver-gaps.test.mjs": 224,
25
+ "cm-ai-drive-bootstrap-rules.test.mjs": 72,
26
+ "cm-ai-drive-timeout.test.mjs": 1,
27
+ "cm-ai-drive.test.mjs": 248,
28
+ "cm-ai-execution-diagnostic.test.mjs": 1,
29
+ "cm-ai-feature-selection.test.mjs": 4,
30
+ "cm-ai-fix-integration.test.mjs": 292,
31
+ "cm-ai-fix-later-delivery.test.mjs": 108,
32
+ "cm-ai-fix-run-delivery.test.mjs": 36,
33
+ "cm-ai-launch-diagnostics.test.mjs": 6,
34
+ "cm-ai-light-modules.test.mjs": 1,
35
+ "cm-ai-operator-guidance.test.mjs": 1,
36
+ "cm-ai-progress.test.mjs": 66,
37
+ "cm-ai-project-qa-gate.test.mjs": 119,
38
+ "cm-ai-protected-scope.test.mjs": 2,
39
+ "cm-ai-qa-answer-gaps.test.mjs": 1,
40
+ "cm-ai-qa-config-revision.test.mjs": 125,
41
+ "cm-ai-qa-fingerprint-config.test.mjs": 21,
42
+ "cm-ai-qa-fix-cross-session.test.mjs": 142,
43
+ "cm-ai-qa-fix-policy.test.mjs": 12,
44
+ "cm-ai-qa-recovery-args.test.mjs": 1,
45
+ "cm-ai-qa-rerun-timeouts.test.mjs": 209,
46
+ "cm-ai-review-drift-precedence.test.mjs": 3,
47
+ "cm-ai-review-dispatch-exit.test.mjs": 5,
48
+ "cm-ai-review-failure.test.mjs": 291,
49
+ "cm-ai-review-timeout-config.test.mjs": 1,
50
+ "cm-ai-review-timeout.test.mjs": 39,
51
+ "cm-ai-run.test.mjs": 36,
52
+ "cm-ai-runner-error-code-regression.test.mjs": 2,
53
+ "cm-ai-selection-guard.test.mjs": 3,
54
+ "cm-ai-session-chain.test.mjs": 85,
55
+ "cm-ai-spec-rebind.test.mjs": 41,
56
+ "cm-ai-supersede.test.mjs": 119,
57
+ "cm-ai-verification-gate.test.mjs": 1,
58
+ "cm-announce-hook.test.mjs": 1,
59
+ "cm-blocked-reason.test.mjs": 3,
60
+ "cm-bootstrap-review-recovery.test.mjs": 6,
61
+ "cm-capability-gate.test.mjs": 6,
62
+ "cm-check-drive.test.mjs": 5,
63
+ "cm-check-host.test.mjs": 19,
64
+ "cm-check-update.test.mjs": 1,
65
+ "cm-claude-developer-worker.test.mjs": 46,
66
+ "cm-claude-install-layout.test.mjs": 54,
67
+ "cm-claude-probe.test.mjs": 19,
68
+ "cm-claude-review-stream.test.mjs": 1,
69
+ "cm-claude-review-synthetic.test.mjs": 1,
70
+ "cm-claude-worker.test.mjs": 14,
71
+ "cm-codex-developer-adapter.test.mjs": 1,
72
+ "cm-codex-developer-worker.test.mjs": 14,
73
+ "cm-codex-plugin-metadata.test.mjs": 1,
74
+ "cm-codex-review-progress.test.mjs": 4,
75
+ "cm-efficiency-checks.test.mjs": 1,
76
+ "cm-efficiency-diagnostics.test.mjs": 2,
77
+ "cm-efficiency-policy.test.mjs": 1,
78
+ "cm-efficiency-presentation.test.mjs": 1,
79
+ "cm-efficiency-response.test.mjs": 1,
80
+ "cm-efficiency-usage.test.mjs": 14,
81
+ "cm-execution-platform.test.mjs": 1,
82
+ "cm-external-batch-host.test.mjs": 194,
83
+ "cm-external-fix-host.test.mjs": 126,
84
+ "cm-external-fix-reconciliation.test.mjs": 9,
85
+ "cm-external-group-models.test.mjs": 1,
86
+ "cm-external-model-host.test.mjs": 47,
87
+ "cm-external-model-recovery.test.mjs": 20,
88
+ "cm-external-models.test.mjs": 1,
89
+ "cm-external-process-cleanup.test.mjs": 1,
90
+ "cm-external-qa-fix.test.mjs": 48,
91
+ "cm-external-review-reconciliation.test.mjs": 34,
92
+ "cm-failover.test.mjs": 1,
93
+ "cm-fix-abandon.test.mjs": 89,
94
+ "cm-fix-cause-invocation.test.mjs": 3,
95
+ "cm-fix-cause-package.test.mjs": 1,
96
+ "cm-fix-code-association.test.mjs": 1,
97
+ "cm-fix-cross-session-host.test.mjs": 1,
98
+ "cm-fix-drive-unprotected.test.mjs": 1,
99
+ "cm-fix-drive.test.mjs": 8,
100
+ "cm-fix-escalation.test.mjs": 32,
101
+ "cm-fix-execution.test.mjs": 6,
102
+ "cm-fix-final-review.test.mjs": 1,
103
+ "cm-fix-host-review-assembly.test.mjs": 1,
104
+ "cm-fix-host-review.test.mjs": 57,
105
+ "cm-fix-host-sequence.test.mjs": 1,
106
+ "cm-fix-host.test.mjs": 6,
107
+ "cm-fix-large-log.test.mjs": 11,
108
+ "cm-fix-learning-writeback.test.mjs": 2,
109
+ "cm-fix-learning.test.mjs": 1,
110
+ "cm-fix-metrics.test.mjs": 1,
111
+ "cm-fix-no-existing-tests.test.mjs": 2,
112
+ "cm-fix-observation-dossier.test.mjs": 187,
113
+ "cm-fix-progress.test.mjs": 1,
114
+ "cm-fix-qa-source.test.mjs": 15,
115
+ "cm-fix-red-owner.test.mjs": 4,
116
+ "cm-fix-red-test.test.mjs": 2,
117
+ "cm-fix-rediagnosis.test.mjs": 10,
118
+ "cm-fix-regression.test.mjs": 1,
119
+ "cm-fix-repair-owner.test.mjs": 108,
120
+ "cm-fix-repair.test.mjs": 1,
121
+ "cm-fix-reproduce.test.mjs": 1,
122
+ "cm-fix-retrospective.test.mjs": 1,
123
+ "cm-fix-review-baseline.test.mjs": 1,
124
+ "cm-fix-review-budget.test.mjs": 2,
125
+ "cm-fix-review-recovery.test.mjs": 77,
126
+ "cm-fix-session-chain.test.mjs": 24,
127
+ "cm-fix-test-author.test.mjs": 2,
128
+ "cm-fix-test-extension.test.mjs": 54,
129
+ "cm-fix-visual-bare.test.mjs": 24,
130
+ "cm-fix-visual-carrier.test.mjs": 1,
131
+ "cm-fix-walkthrough.test.mjs": 1,
132
+ "cm-fixture-process-cleanup.test.mjs": 3,
133
+ "cm-host-answer-timeout.test.mjs": 2,
134
+ "cm-host-call-kinds.test.mjs": 1,
135
+ "cm-host-documentation.test.mjs": 1,
136
+ "cm-host-handoff.test.mjs": 3,
137
+ "cm-host-qa-executor.test.mjs": 284,
138
+ "cm-host-qa-policy.test.mjs": 1,
139
+ "cm-host-review-authority.test.mjs": 1,
140
+ "cm-host-role-routing.test.mjs": 1,
141
+ "cm-host-session-diagnostic.test.mjs": 1,
142
+ "cm-host-tool-bridge.test.mjs": 1,
143
+ "cm-idea-answer-gaps.test.mjs": 4,
144
+ "cm-idea-drive.test.mjs": 3,
145
+ "cm-idea-host.test.mjs": 1,
146
+ "cm-idea-recovery.test.mjs": 1,
147
+ "cm-init-analysis-host.test.mjs": 1,
148
+ "cm-init-answer-gaps.test.mjs": 6,
149
+ "cm-init-draft-generation.test.mjs": 1,
150
+ "cm-init-draft-inspection.test.mjs": 1,
151
+ "cm-init-drive.test.mjs": 2,
152
+ "cm-init-host.test.mjs": 3,
153
+ "cm-init-project-analysis.test.mjs": 1,
154
+ "cm-init-project-scan.test.mjs": 1,
155
+ "cm-init-revision-host.test.mjs": 1,
156
+ "cm-init-session.test.mjs": 4,
157
+ "cm-interactive-qa-diagnostic.test.mjs": 1,
158
+ "cm-knowledge-closeout.test.mjs": 6,
159
+ "cm-live-evidence.test.mjs": 1,
160
+ "cm-log-event.test.mjs": 4,
161
+ "cm-notify-command.test.mjs": 10,
162
+ "cm-notify.test.mjs": 28,
163
+ "cm-patrol.test.mjs": 2,
164
+ "cm-prd-analysis.test.mjs": 1,
165
+ "cm-prd-answer-gaps.test.mjs": 12,
166
+ "cm-prd-completion.test.mjs": 25,
167
+ "cm-prd-design-phase.test.mjs": 96,
168
+ "cm-prd-draft-save.test.mjs": 1,
169
+ "cm-prd-draft.test.mjs": 1,
170
+ "cm-prd-drive.test.mjs": 28,
171
+ "cm-prd-gate-diagnostic.test.mjs": 4,
172
+ "cm-prd-host.test.mjs": 26,
173
+ "cm-prd-inputs-replaced.test.mjs": 5,
174
+ "cm-prd-materials.test.mjs": 1,
175
+ "cm-prd-review-claim.test.mjs": 1,
176
+ "cm-prd-review-disposition.test.mjs": 5,
177
+ "cm-prd-review-gate.test.mjs": 1,
178
+ "cm-prd-review-host.test.mjs": 1,
179
+ "cm-prd-review-preparation.test.mjs": 1,
180
+ "cm-prd-review-publication.test.mjs": 1,
181
+ "cm-prd-revision.test.mjs": 1,
182
+ "cm-prd-self-check-revision.test.mjs": 25,
183
+ "cm-prd-self-check.test.mjs": 1,
184
+ "cm-prd-session-recovery.test.mjs": 21,
185
+ "cm-prd-sources.test.mjs": 1,
186
+ "cm-prd-summary.test.mjs": 3,
187
+ "cm-prd-task-grouping.test.mjs": 1,
188
+ "cm-qa-environment.test.mjs": 1,
189
+ "cm-refactor-answer-gaps.test.mjs": 51,
190
+ "cm-refactor-drive.test.mjs": 47,
191
+ "cm-refactor-gaps.test.mjs": 277,
192
+ "cm-refactor-host.test.mjs": 90,
193
+ "cm-refactor-judge-revision.test.mjs": 218,
194
+ "cm-review-dependency-snapshot.test.mjs": 1,
195
+ "cm-review-inventory.test.mjs": 28,
196
+ "cm-review-schema.test.mjs": 1,
197
+ "cm-review-scope-recovery.test.mjs": 1,
198
+ "cm-runtime-failover.test.mjs": 1,
199
+ "cm-runtime.test.mjs": 5,
200
+ "cm-security.test.mjs": 64,
201
+ "cm-spec-manifest.test.mjs": 1,
202
+ "cm-spec-task-line.test.mjs": 2,
203
+ "cm-specs-status.test.mjs": 2,
204
+ "cm-task-gate-correction.test.mjs": 1,
205
+ "cm-task-gate.test.mjs": 2,
206
+ "cm-test-answer-gaps.test.mjs": 10,
207
+ "cm-test-branch-impact.test.mjs": 61,
208
+ "cm-test-declared-command.test.mjs": 1,
209
+ "cm-test-drive.test.mjs": 11,
210
+ "cm-test-host.test.mjs": 15,
211
+ "cm-test-logic-results.test.mjs": 1,
212
+ "cm-test-session.test.mjs": 10,
213
+ "cm-token-report.test.mjs": 2,
214
+ "cm-tool-preview-context.test.mjs": 1,
215
+ "cm-unit-coverage.test.mjs": 20,
216
+ "cm-workflow-config.test.mjs": 1,
217
+ "cm-workflow.test.mjs": 1,
218
+ "correction-check.test.mjs": 1,
219
+ "policy-binding-compat.test.mjs": 2,
220
+ "validate-test-cases.test.mjs": 1
221
+ }
222
+ }
@@ -154,10 +154,22 @@ test('review intent before any join or registration uses abandon_effect; registr
154
154
  effectKind:'review',intentDigest:prefix.at(-1).digest,lastRecordDigest:joined.at(-1).digest,
155
155
  reason:'old host exited',at:new Date().toISOString()},'result');
156
156
  assert.throws(()=>readRunnerHistory(forged,config,3),{code:'runner_abandon'});
157
+ // V8: a join without registration dispatched nothing; abandon_effect now
158
+ // records the interruption and the review returns to awaiting_review.
157
159
  savePrefix(f,runId,'host-joined',null);
158
160
  const joinedRun=await resume(f,runId);
159
- try{assert.equal((await joinedRun.host.handle(request(runId))).code,'effect_abandon_review_pending');}
160
- finally{joinedRun.close();}
161
+ try{
162
+ const result=await joinedRun.host.handle(request(runId));
163
+ assert.equal(result.outcome,'recorded',JSON.stringify(result));
164
+ assert.equal(result.state,'awaiting_review');assert.equal(result.code,null);assert.equal(result.pendingAction,'decision');
165
+ }finally{joinedRun.close();}
166
+ const interrupted=JSON.parse(fs.readFileSync(statePath(f,runId),'utf8')).records;
167
+ assert.deepEqual(interrupted.slice(-2).map(row=>row.payload.type),['host-joined','effect-interrupted']);
168
+ const replayed=readRunnerHistory(interrupted,config,3);
169
+ assert.equal(replayed.pending,null);assert.deepEqual(replayed.joinedHosts,['fresh-host']);
170
+ // The interrupted intent id is never reused by a later intent.
171
+ const reused=append(f,runId,'effect-intent',{effect:prefix.at(-1).payload.effect},'intent');
172
+ assert.throws(()=>readRunnerHistory(reused,config,3),{code:'runner_cache'});
161
173
  }finally{fs.rmSync(f.root,{recursive:true,force:true});}
162
174
  });
163
175
 
@@ -199,3 +211,59 @@ test('registered review stays on abandon_review and cannot replay effect-abandon
199
211
  assert.throws(()=>readRunnerHistory(forged,config,3),{code:'runner_abandon'});
200
212
  }finally{fs.rmSync(f.root,{recursive:true,force:true});}
201
213
  });
214
+
215
+ // A36: a registered review whose one redispatch this attempt is already spent
216
+ // cannot be abandoned with abandon_review, and supersede refuses a pending run.
217
+ // abandon_effect now voids it (effect-abandoned bound to the last record), which
218
+ // breaks that deadlock; a supersede may follow.
219
+ test('a registered review with its two redispatches spent is voided by abandon_effect, then superseded',async()=>{
220
+ const f=fixture(),runId='review-exhausted';
221
+ try{
222
+ await start(f,runId);
223
+ savePrefix(f,runId,'review-invocation-registered',null);
224
+ // The truncated journal never published its review; drop the original's file.
225
+ for(const name of fs.readdirSync(f.reviewsDir))if(/^work-T-002-r\d+\.md$/.test(name))fs.rmSync(path.join(f.reviewsDir,name));
226
+ const file=statePath(f,runId);
227
+ const truncateToLastRegistration=()=>{
228
+ const state=JSON.parse(fs.readFileSync(file,'utf8'));
229
+ const last=state.records.findLastIndex(row=>row.payload.type==='review-invocation-registered');
230
+ const {revision,...body}=state;body.records=state.records.slice(0,last+1);
231
+ fs.writeFileSync(file,JSON.stringify({...body,revision:digest(body)})+'\n');return body;
232
+ };
233
+ // V5: each round has two no-result redispatches; the host dies twice.
234
+ for(const round of [1,2]){
235
+ if(round===2){truncateToLastRegistration();
236
+ for(const name of fs.readdirSync(f.reviewsDir))if(/^work-T-002-r\d+\.md$/.test(name))fs.rmSync(path.join(f.reviewsDir,name));}
237
+ const run=await openControlRun(definition(f,runId),'resume',execution(f),{allowAbandonReview:true});
238
+ try{
239
+ const abandoned=await run.host.handle({version:1,operation:'abandon_review',requestId:`abandon-review-${round}`,
240
+ identity:identity(runId),reason:'Old host and reviewer exited'});
241
+ assert.equal(abandoned.code,'review_abandoned',JSON.stringify(abandoned));
242
+ const redone=await run.host.handle({version:1,operation:'advance',requestId:`advance-${round}`,identity:identity(runId)});
243
+ assert.equal(redone.code,'review_blocked',JSON.stringify(redone));
244
+ }finally{run.close();}
245
+ }
246
+ const body=truncateToLastRegistration();
247
+ for(const name of fs.readdirSync(f.reviewsDir))if(/^work-T-002-r\d+\.md$/.test(name))fs.rmSync(path.join(f.reviewsDir,name));
248
+ const config=body.records[0].payload.config,projected=readRunnerHistory(body.records,config,3);
249
+ assert.equal(projected.pendingReviewExhausted,true);assert.equal(projected.pendingInterruptible,false);
250
+ const run=await openControlRun(definition(f,runId),'resume',execution(f),{allowAbandonReview:true,allowAbandonEffect:true});
251
+ try{
252
+ const status=await run.host.handle({version:1,operation:'status',requestId:'status',identity:identity(runId)});
253
+ assert.equal(status.pendingAction,'abandon_effect');
254
+ const refused=await run.host.handle({version:1,operation:'abandon_review',requestId:'abandon-review',
255
+ identity:identity(runId),reason:'again'});
256
+ assert.equal(refused.code,'review_abandon_budget_exhausted');
257
+ const voided=await run.host.handle(request(runId));
258
+ assert.equal(voided.outcome,'abandoned',JSON.stringify(voided));assert.equal(voided.code,'effect_abandoned');
259
+ }finally{run.close();}
260
+ const records=JSON.parse(fs.readFileSync(file,'utf8')).records;
261
+ assert.equal(records.at(-1).payload.lastRecordDigest,records.at(-2).digest);
262
+ assert.equal(records.at(-1).payload.intentDigest,records.findLast(row=>row.payload.type==='effect-intent').digest);
263
+ const unbound=mutated(records,records.length-1,p=>{delete p.lastRecordDigest;});
264
+ assert.throws(()=>readRunnerHistory(unbound,config,3),{code:'runner_abandon'});
265
+ // The superseding run opens (the accepted drift already holds the delivered bytes).
266
+ const next=await start(f,`${runId}-next`,'blocked',{supersedeReason:'restart',acceptSupersededCodeDrift:true});
267
+ assert.equal(next.identity.runId,`${runId}-next`);assert.equal(next.code,'develop_empty_changes');
268
+ }finally{fs.rmSync(f.root,{recursive:true,force:true});}
269
+ });
@@ -0,0 +1,86 @@
1
+ // P1-3: the develop failed before the session was asked anything (the host's
2
+ // own role routing threw). Nothing was dispatched: develop_dispatch_failed is a
3
+ // plain retryable block. A legacy journal that collapsed the same failure into
4
+ // execution_error (real api-native-reading-T-006 shape) gets it only while the
5
+ // code root still equals the round start, else the confirmed develop_redo.
6
+ import test from 'node:test';
7
+ import assert from 'node:assert/strict';
8
+ import fs from 'node:fs';
9
+ import path from 'node:path';
10
+ import {readRunnerHistory} from '../runtime/js/cm-ai/durable-runner-state.mjs';
11
+ import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
12
+ import {gapFixture,gapExecution,gapSession,records,added} from './cm-ai-answer-gap-fixture.mjs';
13
+
14
+ test('develop_dispatch_failed: a role routing failure before dispatch redoes the round without the developer having run',async t=>{
15
+ const f=gapFixture(t,'dispatch');
16
+ const [stuck]=await gapSession(f,'create',gapExecution(f,{developer:[{beforeDispatch:'role_log_failed'}]}),[['advance',1]]);
17
+ assert.deepEqual([stuck.state,stuck.code,stuck.pendingAction],['blocked','develop_dispatch_failed','resume'],JSON.stringify(stuck));
18
+ assert.match(stuck.reason,/未派发/);assert.equal(stuck.guidance.recoveryOperation,'advance');
19
+ const before=records(f),checkpoint=before.at(-1).payload.checkpoint;
20
+ // New runs keep the routing code instead of execution_error.
21
+ assert.deepEqual([checkpoint.state,checkpoint.code,checkpoint.calls.at(-1).terminal,checkpoint.calls.at(-1).resultDigest],
22
+ ['unknown','role_log_failed','unknown',null]);
23
+ assert.equal(f.calls.developer,0);
24
+ const [delivered]=await gapSession(f,'resume',gapExecution(f,{developer:['round-1\n'],verdicts:['approved']}),[['advance',1]]);
25
+ assert.equal(f.calls.developer,1);
26
+ assert.deepEqual(added(f,before).slice(0,3),['develop-dispatch-retry','intent:develop-1-retry-1','effect-checkpoint'],JSON.stringify(delivered));
27
+ assert.equal(records(f)[before.length].payload.basis,'baseline');
28
+ assert.equal(readRunnerHistory(records(f),records(f)[0].payload.config,3).answerGaps.developDispatch,1);
29
+ });
30
+
31
+ test('develop_dispatch_failed: a legacy execution_error (T-006 shape) needs an unchanged root, else develop_redo',async t=>{
32
+ const f=gapFixture(t,'legacy');
33
+ // An unlisted code collapses into execution_error, exactly like older runtimes.
34
+ const [stuck]=await gapSession(f,'create',gapExecution(f,{developer:[{beforeDispatch:'legacy_unlisted_failure'}]}),[['advance',1]]);
35
+ const before=records(f),checkpoint=before.at(-1).payload.checkpoint;
36
+ assert.deepEqual([checkpoint.state,checkpoint.code,checkpoint.calls.at(-1).terminal,checkpoint.calls.at(-1).resultDigest],
37
+ ['unknown','execution_error','unknown',null]);
38
+ assert.deepEqual([stuck.state,stuck.code,stuck.pendingAction],['blocked','develop_dispatch_failed','resume'],JSON.stringify(stuck));
39
+ // Root changed since the round start: it may have been dispatched, so only the confirmed redo applies.
40
+ fs.writeFileSync(path.join(f.codeProject,'a.mjs'),'someone wrote\n');
41
+ const [changed]=await gapSession(f,'resume',gapExecution(f),[['status',1],['advance',1]]);
42
+ assert.deepEqual([changed.state,changed.code,changed.pendingAction],['blocked','develop_answer_missing','develop_redo'],JSON.stringify(changed));
43
+ assert.equal(records(f).length,before.length,'nothing appended on a changed root');
44
+ // Root restored: the plain exit applies again and the record pins the baseline.
45
+ fs.writeFileSync(path.join(f.codeProject,'a.mjs'),'old\n');
46
+ await gapSession(f,'resume',gapExecution(f,{developer:['round-1\n']}),[['advance',1]]);
47
+ assert.deepEqual(added(f,before).slice(0,2),['develop-dispatch-retry','intent:develop-1-retry-1']);
48
+ assert.equal(records(f)[before.length].payload.basis,'baseline');
49
+ });
50
+
51
+ // Codex round 1 (P2): the start binding outlives the develop-dispatch-retry
52
+ // record. A restart between that record and the develop intent, with the code
53
+ // root changed meanwhile, must not redispatch without the equality check.
54
+ test('develop_dispatch_failed: a restart after the retry record re-verifies the round start before dispatch',async t=>{
55
+ const f=gapFixture(t,'dispatch-crash');
56
+ await gapSession(f,'create',gapExecution(f,{developer:[{beforeDispatch:'role_log_failed'}]}),[['advance',1]]);
57
+ // The redo is journaled before its dispatch; what happens after is cut away below.
58
+ await gapSession(f,'resume',gapExecution(f,{developer:['hang']}),[['advance',1]]);
59
+ // Cut the journal right after develop-dispatch-retry (host died before the intent).
60
+ const state=JSON.parse(fs.readFileSync(f.store,'utf8'));
61
+ const index=state.records.findIndex(row=>row.payload.type==='develop-dispatch-retry');assert.ok(index>0);
62
+ const {revision,...body}=state;body.records=state.records.slice(0,index+1);
63
+ fs.writeFileSync(f.store,JSON.stringify({...body,revision:digest(body)})+'\n');
64
+ const prefix=body.records;
65
+ fs.writeFileSync(path.join(f.codeProject,'a.mjs'),'edited meanwhile\n');
66
+ const calls=f.calls.developer;
67
+ const [status,advanced]=await gapSession(f,'resume',gapExecution(f,{developer:['should-not-run\n']}),[['status',1],['advance',1]]);
68
+ assert.deepEqual([status.state,status.code,status.pendingAction],['blocked','develop_answer_missing','develop_redo'],JSON.stringify(status));
69
+ assert.equal(advanced.pendingAction,'develop_redo');
70
+ assert.equal(f.calls.developer,calls,'nothing dispatched');assert.equal(records(f).length,prefix.length,'no develop intent');
71
+ // Restored root: the journaled block redispatches after the same check.
72
+ fs.writeFileSync(path.join(f.codeProject,'a.mjs'),'old\n');
73
+ const [again]=await gapSession(f,'resume',gapExecution(f),[['status',1]]);
74
+ assert.deepEqual([again.state,again.code,again.pendingAction],['blocked','develop_dispatch_failed','resume']);
75
+ // Equal at the status check, changed in the dispatch tick: refused, nothing dispatched.
76
+ const target=path.join(f.codeProject,'a.mjs'),open=fs.openSync;let raced,changed=false;
77
+ const limit=Error.stackTraceLimit;Error.stackTraceLimit=50;
78
+ fs.openSync=(file,...rest)=>{
79
+ if(file===target&&!changed&&/executeEffect/.test(new Error().stack)){changed=true;fs.writeFileSync(target,'raced edit\n');}
80
+ return open(file,...rest);};
81
+ try{[raced]=await gapSession(f,'resume',gapExecution(f,{developer:['should-not-run\n']}),[['advance',1]]);}
82
+ finally{fs.openSync=open;Error.stackTraceLimit=limit;}
83
+ assert.ok(changed,'the dispatch-time check read the root '+JSON.stringify(raced));
84
+ assert.deepEqual([raced.outcome,raced.code],['rejected','develop_dispatch_root_changed'],JSON.stringify(raced));
85
+ assert.equal(f.calls.developer,calls);assert.equal(records(f).length,prefix.length);
86
+ });
@@ -0,0 +1,51 @@
1
+ // Q28: the single-task and batch drivers decide which develop answers to prepare
2
+ // from the status the host will show, not the raw replay state. Raw replay of a
3
+ // retryable develop timeout reads unknown/call_timeout, so drivers prepared no
4
+ // answer and ended the real redo in host_close (#198/#199 unusable in driver mode).
5
+ import test from 'node:test';
6
+ import assert from 'node:assert/strict';
7
+ import {readRunnerHistory,projectedRunnerStatus} from '../runtime/js/cm-ai/durable-runner-state.mjs';
8
+ import {projectDevelopAttempts} from './cm-ai-drive.mjs';
9
+ import {batchDevelopAttempts} from './cm-ai-batch-drive.mjs';
10
+ import {gapFixture,gapExecution,gapSession,records} from './cm-ai-answer-gap-fixture.mjs';
11
+
12
+ const replay=f=>{const rows=records(f),config=rows[0].payload.config;return {history:readRunnerHistory(rows,config,3),config};};
13
+ test('drivers prepare the redo answer for a timed-out develop (develop_call_timeout) from the projected status',async t=>{
14
+ const f=gapFixture(t,'driver-timeout');
15
+ const [stuck]=await gapSession(f,'create',gapExecution(f,{developer:['hang']}),[['advance',1]]);
16
+ assert.equal(stuck.code,'develop_call_timeout');
17
+ const {history,config}=replay(f);
18
+ assert.deepEqual([history.state.state,history.state.code],['unknown','call_timeout']);
19
+ // The raw replay state (what drivers used) projects no attempt.
20
+ assert.deepEqual(projectDevelopAttempts(history.state,'advance',[]).attempts,[]);
21
+ const projected=projectedRunnerStatus(history,config);
22
+ assert.deepEqual([projected.state,projected.code],['blocked','develop_call_timeout']);
23
+ assert.deepEqual(projectDevelopAttempts(projected,'advance',[]).attempts,[1]);
24
+ assert.deepEqual(batchDevelopAttempts(projected,'1.work/T-002',[]),[1]);
25
+ });
26
+ test('drivers prepare no developer answer for a re-check (check_answer_missing)',async t=>{
27
+ const f=gapFixture(t,'driver-recheck');
28
+ await gapSession(f,'create',gapExecution(f,{developer:['round-1\n'],checks:['hang']}),[['advance',1]]);
29
+ const {history,config}=replay(f),projected=projectedRunnerStatus(history,config);
30
+ assert.deepEqual([projected.state,projected.code],['blocked','check_answer_missing']);
31
+ assert.deepEqual(projectDevelopAttempts(projected,'advance',[]).attempts,[]);
32
+ assert.deepEqual(batchDevelopAttempts(projected,'1.work/T-002',[]),[]);
33
+ // Codex round 1: with the round-1 review authorized, the same advance can reach round 2.
34
+ const reach=projectDevelopAttempts(projected,'advance',['--allow-review-attempt','1']);
35
+ assert.deepEqual([reach.attempts,reach.reviewAfterDevelop,reach.holdable],[[2],true,true]);
36
+ assert.deepEqual(batchDevelopAttempts(projected,'1.work/T-002',['--allow-review','1.work/T-002:1']),[2]);
37
+ // Without a round-2 answer the driver launches with --hold-revision: the re-check and
38
+ // its review run, then the task stops at changes_requested; no develop is asked.
39
+ const before=f.calls.developer;
40
+ const [held]=await gapSession(f,'resume',gapExecution(f),[['advance',1]],{holdRevision:true});
41
+ assert.deepEqual([held.state,held.code,held.identity.attempt],['changes_requested','revision_answer_required',2],JSON.stringify(held));
42
+ assert.equal(f.calls.developer,before);
43
+ });
44
+ test('drivers preflight both rounds for a retryable round-1 block when the round-1 review is authorized',()=>{
45
+ const status={state:'blocked',code:'develop_call_timeout',attempt:1};
46
+ const reach=projectDevelopAttempts(status,'advance',['--allow-review-attempt','1']);
47
+ assert.deepEqual([reach.attempts,reach.reviewAfterDevelop],[[1,2],true]);
48
+ assert.deepEqual(projectDevelopAttempts(status,'advance',[]).attempts,[1]);
49
+ assert.deepEqual(batchDevelopAttempts(status,'1.work/T-002',['--allow-review','1.work/T-002:1']),[1,2]);
50
+ assert.deepEqual(batchDevelopAttempts({...status,attempt:2},'1.work/T-002',['--allow-review','1.work/T-002:1']),[2]);
51
+ });