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
@@ -45,6 +45,7 @@ helper.check(
45
45
  const registered = [];
46
46
  const sessionHooks = [];
47
47
  let subscribeCount = 0;
48
+ let consumedEvents = 0;
48
49
  const eventQueue = [];
49
50
  const fakeCtx = {
50
51
  location: { directory: workspace },
@@ -76,6 +77,7 @@ helper.check(
76
77
  if (options.signal.aborted) return { done: true, value: undefined };
77
78
  await new Promise((resolve) => setTimeout(resolve, 5));
78
79
  }
80
+ consumedEvents++;
79
81
  return { done: false, value: eventQueue.shift() };
80
82
  },
81
83
  }),
@@ -89,7 +91,10 @@ helper.check(
89
91
  const waitFor = async (predicate) => {
90
92
  const deadline = Date.now() + 5000;
91
93
  while (!predicate()) {
92
- if (Date.now() > deadline) throw new Error('V2 async verification did not settle');
94
+ if (Date.now() > deadline) {
95
+ const editState = path.join(stateRoot, 's1', 'edit-state.json');
96
+ throw new Error(`V2 async verification did not settle: prompts=${prompts.length}; consumedEvents=${consumedEvents}; queued=${eventQueue.length}; editState=${fs.existsSync(editState) ? fs.readFileSync(editState, 'utf8') : 'missing'}`);
97
+ }
93
98
  await new Promise(resolve => setTimeout(resolve, 20));
94
99
  }
95
100
  };
@@ -128,59 +133,73 @@ helper.check(
128
133
  const before = registered.find((r) => r.name === 'execute.before').callback;
129
134
  const after = registered.find((r) => r.name === 'execute.after').callback;
130
135
 
131
- // Flow 1: a failure loop drives verification through real V2 event shapes:
136
+ // Flow 1: repeated failures use real V2 event shapes and leave edits available:
132
137
  // execute.before/after carry {tool, sessionID, id, input}; the event stream
133
138
  // carries flat {type, sessionID}.
134
139
  const sessionDir = path.join(stateRoot, 's1');
135
140
  for (let i = 1; i <= 3; i++) {
141
+ await before({ tool: 'edit', sessionID: 's1', id: `before-${i}`, input: {} });
136
142
  await after({ tool: 'edit', sessionID: 's1', id: `c${i}`, input: {} });
137
143
  push({ type: 'session.idle', sessionID: 's1' });
138
144
  await waitFor(() => prompts.length === i);
139
145
  }
140
146
 
141
147
  helper.check(
142
- '2p. three v2-shaped edit/idle cycles force reflection',
148
+ '2p. three v2-shaped edit/idle cycles send verification reminders',
143
149
  prompts.length === 3,
144
150
  `prompts: ${prompts.length}`
145
151
  );
146
152
 
147
153
  helper.check(
148
154
  '2p. the V2 ctx.session.prompt receives {sessionID, text}, not the V1 {path, body} shape',
149
- prompts.every((p) => typeof p.sessionID === 'string' && typeof p.text === 'string'),
155
+ prompts.every((p) => typeof p.sessionID === 'string' && typeof p.text === 'string'
156
+ && /verification failed/i.test(p.text) && !/reflection token|## Goal|forced reflection|retries before/i.test(p.text)),
150
157
  JSON.stringify(prompts)
151
158
  );
152
159
 
153
- const breaker = JSON.parse(fs.readFileSync(path.join(sessionDir, 'circuit-breaker.json'), 'utf8'));
154
- const signature = Object.keys(breaker.failures)[0];
155
160
  helper.check(
156
- '2p. three same-signature failures via the v2 hooks force reflectionPending',
157
- breaker.failures[signature].count === 3 && breaker.reflectionPending === true,
158
- JSON.stringify(breaker)
161
+ '2p. repeated failures create no breaker state',
162
+ !fs.existsSync(path.join(sessionDir, 'circuit-breaker.json')),
163
+ sessionDir
159
164
  );
160
165
 
161
- let blocked = false;
166
+ let nextEditAllowed = true;
162
167
  try {
163
- await before({ tool: 'edit', sessionID: 's1', id: 'blocked-edit', input: {} });
168
+ await before({ tool: 'edit', sessionID: 's1', id: 'after-threshold', input: {} });
164
169
  } catch {
165
- blocked = true;
170
+ nextEditAllowed = false;
171
+ }
172
+ if (nextEditAllowed) {
173
+ await after({ tool: 'edit', sessionID: 's1', id: 'after-threshold-ran', input: { filePath: path.join(workspace, 'after-threshold.js') } });
174
+ }
175
+ helper.check('2p. the next v2-shaped edit remains available after the former threshold', nextEditAllowed);
176
+ helper.check('2p. the permitted next edit reaches the V2 after hook',
177
+ nextEditAllowed && JSON.parse(fs.readFileSync(path.join(sessionDir, 'edit-state.json'), 'utf8')).editRevision === 4,
178
+ sessionDir);
179
+
180
+ // A pre-retirement pending token is inert at the V2 adapter seam.
181
+ const legacyDir = path.join(stateRoot, 'legacy-pending');
182
+ const legacyBreakerFile = path.join(legacyDir, 'circuit-breaker.json');
183
+ fs.mkdirSync(legacyDir, { recursive: true });
184
+ const legacyState = JSON.stringify({
185
+ failures: { old: { count: 3, firstSeen: 1, lastSeen: 2 } },
186
+ reflectionPending: true, reflectionRequestedAt: 2, reflectionToken: 'old-token', reflectionSignature: 'old'
187
+ }, null, 2);
188
+ fs.writeFileSync(legacyBreakerFile, legacyState);
189
+ let legacyEditAllowed = true;
190
+ try {
191
+ await before({ tool: 'edit', sessionID: 'legacy-pending', id: 'legacy-edit', input: {} });
192
+ } catch {
193
+ legacyEditAllowed = false;
194
+ }
195
+ if (legacyEditAllowed) {
196
+ await after({ tool: 'edit', sessionID: 'legacy-pending', id: 'legacy-edit-after', input: { filePath: path.join(workspace, 'legacy.js') } });
166
197
  }
167
- helper.check('2p. a pending reflection blocks a v2-shaped edit call', blocked, 'edit call was allowed during pending reflection');
168
-
169
- // Flow 2: the reflection artifact is accepted through the V2 after hook,
170
- // proving input-args mapping across the adapter.
171
- const token = (prompts.map((p) => (p.text.match(/reflection token: ([A-Za-z0-9_-]+)/i) || [])[1]).filter(Boolean).pop());
172
- const reflectionFile = path.join(sessionDir, 'zoom-out-report.md');
173
- fs.writeFileSync(
174
- reflectionFile,
175
- `## Goal\nfix the fixture\n## Failed Attempts\nthree retries\n## Verified Facts\ntest stays red\n## Diagnosis\nthe fixture intentionally fails\n## Decision\nRESUME: change the fixture\nReflection token: ${token}\n`
176
- );
177
- await after({ tool: 'write', sessionID: 's1', id: 'reflect-write', input: { filePath: reflectionFile } });
178
-
179
- const breakerAfter = JSON.parse(fs.readFileSync(path.join(sessionDir, 'circuit-breaker.json'), 'utf8'));
180
198
  helper.check(
181
- '2p. a v2-shaped reflection artifact completes the reflection',
182
- breakerAfter.reflectionPending === false && Number.isFinite(breakerAfter.lastReflection) && breakerAfter.failures[signature].count === 0,
183
- JSON.stringify(breakerAfter)
199
+ '2p. legacy pending token state stays inert and the V2 edit completes',
200
+ legacyEditAllowed && fs.readFileSync(legacyBreakerFile, 'utf8') === legacyState
201
+ && fs.existsSync(path.join(legacyDir, 'edit-state.json')),
202
+ legacyDir
184
203
  );
185
204
 
186
205
  // Flow 3: session reset through the flat V2 event shape.
@@ -79,6 +79,7 @@ for (const platform of matrix.platforms) {
79
79
  assert.ok(fs.statSync(path.join(artifactRoot, file)).size > 0, `Missing OpenCode evidence: ${file}`);
80
80
  }
81
81
  const session = path.join(artifactRoot, 'state', 'sessions', 'ses_f5520f1d9ffeB8KLTIUKgA5ng8');
82
+ // This is an archived post-reset snapshot, not a current behavior witness.
82
83
  const breaker = JSON.parse(fs.readFileSync(path.join(session, 'circuit-breaker.json'), 'utf8'));
83
84
  const compliance = JSON.parse(fs.readFileSync(path.join(session, 'compliance.json'), 'utf8'));
84
85
  assert.strictEqual(breaker.hardLock, false, 'Retained snapshot is post-reset, not hard-lock proof');
@@ -312,7 +312,6 @@ try {
312
312
  effect_type: 'plugin-enforcement',
313
313
  contract: pluginContract,
314
314
  contract_sha256: hash(pluginContract),
315
- preflight: { passed: true, plugin_sha256: 'plugin-hash' },
316
315
  arms: {
317
316
  baseline: {
318
317
  ...arm('fail', true),
@@ -329,7 +328,7 @@ try {
329
328
  },
330
329
  };
331
330
  helper.check(
332
- '32. plugin pair is includable only when preflight, hash, constant skill text, and per-arm attribution agree',
331
+ '32. plugin pair is includable with a matching hash, constant skill text, and per-arm attribution',
333
332
  validatePairRecord(pluginPair).included,
334
333
  JSON.stringify(validatePairRecord(pluginPair)),
335
334
  );
@@ -24,7 +24,7 @@ check(/STATE_DIR=\$\(node -e[\s\S]*getSessionDir\(null, 'default'\)/.test(docker
24
24
  '#205 docker verifier resolves one canonical session state directory');
25
25
  check(!dockerVerify.includes(legacyStatePath),
26
26
  '#205 docker verifier does not seed or read the legacy repo-relative state directory');
27
- check((dockerVerify.match(/\$STATE_DIR\//g) || []).length >= 10,
27
+ check((dockerVerify.match(/\$STATE_DIR\//g) || []).length >= 8,
28
28
  '#205 docker verifier routes all state checks through STATE_DIR');
29
29
 
30
30
  const architecture = fs.readFileSync(path.join(ROOT, 'docs/architecture.md'), 'utf8');
@@ -14,7 +14,7 @@ const helper = require('./test-helper');
14
14
  const mod = await import(pathToFileURL(path.join(helper.root, 'opencode-plugin/index.mjs')).href);
15
15
  const { HarnessEnforcement } = mod;
16
16
  const hooks = await HarnessEnforcement({ client, directory: workspace });
17
- const runner = require('./lib/opencode-verification-loader')(helper.root);
17
+ const runner = require('./lib/opencode-verification-loader')(helper.root, { buildFailureSignature: undefined });
18
18
  const configure = scripts => fs.writeFileSync(path.join(workspace, 'package.json'), JSON.stringify({ name: 'async-fixture', scripts }));
19
19
  // npm uses cmd.exe on Windows: JSON string escaping is not shell quoting.
20
20
  // Keep source out of shell commands. setup-node places this Node on PATH;
@@ -52,15 +52,10 @@ const helper = require('./test-helper');
52
52
  await edit('large-output');
53
53
  await idle('large-output');
54
54
  helper.check('338. output beyond the former 16 MiB cap preserves a real test verdict', fs.existsSync(path.join(workspace, 'large-output-bytes.txt')) && fs.readFileSync(path.join(workspace, 'large-output-bytes.txt'), 'utf8') === String(largeBytes) && /verification failed/.test(prompts.at(-1)) && /large-output-check/.test(prompts.at(-1)), prompts.at(-1));
55
- // A producer receipt proves the npm script ran; an independent expected
56
- // stream digest additionally proves the runner consumed every emitted byte.
57
55
  const largeResult = await runner.runVerificationCommand(workspace, largeCommand, 10000);
58
- const stdoutDigest = crypto.createHash('sha256').update('x'.repeat(largeBytes)).digest('hex');
59
- const stderrDigest = crypto.createHash('sha256').update('AssertionError: large-output-check').digest('hex');
60
- const expectedDigest = crypto.createHash('sha256').update(`stdout:${stdoutDigest}\nstderr:${stderrDigest}`).digest('hex').slice(0, 16);
61
- helper.check('338. the complete >16 MiB producer stream reaches the runner',
56
+ helper.check('338. a nonzero exit above the former output cap remains a test failure',
62
57
  largeBytes > 16*1024*1024 && largeResult.outcome === 'test_failure' && largeResult.exitCode === 1
63
- && largeResult.failureMarker === 'AssertionError: large-output-check' && largeResult.evidenceDigest === expectedDigest,
58
+ && /large-output-check/.test(largeResult.error),
64
59
  JSON.stringify(largeResult));
65
60
  helper.check('338. streamed diagnostics stay bounded', prompts.at(-1).length < 2600, `prompt bytes=${prompts.at(-1).length}`);
66
61
 
@@ -79,38 +74,8 @@ const helper = require('./test-helper');
79
74
  const pass = await runner.runVerificationCommand(workspace, node('process.exit(0)'), 2000);
80
75
  helper.check('338. actual exit zero is pass', pass.success && pass.outcome === 'pass' && pass.exitCode === 0, JSON.stringify(pass));
81
76
  const failed = await runner.runVerificationCommand(workspace, node("console.log('FAIL parser.test.js');console.error('AssertionError: parse alpha');process.exitCode=2"), 2000);
82
- helper.check('338. nonzero exit preserves stderr marker and stdout suite context', failed.outcome === 'test_failure' && failed.exitCode === 2 && failed.failureMarker === 'FAIL parser.test.js: AssertionError: parse alpha' && /parse alpha/.test(failed.error), JSON.stringify(failed));
83
-
84
- const signature = (out, err, chunks = 10000) => {
85
- const stdout = runner.createVerificationCapture(), stderr = runner.createVerificationCapture();
86
- for (let i=0; i<out.length; i+=chunks) stdout.write(out.slice(i, i+chunks));
87
- for (let i=0; i<err.length; i+=chunks) stderr.write(err.slice(i, i+chunks));
88
- const a = stdout.finish(), b = stderr.finish();
89
- const marker = a.unsafeIdentity || b.unsafeIdentity ? null : a.marker
90
- ? `${a.markerContext ? `${a.markerContext}: ` : ''}${a.marker}`
91
- : b.marker ? `${b.markerContext || a.context ? `${b.markerContext || a.context}: ` : ''}${b.marker}` : null;
92
- return runner.buildFailureSignature({ command: 'npm test', outcome: 'test_failure', exitCode: 1,
93
- failureMarker: marker, evidenceDigest: crypto.createHash('sha256').update(`stdout:${a.digest}\nstderr:${b.digest}`).digest('hex').slice(0,16) });
94
- };
95
- const longPrefix = `not ok 1 - ${'same'.repeat(1500)}`;
96
- helper.check('338. truncated test identities use complete stream digests', signature(`${longPrefix} ALPHA\n`, '') !== signature(`${longPrefix} BETA\n`, ''));
97
- const observedLong = [];
98
- for (const name of ['ALPHA', 'BETA']) {
99
- fs.writeFileSync(path.join(workspace, 'long-marker.js'), `console.log(${JSON.stringify(longPrefix+name)});process.exitCode=1`);
100
- observedLong.push(await runner.runVerificationCommand(workspace, nodeFile('long-marker.js'), 2000));
101
- }
102
- helper.check('338. real long-marker child verdicts cannot collide after truncation', observedLong.every(value => value.outcome === 'test_failure' && value.failureMarker === null) && runner.buildFailureSignature(observedLong[0]) !== runner.buildFailureSignature(observedLong[1]));
103
- helper.check('338. truncated suite contexts cannot merge distinct failures', signature(`FAIL ${longPrefix}ALPHA\n`, 'AssertionError: same assertion\n') !== signature(`FAIL ${longPrefix}BETA\n`, 'AssertionError: same assertion\n'));
104
- const stableFailures = [];
105
- for (const banner of ['ALPHA', 'BETA']) {
106
- fs.writeFileSync(path.join(workspace, 'volatile-banner.js'), `process.stdout.write('${banner}'+'x'.repeat(17*1024*1024));console.error('AssertionError: stable failure');process.exitCode=1`);
107
- stableFailures.push(await runner.runVerificationCommand(workspace, nodeFile('volatile-banner.js'), 3000));
108
- }
109
- helper.check('338. huge volatile non-marker banners preserve a later stable failure identity', stableFailures.every(value => value.failureMarker === 'AssertionError: stable failure') && runner.buildFailureSignature(stableFailures[0]) === runner.buildFailureSignature(stableFailures[1]));
110
- const context = 'FAIL parser.test.js\n ● Console\n console.log\n ● payload\n';
111
- const stderr = ' ● parser › alpha (1.2ms)\n';
112
- helper.check('338. chunk boundaries preserve marker and stream context', signature(context, stderr, 1) === signature(context, stderr, 10000) && /FAIL parser.test.js: ● parser › alpha/.test(signature(context, stderr, 1)));
113
- helper.check('338. markerless whitespace normalization survives chunk boundaries', signature(' progress \n still running ', ' last line ', 1) === signature('progress still running', 'last line', 10000));
77
+ helper.check('338. nonzero exit remains a test failure with bounded diagnostics',
78
+ failed.outcome === 'test_failure' && failed.exitCode === 2 && /parse alpha/.test(failed.error), JSON.stringify(failed));
114
79
 
115
80
  // Both shell and nested child remain in the inherited process group.
116
81
  fs.writeFileSync(path.join(workspace, 'grandchild.js'), "const fs=require('fs');process.on('SIGTERM',()=>{});setInterval(()=>fs.appendFileSync('heartbeat.txt','x'),20)");
@@ -121,11 +86,14 @@ const helper = require('./test-helper');
121
86
  await new Promise(resolve => setTimeout(resolve, 200));
122
87
  helper.check('338. timeout stops nested SIGTERM-ignoring child output', cleanupResult.outcome === 'timeout' && size > 0 && fs.statSync(heartbeat).size === size, JSON.stringify({ cleanupResult, size }));
123
88
  if (process.platform !== 'win32') {
124
- const externalRunner = require('./lib/opencode-verification-loader')(helper.root, { spawn: (command, options) => {
125
- const child = require('child_process').spawn(command, options);
126
- setTimeout(() => { try { child.kill('SIGTERM'); } catch {} }, 300);
127
- return child;
128
- } });
89
+ const externalRunner = require('./lib/opencode-verification-loader')(helper.root, {
90
+ buildFailureSignature: undefined,
91
+ spawn: (command, options) => {
92
+ const child = require('child_process').spawn(command, options);
93
+ setTimeout(() => { try { child.kill('SIGTERM'); } catch {} }, 300);
94
+ return child;
95
+ },
96
+ });
129
97
  const signalled = await externalRunner.runVerificationCommand(workspace, nodeFile('worker.js'), 3000);
130
98
  const afterSignal = fs.statSync(heartbeat).size;
131
99
  await new Promise(resolve => setTimeout(resolve, 200));
@@ -202,7 +170,7 @@ const helper = require('./test-helper');
202
170
  await waitFor(() => fs.existsSync(v2Ready));
203
171
  await dispose();
204
172
  const v2DisposedDir = path.join(sessions, 'v2-disposed');
205
- const disposeStateFiles = ['edit-state.json', 'circuit-breaker.json', 'compliance.json']
173
+ const disposeStateFiles = ['edit-state.json', 'compliance.json']
206
174
  .map(name => path.join(v2DisposedDir, name));
207
175
  const stateAtDispose = disposeStateFiles.map(file => fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : null);
208
176
  const stopped = fs.statSync(v2Heartbeat).size;
@@ -210,11 +178,12 @@ const helper = require('./test-helper');
210
178
  const stateStable = disposeStateFiles.every((file, index) =>
211
179
  (fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : null) === stateAtDispose[index]);
212
180
  const editAtDispose = JSON.parse(stateAtDispose[0]);
213
- const complianceAtDispose = JSON.parse(stateAtDispose[2]);
214
- helper.check('338. V2 disposal waits for active child cleanup without late follow-up, breaker, or compliance writes',
181
+ const complianceAtDispose = JSON.parse(stateAtDispose[1]);
182
+ helper.check('338. V2 disposal waits for active child cleanup without late follow-up or compliance writes',
215
183
  fs.statSync(v2Heartbeat).size === stopped && prompts.length === beforeConcurrent && stateStable
216
184
  && editAtDispose.verificationPending === true && editAtDispose.followUpPending === false
217
- && complianceAtDispose.verifiedEdits === 0 && complianceAtDispose.circuitBreakerTrips === 0,
185
+ && complianceAtDispose.verifiedEdits === 0 && !Object.hasOwn(complianceAtDispose, 'circuitBreakerTrips')
186
+ && !fs.existsSync(path.join(v2DisposedDir, 'circuit-breaker.json')),
218
187
  JSON.stringify({ stateStable, editAtDispose, complianceAtDispose, prompts: prompts.length - beforeConcurrent }));
219
188
  // A new idle can arrive while an edit-cancelled child is still being reaped.
220
189
  // That idle must verify the newer revision after cleanup, rather than vanish.
@@ -2,7 +2,6 @@ const assert = require('assert');
2
2
  const fs = require('fs');
3
3
  const path = require('path');
4
4
  const vm = require('vm');
5
- const crypto = require('crypto');
6
5
  const helper = require('./test-helper');
7
6
 
8
7
  const root = helper.root;
@@ -53,20 +52,6 @@ function loadVerificationLogic(source) {
53
52
  return context;
54
53
  }
55
54
 
56
- function loadSignatureLogic(source) {
57
- const context = { createHash: crypto.createHash };
58
- vm.createContext(context);
59
- const script = [
60
- extractConst(source, 'FAILURE_MARKER_PATTERNS'),
61
- extractConst(source, 'CONTEXT_MARKER_PATTERNS'),
62
- extractFunction(source, 'normalizeFailureLine'),
63
- extractFunction(source, 'firstFailureMarker'),
64
- extractFunction(source, 'buildFailureSignature'),
65
- ].join('\n\n');
66
- vm.runInContext(script, context, { filename: 'signature-logic.js' });
67
- return context;
68
- }
69
-
70
55
  const DEFAULTS = [pluginSource, cliSource];
71
56
  const LABELS = ['opencode-plugin/index.mjs', 'opencode-plugin/hooks/verify.js'];
72
57
 
@@ -79,7 +64,7 @@ for (let i = 0; i < DEFAULTS.length; i += 1) {
79
64
  assert.ok(/timed out after/.test(source), `${label} labels timeout failures as timeouts`);
80
65
  assert.ok(/test_failure/.test(source), `${label} classifies confirmed failing checks`);
81
66
  assert.ok(/execution_error/.test(source), `${label} classifies spawn-level execution errors`);
82
- assert.ok(i === 0 ? /VERIFY_LINE_LIMIT = 4096/.test(source) : /maxBuffer/.test(source), `${label} bounds retained output`);
67
+ assert.ok(/VERIFY_OUTPUT_LIMIT = 2000/.test(source), `${label} bounds retained output`);
83
68
  const declared = Number(source.match(/^const DEFAULT_VERIFY_TIMEOUT_MS = (\d+);?$/m)[1]);
84
69
  assert.ok(declared >= 300000, `${label} default budget (${declared}ms) clears a several-minute suite`);
85
70
  }
@@ -112,8 +97,7 @@ assert.strictEqual(
112
97
  }
113
98
 
114
99
  // Plugin outcome, evidence and cleanup behavior is covered with real child
115
- // processes in mechanism-338-opencode-async.test.js, and downstream Rule-of-3
116
- // behavior remains in mechanism-39-opencode-verify-outcomes.test.js.
100
+ // processes in mechanism-338-opencode-async.test.js and mechanism-39.
117
101
 
118
102
  // Behavior: the manual CLI mirror classifies the same way.
119
103
  {
@@ -200,174 +184,4 @@ assert.strictEqual(
200
184
  assert.ok(!/timed out/.test(result.error), 'the CLI does not report ENOBUFS as a timeout');
201
185
  }
202
186
 
203
- // Behavior: failure signatures key on real failing-check evidence.
204
- {
205
- const context = loadSignatureLogic(pluginSource);
206
- const banner = '> harness-everything@0.34.0 test\n> node self-evolve/scripts/self-regression.js\n';
207
- const result = (error, extra = {}) => ({ command: 'npm test', outcome: 'test_failure', exitCode: 1, signal: null, error, ...extra });
208
-
209
- const alpha = result(`${banner}✖ alpha check (1.2ms)\nAssertionError [ERR_ASSERTION]: alpha boom`);
210
- assert.strictEqual(context.buildFailureSignature(alpha), context.buildFailureSignature(alpha), 'the same observation yields the same signature');
211
- const beta = result(`${banner}✖ beta check (0.8ms)\nAssertionError [ERR_ASSERTION]: beta boom`);
212
- assert.notStrictEqual(context.buildFailureSignature(alpha), context.buildFailureSignature(beta), 'different failing checks sharing a banner do not collide');
213
-
214
- const ansi = result(`${banner}\u001b[31m✖\u001b[39m alpha check (1.2ms)`);
215
- assert.strictEqual(context.buildFailureSignature(ansi), context.buildFailureSignature(alpha), 'ANSI decoration and timing suffixes do not change the signature');
216
-
217
- const tapA = result('not ok 2 - parser handles unicode');
218
- const tapB = result('not ok 5 - parser handles unicode');
219
- assert.strictEqual(context.buildFailureSignature(tapA), context.buildFailureSignature(tapB), 'TAP plan numbering does not change the signature');
220
-
221
- // P1: full stdout+stderr evidence drives the marker/digest, not a prefix.
222
- const withEvidence = (stdout, stderr) => {
223
- const evidence = stderr ? `${stdout}\nstderr:\n${stderr}` : stdout;
224
- return result(evidence, { evidence });
225
- };
226
- const sharedStdout = '> fixture@0.0.0 test\n> node fixture.js\n';
227
- const stderrAlpha = withEvidence(sharedStdout, 'AssertionError [ERR_ASSERTION]: alpha boom');
228
- const stderrBeta = withEvidence(sharedStdout, 'AssertionError [ERR_ASSERTION]: beta boom');
229
- assert.notStrictEqual(
230
- context.buildFailureSignature(stderrAlpha),
231
- context.buildFailureSignature(stderrBeta),
232
- 'shared stdout with different stderr assertions does not collide',
233
- );
234
-
235
- const prefix = 'progress '.repeat(400); // longer than the old 2 KiB leading-prefix cut
236
- const tailAlpha = withEvidence(`${prefix}HARNESS-UNIQUE-ALPHA`, '');
237
- const tailBeta = withEvidence(`${prefix}HARNESS-UNIQUE-BETA`, '');
238
- assert.ok(/unrecognized-output/.test(context.buildFailureSignature(tailAlpha)), 'markerless evidence uses the digest fallback');
239
- assert.notStrictEqual(
240
- context.buildFailureSignature(tailAlpha),
241
- context.buildFailureSignature(tailBeta),
242
- 'a >2 KiB shared markerless prefix with different tails does not collide',
243
- );
244
- assert.strictEqual(
245
- context.buildFailureSignature(tailAlpha),
246
- context.buildFailureSignature(withEvidence(`${prefix}HARNESS-UNIQUE-ALPHA`, '')),
247
- 'identical evidence still matches',
248
- );
249
-
250
- // P1: the Jest suite header is context; the test block is the identity.
251
- const jestLike = (name, file = 'src/parser.test.js') => `FAIL ${file}\n ● parser › accepts ${name}\n AssertionError: ${name}\n`;
252
- assert.strictEqual(
253
- context.firstFailureMarker(jestLike('alpha')),
254
- 'FAIL src/parser.test.js: ● parser › accepts alpha',
255
- 'the Jest suite header is carried as context for the specific test block',
256
- );
257
- const jestAlpha = result(jestLike('alpha'));
258
- const jestBeta = result(jestLike('beta'));
259
- const jestGamma = result(jestLike('gamma'));
260
- assert.notStrictEqual(context.buildFailureSignature(jestAlpha), context.buildFailureSignature(jestBeta), 'different Jest failures from the same file do not collide');
261
- assert.notStrictEqual(context.buildFailureSignature(jestBeta), context.buildFailureSignature(jestGamma), 'the second and third Jest failures stay distinct too');
262
- assert.strictEqual(context.buildFailureSignature(jestAlpha), context.buildFailureSignature(result(jestLike('alpha'))), 'an identical Jest failure still matches');
263
- assert.notStrictEqual(
264
- context.buildFailureSignature(jestAlpha),
265
- context.buildFailureSignature(result(jestLike('alpha', 'src/other.test.js'))),
266
- 'the file context distinguishes same-named first failures across suites',
267
- );
268
-
269
- const failOnly = result('FAIL src/parser.test.js\n');
270
- assert.ok(/unrecognized-output/.test(context.buildFailureSignature(failOnly)), 'a lone suite header is not a failing-check identity');
271
- assert.notStrictEqual(
272
- context.buildFailureSignature(failOnly),
273
- context.buildFailureSignature(result('FAIL src/other.test.js\n')),
274
- 'lone suite headers from different files stay distinct via the digest',
275
- );
276
-
277
- assert.strictEqual(context.firstFailureMarker(' ● Console\n console.log\n noise\n'), null, 'the Jest Console section is not a failure marker');
278
- const jestWithConsole = `FAIL src/parser.test.js\n ● Console\n\n console.log\n noise\n\n ● parser › accepts alpha\n`;
279
- assert.strictEqual(context.firstFailureMarker(jestWithConsole), 'FAIL src/parser.test.js: ● parser › accepts alpha', 'a Console block before the failure does not confuse the marker');
280
-
281
- // P2 follow-up: indented error lines are Mocha evidence, but they must not
282
- // reach into a Jest Console payload, whose logged Error lines are not
283
- // failure evidence and vary run to run.
284
- const consolePayloadBeforeFailure = `PASS src/loggy.test.js\n ● Console\n\n console.error\n Error: connection refused at 127.0.0.1:8080\n\nFAIL src/parser.test.js\n ● parser › accepts alpha\n`;
285
- assert.strictEqual(
286
- context.firstFailureMarker(consolePayloadBeforeFailure),
287
- 'FAIL src/parser.test.js: ● parser › accepts alpha',
288
- 'an indented Error line inside a Console payload is not a failure marker',
289
- );
290
- const consolePayloadOnly = `PASS src/loggy.test.js\n ● Console\n\n console.error\n Error: connection refused at 127.0.0.1:8080\n`;
291
- assert.strictEqual(context.firstFailureMarker(consolePayloadOnly), null, 'a Console payload alone leaves the run markerless');
292
- const noisyFailure = (noise) => `PASS src/loggy.test.js\n ● Console\n\n console.error\n Error: connection refused at ${noise}\n\nFAIL src/parser.test.js\n ● parser › accepts alpha\n`;
293
- assert.strictEqual(
294
- context.buildFailureSignature(result(noisyFailure('port 8080'))),
295
- context.buildFailureSignature(result(noisyFailure('port 9091'))),
296
- 'changing Console payload noise does not change the failure signature',
297
- );
298
-
299
-
300
- // P1: a logged bullet deeper than Jest's " ● Console" heading is
301
- // payload, not a new section or a test-level failure marker.
302
- const consoleBulletOutput = (name, noise) =>
303
- `PASS src/loggy.test.js\n ● Console\n\n console.log\n ● ${noise}\n ● Console\n\nFAIL src/parser.test.js\n ● parser › accepts ${name}\n`;
304
- assert.strictEqual(
305
- context.firstFailureMarker(consoleBulletOutput('alpha', 'preparing runtime')),
306
- 'FAIL src/parser.test.js: ● parser › accepts alpha',
307
- 'deeply indented Console bullets do not mask the actual Jest failure',
308
- );
309
- assert.strictEqual(
310
- context.firstFailureMarker('PASS src/loggy.test.js\n ● Console\n\n console.log\n ● preparing runtime\n'),
311
- null,
312
- 'Console-only output with a nested bullet remains markerless',
313
- );
314
- assert.notStrictEqual(
315
- context.buildFailureSignature(result(consoleBulletOutput('alpha', 'common log'))),
316
- context.buildFailureSignature(result(consoleBulletOutput('beta', 'common log'))),
317
- 'different Jest checks with the same logged Console bullet remain distinct',
318
- );
319
- assert.strictEqual(
320
- context.buildFailureSignature(result(consoleBulletOutput('stable', 'preparing runtime'))),
321
- context.buildFailureSignature(result(consoleBulletOutput('stable', 'loaded 12 plugins'))),
322
- 'the same Jest check retains its signature when logged Console bullet content changes',
323
- );
324
-
325
- // P2: Mocha indents both numbered failures and assertion lines. Signatures
326
- // must use the test identity, not the whole output (volatile stack/timing).
327
- const mochaLike = (name, frame) =>
328
- ` 1) should parse ${name}\n AssertionError: expected true to equal false\n at Context.<anonymous> (fixture.test.js:${frame}:7)\n`;
329
- const mochaAlpha = result(mochaLike('alpha', 17));
330
- const mochaBeta = result(mochaLike('beta', 18));
331
- assert.strictEqual(
332
- context.firstFailureMarker(mochaLike('alpha', 17)),
333
- '1) should parse alpha',
334
- 'indented Mocha test-number lines are recognized and normalized',
335
- );
336
- assert.notStrictEqual(
337
- context.buildFailureSignature(mochaAlpha),
338
- context.buildFailureSignature(mochaBeta),
339
- 'different indented Mocha failures have different signatures',
340
- );
341
- assert.strictEqual(
342
- context.buildFailureSignature(mochaAlpha),
343
- context.buildFailureSignature(result(mochaLike('alpha', 93))),
344
- 'the same Mocha failure keeps one signature despite changing stack line numbers',
345
- );
346
- assert.strictEqual(
347
- context.firstFailureMarker(' AssertionError [ERR_ASSERTION]: same assertion\n'),
348
- 'AssertionError [ERR_ASSERTION]: same assertion',
349
- 'indented assertion-only output is recognized as failure evidence',
350
- );
351
- assert.notStrictEqual(
352
- context.buildFailureSignature(result(' AssertionError: alpha boom\n')),
353
- context.buildFailureSignature(result(' AssertionError: beta boom\n')),
354
- 'distinct indented assertion failures remain distinct',
355
- );
356
- assert.strictEqual(
357
- context.firstFailureMarker('not ok 7 - TAP check\n'),
358
- 'not ok - TAP check',
359
- 'TAP marker numbering is normalized independently of Mocha indentation support',
360
- );
361
-
362
- const bannerOnly = result(banner);
363
- assert.strictEqual(context.buildFailureSignature(bannerOnly), context.buildFailureSignature(result(banner)), 'identical markerless output still matches');
364
- const bannerPlusTail = result(`${banner}different tail`);
365
- assert.notStrictEqual(context.buildFailureSignature(bannerOnly), context.buildFailureSignature(bannerPlusTail), 'markerless signatures fall back to the full-output digest');
366
- assert.ok(/unrecognized-output/.test(context.buildFailureSignature(bannerOnly)), 'markerless signatures are labeled as unrecognized output');
367
- assert.ok(/exit=1/.test(context.buildFailureSignature(bannerOnly)), 'the signature records the exit condition');
368
-
369
- const nodeTest = '# failing tests:\n✖ failing tests:\n✖ real specific check (3ms)\n';
370
- assert.strictEqual(context.firstFailureMarker(nodeTest), '✖ real specific check', 'the generic failing-tests header is skipped for the specific check');
371
- }
372
-
373
- console.log('mechanism-36-verify-timeout: plugin and CLI verification budget, outcome taxonomy, and signature contracts hold');
187
+ console.log('mechanism-36-verify-timeout: plugin and CLI verification budget and outcome taxonomy hold');