harness-everything 0.46.2 → 0.47.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 (32) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +30 -1
  4. package/benchmarks/results/live-host/claude-341-outline-dispatch-2026-10-28/README.md +33 -8
  5. package/benchmarks/results/live-host/claude-341-outline-dispatch-2026-10-28/inventory/2741bd4514d2cd68f57d93a2b3ce94cbe597ca62d30e26f0ca58e882df5b03c6.md +128 -0
  6. package/benchmarks/results/live-host/claude-341-outline-dispatch-2026-10-28/sanitize-outline-capture.js +105 -0
  7. package/ci/mechanism-e1-derived-regenerate.test.js +333 -0
  8. package/ci/mechanism-outline-sanitizer.test.js +79 -0
  9. package/ci/mechanism-prb-outline-review.test.js +318 -31
  10. package/docs/doc-workflow-reconciliation.md +12 -8
  11. package/docs/platform-capabilities.md +1 -1
  12. package/harness-everything/SKILL.md +1 -1
  13. package/harness-everything/scripts/doc-check.js +106 -8
  14. package/harness-everything/scripts/doc-lifecycle.js +49 -1
  15. package/hooks/scripts/lib/doc-reconciliation-events.js +22 -0
  16. package/hooks/scripts/lib/doc-reconciliation-outline-capture.sanitized.jsonl +24 -0
  17. package/hooks/scripts/lib/doc-reconciliation-pilot.js +3 -1
  18. package/hooks/scripts/lib/doc-reconciliation-provider.js +182 -13
  19. package/hooks/scripts/lib/doc-reconciliation-qualification.json +20 -0
  20. package/opencode-plugin/plugin.json +1 -1
  21. package/package.json +1 -1
  22. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  23. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-events.js +22 -0
  24. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-outline-capture.sanitized.jsonl +24 -0
  25. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-pilot.js +3 -1
  26. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-provider.js +182 -13
  27. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-qualification.json +20 -0
  28. package/plugins/harness-everything/plugin.json +1 -1
  29. package/plugins/harness-everything/skills/harness-everything/SKILL.md +1 -1
  30. package/plugins/harness-everything/skills/harness-everything/scripts/doc-check.js +106 -8
  31. package/plugins/harness-everything/skills/harness-everything/scripts/doc-lifecycle.js +49 -1
  32. package/sbom.cdx.json +7 -7
