harness-everything 0.55.2 → 0.55.4

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 (177) 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 +22 -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/doc-obligations/reconciliation-s2b/wiring/legacy-off-golden.json +0 -6
  16. package/ci/invariant-routing.test.js +32 -6
  17. package/ci/lib/opencode-verification-loader.js +3 -5
  18. package/ci/mechanism-2a-rule-of-3.test.js +111 -97
  19. package/ci/mechanism-2n-opencode-plugin.test.js +68 -206
  20. package/ci/mechanism-2p-opencode-v2-entrypoint.test.js +47 -28
  21. package/ci/mechanism-2w-platform-compatibility.test.js +1 -0
  22. package/ci/mechanism-32-paired-benchmark.test.js +1 -2
  23. package/ci/mechanism-33-issues-205-207.test.js +1 -1
  24. package/ci/mechanism-338-opencode-async.test.js +18 -49
  25. package/ci/mechanism-36-verify-timeout.test.js +3 -189
  26. package/ci/mechanism-39-opencode-verify-outcomes.test.js +56 -323
  27. package/ci/mechanism-397-opencode-observations.test.js +64 -9
  28. package/ci/mechanism-check-packet-write-set.test.js +163 -8
  29. package/ci/mechanism-codex-hook-results.test.js +9 -5
  30. package/ci/mechanism-prb-outline-review.test.js +1 -13
  31. package/ci/mechanism-system-one-router.test.js +1 -1
  32. package/ci/openai-plugin-package.test.js +30 -7
  33. package/ci/openai-plugin-runtime.test.js +64 -32
  34. package/ci/prompt-contract-regressions.test.js +1 -5
  35. package/ci/router-workflow-plan.test.js +8 -8
  36. package/ci/self-evolve-loop.test.js +51 -51
  37. package/ci/workflow-execution-contract.test.js +3 -6
  38. package/code-review/SKILL.md +1 -1
  39. package/code-review/templates/finding.template.md +17 -1
  40. package/docker-verify.sh +1 -117
  41. package/docs/architecture.md +9 -7
  42. package/docs/document-lifecycle.md +1 -1
  43. package/docs/enforcement-locks.md +12 -10
  44. package/docs/mechanism-first-skill-mesh.md +2 -2
  45. package/docs/openai-plugin.md +3 -3
  46. package/docs/philosophy.md +1 -1
  47. package/docs/platform-capabilities.md +4 -3
  48. package/docs/platform-compatibility.json +2 -2
  49. package/docs/reflection.md +1 -1
  50. package/docs/routing.md +2 -2
  51. package/docs/system-one-suggestion-gates.md +4 -4
  52. package/docs/troubleshooting.md +9 -35
  53. package/docs/workflow-runtime.md +19 -18
  54. package/docs/workflows/environment-detection.md +11 -9
  55. package/docs/workflows/fable-discipline.md +6 -5
  56. package/docs/workflows/fable-mode.md +6 -5
  57. package/docs/workflows/harness-everything.md +5 -5
  58. package/docs/workflows/improve-codebase-architecture.md +10 -8
  59. package/docs/workflows/install-cognitive-os.md +5 -5
  60. package/docs/workflows/tdd.md +9 -9
  61. package/docs/workflows/zoom-out.md +20 -30
  62. package/environment-detection/SKILL.md +2 -2
  63. package/environment-detection/references/shell-syntax-rules.md +1 -1
  64. package/eval-harness/SKILL.md +1 -1
  65. package/eval-harness/references/scoring-rubric.md +3 -3
  66. package/evals/zoom-out/eval.yaml +2 -2
  67. package/evals/zoom-out/tasks/negative-productive-iteration.yaml +15 -0
  68. package/evals/zoom-out/tasks/negative-trivial-edit.yaml +6 -6
  69. package/evals/zoom-out/tasks/positive-first-failure.yaml +15 -0
  70. package/evals/zoom-out/tasks/positive-repair-loop.yaml +1 -1
  71. package/fable-discipline/SKILL.md +3 -3
  72. package/fable-discipline/references/discipline-rules.md +1 -1
  73. package/fable-mode/SKILL.md +1 -1
  74. package/fable-mode/execution-guardrails/SKILL.md +2 -4
  75. package/fable-mode/execution-guardrails/references/guardrail-rules.md +3 -3
  76. package/fable-mode/fable-haiku/SKILL.md +1 -1
  77. package/fable-mode/fable-opus/SKILL.md +2 -2
  78. package/fable-mode/fable-sonnet/SKILL.md +1 -1
  79. package/fable-mode/references/execution-phases.md +2 -2
  80. package/harness-everything/SKILL.md +3 -3
  81. package/harness-everything/references/router-workflow-plan.md +2 -2
  82. package/harness-everything/references/skill-registry.md +2 -2
  83. package/harness-everything/references/triage-and-tiers.md +5 -5
  84. package/harness-everything/scripts/bootstrap.js +1 -26
  85. package/harness-everything/scripts/kernel-router-core.js +2 -3
  86. package/harness-everything/scripts/kernel-router.js +1 -1
  87. package/harness-everything/scripts/router-contract-core.js +1 -1
  88. package/harness-everything/scripts/routing-keywords.json +0 -2
  89. package/hooks/hooks.json +0 -33
  90. package/hooks/scripts/lib/harness-state.js +5 -6
  91. package/hooks/scripts/lib/learning-opportunity.js +3 -13
  92. package/hooks/scripts/openai-session-start.js +2 -4
  93. package/improve-codebase-architecture/SKILL.md +3 -3
  94. package/improve-codebase-architecture/guides/refactoring-workflow.md +5 -4
  95. package/install-cognitive-os/SKILL.md +3 -3
  96. package/opencode-plugin/README.md +18 -43
  97. package/opencode-plugin/index.mjs +52 -380
  98. package/opencode-plugin/plugin.json +1 -1
  99. package/package.json +1 -4
  100. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  101. package/plugins/harness-everything/hooks/hooks.json +0 -14
  102. package/plugins/harness-everything/hooks/scripts/lib/harness-state.js +5 -6
  103. package/plugins/harness-everything/hooks/scripts/lib/learning-opportunity.js +3 -13
  104. package/plugins/harness-everything/hooks/scripts/lib/workspace.js +2 -2
  105. package/plugins/harness-everything/hooks/scripts/openai-session-start.js +2 -4
  106. package/plugins/harness-everything/hooks/session-start.js +2 -4
  107. package/plugins/harness-everything/plugin.json +1 -1
  108. package/plugins/harness-everything/scripts/lib/advisory-text.js +2 -2
  109. package/plugins/harness-everything/scripts/lib/workspace.js +2 -2
  110. package/plugins/harness-everything/skills/code-review/SKILL.md +1 -1
  111. package/plugins/harness-everything/skills/code-review/templates/finding.template.md +17 -1
  112. package/plugins/harness-everything/skills/environment-detection/SKILL.md +2 -2
  113. package/plugins/harness-everything/skills/environment-detection/references/shell-syntax-rules.md +1 -1
  114. package/plugins/harness-everything/skills/eval-harness/SKILL.md +1 -1
  115. package/plugins/harness-everything/skills/eval-harness/references/scoring-rubric.md +3 -3
  116. package/plugins/harness-everything/skills/fable-discipline/SKILL.md +3 -3
  117. package/plugins/harness-everything/skills/fable-discipline/references/discipline-rules.md +1 -1
  118. package/plugins/harness-everything/skills/fable-mode/SKILL.md +1 -1
  119. package/plugins/harness-everything/skills/fable-mode/execution-guardrails/SKILL.md +2 -4
  120. package/plugins/harness-everything/skills/fable-mode/execution-guardrails/references/guardrail-rules.md +3 -3
  121. package/plugins/harness-everything/skills/fable-mode/fable-haiku/SKILL.md +1 -1
  122. package/plugins/harness-everything/skills/fable-mode/fable-opus/SKILL.md +2 -2
  123. package/plugins/harness-everything/skills/fable-mode/fable-sonnet/SKILL.md +1 -1
  124. package/plugins/harness-everything/skills/fable-mode/references/execution-phases.md +2 -2
  125. package/plugins/harness-everything/skills/harness-everything/SKILL.md +3 -3
  126. package/plugins/harness-everything/skills/harness-everything/references/router-workflow-plan.md +2 -2
  127. package/plugins/harness-everything/skills/harness-everything/references/skill-registry.md +2 -2
  128. package/plugins/harness-everything/skills/harness-everything/references/triage-and-tiers.md +5 -5
  129. package/plugins/harness-everything/skills/harness-everything/scripts/bootstrap.js +1 -26
  130. package/plugins/harness-everything/skills/harness-everything/scripts/kernel-router-core.js +2 -3
  131. package/plugins/harness-everything/skills/harness-everything/scripts/kernel-router.js +1 -1
  132. package/plugins/harness-everything/skills/harness-everything/scripts/router-contract-core.js +1 -1
  133. package/plugins/harness-everything/skills/harness-everything/scripts/routing-keywords.json +0 -2
  134. package/plugins/harness-everything/skills/improve-codebase-architecture/SKILL.md +3 -3
  135. package/plugins/harness-everything/skills/improve-codebase-architecture/guides/refactoring-workflow.md +5 -4
  136. package/plugins/harness-everything/skills/install-cognitive-os/SKILL.md +3 -3
  137. package/plugins/harness-everything/skills/self-evolve/SKILL.md +1 -1
  138. package/plugins/harness-everything/skills/self-evolve/references/memory-resolution.md +3 -3
  139. package/plugins/harness-everything/skills/self-evolve/schemas/lesson-candidate.schema.json +4 -1
  140. package/plugins/harness-everything/skills/self-evolve/scripts/lesson-candidate.js +1 -0
  141. package/plugins/harness-everything/skills/skill-creator/SKILL.md +1 -1
  142. package/plugins/harness-everything/skills/skill-creator/references/quality-checklist.md +1 -1
  143. package/plugins/harness-everything/skills/skill-creator/references/quality-principles.md +4 -4
  144. package/plugins/harness-everything/skills/tdd/SKILL.md +2 -2
  145. package/plugins/harness-everything/skills/tdd/references/core-discipline.md +3 -5
  146. package/plugins/harness-everything/skills/todo-driven-workflow/SKILL.md +2 -2
  147. package/plugins/harness-everything/skills/zoom-out/SKILL.md +14 -26
  148. package/plugins/harness-everything/skills/zoom-out/references/circuit-breaker.md +18 -62
  149. package/references/platform-advisory-template.md +3 -9
  150. package/sbom.cdx.json +7 -7
  151. package/scripts/check-packet-write-set.js +76 -1
  152. package/scripts/lib/advisory-text.js +2 -2
  153. package/scripts/lib/workspace.js +2 -2
  154. package/self-evolve/SKILL.md +1 -1
  155. package/self-evolve/references/memory-resolution.md +3 -3
  156. package/self-evolve/schemas/lesson-candidate.schema.json +4 -1
  157. package/self-evolve/scripts/lesson-candidate.js +1 -0
  158. package/skill-creator/SKILL.md +1 -1
  159. package/skill-creator/references/quality-checklist.md +1 -1
  160. package/skill-creator/references/quality-principles.md +4 -4
  161. package/submission/openai/test-cases.json +5 -5
  162. package/tdd/SKILL.md +2 -2
  163. package/tdd/references/core-discipline.md +3 -5
  164. package/todo-driven-workflow/SKILL.md +2 -2
  165. package/zoom-out/SKILL.md +14 -26
  166. package/zoom-out/references/circuit-breaker.md +18 -62
  167. package/behavioral-evals/opencode-hardlock-live.js +0 -17
  168. package/behavioral-evals/opencode-reflection-gate-live.js +0 -342
  169. package/ci/mechanism-31-opencode-hardlock-evidence.test.js +0 -82
  170. package/evals/zoom-out/tasks/negative-first-edge-case-review.yaml +0 -16
  171. package/evals/zoom-out/tasks/positive-repeated-failure.yaml +0 -15
  172. package/hooks/scripts/reset-circuit-breaker.js +0 -30
  173. package/hooks/scripts/rule-of-3-tracker.js +0 -165
  174. package/hooks/scripts/rule-of-3.js +0 -171
  175. package/plugins/harness-everything/hooks/scripts/reset-circuit-breaker.js +0 -30
  176. package/plugins/harness-everything/hooks/scripts/rule-of-3-tracker.js +0 -165
  177. package/plugins/harness-everything/hooks/scripts/rule-of-3.js +0 -171
@@ -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');