harness-everything 0.54.0 → 0.55.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 (72) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +2 -1
  3. package/CHANGELOG.md +25 -0
  4. package/README.md +1 -0
  5. package/ci/action-gate.test.js +1 -1
  6. package/ci/mechanism-2at-fable-execution-phases.test.js +38 -0
  7. package/ci/mechanism-codex-hook-results.test.js +145 -0
  8. package/ci/mechanism-error-ledger-oracle.test.js +222 -0
  9. package/ci/mechanism-error-ledger-promote.test.js +520 -0
  10. package/ci/mechanism-error-ledger-scan.test.js +640 -0
  11. package/ci/mechanism-errors-sync-root.test.js +215 -0
  12. package/ci/openai-plugin-package.test.js +1 -1
  13. package/ci/openai-plugin-runtime.test.js +2 -1
  14. package/ci/prompt-contract-regressions.test.js +6 -2
  15. package/docs/platform-capabilities.md +17 -0
  16. package/docs/workflows/error-ledger-bootstrap.md +23 -0
  17. package/error-ledger-bootstrap/SKILL.md +33 -0
  18. package/error-ledger-bootstrap/references/workflow.md +79 -0
  19. package/error-ledger-bootstrap/scripts/promote.js +613 -0
  20. package/error-ledger-bootstrap/scripts/scan.js +654 -0
  21. package/evals/error-ledger-bootstrap/eval.yaml +26 -0
  22. package/evals/error-ledger-bootstrap/tasks/negative-error-handling-map.yaml +16 -0
  23. package/evals/error-ledger-bootstrap/tasks/negative-trigger.yaml +16 -0
  24. package/evals/error-ledger-bootstrap/tasks/positive-trigger.yaml +15 -0
  25. package/fable-mode/SKILL.md +5 -5
  26. package/fable-mode/execution-guardrails/SKILL.md +1 -1
  27. package/fable-mode/fable-haiku/SKILL.md +1 -1
  28. package/fable-mode/fable-opus/SKILL.md +1 -1
  29. package/fable-mode/fable-sonnet/SKILL.md +1 -1
  30. package/fable-mode/references/execution-phases.md +26 -4
  31. package/harness-everything/SKILL.md +1 -1
  32. package/harness-everything/references/skill-registry.md +1 -0
  33. package/harness-everything/scripts/routing-keywords.json +11 -0
  34. package/hooks/scripts/action-gate.js +5 -0
  35. package/hooks/scripts/codex-action-gate-post.js +3 -12
  36. package/hooks/scripts/contract-test.js +17 -7
  37. package/hooks/scripts/lib/codex-tool-outcome.js +28 -0
  38. package/hooks/scripts/rule-of-3-tracker.js +11 -4
  39. package/hooks/scripts/state-persist.js +15 -9
  40. package/hooks/scripts/subagent-scope-guard.js +32 -25
  41. package/hooks/scripts/subagent-start.js +1 -1
  42. package/hooks/scripts/subagent-stop.js +14 -3
  43. package/opencode-plugin/plugin.json +1 -1
  44. package/package.json +1 -1
  45. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  46. package/plugins/harness-everything/hooks/hooks.json +6 -6
  47. package/plugins/harness-everything/hooks/scripts/action-gate.js +5 -0
  48. package/plugins/harness-everything/hooks/scripts/codex-action-gate-post.js +3 -12
  49. package/plugins/harness-everything/hooks/scripts/contract-test.js +17 -7
  50. package/plugins/harness-everything/hooks/scripts/lib/codex-tool-outcome.js +28 -0
  51. package/plugins/harness-everything/hooks/scripts/rule-of-3-tracker.js +11 -4
  52. package/plugins/harness-everything/hooks/scripts/state-persist.js +15 -9
  53. package/plugins/harness-everything/hooks/scripts/subagent-scope-guard.js +32 -25
  54. package/plugins/harness-everything/hooks/scripts/subagent-start.js +1 -1
  55. package/plugins/harness-everything/hooks/scripts/subagent-stop.js +14 -3
  56. package/plugins/harness-everything/plugin.json +1 -1
  57. package/plugins/harness-everything/skills/error-ledger-bootstrap/SKILL.md +33 -0
  58. package/plugins/harness-everything/skills/error-ledger-bootstrap/references/workflow.md +79 -0
  59. package/plugins/harness-everything/skills/error-ledger-bootstrap/scripts/promote.js +613 -0
  60. package/plugins/harness-everything/skills/error-ledger-bootstrap/scripts/scan.js +654 -0
  61. package/plugins/harness-everything/skills/fable-mode/SKILL.md +5 -5
  62. package/plugins/harness-everything/skills/fable-mode/execution-guardrails/SKILL.md +1 -1
  63. package/plugins/harness-everything/skills/fable-mode/fable-haiku/SKILL.md +1 -1
  64. package/plugins/harness-everything/skills/fable-mode/fable-opus/SKILL.md +1 -1
  65. package/plugins/harness-everything/skills/fable-mode/fable-sonnet/SKILL.md +1 -1
  66. package/plugins/harness-everything/skills/fable-mode/references/execution-phases.md +26 -4
  67. package/plugins/harness-everything/skills/harness-everything/SKILL.md +1 -1
  68. package/plugins/harness-everything/skills/harness-everything/references/skill-registry.md +1 -0
  69. package/plugins/harness-everything/skills/harness-everything/scripts/routing-keywords.json +11 -0
  70. package/sbom.cdx.json +7 -7
  71. package/scripts/error-ledger-oracle.js +257 -0
  72. package/scripts/errors-sync.js +175 -12