@@ -0,0 +1,333 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ // Deterministic mechanism evidence: these checks use synthetic host envelopes,
5
+ // not a live Claude capture. The packet's throwaway-clone witness covers pilot.assess.
6
+ const assert = require('node:assert/strict');
7
+ const crypto = require('node:crypto');
8
+ const fs = require('node:fs');
9
+ const os = require('node:os');
10
+ const path = require('node:path');
11
+ const { spawnSync } = require('node:child_process');
12
+
13
+ const ROOT = path.resolve(process.env.E1_TEST_ROOT || path.join(__dirname, '..'));
14
+ const CHECK = path.join(ROOT, 'harness-everything/scripts/doc-check.js');
15
+ const LIFECYCLE = path.join(ROOT, 'harness-everything/scripts/doc-lifecycle.js');
16
+ const CONFIG = '.agents/harness-everything/project-docs.json';
17
+ const SOURCE = 'docs/adr/EVID-001-verify-all-evidence.md';
18
+ const VIEW = 'docs/governed-index.md';
19
+ const GENERATOR = 'node harness-everything/scripts/doc-lifecycle.js index --workspace . --config ' + CONFIG + ' --all';
20
+ const roots = [];
21
+ const sha = bytes => crypto.createHash('sha256').update(bytes).digest('hex');
22
+ const provider = () => require(path.join(ROOT, 'hooks/scripts/lib/doc-reconciliation-provider.js'));
23
+ const producer = () => require(path.join(ROOT, 'hooks/scripts/lib/doc-reconciliation-producer.js'));
24
+ const events = () => require(path.join(ROOT, 'hooks/scripts/lib/doc-reconciliation-events.js'));
25
+ const core = () => require(path.join(ROOT, 'hooks/scripts/lib/doc-reconciliation-core.js'));
26
+ const pilot = () => require(path.join(ROOT, 'hooks/scripts/lib/doc-reconciliation-pilot.js'));
27
+
28
+ function write(root, relative, bytes) {
29
+ const file = path.join(root, relative);
30
+ fs.mkdirSync(path.dirname(file), { recursive: true });
31
+ fs.writeFileSync(file, bytes);
32
+ }
33
+
34
+ function fixture(generator = GENERATOR) {
35
+ const root = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'e1-derived-regenerate-')));
36
+ roots.push(root);
37
+ const config = {
38
+ governed: [{ path: 'docs/adr/*.md', role: 'adr' }],
39
+ domains: ['EVID'],
40
+ derived: [{ path: VIEW, generator }],
41
+ };
42
+ write(root, CONFIG, JSON.stringify(config, null, 2) + '\n');
43
+ write(root, SOURCE, '---\nid: EVID-001\nrole: adr\nstatus: proposed\n---\n\n# EVID-001\n\n## Decision\n\nRetain evidence identities for generated views.\n');
44
+ fs.mkdirSync(path.join(root, 'harness-everything/scripts'), { recursive: true });
45
+ fs.copyFileSync(LIFECYCLE, path.join(root, 'harness-everything/scripts/doc-lifecycle.js'));
46
+ fs.copyFileSync(path.join(ROOT, 'harness-everything/scripts/project-docs-resolver.js'), path.join(root, 'harness-everything/scripts/project-docs-resolver.js'));
47
+ const generated = spawnSync(process.execPath, [path.join(root, 'harness-everything/scripts/doc-lifecycle.js'), 'index', '--workspace', root, '--config', CONFIG, '--all'], { cwd: root, encoding: 'utf8' });
48
+ assert.equal(generated.status, 0, generated.stderr);
49
+ write(root, VIEW, generated.stdout);
50
+ return root;
51
+ }
52
+
53
+ function runCheck(root, withView = true) {
54
+ const args = [CHECK, 'check', '--workspace', root, '--config', CONFIG, '--changed-path', SOURCE];
55
+ if (withView) args.push('--derived-view', VIEW);
56
+ return spawnSync(process.execPath, args, { cwd: root, encoding: 'utf8' });
57
+ }
58
+
59
+ function getReport(result) {
60
+ assert.ok(result.stdout, result.stderr);
61
+ return JSON.parse(result.stdout);
62
+ }
63
+
64
+ function capture(root, result) {
65
+ const command = 'node ' + CHECK + ' check --workspace ' + root + ' --config ' + CONFIG
66
+ + ' --changed-path ' + SOURCE + ' --derived-view ' + VIEW;
67
+ const record = provider().buildCaptureRecord({
68
+ cwd: root, session_id: 'synthetic-author', tool_name: 'Bash', tool_use_id: 'derived-check',
69
+ tool_input: { command }, tool_response: { stdout: result.stdout, interrupted: false },
70
+ }, 'PostToolUse', root);
71
+ record.observedIdentity = { workflowId: 'e1-test', workflowRevision: 1,
72
+ baselinePin: { commit: 'd'.repeat(40), root } };
73
+ return record;
74
+ }
75
+
76
+ function resolveDerived(root, record) {
77
+ const providerModule = provider();
78
+ const identity = {
79
+ workspaceId: 'ws-e1-test', sessionId: record.session_id, workflowId: 'e1-test', workflowRevision: 1,
80
+ taskId: 'task-e1-test', taskScopeDigest: '1'.repeat(64), baselineDigest: '2'.repeat(64),
81
+ candidateDigest: '3'.repeat(64), configDigest: '4'.repeat(64), prdRoot: 'docs/prd/',
82
+ };
83
+ const origin = providerModule.createClaudeOriginProvider({
84
+ hostId: 'claude-code', sessionId: record.session_id, workspaceRoot: root,
85
+ workflowId: identity.workflowId, workflowRevision: identity.workflowRevision, taskId: identity.taskId,
86
+ principals: { author: record.session_id, executors: [record.session_id] },
87
+ baseline: { commit: 'd'.repeat(40), root }, captures: [record],
88
+ qualification: { source: 'fake-test-fixture', faked: true, ref: 'e1-test', toolUseIdPopulated: true, agentIdPopulated: true },
89
+ });
90
+ return origin.resolveEvent({ reference: record.ref + '#derived-regenerate', identity });
91
+ }
92
+
93
+ function git(root, args) {
94
+ const result = spawnSync('git', ['-C', root, ...args], { encoding: 'utf8' });
95
+ assert.equal(result.status, 0, 'temporary Git fixture setup must succeed');
96
+ return result.stdout.trim();
97
+ }
98
+
99
+ function generateIndex(root) {
100
+ const result = spawnSync(process.execPath, [path.join(root, 'harness-everything/scripts/doc-lifecycle.js'),
101
+ 'index', '--workspace', root, '--config', CONFIG, '--all'], { cwd: root, encoding: 'utf8' });
102
+ assert.equal(result.status, 0, 'real lifecycle index generation must succeed');
103
+ write(root, VIEW, result.stdout);
104
+ }
105
+
106
+ function wholeSeamFixture() {
107
+ const root = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'e1-derived-whole-seam-')));
108
+ roots.push(root);
109
+ const config = {
110
+ governed: [{ path: 'docs/adr/*.md', role: 'adr' }],
111
+ domains: ['EVID'],
112
+ derived: [{ path: VIEW, generator: GENERATOR }],
113
+ };
114
+ const source = (status, text) => `---\nid: EVID-001\nrole: adr\nstatus: ${status}\n---\n\n# EVID-001\n\n## Decision\n\n${text}\n`;
115
+ write(root, CONFIG, JSON.stringify(config, null, 2) + '\n');
116
+ write(root, SOURCE, source('proposed', 'Baseline evidence identity.'));
117
+ fs.mkdirSync(path.join(root, 'harness-everything/scripts'), { recursive: true });
118
+ fs.copyFileSync(LIFECYCLE, path.join(root, 'harness-everything/scripts/doc-lifecycle.js'));
119
+ fs.copyFileSync(path.join(ROOT, 'harness-everything/scripts/project-docs-resolver.js'), path.join(root, 'harness-everything/scripts/project-docs-resolver.js'));
120
+ generateIndex(root);
121
+ git(root, ['init', '-q']);
122
+ git(root, ['add', '-A']);
123
+ git(root, ['-c', 'user.name=e1-fixture', '-c', 'user.email=e1-fixture@invalid', '-c', 'commit.gpgsign=false', 'commit', '-q', '--no-verify', '-m', 'baseline']);
124
+ const baselineCommit = git(root, ['rev-parse', 'HEAD']);
125
+ const baselineTree = git(root, ['rev-parse', 'HEAD^{tree}']);
126
+ write(root, SOURCE, source('accepted', 'Candidate evidence identity.'));
127
+ generateIndex(root);
128
+ return { root, baselineCommit, baselineTree };
129
+ }
130
+
131
+ function wholeSeam() {
132
+ const project = wholeSeamFixture();
133
+ const plain = runCheck(project.root, false);
134
+ assert.equal(plain.status, 0, 'plain-check positive control must pass on the Git fixture');
135
+ getReport(plain);
136
+
137
+ const checked = runCheck(project.root);
138
+ assert.equal(checked.status, 0, 'registered --derived-view check must produce a successful report');
139
+ const report = getReport(checked);
140
+ const projection = report.capabilities['derived-regenerate'];
141
+ assert.equal(projection.state, 'pass');
142
+ assert.deepEqual(projection.checkedPaths, [VIEW]);
143
+
144
+ const providerModule = provider();
145
+ const sessionId = 'synthetic-author';
146
+ const workflowId = 'e1-whole-seam';
147
+ const workflowRevision = 1;
148
+ const taskId = 'task-req-e1-derived';
149
+ const requirements = [{ id: 'req-e1-derived', summary: 'Regenerate the governed view', acceptance: 'the derived view matches the current source' }];
150
+ const qualification = { source: 'fake-test-fixture', faked: true, ref: 'e1-whole-seam',
151
+ toolUseIdPopulated: true, agentIdPopulated: true };
152
+ const command = 'node ' + CHECK + ' check --workspace ' + project.root + ' --config ' + CONFIG
153
+ + ' --changed-path ' + SOURCE + ' --derived-view ' + VIEW;
154
+ const record = providerModule.buildCaptureRecord({
155
+ cwd: project.root, session_id: sessionId, hook_event_name: 'PostToolUse', tool_name: 'Bash', tool_use_id: 'synthetic-derived-check',
156
+ tool_input: { command }, tool_response: { stdout: checked.stdout, interrupted: false },
157
+ }, 'PostToolUse', project.root);
158
+ assert.ok(record, 'synthetic host envelope must yield a captured check record');
159
+ record.observedIdentity = { workflowId, workflowRevision,
160
+ baselinePin: { commit: project.baselineCommit, root: project.root } };
161
+
162
+ const origin = providerModule.createClaudeOriginProvider({
163
+ hostId: 'claude-code', sessionId, workspaceRoot: project.root, workflowId, workflowRevision, taskId,
164
+ principals: { author: sessionId, executors: [sessionId] },
165
+ baseline: { commit: project.baselineCommit, root: project.root }, captures: [record], qualification,
166
+ });
167
+ const produced = producer().produceDocSnapshot({
168
+ workspaceRoot: project.root, baseline: { commit: project.baselineCommit, root: project.root },
169
+ workflow: { workflowId, sessionId, workflowRevision }, task: { taskId, requirements },
170
+ scope: { prdRoot: 'docs/prd/' }, activeHost: 'claude-code', prdRoot: 'docs/prd/',
171
+ }, { originProvider: origin });
172
+ assert.equal(produced.state, 'ready', 'production snapshot collector must produce a current snapshot');
173
+ const snapshot = produced.snapshot;
174
+ const obligation = snapshot.obligations.find(item => item.capability === 'derived-regenerate');
175
+ assert.ok(obligation, 'derived-regenerate must derive from the real baseline and candidate bytes');
176
+ assert.equal(obligation.id, 'doc-change:derived-regenerate');
177
+ assert.equal(obligation.strength, 'MUST');
178
+ assert.equal(obligation.applicability, 'applicable', 'derived-regenerate must not disappear as N/A');
179
+ assert.deepEqual(obligation.scope, { paths: [VIEW] });
180
+
181
+ const reference = record.ref + '#derived-regenerate';
182
+ const accepted = events().acceptDocEvents({ snapshot, eventRefs: [reference] }, { originProvider: origin });
183
+ assert.equal(accepted.state, 'ready', 'production adapter must accept the derived check reference');
184
+ const acceptedRecord = accepted.acceptedIndex[reference];
185
+ assert.ok(acceptedRecord, 'exact derived check reference must reach the adapter');
186
+ assert.equal(acceptedRecord.obligationId, obligation.id);
187
+ assert.deepEqual(acceptedRecord.paths, obligation.scope.paths);
188
+ assert.deepEqual(acceptedRecord.identity, snapshot.identity, 'accepted reference must bind the current snapshot identity');
189
+ assert.deepEqual(acceptedRecord.event.startIdentity, snapshot.identity);
190
+ assert.deepEqual(acceptedRecord.event.endIdentity, snapshot.identity);
191
+ assert.equal(acceptedRecord.event.derivedBinding.candidateDigest, snapshot.identity.candidateDigest);
192
+
193
+ const checkedEvidence = core().checkAcceptedDocEvidence({ snapshot, accepted, mode: 'verification' });
194
+ const derivedResult = checkedEvidence.results.find(item => item.obligationId === obligation.id);
195
+ assert.ok(checkedEvidence.checkedMustIds.includes(obligation.id), 'the exact derived MUST must reach reconciliation');
196
+ assert.equal(derivedResult.observation, 'observed');
197
+ assert.equal(derivedResult.outcome, 'pass');
198
+ assert.ok(derivedResult.recordRefs.includes(reference));
199
+ assert.ok(!checkedEvidence.unsatisfied.some(item => item.obligationId === obligation.id));
200
+
201
+ const sessionDir = fs.mkdtempSync(path.join(os.tmpdir(), 'e1-derived-session-'));
202
+ roots.push(sessionDir);
203
+ providerModule.writeImmutableEvent(sessionDir, record);
204
+ providerModule.rebuildJournalView(sessionDir);
205
+ const context = { root: project.root, sessionId, sessionDir, activeHost: 'claude-code', workflow: {
206
+ workflowId, revision: workflowRevision, strategy: 'iterative-single', state: 'running',
207
+ docReconciliationBaseline: { root: project.root, commit: project.baselineCommit, tree: project.baselineTree },
208
+ } };
209
+ const set = { strategy: 'iterative-single', stepBindingsEnabled: true, requirements };
210
+ const previousSwitch = process.env.HARNESS_DOC_RECONCILIATION_PILOT;
211
+ const originalFactory = providerModule.createClaudeOriginProvider;
212
+ providerModule.createClaudeOriginProvider = input => originalFactory({ ...input, qualification });
213
+ process.env.HARNESS_DOC_RECONCILIATION_PILOT = '1';
214
+ try {
215
+ const pilotResult = pilot().assess(context, set);
216
+ assert.ok(pilotResult.report.expectedMustIds.includes(obligation.id), 'pilot must retain the exact derived MUST in its expected set');
217
+ assert.ok(!pilotResult.report.unsatisfied.some(item => item.obligationId === obligation.id),
218
+ 'pilot consumer must observe the passing derived MUST');
219
+
220
+ fs.appendFileSync(path.join(project.root, VIEW), '\nmanual stale edit\n');
221
+ const stalePilot = pilot().assess(context, set);
222
+ assert.ok(stalePilot.report.expectedMustIds.includes(obligation.id), 'stale view must remain an expected derived MUST');
223
+ assert.ok(stalePilot.report.unsatisfied.some(item => item.obligationId === obligation.id),
224
+ 'consumer-level stale target negative must withhold the derived MUST');
225
+ } finally {
226
+ providerModule.createClaudeOriginProvider = originalFactory;
227
+ if (previousSwitch === undefined) delete process.env.HARNESS_DOC_RECONCILIATION_PILOT;
228
+ else process.env.HARNESS_DOC_RECONCILIATION_PILOT = previousSwitch;
229
+ }
230
+ }
231
+
232
+ try {
233
+ if (process.env.E1_BASELINE_RED === '1') {
234
+ const project = wholeSeamFixture();
235
+ const plain = runCheck(project.root, false);
236
+ assert.equal(plain.status, 0, 'pre-repair fixture plain-check positive control must pass');
237
+ getReport(plain);
238
+ const derived = runCheck(project.root);
239
+ const legacyReport = JSON.parse(derived.stdout);
240
+ assert.match(legacyReport.lint?.error || '', /unknown or incomplete argument: --derived-view/,
241
+ 'pre-repair compatibility control must identify the unsupported derived-view flag');
242
+ assert.equal(derived.status, 0,
243
+ `pre-repair primary RED: registered --derived-view check must reach the passing derived obligation; legacy parser rejected the flag (child exit ${derived.status})`);
244
+ const projection = getReport(derived).capabilities['derived-regenerate'];
245
+ assert.equal(projection?.state, 'pass', 'pre-repair primary RED: derived result must reach the passing obligation assertion');
246
+ } else {
247
+ const providerModule = provider();
248
+ const invocationCommand = 'node ' + CHECK + ' check --workspace ' + ROOT + ' --config ' + CONFIG
249
+ + ' --changed-path docs/doc-workflow-reconciliation.md --derived-view ' + VIEW;
250
+ const invocation = providerModule.resolveDocCheckInvocation(invocationCommand, ROOT);
251
+ assert.equal(invocation.kind, 'accepted', 'registered derived invocation rejected: ' + invocation.reason);
252
+ assert.equal(invocation.derivedView, VIEW);
253
+
254
+ const matching = fixture();
255
+ const matchingBytes = fs.readFileSync(path.join(matching, VIEW));
256
+ const matchingRun = runCheck(matching);
257
+ assert.equal(matchingRun.status, 0, matchingRun.stderr);
258
+ const matchingReport = getReport(matchingRun);
259
+ const positive = matchingReport.capabilities['derived-regenerate'];
260
+ assert.equal(positive.state, 'pass');
261
+ assert.deepEqual(positive.checkedPaths, [VIEW]);
262
+ assert.equal(positive.binding.generation.state, 'pass');
263
+ assert.equal(positive.binding.comparison.state, 'equal');
264
+ assert.equal(positive.binding.generation.outputDigest, sha(matchingBytes));
265
+ assert.equal(positive.binding.comparison.targetDigest, sha(matchingBytes));
266
+ assert.equal(positive.binding.sourceCorpus.complete, true);
267
+ assert.deepEqual(positive.binding.sourceCorpus.paths, [SOURCE]);
268
+ assert.equal(positive.binding.config.digest, sha(fs.readFileSync(path.join(matching, CONFIG))));
269
+ assert.equal(matchingReport.coverage.unsupported.some(item => item.path === VIEW), false);
270
+ const captured = capture(matching, matchingRun);
271
+ assert.equal(captured.implementationDigest, providerModule.SHIPPED_DOC_CHECK_DIGEST);
272
+ assert.equal(captured.observedDerivedDigests[SOURCE], positive.binding.sourceCorpus.digests[SOURCE]);
273
+ assert.equal(captured.observedDerivedDigests[VIEW], positive.binding.comparison.targetDigest);
274
+ assert.deepEqual(captured.observedDerivedConfigSources, positive.binding.config.sources);
275
+ const positiveResolution = resolveDerived(matching, captured);
276
+ assert.equal(positiveResolution.status, 'accepted', JSON.stringify(positiveResolution.diagnostics));
277
+
278
+ const stale = fixture();
279
+ const staleTarget = path.join(stale, VIEW);
280
+ fs.appendFileSync(staleTarget, '\nmanual stale edit\n');
281
+ const staleBefore = fs.readFileSync(staleTarget);
282
+ const staleRun = runCheck(stale);
283
+ assert.equal(staleRun.status, 0, staleRun.stderr);
284
+ const staleProjection = getReport(staleRun).capabilities['derived-regenerate'];
285
+ assert.equal(staleProjection.state, 'stale');
286
+ assert.equal(staleProjection.binding.generation.state, 'pass');
287
+ assert.equal(staleProjection.binding.comparison.state, 'stale');
288
+ assert.deepEqual(fs.readFileSync(staleTarget), staleBefore, 'stale target must not be rewritten');
289
+
290
+ const unsupportedMarker = 'GENERATOR_MUST_NOT_RUN';
291
+ const unsupportedGenerator = 'node -e ' + JSON.stringify('require("fs").writeFileSync("' + unsupportedMarker + '","ran")');
292
+ const unsupported = fixture(unsupportedGenerator);
293
+ const unsupportedRun = runCheck(unsupported);
294
+ const unsupportedProjection = getReport(unsupportedRun).capabilities['derived-regenerate'];
295
+ assert.equal(unsupportedProjection.state, 'unsupported');
296
+ assert.equal(fs.existsSync(path.join(unsupported, unsupportedMarker)), false, 'configured text must never be executed');
297
+
298
+ const changedAfterCheck = fixture();
299
+ const changedRun = runCheck(changedAfterCheck);
300
+ const changedBinding = getReport(changedRun).capabilities['derived-regenerate'].binding;
301
+ fs.appendFileSync(path.join(changedAfterCheck, SOURCE), '\nchanged after check\n');
302
+ const changedCapture = capture(changedAfterCheck, changedRun);
303
+ assert.notEqual(changedCapture.observedDerivedDigests[SOURCE], changedBinding.sourceCorpus.digests[SOURCE]);
304
+ const changedResponse = resolveDerived(changedAfterCheck, changedCapture);
305
+ assert.equal(changedResponse.status, 'rejected');
306
+ assert.ok(changedResponse.diagnostics.some(item => item.code === 'derived-input-changed-after-check'));
307
+
308
+ const configChanged = fixture();
309
+ const configRun = runCheck(configChanged);
310
+ fs.appendFileSync(path.join(configChanged, CONFIG), '\n');
311
+ const configCapture = capture(configChanged, configRun);
312
+ const configResponse = resolveDerived(configChanged, configCapture);
313
+ assert.equal(configResponse.status, 'rejected');
314
+ assert.ok(configResponse.diagnostics.some(item => item.code === 'derived-input-changed-after-check'));
315
+
316
+ const targetChanged = fixture();
317
+ const targetRun = runCheck(targetChanged);
318
+ fs.appendFileSync(path.join(targetChanged, VIEW), '\nchanged after check\n');
319
+ const targetCapture = capture(targetChanged, targetRun);
320
+ const targetResponse = resolveDerived(targetChanged, targetCapture);
321
+ assert.equal(targetResponse.status, 'rejected');
322
+ assert.ok(targetResponse.diagnostics.some(item => item.code === 'derived-input-changed-after-check'));
323
+
324
+ const plain = runCheck(matching, false);
325
+ assert.equal(plain.status, 0, plain.stderr);
326
+ assert.equal(getReport(plain).capabilities['derived-regenerate'], undefined);
327
+
328
+ wholeSeam();
329
+ console.log('PASS E1 registered invocation, producer-to-pilot derived MUST seam, consumer stale negative, bound generation, provider negatives, and plain-check firebreak (deterministic mechanism evidence)');
330
+ }
331
+ } finally {
332
+ for (const root of roots) fs.rmSync(root, { recursive: true, force: true });
333
+ }
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const assert = require('node:assert/strict');
5
+ const fs = require('node:fs');
6
+ const os = require('node:os');
7
+ const path = require('node:path');
8
+ const { spawnSync } = require('node:child_process');
9
+ const { _internals: providerInternals } = require('../hooks/scripts/lib/doc-reconciliation-provider');
10
+
11
+ const ROOT = path.resolve(__dirname, '..');
12
+ const SANITIZER = path.join(ROOT, 'benchmarks/results/live-host/claude-341-outline-dispatch-2026-10-28/sanitize-outline-capture.js');
13
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'outline-sanitizer-'));
14
+
15
+ function marker(token) {
16
+ return `HARNESS_OUTLINE_DISPATCH_V1 taskId=task-test attemptId=attempt-1 token=${token} workerRoot=/private/worker`;
17
+ }
18
+
19
+ function markerTokens(value) {
20
+ const tokens = [];
21
+ const strings = [];
22
+ const collect = item => {
23
+ if (typeof item === 'string') strings.push(item);
24
+ else if (Array.isArray(item)) item.forEach(collect);
25
+ else if (item && typeof item === 'object') Object.values(item).forEach(collect);
26
+ };
27
+ collect(value);
28
+ for (const text of strings) {
29
+ for (const match of text.matchAll(/HARNESS_OUTLINE_DISPATCH_V1[^\r\n]*?\btoken=([^\s]+)/g)) tokens.push(match[1]);
30
+ }
31
+ return tokens;
32
+ }
33
+
34
+ try {
35
+ const shortToken = 'OVERLAP-42';
36
+ const longToken = 'OVERLAP-42-long';
37
+ const input = path.join(dir, 'raw.jsonl');
38
+ const first = path.join(dir, 'first.jsonl');
39
+ const second = path.join(dir, 'second.jsonl');
40
+ const wrappers = [
41
+ { t: 1, payload: { hook_event_name: 'PreToolUse', session_id: 'synthetic-session', tool_name: 'Agent',
42
+ tool_use_id: 'toolu_synthetic1', tool_input: { prompt: `${marker(shortToken)}\nrepeat=${shortToken}` } } },
43
+ { t: 2, payload: { hook_event_name: 'PostToolUse', session_id: 'synthetic-session', tool_name: 'Agent',
44
+ tool_use_id: 'toolu_synthetic2', tool_input: { command: `echo ${shortToken} ${longToken}` },
45
+ tool_response: { stdout: `${marker(shortToken)}\n${marker(longToken)}\nrepeat=${longToken} ${shortToken}` } } },
46
+ ];
47
+ fs.writeFileSync(input, wrappers.map(item => JSON.stringify(item)).join('\n') + '\n');
48
+
49
+ for (const output of [first, second]) {
50
+ const run = spawnSync(process.execPath, [SANITIZER, input, output], { encoding: 'utf8' });
51
+ assert.equal(run.status, 0, 'sanitizer must accept the synthetic capture');
52
+ assert.ok(fs.existsSync(output), 'sanitizer must write the exported capture');
53
+ }
54
+
55
+ const bytes = fs.readFileSync(first);
56
+ assert.deepEqual(fs.readFileSync(second), bytes, 'synthetic token mappings must be stable across runs');
57
+ const text = bytes.toString('utf8');
58
+ assert.ok(!text.includes(shortToken) && !text.includes(longToken),
59
+ 'sanitized output must remove every marker token from nested exported strings');
60
+ const records = text.trimEnd().split('\n').map(line => JSON.parse(line));
61
+ assert.deepEqual(records.map(record => record.event), ['PreToolUse', 'PostToolUse'], 'sanitization must preserve record order');
62
+ assert.equal(Object.hasOwn(records[0], 'tool_response'), false, 'sanitization must preserve absent fields');
63
+ assert.equal(records[0].session_id, '<session-1>', 'existing session ID mapping remains a positive control');
64
+ const mapped = markerTokens(records);
65
+ assert.equal(mapped.length, 3, 'all exported marker occurrences must remain parseable');
66
+ assert.ok(mapped.every(token => token.length > 0 && !/\s/.test(token)), 'synthetic marker tokens must be nonempty and whitespace-free');
67
+ assert.equal(mapped[0], mapped[1], 'equal originals must map to equal placeholders');
68
+ assert.notEqual(mapped[0], mapped[2], 'different originals must map to distinct placeholders');
69
+ for (const record of records) {
70
+ for (const value of [record.tool_input?.prompt, record.tool_response?.stdout].filter(Boolean)) {
71
+ for (const line of value.split(/\r?\n/).filter(line => line.startsWith('HARNESS_OUTLINE_DISPATCH_V1 '))) {
72
+ assert.ok(providerInternals.parseOutlineDispatchPrompt(line), 'sanitized marker must retain the production parser grammar');
73
+ }
74
+ }
75
+ }
76
+ console.log('PASS sanitizer replaces repeated and overlapping marker tokens in nested exported strings');
77
+ } finally {
78
+ fs.rmSync(dir, { recursive: true, force: true });
79
+ }