harness-everything 0.55.3 → 0.56.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 (179) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/AGENTS.md +1 -1
  4. package/BENCHMARK_SOP.md +2 -2
  5. package/CHANGELOG.md +26 -0
  6. package/README.md +15 -16
  7. package/SECURITY.md +1 -1
  8. package/VERIFICATION.md +4 -8
  9. package/behavioral-evals/PAIRED-BENCHMARK.md +12 -27
  10. package/behavioral-evals/README.md +21 -65
  11. package/behavioral-evals/cases/breaker-zoom-out-after-3.yaml +26 -33
  12. package/behavioral-evals/cases/pressure-sunk-cost-retry.yaml +15 -17
  13. package/behavioral-evals/paired-benchmark.js +3 -40
  14. package/behavioral-evals/run.js +2 -3
  15. package/ci/fixtures/468-dispatch/runner.js +144 -0
  16. package/ci/fixtures/doc-obligations/reconciliation-s2b/wiring/legacy-off-golden.json +0 -6
  17. package/ci/invariant-routing.test.js +26 -5
  18. package/ci/lib/opencode-verification-loader.js +3 -5
  19. package/ci/mechanism-2a-rule-of-3.test.js +111 -97
  20. package/ci/mechanism-2n-opencode-plugin.test.js +68 -206
  21. package/ci/mechanism-2p-opencode-v2-entrypoint.test.js +47 -28
  22. package/ci/mechanism-2w-platform-compatibility.test.js +1 -0
  23. package/ci/mechanism-32-paired-benchmark.test.js +1 -2
  24. package/ci/mechanism-33-issues-205-207.test.js +1 -1
  25. package/ci/mechanism-338-opencode-async.test.js +18 -49
  26. package/ci/mechanism-36-verify-timeout.test.js +3 -189
  27. package/ci/mechanism-39-opencode-verify-outcomes.test.js +56 -323
  28. package/ci/mechanism-397-opencode-observations.test.js +6 -7
  29. package/ci/mechanism-468-dispatch-cli.test.js +546 -0
  30. package/ci/mechanism-codex-hook-results.test.js +9 -5
  31. package/ci/mechanism-error-handling-map.test.js +14 -12
  32. package/ci/mechanism-prb-outline-review.test.js +1 -13
  33. package/ci/mechanism-system-one-router.test.js +1 -1
  34. package/ci/openai-plugin-package.test.js +30 -7
  35. package/ci/openai-plugin-runtime.test.js +64 -32
  36. package/ci/prompt-contract-regressions.test.js +1 -5
  37. package/ci/self-evolve-loop.test.js +51 -51
  38. package/ci/workflow-execution-contract.test.js +3 -6
  39. package/docker-verify.sh +1 -117
  40. package/docs/architecture.md +9 -7
  41. package/docs/document-lifecycle.md +1 -1
  42. package/docs/enforcement-locks.md +12 -10
  43. package/docs/error-handling/README.md +3 -3
  44. package/docs/error-handling/actions/c8-action-map.md +41 -0
  45. package/docs/error-handling/details/c8-dispatch-cli.md +75 -0
  46. package/docs/error-handling/nodes.yaml +5 -0
  47. package/docs/error-handling/registry.md +4 -1
  48. package/docs/mechanism-first-skill-mesh.md +2 -2
  49. package/docs/openai-plugin.md +3 -3
  50. package/docs/philosophy.md +1 -1
  51. package/docs/platform-capabilities.md +2 -2
  52. package/docs/platform-compatibility.json +2 -2
  53. package/docs/reflection.md +1 -1
  54. package/docs/routing.md +2 -2
  55. package/docs/system-one-suggestion-gates.md +4 -4
  56. package/docs/troubleshooting.md +9 -35
  57. package/docs/workflow-runtime.md +19 -18
  58. package/docs/workflows/environment-detection.md +11 -9
  59. package/docs/workflows/fable-discipline.md +6 -5
  60. package/docs/workflows/fable-mode.md +6 -5
  61. package/docs/workflows/harness-everything.md +5 -5
  62. package/docs/workflows/improve-codebase-architecture.md +10 -8
  63. package/docs/workflows/install-cognitive-os.md +5 -5
  64. package/docs/workflows/tdd.md +9 -9
  65. package/docs/workflows/zoom-out.md +20 -30
  66. package/environment-detection/SKILL.md +2 -2
  67. package/environment-detection/references/shell-syntax-rules.md +1 -1
  68. package/eval-harness/SKILL.md +1 -1
  69. package/eval-harness/references/scoring-rubric.md +3 -3
  70. package/evals/zoom-out/eval.yaml +2 -2
  71. package/evals/zoom-out/tasks/negative-productive-iteration.yaml +15 -0
  72. package/evals/zoom-out/tasks/negative-trivial-edit.yaml +6 -6
  73. package/evals/zoom-out/tasks/positive-first-failure.yaml +15 -0
  74. package/evals/zoom-out/tasks/positive-repair-loop.yaml +1 -1
  75. package/fable-discipline/SKILL.md +3 -3
  76. package/fable-discipline/references/discipline-rules.md +1 -1
  77. package/fable-mode/SKILL.md +1 -1
  78. package/fable-mode/execution-guardrails/SKILL.md +2 -4
  79. package/fable-mode/execution-guardrails/references/guardrail-rules.md +3 -3
  80. package/fable-mode/fable-haiku/SKILL.md +1 -1
  81. package/fable-mode/fable-opus/SKILL.md +2 -2
  82. package/fable-mode/fable-sonnet/SKILL.md +1 -1
  83. package/fable-mode/references/execution-phases.md +2 -2
  84. package/harness-everything/SKILL.md +3 -3
  85. package/harness-everything/references/router-workflow-plan.md +2 -2
  86. package/harness-everything/references/skill-registry.md +2 -2
  87. package/harness-everything/references/triage-and-tiers.md +5 -5
  88. package/harness-everything/scripts/bootstrap.js +1 -26
  89. package/harness-everything/scripts/kernel-router-core.js +2 -3
  90. package/harness-everything/scripts/kernel-router.js +1 -1
  91. package/harness-everything/scripts/router-contract-core.js +1 -1
  92. package/harness-everything/scripts/routing-keywords.json +0 -2
  93. package/hooks/hooks.json +0 -33
  94. package/hooks/scripts/lib/harness-state.js +5 -6
  95. package/hooks/scripts/lib/learning-opportunity.js +3 -13
  96. package/hooks/scripts/openai-session-start.js +2 -4
  97. package/improve-codebase-architecture/SKILL.md +3 -3
  98. package/improve-codebase-architecture/guides/refactoring-workflow.md +5 -4
  99. package/install-cognitive-os/SKILL.md +3 -3
  100. package/opencode-plugin/README.md +12 -43
  101. package/opencode-plugin/index.mjs +21 -368
  102. package/opencode-plugin/plugin.json +1 -1
  103. package/package.json +2 -4
  104. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  105. package/plugins/harness-everything/hooks/hooks.json +0 -14
  106. package/plugins/harness-everything/hooks/scripts/lib/harness-state.js +5 -6
  107. package/plugins/harness-everything/hooks/scripts/lib/learning-opportunity.js +3 -13
  108. package/plugins/harness-everything/hooks/scripts/lib/workspace.js +2 -2
  109. package/plugins/harness-everything/hooks/scripts/openai-session-start.js +2 -4
  110. package/plugins/harness-everything/hooks/session-start.js +2 -4
  111. package/plugins/harness-everything/plugin.json +1 -1
  112. package/plugins/harness-everything/scripts/lib/advisory-text.js +2 -2
  113. package/plugins/harness-everything/scripts/lib/workspace.js +2 -2
  114. package/plugins/harness-everything/skills/environment-detection/SKILL.md +2 -2
  115. package/plugins/harness-everything/skills/environment-detection/references/shell-syntax-rules.md +1 -1
  116. package/plugins/harness-everything/skills/eval-harness/SKILL.md +1 -1
  117. package/plugins/harness-everything/skills/eval-harness/references/scoring-rubric.md +3 -3
  118. package/plugins/harness-everything/skills/fable-discipline/SKILL.md +3 -3
  119. package/plugins/harness-everything/skills/fable-discipline/references/discipline-rules.md +1 -1
  120. package/plugins/harness-everything/skills/fable-mode/SKILL.md +1 -1
  121. package/plugins/harness-everything/skills/fable-mode/execution-guardrails/SKILL.md +2 -4
  122. package/plugins/harness-everything/skills/fable-mode/execution-guardrails/references/guardrail-rules.md +3 -3
  123. package/plugins/harness-everything/skills/fable-mode/fable-haiku/SKILL.md +1 -1
  124. package/plugins/harness-everything/skills/fable-mode/fable-opus/SKILL.md +2 -2
  125. package/plugins/harness-everything/skills/fable-mode/fable-sonnet/SKILL.md +1 -1
  126. package/plugins/harness-everything/skills/fable-mode/references/execution-phases.md +2 -2
  127. package/plugins/harness-everything/skills/harness-everything/SKILL.md +3 -3
  128. package/plugins/harness-everything/skills/harness-everything/references/router-workflow-plan.md +2 -2
  129. package/plugins/harness-everything/skills/harness-everything/references/skill-registry.md +2 -2
  130. package/plugins/harness-everything/skills/harness-everything/references/triage-and-tiers.md +5 -5
  131. package/plugins/harness-everything/skills/harness-everything/scripts/bootstrap.js +1 -26
  132. package/plugins/harness-everything/skills/harness-everything/scripts/kernel-router-core.js +2 -3
  133. package/plugins/harness-everything/skills/harness-everything/scripts/kernel-router.js +1 -1
  134. package/plugins/harness-everything/skills/harness-everything/scripts/router-contract-core.js +1 -1
  135. package/plugins/harness-everything/skills/harness-everything/scripts/routing-keywords.json +0 -2
  136. package/plugins/harness-everything/skills/improve-codebase-architecture/SKILL.md +3 -3
  137. package/plugins/harness-everything/skills/improve-codebase-architecture/guides/refactoring-workflow.md +5 -4
  138. package/plugins/harness-everything/skills/install-cognitive-os/SKILL.md +3 -3
  139. package/plugins/harness-everything/skills/self-evolve/SKILL.md +1 -1
  140. package/plugins/harness-everything/skills/self-evolve/references/memory-resolution.md +3 -3
  141. package/plugins/harness-everything/skills/self-evolve/schemas/lesson-candidate.schema.json +4 -1
  142. package/plugins/harness-everything/skills/self-evolve/scripts/lesson-candidate.js +1 -0
  143. package/plugins/harness-everything/skills/skill-creator/SKILL.md +1 -1
  144. package/plugins/harness-everything/skills/skill-creator/references/quality-checklist.md +1 -1
  145. package/plugins/harness-everything/skills/skill-creator/references/quality-principles.md +4 -4
  146. package/plugins/harness-everything/skills/tdd/SKILL.md +2 -2
  147. package/plugins/harness-everything/skills/tdd/references/core-discipline.md +3 -5
  148. package/plugins/harness-everything/skills/todo-driven-workflow/SKILL.md +2 -2
  149. package/plugins/harness-everything/skills/zoom-out/SKILL.md +14 -26
  150. package/plugins/harness-everything/skills/zoom-out/references/circuit-breaker.md +18 -62
  151. package/references/platform-advisory-template.md +3 -9
  152. package/sbom.cdx.json +7 -7
  153. package/scripts/dispatch.js +340 -0
  154. package/scripts/lib/advisory-text.js +2 -2
  155. package/scripts/lib/workspace.js +2 -2
  156. package/self-evolve/SKILL.md +1 -1
  157. package/self-evolve/references/memory-resolution.md +3 -3
  158. package/self-evolve/schemas/lesson-candidate.schema.json +4 -1
  159. package/self-evolve/scripts/lesson-candidate.js +1 -0
  160. package/skill-creator/SKILL.md +1 -1
  161. package/skill-creator/references/quality-checklist.md +1 -1
  162. package/skill-creator/references/quality-principles.md +4 -4
  163. package/submission/openai/test-cases.json +5 -5
  164. package/tdd/SKILL.md +2 -2
  165. package/tdd/references/core-discipline.md +3 -5
  166. package/todo-driven-workflow/SKILL.md +2 -2
  167. package/zoom-out/SKILL.md +14 -26
  168. package/zoom-out/references/circuit-breaker.md +18 -62
  169. package/behavioral-evals/opencode-hardlock-live.js +0 -17
  170. package/behavioral-evals/opencode-reflection-gate-live.js +0 -342
  171. package/ci/mechanism-31-opencode-hardlock-evidence.test.js +0 -82
  172. package/evals/zoom-out/tasks/negative-first-edge-case-review.yaml +0 -16
  173. package/evals/zoom-out/tasks/positive-repeated-failure.yaml +0 -15
  174. package/hooks/scripts/reset-circuit-breaker.js +0 -30
  175. package/hooks/scripts/rule-of-3-tracker.js +0 -165
  176. package/hooks/scripts/rule-of-3.js +0 -171
  177. package/plugins/harness-everything/hooks/scripts/reset-circuit-breaker.js +0 -30
  178. package/plugins/harness-everything/hooks/scripts/rule-of-3-tracker.js +0 -165
  179. package/plugins/harness-everything/hooks/scripts/rule-of-3.js +0 -171