@@ -0,0 +1,640 @@
1
+ 'use strict';
2
+
3
+ const assert = require('node:assert/strict');
4
+ const childProcess = require('node:child_process');
5
+ const fs = require('node:fs');
6
+ const os = require('node:os');
7
+ const path = require('node:path');
8
+ const { isWithin } = require('../error-ledger-bootstrap/scripts/scan');
9
+
10
+ const ROOT = path.resolve(__dirname, '..');
11
+ const SCANNER = path.join(ROOT, 'error-ledger-bootstrap', 'scripts', 'scan.js');
12
+ const TMP = fs.realpathSync.native(fs.mkdtempSync(path.join(os.tmpdir(), 'harness-error-ledger-scan-')));
13
+ const GIT_MAX_BUFFER = 32 * 1024 * 1024;
14
+ const FIXED_DATE = '2024-01-02T03:04:05Z';
15
+ const VALID_SOURCE_STATUSES = new Set(['used', 'missing', 'disabled', 'unverified']);
16
+
17
+ function git(repo, args, env = {}) {
18
+ return childProcess.execFileSync('git', ['-C', repo, ...args], {
19
+ encoding: 'utf8',
20
+ env: { ...process.env, GIT_CONFIG_NOSYSTEM: '1', ...env },
21
+ stdio: ['ignore', 'pipe', 'pipe']
22
+ }).trim();
23
+ }
24
+
25
+ function write(repo, relative, text) {
26
+ const file = path.join(repo, relative);
27
+ fs.mkdirSync(path.dirname(file), { recursive: true });
28
+ fs.writeFileSync(file, text);
29
+ }
30
+
31
+ function writeFile(file, text) {
32
+ fs.mkdirSync(path.dirname(file), { recursive: true });
33
+ fs.writeFileSync(file, text);
34
+ }
35
+
36
+ function commit(repo, subject, files, seconds) {
37
+ for (const [relative, text] of Object.entries(files)) write(repo, relative, text);
38
+ git(repo, ['add', '-A']);
39
+ const date = new Date(Date.parse(FIXED_DATE) + seconds * 1000).toISOString();
40
+ git(repo, ['commit', '-q', '-m', subject], {
41
+ GIT_AUTHOR_NAME: 'Scanner Fixture',
42
+ GIT_AUTHOR_EMAIL: 'scanner@example.invalid',
43
+ GIT_COMMITTER_NAME: 'Scanner Fixture',
44
+ GIT_COMMITTER_EMAIL: 'scanner@example.invalid',
45
+ GIT_AUTHOR_DATE: date,
46
+ GIT_COMMITTER_DATE: date
47
+ });
48
+ }
49
+
50
+ function run(args, home, preload = null, extraEnv = {}) {
51
+ const nodeArgs = preload ? ['--require', preload] : [];
52
+ const result = childProcess.spawnSync(process.execPath, [...nodeArgs, SCANNER, ...args, '--json'], {
53
+ encoding: 'utf8',
54
+ env: { ...process.env, HOME: home, USERPROFILE: home, ...extraEnv }
55
+ });
56
+ assert.ifError(result.error);
57
+ return result;
58
+ }
59
+
60
+ function reportFrom(result, expectedStatus = 0) {
61
+ assert.strictEqual(result.status, expectedStatus,
62
+ `scanner exit ${result.status}; expected ${expectedStatus}; stderr: ${result.stderr}`);
63
+ if (expectedStatus === 0) assert.strictEqual(result.stderr.trim(), '', 'successful scans do not write stderr');
64
+ else assert.match(result.stderr.trim(), /^[^\r\n]+$/, 'failures write one stderr line');
65
+ return JSON.parse(result.stdout);
66
+ }
67
+
68
+ function inside(root, candidate) {
69
+ const relative = path.relative(root, candidate);
70
+ return relative === '' || (!path.isAbsolute(relative) && relative !== '..' && !relative.startsWith(`..${path.sep}`));
71
+ }
72
+
73
+ function candidate(report, site, type) {
74
+ return report.candidates.find(item => item.sites.includes(site) && item.sources.some(source => source.type === type));
75
+ }
76
+
77
+ const repo = path.join(TMP, 'PRIVATE_OPERATOR_SENTINEL-PRIVATE_SLUG_SENTINEL', 'synthetic-harness');
78
+ const home = path.join(TMP, 'PRIVATE_OPERATOR_SENTINEL-home');
79
+ const slug = path.resolve(repo).replace(/[^a-z0-9]/gi, '-');
80
+ const autoMemoryDir = path.join(home, '.claude', 'projects', slug, 'memory');
81
+ const autoMemory = path.join(autoMemoryDir, 'lesson-PRIVATE_FILENAME_SENTINEL-auto.md');
82
+ const explicitMemory = path.join(home, 'notes', 'lesson-PRIVATE_FILENAME_SENTINEL-explicit.md');
83
+ const globalInstructions = path.join(home, '.codex', 'AGENTS.md');
84
+ const localInstructions = path.join(repo, 'private-inputs', 'PRIVATE_FILENAME_SENTINEL-instructions.md');
85
+ const defaultReports = [];
86
+
87
+ try {
88
+ fs.mkdirSync(repo, { recursive: true });
89
+ fs.mkdirSync(home, { recursive: true });
90
+ git(repo, ['init', '-q']);
91
+ git(repo, ['config', 'user.name', 'Scanner Fixture']);
92
+ git(repo, ['config', 'user.email', 'scanner@example.invalid']);
93
+ git(repo, ['config', 'commit.gpgsign', 'false']);
94
+
95
+ commit(repo, 'feat: add parser fixtures', {
96
+ 'AGENTS.md': '# Local instructions\n\n## Cue\nThe parser loses a token after a boundary.\n\n## Lesson\nKeep the parser boundary regression covered.\n',
97
+ 'private-inputs/PRIVATE_FILENAME_SENTINEL-instructions.md': '# Private local instructions\n\n## Lesson\nUse `src/parser.js` as the example.\n',
98
+ 'src/parser.js': 'module.exports = value => value;\n',
99
+ 'src/single.js': 'module.exports = true;\n',
100
+ 'ci/parser.test.js': "const parser = require('../src/parser.js');\nvoid parser;\n",
101
+ 'src/__tests__/parser.test.js': "const parser = require('../parser');\nvoid parser;\n",
102
+ 'inside-output/.keep': 'existing target directory\n'
103
+ }, 0);
104
+ commit(repo, 'fix: repair parser on empty input', {
105
+ 'src/parser.js': 'module.exports = value => value == null ? "" : value;\n'
106
+ }, 1);
107
+ commit(repo, 'fix(parser): preserve token boundaries', {
108
+ 'src/parser.js': 'module.exports = value => String(value ?? "").trim();\n'
109
+ }, 2);
110
+ commit(repo, 'fix: handle one-time edge case', {
111
+ 'src/single.js': 'module.exports = false;\n'
112
+ }, 3);
113
+ commit(repo, 'fix: mixed ledger change', {
114
+ 'src/parser.js': 'module.exports = value => String(value ?? "").trim().toLowerCase();\n',
115
+ '.agents/harness-everything/errors/E-fixture.md': 'NEVER COPY LEDGER BODY INTO A REPORT\n',
116
+ 'docs/error-handling/generated.md': 'GENERATED_LEDGER_COPY_SENTINEL updated\n'
117
+ }, 4);
118
+ commit(repo, 'fix: ledger only change', {
119
+ '.agents/harness-everything/errors/E-fixture.md': 'LEDGER_ONLY_SENTINEL\n',
120
+ '.agents/harness-everything/errors/index.jsonl': '{"generated":true}\n',
121
+ 'docs/error-handling/generated.md': 'GENERATED_LEDGER_COPY_SENTINEL\n'
122
+ }, 5);
123
+ commit(repo, 'fix: clarify documentation paths', {
124
+ 'guide.md': '# Repeated guide\nFirst correction.\n',
125
+ 'docs/reference.json': '{"guide":"First correction"}\n',
126
+ 'docs/single.md': '# Single guide\nOne correction.\n'
127
+ }, 6);
128
+ commit(repo, 'revert: restore repeated documentation example', {
129
+ 'guide.md': '# Repeated guide\nRestored example.\n',
130
+ 'docs/reference.json': '{"guide":"Restored example"}\n'
131
+ }, 7);
132
+
133
+ writeFile(autoMemory, [
134
+ '---',
135
+ 'type: feedback',
136
+ 'title: PRIVATE_TITLE_SENTINEL parser lesson',
137
+ '---',
138
+ `Repository: ${path.basename(repo)}`,
139
+ '## Cue',
140
+ 'A parser boundary loses the final token. PRIVATE_RAW_TEXT_SENTINEL',
141
+ '## Lesson',
142
+ 'Add a regression for `src/parser.js` and inspect `private/PRIVATE_UNCORROBORATED_SENTINEL.js`.',
143
+ ''
144
+ ].join('\n'));
145
+ writeFile(explicitMemory, [
146
+ '---',
147
+ 'type: feedback',
148
+ 'title: explicit memory parser lesson',
149
+ '---',
150
+ '## Cue',
151
+ 'A parser regression reappears after a cleanup.',
152
+ '## Lesson',
153
+ 'Keep checking `src/parser.js`.',
154
+ ''
155
+ ].join('\n'));
156
+ const explicitMemoryDir = path.join(home, 'notes', 'directory-lessons');
157
+ writeFile(path.join(explicitMemoryDir, 'lesson-single.md'), [
158
+ '## Cue',
159
+ 'A single edge case returned the wrong state.',
160
+ '## Lesson',
161
+ 'Review `src/single.js` before changing its behavior.',
162
+ ''
163
+ ].join('\n'));
164
+ writeFile(globalInstructions, '# Global instruction\n\n## Lesson\nGlobal instruction sentinel must be explicitly selected.\n');
165
+ writeFile(path.join(home, '.claude', 'CLAUDE.md'), '# Other global instruction\n\n## Lesson\nOther global instruction sentinel.\n');
166
+
167
+ const statusBefore = git(repo, ['status', '--porcelain']);
168
+ assert.strictEqual(statusBefore, '', 'synthetic target starts clean');
169
+
170
+ const defaultResult = run(['--root', repo, '--hide-ledger', '--home', home], home);
171
+ const defaultPayload = reportFrom(defaultResult);
172
+ assert.strictEqual(defaultPayload.ok, true);
173
+ const defaultJson = JSON.parse(fs.readFileSync(defaultPayload.reportJson, 'utf8'));
174
+ const defaultMd = fs.readFileSync(defaultPayload.reportMd, 'utf8');
175
+ assert.strictEqual(defaultPayload.counts.candidates, defaultJson.candidates.length);
176
+ defaultReports.push(path.dirname(defaultPayload.reportJson));
177
+ assert.ok(!inside(repo, defaultPayload.reportJson), 'default JSON report is outside the target');
178
+ assert.ok(!inside(repo, defaultPayload.reportMd), 'default Markdown report is outside the target');
179
+ if (process.platform !== 'win32') {
180
+ assert.strictEqual(fs.statSync(path.dirname(defaultPayload.reportJson)).mode & 0o777, 0o700,
181
+ 'default report directory is private');
182
+ }
183
+
184
+ assert.deepStrictEqual(Object.keys(defaultJson).sort(),
185
+ ['candidates', 'generatedAt', 'options', 'root', 'schemaVersion', 'sources'].sort());
186
+ assert.strictEqual(defaultJson.schemaVersion, 1);
187
+ assert.strictEqual(defaultJson.root, path.basename(repo));
188
+ assert.ok(!path.isAbsolute(defaultJson.root));
189
+ assert.ok(defaultJson.generatedAt);
190
+ assert.ok(defaultJson.sources.length > 0);
191
+ assert.ok(defaultJson.sources.every(source => VALID_SOURCE_STATUSES.has(source.status)),
192
+ 'all source statuses use the public enum');
193
+ assert.deepStrictEqual(new Set(defaultJson.sources.map(source => source.type)),
194
+ new Set(['git', 'doc', 'tracker', 'memory', 'instruction']));
195
+ assert.strictEqual(defaultJson.sources.find(source => source.type === 'doc').status, 'used');
196
+ assert.strictEqual(defaultJson.sources.find(source => source.type === 'tracker').status, 'missing');
197
+ for (const item of defaultJson.candidates) {
198
+ assert.strictEqual(item.kind, 'error-candidate');
199
+ assert.strictEqual(item.status, 'UNVERIFIED');
200
+ assert.ok(item.domain && item.title && item.signature && item.sources.length);
201
+ assert.ok(item.sites.every(site => !path.posix.isAbsolute(site) && !site.includes('\\') && path.posix.normalize(site) === site),
202
+ 'candidate sites are portable root-relative paths');
203
+ }
204
+
205
+ const parserLead = candidate(defaultJson, 'src/parser.js', 'git');
206
+ assert.ok(parserLead, 'two or more fix commits create a path lead');
207
+ assert.strictEqual(parserLead.kind, 'error-candidate');
208
+ assert.strictEqual(parserLead.status, 'UNVERIFIED');
209
+ assert.strictEqual(parserLead.domain, 'src');
210
+ assert.match(parserLead.id, /^[a-f0-9]+$/);
211
+ assert.strictEqual(parserLead.sources.filter(source => source.type === 'git').length, 3,
212
+ 'distinct fix commits, including the stripped mixed commit path, are listed');
213
+ assert.ok(parserLead.sources.every(source => /^[a-f0-9]{40}$/.test(source.sha) && source.subject));
214
+ assert.ok(!candidate(defaultJson, 'src/single.js', 'git'), 'one fix commit does not create a lead');
215
+ const docLead = candidate(defaultJson, 'guide.md', 'doc');
216
+ assert.ok(docLead, 'two fix/revert commits to one Markdown path create a doc candidate');
217
+ assert.strictEqual(docLead.sources.length, 2);
218
+ assert.ok(docLead.sources.every(source => source.type === 'doc' && source.path === 'guide.md' && /^[a-f0-9]{40}$/.test(source.sha)),
219
+ 'doc sources identify their path and commit SHA');
220
+ assert.ok(!candidate(defaultJson, 'guide.md', 'git'), 'documentation history stays separate from code path groups');
221
+ const docsTreeLead = candidate(defaultJson, 'docs/reference.json', 'doc');
222
+ assert.ok(docsTreeLead && docsTreeLead.sources.length === 2, 'repeated paths anywhere under docs are documentation candidates');
223
+ assert.ok(!candidate(defaultJson, 'docs/single.md', 'doc'), 'one fix commit to a Markdown path does not create a doc candidate');
224
+ assert.ok(defaultMd.includes(`guide.md — ${docLead.sources[0].sha}`), 'Markdown reports include each doc path and commit SHA');
225
+ assert.ok(!defaultJson.candidates.some(item => JSON.stringify(item).includes('LEDGER_ONLY_SENTINEL')));
226
+ assert.ok(!defaultJson.candidates.some(item => item.sources.some(source => source.subject === 'fix: ledger only change')));
227
+ assert.ok(!defaultJson.candidates.some(item => item.sites.some(site => site.includes('.agents/harness-everything/errors'))));
228
+ assert.ok(!defaultJson.candidates.some(item => item.sites.some(site => site.startsWith('docs/error-handling/'))));
229
+ assert.ok(!defaultJson.candidates.some(item => JSON.stringify(item).includes('GENERATED_LEDGER_COPY_SENTINEL')));
230
+
231
+ assert.ok(parserLead.attachments.some(item => item.type === 'test-link' && item.ref === 'ci/parser.test.js'),
232
+ 'test provenance attaches separately');
233
+ assert.ok(parserLead.attachments.some(item => item.type === 'test-link' && item.ref === 'src/__tests__/parser.test.js'),
234
+ 'relative imports resolve back to the candidate path');
235
+ assert.ok(defaultJson.candidates.some(item => item.sources.some(source => source.type === 'instruction' && source.ref === 'repo/AGENTS.md')),
236
+ 'target-repository instruction provenance remains usable');
237
+ assert.ok(!parserLead.sources.some(source => source.type === 'test-link'),
238
+ 'test links are not counted as incidents');
239
+ assert.ok(defaultJson.candidates.every(item => item.sources.length > 0));
240
+ assert.ok(defaultMd.includes(parserLead.id) && defaultMd.includes('UNVERIFIED') && defaultMd.includes('src/parser.js'));
241
+ assert.ok(!defaultMd.includes(repo) && !defaultMd.includes(home), 'Markdown contains no absolute fixture paths');
242
+ assert.ok(defaultMd.includes('hideLedger: true') && defaultMd.includes('noMemory: false'));
243
+ assert.ok(!fs.readFileSync(defaultPayload.reportJson, 'utf8').includes(repo));
244
+ assert.ok(!fs.readFileSync(defaultPayload.reportJson, 'utf8').includes(home));
245
+
246
+ const autoSource = defaultJson.sources.find(source => source.type === 'memory' && source.origin === 'auto');
247
+ assert.ok(autoSource && autoSource.verified === true && autoSource.reason,
248
+ 'auto-discovered memory records why the slug hint was verified');
249
+ const autoMemoryLead = candidate(defaultJson, 'src/parser.js', 'memory');
250
+ assert.ok(autoMemoryLead, 'verified lesson memory creates a lead');
251
+ assert.deepStrictEqual(autoMemoryLead.sites, ['src/parser.js'], 'private memory sites are limited to files in the target repository');
252
+ assert.strictEqual(autoMemoryLead.title, 'Local memory lead', 'private memory uses a neutral generated title');
253
+ assert.strictEqual(autoMemoryLead.status, 'UNVERIFIED');
254
+ assert.ok(defaultMd.includes(`### ${autoMemoryLead.title}`), 'Markdown keeps the neutral private-source title');
255
+ assert.ok(autoMemoryLead.sources.some(source => source.type === 'memory' && /^local\/[a-f0-9]{64}$/.test(source.ref)),
256
+ 'memory candidate provenance uses an opaque local ID');
257
+ assert.match(autoSource.ref, /^local\/[a-f0-9]{64}$/);
258
+ assert.match(autoSource.verificationRef, /^local\/[a-f0-9]{64}$/);
259
+ const privateSentinels = /PRIVATE_(?:OPERATOR|SLUG|FILENAME|TITLE|RAW_TEXT|UNCORROBORATED)_SENTINEL/;
260
+ assert.doesNotMatch(JSON.stringify(defaultJson), privateSentinels,
261
+ 'JSON excludes private operator, slug, filename, title, raw-text, and uncorroborated-site sentinels');
262
+ assert.doesNotMatch(defaultMd, privateSentinels,
263
+ 'Markdown excludes private operator, slug, filename, title, raw-text, and uncorroborated-site sentinels');
264
+ assert.ok(!defaultJson.candidates.some(item => /global instruction sentinel/i.test(JSON.stringify(item))),
265
+ 'global instructions are not discovered automatically');
266
+
267
+ const noHidePayload = reportFrom(run(['--root', repo, '--home', home], home));
268
+ defaultReports.push(path.dirname(noHidePayload.reportJson));
269
+ const noHideJson = JSON.parse(fs.readFileSync(noHidePayload.reportJson, 'utf8'));
270
+ assert.ok(candidate(noHideJson, '.agents/harness-everything/errors/E-fixture.md', 'doc'),
271
+ 'positive control sees the repeated ledger path when --hide-ledger is absent');
272
+ assert.ok(candidate(noHideJson, 'docs/error-handling/generated.md', 'doc'),
273
+ 'positive control sees the generated copy path when --hide-ledger is absent');
274
+
275
+ const explicitOut = path.join(TMP, 'explicit-reports');
276
+ const explicitArgs = [
277
+ '--root', repo, '--out', explicitOut, '--hide-ledger', '--home', home,
278
+ '--memory', explicitMemory, '--memory', explicitMemoryDir,
279
+ '--instructions', globalInstructions, '--instructions', localInstructions
280
+ ];
281
+ const explicitPayload = reportFrom(run(explicitArgs, home));
282
+ const explicitJson = JSON.parse(fs.readFileSync(explicitPayload.reportJson, 'utf8'));
283
+ assert.ok(candidate(explicitJson, 'src/parser.js', 'memory'), 'explicit memory paths create candidates');
284
+ assert.ok(candidate(explicitJson, 'src/single.js', 'memory'), 'explicit memory directories create candidates');
285
+ assert.ok(explicitJson.options.memory.every(ref => /^local\/[a-f0-9]{64}$/.test(ref)),
286
+ 'explicit memory input summaries use opaque local IDs');
287
+ assert.ok(explicitJson.options.instructions.every(ref => /^local\/[a-f0-9]{64}$/.test(ref)),
288
+ 'explicit instruction input summaries use opaque local IDs');
289
+ assert.ok(!inside(repo, explicitPayload.reportJson) && !inside(repo, explicitPayload.reportMd),
290
+ 'successful explicit output stays outside the target');
291
+ const explicitMemoryRefs = explicitJson.sources
292
+ .filter(source => source.type === 'memory' && source.origin === 'explicit')
293
+ .map(source => source.ref);
294
+ assert.strictEqual(new Set(explicitMemoryRefs).size, explicitMemoryRefs.length,
295
+ 'distinct explicit memory inputs retain distinct opaque IDs');
296
+ assert.ok(explicitJson.sources.filter(source => source.type === 'instruction' && source.origin === 'global-explicit')
297
+ .every(source => /^local\/[a-f0-9]{64}$/.test(source.ref)),
298
+ 'explicit instruction source status uses opaque local IDs');
299
+ const explicitInstructionCandidates = explicitJson.candidates.filter(item =>
300
+ item.sources.some(source => source.type === 'instruction' && /^local\//.test(source.ref)));
301
+ assert.strictEqual(explicitInstructionCandidates.length, 2, 'both explicit instruction inputs produce local leads');
302
+ assert.ok(explicitInstructionCandidates.every(item => item.title === 'Local instruction lead' &&
303
+ item.sources.every(source => source.type !== 'instruction' || /^local\/[a-f0-9]{64}$/.test(source.ref))),
304
+ 'explicit instruction provenance uses opaque local IDs and neutral titles');
305
+ assert.ok(explicitJson.candidates.filter(item => item.sources.some(source => source.type === 'memory'))
306
+ .every(item => item.title === 'Local memory lead'), 'explicit memory candidates use neutral titles');
307
+ assert.ok(!JSON.stringify(explicitJson).includes(home) && !JSON.stringify(explicitJson).includes(repo));
308
+ const explicitMd = fs.readFileSync(explicitPayload.reportMd, 'utf8');
309
+ assert.doesNotMatch(JSON.stringify(explicitJson), privateSentinels,
310
+ 'explicit-memory JSON excludes private input sentinels');
311
+ assert.doesNotMatch(explicitMd, privateSentinels,
312
+ 'explicit-memory Markdown excludes private input sentinels');
313
+ assert.ok(!explicitMd.includes(home) && !explicitMd.includes(repo));
314
+ assert.ok(!explicitJson.candidates.some(item => /other global instruction sentinel/i.test(JSON.stringify(item))),
315
+ 'unselected global instruction files stay ignored');
316
+
317
+ const noMemoryOut = path.join(TMP, 'no-memory-reports');
318
+ const noMemoryPayload = reportFrom(run([
319
+ '--root', repo, '--out', noMemoryOut, '--hide-ledger', '--home', home,
320
+ '--memory', explicitMemory, '--instructions', globalInstructions,
321
+ '--instructions', localInstructions, '--no-memory'
322
+ ], home));
323
+ const noMemoryJson = JSON.parse(fs.readFileSync(noMemoryPayload.reportJson, 'utf8'));
324
+ const noMemoryMd = fs.readFileSync(noMemoryPayload.reportMd, 'utf8');
325
+ assert.ok(!noMemoryJson.candidates.some(item => item.sources.some(source => ['memory', 'instruction'].includes(source.type))));
326
+ assert.ok(noMemoryJson.sources.filter(source => ['memory', 'instruction'].includes(source.type))
327
+ .every(source => source.status === 'disabled'), '--no-memory disables memory and all instruction inputs');
328
+ assert.ok(noMemoryJson.options.memory.every(ref => /^local\/[a-f0-9]{64}$/.test(ref)) &&
329
+ noMemoryJson.options.instructions.every(ref => /^local\/[a-f0-9]{64}$/.test(ref)),
330
+ '--no-memory input summaries retain opaque local IDs');
331
+ assert.ok(noMemoryJson.sources.filter(source => ['memory', 'instruction'].includes(source.type) && source.ref)
332
+ .every(source => /^local\/[a-f0-9]{64}$/.test(source.ref)),
333
+ '--no-memory source status retains opaque local IDs');
334
+ assert.doesNotMatch(JSON.stringify(noMemoryJson), privateSentinels, '--no-memory source labels omit private path sentinels');
335
+ assert.doesNotMatch(noMemoryMd, privateSentinels, '--no-memory Markdown omits private path sentinels');
336
+
337
+ const trackerFile = path.join(TMP, 'offline-issues.json');
338
+ writeFile(trackerFile, JSON.stringify([
339
+ {
340
+ number: 421,
341
+ title: 'Parser loses token',
342
+ labels: [{ name: 'BUG' }],
343
+ body: 'Regression at src/parser.js; missing/path.js is not in the repository. TRACKER_PRIVATE_BODY_SENTINEL',
344
+ closedAt: null,
345
+ state: 'OPEN'
346
+ },
347
+ {
348
+ number: 422,
349
+ title: 'Add another parser option',
350
+ labels: [{ name: 'enhancement' }],
351
+ body: 'src/parser.js',
352
+ closedAt: null,
353
+ state: 'OPEN'
354
+ },
355
+ {
356
+ number: 423,
357
+ title: 'Fix command documentation',
358
+ labels: [{ name: 'enhancement' }],
359
+ body: 'guide.md',
360
+ closedAt: null,
361
+ state: 'OPEN'
362
+ },
363
+ {
364
+ number: 424,
365
+ title: 'bug: parser issue without a bug label',
366
+ labels: [{ name: 'enhancement' }],
367
+ body: 'src/single.js',
368
+ closedAt: null,
369
+ state: 'OPEN'
370
+ },
371
+ {
372
+ number: 425,
373
+ title: 'Intermittent parser failure',
374
+ labels: [{ name: 'Regression' }],
375
+ body: 'src/parser.js',
376
+ closedAt: null,
377
+ state: 'OPEN'
378
+ },
379
+ {
380
+ number: 426,
381
+ title: 'Flaky parser failure',
382
+ labels: [{ name: 'FlAkE' }],
383
+ body: 'src/parser.js',
384
+ closedAt: null,
385
+ state: 'OPEN'
386
+ }
387
+ ], null, 2));
388
+ const secondTrackerFile = path.join(TMP, 'offline-issues-2.json');
389
+ writeFile(secondTrackerFile, JSON.stringify([{
390
+ number: 427,
391
+ title: 'Another intermittent issue',
392
+ labels: [{ name: 'regression' }],
393
+ body: 'docs/single.md',
394
+ closedAt: null,
395
+ state: 'OPEN'
396
+ }], null, 2));
397
+ const trackerOut = path.join(TMP, 'tracker-reports');
398
+ const trackerPayload = reportFrom(run([
399
+ '--root', repo, '--out', trackerOut, '--hide-ledger', '--home', home,
400
+ '--no-memory', '--tracker', trackerFile, '--tracker', secondTrackerFile
401
+ ], home));
402
+ const trackerJsonText = fs.readFileSync(trackerPayload.reportJson, 'utf8');
403
+ const trackerJson = JSON.parse(trackerJsonText);
404
+ const trackerMd = fs.readFileSync(trackerPayload.reportMd, 'utf8');
405
+ const bugCandidate = candidate(trackerJson, 'src/parser.js', 'tracker');
406
+ assert.ok(bugCandidate, 'a bug-labelled offline issue mentioning an existing path creates a candidate');
407
+ assert.deepStrictEqual(bugCandidate.sites, ['src/parser.js']);
408
+ assert.deepStrictEqual(bugCandidate.sources, [{ type: 'tracker', ref: '#421' }],
409
+ 'tracker candidate source exposes only its issue reference');
410
+ assert.ok(candidate(trackerJson, 'guide.md', 'tracker'), 'a fix-prefixed title qualifies without a bug label');
411
+ assert.ok(trackerJson.candidates.some(item => item.sources.some(source => source.type === 'tracker' && source.ref === '#424')),
412
+ 'a bug-prefixed title qualifies without a bug label');
413
+ assert.ok(trackerJson.candidates.some(item => item.sources.some(source => source.type === 'tracker' && source.ref === '#425')),
414
+ 'regression labels qualify case-insensitively');
415
+ assert.ok(trackerJson.candidates.some(item => item.sources.some(source => source.type === 'tracker' && source.ref === '#426')),
416
+ 'flake labels qualify case-insensitively');
417
+ assert.ok(candidate(trackerJson, 'docs/single.md', 'tracker'), 'repeated --tracker options include each offline export');
418
+ assert.strictEqual(trackerJson.sources.filter(source => source.type === 'tracker').length, 2);
419
+ assert.ok(trackerMd.includes('#421'), 'Markdown report includes tracker issue references');
420
+ assert.ok(!trackerJson.candidates.some(item => item.sources.some(source => source.type === 'tracker' && source.ref === '#422')),
421
+ 'an unlabelled non-bug issue is ignored');
422
+ assert.strictEqual(trackerJson.sources.find(source => source.type === 'tracker').status, 'used');
423
+ assert.ok(candidate(trackerJson, 'guide.md', 'doc'), '--no-memory leaves docs history enabled');
424
+ assert.ok(!trackerJson.candidates.some(item => item.sources.some(source => ['memory', 'instruction'].includes(source.type))));
425
+ assert.ok(!trackerJsonText.includes('TRACKER_PRIVATE_BODY_SENTINEL') && !trackerMd.includes('TRACKER_PRIVATE_BODY_SENTINEL'),
426
+ 'tracker issue bodies never appear in either report');
427
+
428
+ const missingTracker = run([
429
+ '--root', repo, '--hide-ledger', '--home', home,
430
+ '--tracker', path.join(TMP, 'missing-issues.json')
431
+ ], home);
432
+ const missingTrackerPayload = reportFrom(missingTracker, 2);
433
+ assert.strictEqual(missingTrackerPayload.ok, false);
434
+ assert.match(missingTrackerPayload.error, /tracker/i);
435
+
436
+ const repeatOut = path.join(TMP, 'repeat-reports');
437
+ const repeatPayload = reportFrom(run([
438
+ '--root', repo, '--out', repeatOut, '--hide-ledger', '--home', home
439
+ ], home));
440
+ const repeatJson = JSON.parse(fs.readFileSync(repeatPayload.reportJson, 'utf8'));
441
+ assert.strictEqual(candidate(repeatJson, 'src/parser.js', 'git').id, parserLead.id,
442
+ 'candidate id is stable across report runs');
443
+ assert.strictEqual(candidate(repeatJson, 'src/parser.js', 'memory').id, autoMemoryLead.id,
444
+ 'private candidate id is stable across report runs');
445
+
446
+ writeFile(autoMemory, '---\ntype: feedback\ntitle: unrelated auto memory\n---\n## Cue\nAn unrelated local note.\n## Lesson\nNo repository site is named.\n');
447
+ const unverifiedOut = path.join(TMP, 'unverified-reports');
448
+ const unverifiedPayload = reportFrom(run(['--root', repo, '--out', unverifiedOut, '--hide-ledger', '--home', home], home));
449
+ const unverifiedJson = JSON.parse(fs.readFileSync(unverifiedPayload.reportJson, 'utf8'));
450
+ const unverifiedSource = unverifiedJson.sources.find(source => source.type === 'memory' && source.origin === 'auto');
451
+ assert.strictEqual(unverifiedSource.status, 'unverified');
452
+ assert.strictEqual(unverifiedSource.verified, false);
453
+ assert.ok(unverifiedSource.reason);
454
+ assert.ok(!unverifiedJson.candidates.some(item => item.sources.some(source => source.type === 'memory')),
455
+ 'unverified automatic memory is not used');
456
+
457
+ const memoryMarker = path.join(path.dirname(autoMemoryDir), 'MEMORY.md');
458
+ writeFile(memoryMarker, '# Memory index\n');
459
+ const markerOut = path.join(TMP, 'memory-marker-reports');
460
+ const markerPayload = reportFrom(run(['--root', repo, '--out', markerOut, '--hide-ledger', '--home', home], home));
461
+ const markerJson = JSON.parse(fs.readFileSync(markerPayload.reportJson, 'utf8'));
462
+ const markerSource = markerJson.sources.find(source => source.type === 'memory' && source.origin === 'auto');
463
+ assert.strictEqual(markerSource.status, 'used');
464
+ assert.strictEqual(markerSource.verified, true);
465
+ assert.match(markerSource.verificationRef, /^local\/[a-f0-9]{64}$/);
466
+ assert.ok(markerSource.reason.includes('memory marker'));
467
+ assert.ok(markerJson.candidates.some(item => item.sources.some(source => source.type === 'memory')),
468
+ 'MEMORY.md verifies the hinted directory');
469
+ fs.rmSync(memoryMarker);
470
+
471
+ const insideOut = path.join(repo, 'must-not-be-created');
472
+ const insideResult = run(['--root', repo, '--out', insideOut, '--hide-ledger', '--home', home], home);
473
+ const insidePayload = reportFrom(insideResult, 2);
474
+ assert.strictEqual(insidePayload.ok, false);
475
+ assert.match(insidePayload.error, /inside|target|root/i);
476
+ assert.strictEqual(fs.existsSync(insideOut), false, 'direct in-root output refusal writes nothing');
477
+
478
+ const symlinkOut = path.join(TMP, 'output-link');
479
+ fs.symlinkSync(path.join(repo, 'inside-output'), symlinkOut, process.platform === 'win32' ? 'junction' : 'dir');
480
+ const symlinkResult = run(['--root', repo, '--out', path.join(symlinkOut, 'child'), '--hide-ledger', '--home', home], home);
481
+ const symlinkPayload = reportFrom(symlinkResult, 2);
482
+ assert.strictEqual(symlinkPayload.ok, false);
483
+ assert.match(symlinkPayload.error, /inside|target|root/i);
484
+ assert.deepStrictEqual(fs.readdirSync(path.join(repo, 'inside-output')), ['.keep'],
485
+ 'symlinked in-root output refusal writes nothing');
486
+
487
+ const badArgs = reportFrom(run(['--root', repo, '--unknown', 'x', '--home', home], home), 2);
488
+ assert.strictEqual(badArgs.ok, false, 'bad arguments use refusal exit code');
489
+
490
+ const fileAsDirectory = path.join(TMP, 'not-a-directory');
491
+ writeFile(fileAsDirectory, 'not a directory\n');
492
+ const internalFailure = reportFrom(run(['--root', repo, '--out', fileAsDirectory, '--home', home], home), 1);
493
+ assert.strictEqual(internalFailure.ok, false, 'internal errors use exit code 1');
494
+
495
+ const win32 = path.win32;
496
+ assert.strictEqual(isWithin('C:\\Repo', 'c:\\repo\\src\\file.js', win32), true,
497
+ 'Windows containment compares paths case-insensitively');
498
+ assert.strictEqual(isWithin('C:\\Repo', 'D:\\temp\\file.js', win32), false,
499
+ 'Windows cross-drive relative paths remain outside');
500
+ assert.strictEqual(isWithin('C:\\Repo', 'C:\\Repo\\..cache\\file.js', win32), true,
501
+ 'a child beginning with two dots is still inside');
502
+
503
+ assert.strictEqual(git(repo, ['status', '--porcelain']), statusBefore,
504
+ 'scanner leaves the target repository unchanged');
505
+
506
+ const acceptanceFailures = [];
507
+ const checkAcceptance = (passed, message) => {
508
+ if (!passed) acceptanceFailures.push(message);
509
+ };
510
+ const overflowShim = path.join(TMP, 'git-overflow-preload.js');
511
+ writeFile(overflowShim, [
512
+ "'use strict';",
513
+ "const childProcess = require('node:child_process');",
514
+ "const fs = require('node:fs');",
515
+ 'const original = childProcess.execFileSync;',
516
+ 'const calls = [];',
517
+ 'function save() { fs.writeFileSync(process.env.SCAN_MARKER, JSON.stringify(calls)); }',
518
+ 'childProcess.execFileSync = function (file, args, options) {',
519
+ " const command = file === 'git' ? args[2] : null;",
520
+ " const call = { command, maxBuffer: options && options.maxBuffer, result: 'ok' };",
521
+ ' if (command === process.env.SCAN_FAIL_COMMAND) {',
522
+ " call.result = 'failed';",
523
+ ' calls.push(call);',
524
+ ' save();',
525
+ " const error = new Error('synthetic subprocess failure');",
526
+ " error.code = process.env.SCAN_FAIL_CODE || 'ENOBUFS';",
527
+ " error.stdout = Buffer.from('GIT_CAPTURED_OUTPUT_SENTINEL');",
528
+ " error.stderr = Buffer.from('GIT_CAPTURED_STDERR_SENTINEL');",
529
+ ' throw error;',
530
+ ' }',
531
+ ' const result = original.call(this, file, args, options);',
532
+ ' if (command) { calls.push(call); save(); }',
533
+ ' return result;',
534
+ '};',
535
+ ''
536
+ ].join('\n'));
537
+
538
+ for (const scenario of [
539
+ { command: 'log', code: 'ENOBUFS', label: 'log overflow', checkDiagnostic: true },
540
+ { command: 'ls-files', code: 'ENOBUFS', label: 'ls-files overflow', checkDiagnostic: true },
541
+ { command: 'rev-parse', code: 'EIO', label: 'ordinary Git failure', checkDiagnostic: false }
542
+ ]) {
543
+ const output = path.join(TMP, `overflow-${scenario.command}-reports`);
544
+ const marker = path.join(TMP, `overflow-${scenario.command}-calls.json`);
545
+ const result = run([
546
+ '--root', repo, '--out', output, '--hide-ledger', '--no-memory', '--home', home
547
+ ], home, overflowShim, {
548
+ SCAN_FAIL_COMMAND: scenario.command,
549
+ SCAN_FAIL_CODE: scenario.code,
550
+ SCAN_MARKER: marker
551
+ });
552
+ checkAcceptance(result.status !== 0, `${scenario.label}: scanner must exit nonzero`);
553
+ checkAcceptance(!result.stderr.includes('GIT_CAPTURED_') && !result.stdout.includes('GIT_CAPTURED_'),
554
+ `${scenario.label}: captured child output must stay out of diagnostics`);
555
+ checkAcceptance(!fs.existsSync(output), `${scenario.label}: no partial report directory may be created`);
556
+
557
+ let failurePayload;
558
+ let calls;
559
+ try {
560
+ failurePayload = JSON.parse(result.stdout);
561
+ calls = JSON.parse(fs.readFileSync(marker, 'utf8'));
562
+ } catch (cause) {
563
+ acceptanceFailures.push(`${scenario.label}: expected failure JSON and subprocess trace (${cause.message})`);
564
+ continue;
565
+ }
566
+ checkAcceptance(failurePayload.ok === false && !failurePayload.reportJson && !failurePayload.reportMd,
567
+ `${scenario.label}: failure must not return a success payload`);
568
+ checkAcceptance(calls.some(call => call.command === scenario.command && call.result === 'failed'),
569
+ `${scenario.label}: injected subprocess failure must reach the real scanner`);
570
+ if (scenario.checkDiagnostic) {
571
+ checkAcceptance(result.stderr.includes(`git ${scenario.command}`) &&
572
+ result.stderr.includes(`${GIT_MAX_BUFFER} bytes`),
573
+ `${scenario.label}: diagnostic must name the Git command and ${GIT_MAX_BUFFER}-byte limit`);
574
+ checkAcceptance(calls.find(call => call.command === scenario.command)?.maxBuffer === GIT_MAX_BUFFER,
575
+ `${scenario.label}: subprocess must receive the configured ${GIT_MAX_BUFFER}-byte limit`);
576
+ } else {
577
+ checkAcceptance(failurePayload.error === 'git rev-parse failed for the target repository',
578
+ 'ordinary Git failures must keep the existing diagnostic path');
579
+ }
580
+ if (scenario.command === 'ls-files') {
581
+ checkAcceptance(calls.some(call => call.command === 'log' && call.result === 'ok'),
582
+ 'ls-files overflow must occur after history inventory succeeds');
583
+ }
584
+ }
585
+
586
+ const largeRepo = path.join(TMP, 'large');
587
+ fs.mkdirSync(largeRepo, { recursive: true });
588
+ git(largeRepo, ['init', '-q']);
589
+ git(largeRepo, ['config', 'user.name', 'Scanner Fixture']);
590
+ git(largeRepo, ['config', 'user.email', 'scanner@example.invalid']);
591
+ git(largeRepo, ['config', 'commit.gpgsign', 'false']);
592
+ const historyFiles = { 'src/repeated.js': 'initial\n' };
593
+ const historyNameSuffix = 'x'.repeat(142);
594
+ for (let i = 0; i < 14000; i++) {
595
+ historyFiles[`history-${String(i).padStart(5, '0')}-${historyNameSuffix}.txt`] = 'history\n';
596
+ }
597
+ commit(largeRepo, 'feat: seed large history', historyFiles, 0);
598
+ commit(largeRepo, 'fix: first repeated change', { 'src/repeated.js': 'first fix\n' }, 1);
599
+ commit(largeRepo, 'fix: second repeated change', { 'src/repeated.js': 'second fix\n' }, 2);
600
+ const history = childProcess.execFileSync('git', [
601
+ '-C', largeRepo, 'log', '-z', '--name-status', '--format=%H%x00%s'
602
+ ], { encoding: 'buffer', maxBuffer: GIT_MAX_BUFFER });
603
+ checkAcceptance(history.length > 2 * 1024 * 1024,
604
+ `large-history fixture must emit more than 2 MiB (measured ${history.length} bytes)`);
605
+ checkAcceptance(history.length < GIT_MAX_BUFFER,
606
+ `large-history fixture must remain below ${GIT_MAX_BUFFER} bytes (measured ${history.length} bytes)`);
607
+ const largeOutput = path.join(TMP, 'large-history-reports');
608
+ const largeResult = run([
609
+ '--root', largeRepo, '--out', largeOutput, '--hide-ledger', '--no-memory', '--home', home
610
+ ], home);
611
+ checkAcceptance(largeResult.status === 0,
612
+ `history larger than 2 MiB must scan successfully; exit=${largeResult.status}, stderr=${largeResult.stderr.trim()}`);
613
+ try {
614
+ const largePayload = JSON.parse(largeResult.stdout);
615
+ checkAcceptance(largePayload.ok === true, 'large-history scan must return a success payload');
616
+ if (largePayload.ok) {
617
+ const largeJson = JSON.parse(fs.readFileSync(largePayload.reportJson, 'utf8'));
618
+ const largeMarkdown = fs.readFileSync(largePayload.reportMd, 'utf8');
619
+ const repeated = candidate(largeJson, 'src/repeated.js', 'git');
620
+ checkAcceptance(largeJson.candidates.length === largePayload.counts.candidates &&
621
+ fs.existsSync(largePayload.reportMd), 'large JSON and Markdown reports must be complete');
622
+ checkAcceptance(Boolean(repeated) && repeated.sources.length === 2,
623
+ 'large-history report must retain the repeated-fix candidate and both provenance rows');
624
+ if (repeated) {
625
+ checkAcceptance(repeated.sources.every(source => /^[a-f0-9]{40}$/.test(source.sha) && source.subject),
626
+ 'repeated-fix provenance must retain commit SHAs and subjects');
627
+ checkAcceptance(repeated.sources.every(source => largeMarkdown.includes(source.sha)),
628
+ 'Markdown report must retain repeated-fix provenance');
629
+ }
630
+ }
631
+ } catch (cause) {
632
+ acceptanceFailures.push(`large-history report must be valid JSON with complete report files (${cause.message})`);
633
+ }
634
+ assert.deepStrictEqual(acceptanceFailures, [], `G3 acceptance failures:\n${acceptanceFailures.join('\n')}`);
635
+
636
+ console.log(`Error-ledger scan CLI verified: ${defaultJson.candidates.length} candidates, ${parserLead.sources.length} parser leads; large history ${history.length} bytes.`);
637
+ } finally {
638
+ for (const directory of defaultReports) fs.rmSync(directory, { recursive: true, force: true });
639
+ fs.rmSync(TMP, { recursive: true, force: true });
640
+ }