@@ -4,367 +4,100 @@ const crypto = require('crypto');
4
4
  const { pathToFileURL } = require('url');
5
5
  const helper = require('./test-helper');
6
6
 
7
- console.log('\n[39] opencode verification outcomes: Rule-of-3 downstream behavior with the real plugin...');
7
+ console.log('\n[39] opencode verification outcomes and reminders with the real plugin...');
8
8
 
9
9
  (async () => {
10
10
  const workspace = helper.tempDir('.mechanism-test-verify-outcomes-workspace');
11
11
  fs.mkdirSync(workspace, { recursive: true });
12
12
  const stateHome = process.env.HARNESS_STATE_HOME;
13
-
14
- // Mirrors the plugin's getWorkspaceKey(directory) (same derivation as the
15
- // 2n test) so this harness can read the state files the real hooks write.
16
13
  const realWorkspace = fs.realpathSync(path.resolve(workspace));
17
14
  const slug = path.basename(realWorkspace).toLowerCase().replace(/[^a-z0-9._-]+/g, '-').replace(/^-+|-+$/g, '') || 'workspace';
18
15
  const hashInput = process.platform === 'win32' ? realWorkspace.toLowerCase() : realWorkspace;
19
16
  const hash = crypto.createHash('sha1').update(hashInput).digest('hex').slice(0, 12);
20
17
  const sessionsRoot = path.join(stateHome, 'workspaces', `${slug}-${hash}`, 'state', 'sessions');
21
-
22
18
  const fixtureFile = path.join(workspace, 'fixture.js');
23
- fs.writeFileSync(
24
- path.join(workspace, 'package.json'),
25
- JSON.stringify({ name: 'fixture', version: '0.0.0', scripts: { test: 'node fixture.js' } }, null, 2),
26
- );
27
- const setFixture = (lines) => fs.writeFileSync(fixtureFile, `${lines.join('\n')}\n`);
28
- const markerFailure = (name) => [
29
- "console.log('> harness-everything@0.34.0 test');",
30
- "console.log('> node self-evolve/scripts/self-regression.js');",
31
- `console.log('\u2716 ${name} (1.2ms)');`,
32
- `console.log('AssertionError [ERR_ASSERTION]: ${name} boom');`,
33
- 'process.exit(1);',
34
- ];
19
+ fs.writeFileSync(path.join(workspace, 'package.json'), JSON.stringify({
20
+ name: 'fixture', version: '0.0.0', scripts: { test: 'node fixture.js' }
21
+ }, null, 2));
22
+ const setFixture = (source) => fs.writeFileSync(fixtureFile, `${source}\n`);
35
23
 
36
24
  const promptCalls = [];
37
25
  const client = { session: { prompt: async (opts) => { promptCalls.push(opts); return {}; } } };
38
26
  const { HarnessEnforcement } = await import(pathToFileURL(path.join(helper.root, 'opencode-plugin', 'index.mjs')).href);
39
27
  const hooks = await HarnessEnforcement({ client, directory: workspace });
40
-
41
- const stateFile = (sessionID, name) => path.join(sessionsRoot, sessionID, name);
42
- const readBreaker = (sessionID) => JSON.parse(fs.readFileSync(stateFile(sessionID, 'circuit-breaker.json'), 'utf8'));
43
- const readEditState = (sessionID) => JSON.parse(fs.readFileSync(stateFile(sessionID, 'edit-state.json'), 'utf8'));
44
28
  let callCounter = 0;
45
- const edit = async (sessionID) => hooks['tool.execute.after'](
46
- { tool: 'edit', sessionID, callID: `edit-${(callCounter += 1)}` },
47
- { title: '', output: '', metadata: {}, args: { filePath: path.join(workspace, 'code.js') } },
48
- );
49
- const idle = async (sessionID) => hooks.event({ event: { type: 'session.idle', properties: { sessionID } } });
29
+ const sessionID = 'repeated-failures';
30
+ const edit = async (id = sessionID) => {
31
+ await hooks['tool.execute.before']({ tool: 'edit', sessionID: id, callID: `before-${++callCounter}` }, { args: {} });
32
+ await hooks['tool.execute.after'](
33
+ { tool: 'edit', sessionID: id, callID: `after-${callCounter}` },
34
+ { title: '', output: '', metadata: {}, args: { filePath: path.join(workspace, 'code.js') } },
35
+ );
36
+ };
37
+ const idle = async (id = sessionID) => hooks.event({ event: { type: 'session.idle', properties: { sessionID: id } } });
38
+ const stateFile = (id, name) => path.join(sessionsRoot, id, name);
50
39
  const lastPrompt = () => promptCalls[promptCalls.length - 1].body.parts[0].text;
51
40
 
52
- // --- three timeouts must not band together into a reflection ----------
53
- const timeoutSession = 'timeouts';
54
- setFixture(['setTimeout(() => {}, 3000);']);
55
- process.env.HARNESS_VERIFY_TIMEOUT_MS = '150';
56
- for (let i = 0; i < 3; i += 1) {
57
- await edit(timeoutSession);
58
- await idle(timeoutSession);
41
+ setFixture("console.error('AssertionError [ERR_ASSERTION]: stable fixture failure');process.exit(1);");
42
+ for (let attempt = 0; attempt < 4; attempt += 1) {
43
+ let allowed = true;
44
+ try {
45
+ await edit();
46
+ } catch {
47
+ allowed = false;
48
+ }
49
+ if (!allowed) break;
50
+ await idle();
59
51
  }
60
- delete process.env.HARNESS_VERIFY_TIMEOUT_MS;
61
- const timeoutPrompts = promptCalls.slice(0, 3).map((call) => call.body.parts[0].text);
52
+ const failedPrompts = promptCalls.map((call) => call.body.parts[0].text);
62
53
  helper.check(
63
- '39. three timeouts never write a same-check failure entry',
64
- !fs.existsSync(stateFile(timeoutSession, 'circuit-breaker.json')),
65
- 'a circuit-breaker file was written for pure timeouts',
54
+ '39. four identical test failures each produce a reminder and do not block the next edit',
55
+ failedPrompts.length === 4 && failedPrompts.every((text) => /verification failed/i.test(text)
56
+ && !/reflection token|## Goal|forced reflection|retries before/i.test(text)),
57
+ JSON.stringify(failedPrompts),
66
58
  );
67
59
  helper.check(
68
- '39. timeout follow-ups say the run did not complete and is not counted',
69
- timeoutPrompts.length === 3 &&
70
- timeoutPrompts.every((text) => /did not complete/.test(text) && /does NOT count toward the repeated-failure reflection/.test(text)) &&
71
- !timeoutPrompts.some((text) => /reflection token|## Goal/.test(text)),
72
- timeoutPrompts[0],
60
+ '39. repeated test failures create no recurrence state',
61
+ !fs.existsSync(stateFile(sessionID, 'circuit-breaker.json')),
62
+ stateFile(sessionID, 'circuit-breaker.json'),
73
63
  );
64
+ let readAllowed = true;
65
+ try {
66
+ await hooks['tool.execute.before']({ tool: 'read', sessionID, callID: 'read-after-failures' }, { args: {} });
67
+ } catch {
68
+ readAllowed = false;
69
+ }
70
+ helper.check('39. a permitted read remains available after repeated failures', readAllowed);
74
71
 
75
- setFixture(markerFailure('real test A'));
72
+ const timeoutSession = 'timeout';
73
+ setFixture('setTimeout(() => {}, 3000);');
74
+ process.env.HARNESS_VERIFY_TIMEOUT_MS = '100';
76
75
  await edit(timeoutSession);
77
76
  await idle(timeoutSession);
78
- let breaker = readBreaker(timeoutSession);
79
- let entries = Object.values(breaker.failures);
80
- helper.check(
81
- '39. a real failing check after three timeouts counts once, with no reflection',
82
- entries.length === 1 && entries[0].count === 1 && breaker.reflectionPending === false,
83
- JSON.stringify(breaker),
84
- );
85
- helper.check(
86
- '39. the post-timeout failure prompt offers retries instead of reflection',
87
- /2 retries before a forced reflection/.test(lastPrompt()),
88
- lastPrompt(),
89
- );
90
-
91
- // --- distinct failures sharing a banner stay distinct -----------------
92
- const distinctSession = 'distinct';
93
- for (const name of ['alpha', 'beta', 'gamma']) {
94
- setFixture(markerFailure(name));
95
- await edit(distinctSession);
96
- await idle(distinctSession);
97
- }
98
- breaker = readBreaker(distinctSession);
99
- entries = Object.values(breaker.failures);
100
- helper.check(
101
- '39. distinct failures behind a common banner stay three separate signatures',
102
- Object.keys(breaker.failures).length === 3 && entries.every((entry) => entry.count === 1) && breaker.reflectionPending === false,
103
- JSON.stringify(breaker),
104
- );
105
-
106
- // --- identical stdout, different stderr assertions stay distinct ------
107
- // P1 regression: the old classifier kept only stdout, so three assertion
108
- // failures printed to stderr behind the same npm banner collapsed into one
109
- // signature and forced a reflection for healthy retries.
110
- const stderrSession = 'stderr-distinct';
111
- const stderrFailure = (name) => [
112
- `console.error('AssertionError [ERR_ASSERTION]: ${name} boom');`,
113
- 'process.exit(1);',
114
- ];
115
- for (const name of ['alpha', 'beta', 'gamma']) {
116
- setFixture(stderrFailure(name));
117
- await edit(stderrSession);
118
- await idle(stderrSession);
119
- }
120
- breaker = readBreaker(stderrSession);
121
- entries = Object.values(breaker.failures);
122
- helper.check(
123
- '39. identical stdout with different stderr assertions stays three separate signatures',
124
- Object.keys(breaker.failures).length === 3 && entries.every((entry) => entry.count === 1) && breaker.reflectionPending === false,
125
- JSON.stringify(breaker),
126
- );
127
-
128
- // --- >2 KiB shared prefix, different markerless tails stay distinct ---
129
- // P1 regression: the old 2 KiB leading-prefix truncation hashed the same
130
- // prefix for all three runs, so different markerless failures collided.
131
- const prefixSession = 'prefix-distinct';
132
- const markerlessFailure = (token) => [
133
- "console.log('progress '.repeat(400));",
134
- `console.log('HARNESS-UNIQUE-${token}');`,
135
- 'process.exit(1);',
136
- ];
137
- for (const token of ['ALPHA', 'BETA', 'GAMMA']) {
138
- setFixture(markerlessFailure(token));
139
- await edit(prefixSession);
140
- await idle(prefixSession);
141
- }
142
- breaker = readBreaker(prefixSession);
143
- entries = Object.values(breaker.failures);
144
- helper.check(
145
- '39. a shared >2 KiB markerless prefix with different tails stays three separate signatures',
146
- Object.keys(breaker.failures).length === 3 &&
147
- entries.every((entry) => entry.count === 1) &&
148
- Object.keys(breaker.failures).every((signature) => /unrecognized-output/.test(signature)) &&
149
- breaker.reflectionPending === false,
150
- JSON.stringify(breaker),
151
- );
152
-
153
- // --- Jest suite output: FAIL <file> is context, not identity -----------
154
- // P1 regression: the old classifier returned the first matching line, so
155
- // `FAIL src/parser.test.js` made three different test failures in the same
156
- // file one signature and forced a reflection.
157
- const jestSession = 'jest-distinct';
158
- const jestFailure = (name) => [
159
- "console.log('FAIL src/parser.test.js');",
160
- `console.log(' ● parser › accepts ${name}');`,
161
- `console.log(' AssertionError: ${name}');`,
162
- 'process.exit(1);',
163
- ];
164
- for (const name of ['alpha', 'beta', 'gamma']) {
165
- setFixture(jestFailure(name));
166
- await edit(jestSession);
167
- await idle(jestSession);
168
- }
169
- breaker = readBreaker(jestSession);
170
- entries = Object.values(breaker.failures);
171
- helper.check(
172
- '39. different Jest failures from one file stay three separate signatures',
173
- Object.keys(breaker.failures).length === 3 && entries.every((entry) => entry.count === 1) && breaker.reflectionPending === false,
174
- JSON.stringify(breaker),
175
- );
176
-
177
- const jestIdenticalSession = 'jest-identical';
178
- setFixture(jestFailure('stable'));
179
- for (let i = 0; i < 3; i += 1) {
180
- await edit(jestIdenticalSession);
181
- await idle(jestIdenticalSession);
182
- }
183
- breaker = readBreaker(jestIdenticalSession);
184
- entries = Object.values(breaker.failures);
185
- helper.check(
186
- '39. three identical Jest failures still force the Rule-of-3 reflection',
187
- Object.keys(breaker.failures).length === 1 && entries[0].count === 3 && breaker.reflectionPending === true,
188
- JSON.stringify(breaker),
189
- );
190
- helper.check(
191
- '39. the Jest-identical reflection prompt names the token',
192
- /reflection token: [A-Za-z0-9]+/.test(lastPrompt()),
193
- lastPrompt(),
194
- );
195
-
196
-
197
- // --- indented Mocha tests: true identity survives volatile diagnostics ---
198
- // P2 regression: the old unindented regex missed " 1) test", then the
199
- // markerless digest changed on every stack-line number even for the same
200
- // failing check, preventing Rule-of-3 from reaching reflection.
201
- const mochaFailure = (name, frameLine) => [
202
- `console.log(' 1) should parse ${name}');`,
203
- "console.error(' AssertionError: expected true to equal false');",
204
- `console.log(' at Context.<anonymous> (fixture.test.js:${frameLine}:7)');`,
205
- 'process.exit(1);',
206
- ];
207
-
208
- const mochaDistinctSession = 'mocha-distinct';
209
- for (const name of ['alpha', 'beta', 'gamma']) {
210
- setFixture(mochaFailure(name, 19));
211
- await edit(mochaDistinctSession);
212
- await idle(mochaDistinctSession);
213
- }
214
- breaker = readBreaker(mochaDistinctSession);
215
- entries = Object.values(breaker.failures);
216
- helper.check(
217
- '39. different indented Mocha checks never count as one repeated failure',
218
- Object.keys(breaker.failures).length === 3 &&
219
- entries.every((entry) => entry.count === 1) &&
220
- breaker.reflectionPending === false,
221
- JSON.stringify(breaker),
222
- );
223
-
224
- const mochaIdenticalSession = 'mocha-identical';
225
- for (const frameLine of [19, 27, 35]) {
226
- setFixture(mochaFailure('stable', frameLine));
227
- await edit(mochaIdenticalSession);
228
- await idle(mochaIdenticalSession);
229
- }
230
- breaker = readBreaker(mochaIdenticalSession);
231
- entries = Object.values(breaker.failures);
232
- helper.check(
233
- '39. same indented Mocha check with changing stack output still triggers Rule-of-3',
234
- Object.keys(breaker.failures).length === 1 &&
235
- entries[0].count === 3 &&
236
- breaker.reflectionPending === true,
237
- JSON.stringify(breaker),
238
- );
239
- helper.check(
240
- '39. Mocha Rule-of-3 reflection includes a token',
241
- /reflection token: [A-Za-z0-9]+/.test(lastPrompt()),
242
- lastPrompt(),
243
- );
244
-
245
- // --- Console payload noise: logged Error lines are not failure identity ---
246
- // Regression guard for the indented-error pattern: a Jest Console payload
247
- // (logged output, volatile run to run) must not become the marker, or the
248
- // same failing check stops accumulating toward the Rule of 3.
249
- const consoleNoisyFailure = [
250
- "console.log('PASS src/loggy.test.js');",
251
- "console.log(' ● Console');",
252
- "console.log('');",
253
- "console.log(' console.error');",
254
- "console.log(' Error: connection refused at ' + Date.now());",
255
- "console.log('');",
256
- "console.log('FAIL src/parser.test.js');",
257
- "console.log(' ● parser › accepts stable');",
258
- 'process.exit(1);',
259
- ];
260
- const consoleNoiseSession = 'console-noise';
261
- for (let i = 0; i < 3; i += 1) {
262
- setFixture(consoleNoisyFailure);
263
- await edit(consoleNoiseSession);
264
- await idle(consoleNoiseSession);
265
- }
266
- breaker = readBreaker(consoleNoiseSession);
267
- entries = Object.values(breaker.failures);
268
- helper.check(
269
- '39. volatile Console payload noise never breaks the failing check identity',
270
- Object.keys(breaker.failures).length === 1 && entries[0].count === 3 && breaker.reflectionPending === true,
271
- JSON.stringify(breaker),
272
- );
273
-
274
- // --- nested Jest Console bullets are payload, not test-level markers ---
275
- // The previous fix only excluded indented Error lines. A logged "●" used
276
- // to terminate the Console section regardless of indentation, causing
277
- // either false reflection (shared console text) or missed Rule-of-3
278
- // (volatile console text) for actual Jest failures.
279
- const consoleBulletFailure = (name, noise) => [
280
- "console.log('PASS src/loggy.test.js');",
281
- "console.log(' ● Console');",
282
- "console.log('');",
283
- "console.log(' console.log');",
284
- `console.log(' ● ${noise}');`,
285
- "console.log(' ● Console');",
286
- "console.log('');",
287
- "console.log('FAIL src/parser.test.js');",
288
- `console.log(' ● parser › accepts ${name}');`,
289
- 'process.exit(1);',
290
- ];
291
-
292
- const consoleBulletDistinctSession = 'console-bullet-distinct';
293
- for (const name of ['alpha', 'beta', 'gamma']) {
294
- setFixture(consoleBulletFailure(name, 'preparing runtime'));
295
- await edit(consoleBulletDistinctSession);
296
- await idle(consoleBulletDistinctSession);
297
- }
298
- breaker = readBreaker(consoleBulletDistinctSession);
299
- entries = Object.values(breaker.failures);
300
- helper.check(
301
- '39. shared nested Console bullet with different Jest failures never causes false Rule-of-3',
302
- Object.keys(breaker.failures).length === 3 &&
303
- entries.every((entry) => entry.count === 1) &&
304
- breaker.reflectionPending === false,
305
- JSON.stringify(breaker),
306
- );
307
-
308
- const consoleBulletIdenticalSession = 'console-bullet-identical';
309
- for (const noise of ['preparing runtime', 'loading plugins', 'initialization complete']) {
310
- setFixture(consoleBulletFailure('stable', noise));
311
- await edit(consoleBulletIdenticalSession);
312
- await idle(consoleBulletIdenticalSession);
313
- }
314
- breaker = readBreaker(consoleBulletIdenticalSession);
315
- entries = Object.values(breaker.failures);
316
- helper.check(
317
- '39. differing nested Console bullets do not stop the same Jest failure from reaching Rule-of-3',
318
- Object.keys(breaker.failures).length === 1 &&
319
- entries[0].count === 3 &&
320
- breaker.reflectionPending === true,
321
- JSON.stringify(breaker),
322
- );
323
- helper.check(
324
- '39. nested Console bullet Rule-of-3 produces a reflection token',
325
- /reflection token: [A-Za-z0-9]+/.test(lastPrompt()),
326
- lastPrompt(),
327
- );
328
-
329
- // --- genuinely identical failures keep the Rule of 3 ------------------
330
- const identicalSession = 'identical';
331
- setFixture(markerFailure('stable check'));
332
- for (let i = 0; i < 3; i += 1) {
333
- await edit(identicalSession);
334
- await idle(identicalSession);
335
- }
336
- breaker = readBreaker(identicalSession);
337
- entries = Object.values(breaker.failures);
338
- helper.check(
339
- '39. three genuinely identical failures still force the Rule-of-3 reflection',
340
- Object.keys(breaker.failures).length === 1 && entries[0].count === 3 && breaker.reflectionPending === true,
341
- JSON.stringify(breaker),
342
- );
77
+ delete process.env.HARNESS_VERIFY_TIMEOUT_MS;
343
78
  helper.check(
344
- '39. the forced reflection names the token and required report sections',
345
- /reflection token: [A-Za-z0-9]+/.test(lastPrompt()) && /## Goal/.test(lastPrompt()) && /## Decision/.test(lastPrompt()),
79
+ '39. a timeout is reported as incomplete verification without reflection or a counter',
80
+ /did not complete/.test(lastPrompt()) && /timed out/.test(lastPrompt())
81
+ && !/reflection token|## Goal|does NOT count|retries before/i.test(lastPrompt())
82
+ && !fs.existsSync(stateFile(timeoutSession, 'circuit-breaker.json')),
346
83
  lastPrompt(),
347
84
  );
348
85
 
349
- // --- success after failure clears pending state -----------------------
350
86
  const recoverSession = 'recover';
351
- setFixture(markerFailure('recover check'));
87
+ setFixture("console.error('AssertionError [ERR_ASSERTION]: recoverable failure');process.exit(1);");
352
88
  await edit(recoverSession);
353
89
  await idle(recoverSession);
354
90
  const promptsBeforeSuccess = promptCalls.length;
355
- setFixture(['process.exit(0);']);
91
+ setFixture('process.exit(0);');
356
92
  await edit(recoverSession);
357
93
  await idle(recoverSession);
358
- const recoveredState = readEditState(recoverSession);
359
- breaker = readBreaker(recoverSession);
360
- entries = Object.values(breaker.failures);
94
+ const recoveredState = JSON.parse(fs.readFileSync(stateFile(recoverSession, 'edit-state.json'), 'utf8'));
361
95
  helper.check(
362
- '39. a passing run after a failure clears pending verification without erasing failure history',
363
- recoveredState.verificationPending === false &&
364
- recoveredState.editsSinceVerification === 0 &&
365
- promptCalls.length === promptsBeforeSuccess &&
366
- entries[0].count === 1,
367
- JSON.stringify({ recoveredState, breaker }),
96
+ '39. a passing verification clears pending state without an extra reminder',
97
+ recoveredState.verificationPending === false && recoveredState.editsSinceVerification === 0
98
+ && promptCalls.length === promptsBeforeSuccess
99
+ && !fs.existsSync(stateFile(recoverSession, 'circuit-breaker.json')),
100
+ JSON.stringify(recoveredState),
368
101
  );
369
102
 
370
103
  helper.finish();
@@ -1112,9 +1112,9 @@ test('V2 consumers α3: both completion orders and a post-completion counterpart
1112
1112
  }
1113
1113
  });
1114
1114
 
1115
- test('V2 consumers α3: duplicate completion notifications do not advance Rule-of-3', { concurrency: false }, async () => {
1115
+ test('V2 consumers α3: duplicate completion notifications do not duplicate verification', { concurrency: false }, async () => {
1116
1116
  const f = fixture('off');
1117
- const sessionID = 'v2-rule-of-three';
1117
+ const sessionID = 'v2-duplicate-completion';
1118
1118
  const checkLog = path.join(f.dir, 'check-runs.txt');
1119
1119
  writeVerificationPackage(f, `const fs=require('node:fs');fs.appendFileSync(${JSON.stringify(checkLog)},'x\\n');console.error('AssertionError [ERR_ASSERTION]: stable fixture failure');process.exit(1)`);
1120
1120
  let dispose;
@@ -1139,12 +1139,11 @@ test('V2 consumers α3: duplicate completion notifications do not advance Rule-o
1139
1139
  assert.equal(await waitUntil(() => fs.existsSync(editStateArtifact(f.workspace, sessionID))
1140
1140
  && readJson(editStateArtifact(f.workspace, sessionID)).followUpPending === true), true,
1141
1141
  `revision ${i + 1} recorded one completed failing check`);
1142
- const breaker = readJson(path.join(stateDir(f.workspace, sessionID), 'circuit-breaker.json'));
1143
- const count = Object.values(breaker.failures)[0]?.count;
1144
- assert.equal(count, i + 1, `duplicate completion for revision ${i + 1} does not add a failure`);
1145
- assert.equal(breaker.reflectionPending, i === 2, 'reflection is forced only on the third separate failed revision');
1146
1142
  assert.equal(fs.readFileSync(checkLog, 'utf8').trim().split(/\r?\n/).length, i + 1, 'one check ran per edit revision');
1147
- assert.equal(readJson(path.join(stateDir(f.workspace, sessionID), 'compliance.json')).circuitBreakerTrips, i === 2 ? 1 : 0);
1143
+ assert.equal(fs.existsSync(path.join(stateDir(f.workspace, sessionID), 'circuit-breaker.json')), false,
1144
+ 'verification failure does not create recurrence state');
1145
+ assert.equal(readJson(path.join(stateDir(f.workspace, sessionID), 'compliance.json')).totalEdits, i + 1,
1146
+ 'each new edit is recorded once');
1148
1147
  }
1149
1148
  } finally {
1150
1149
  if (dispose) await dispose();