harness-everything 1.3.0 → 1.3.1

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 (125) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +6 -0
  4. package/ci/archive/325-prep/README.md +9 -2
  5. package/ci/archive/325-prep/doc-reconciliation-red.js +34 -8
  6. package/ci/fixtures/553-t2a/body-edit/base/.agents/harness-everything/project-docs.json +11 -0
  7. package/ci/fixtures/553-t2a/body-edit/base/docs/a.md +6 -0
  8. package/ci/fixtures/553-t2a/body-edit/base/docs/b.md +1 -0
  9. package/ci/fixtures/553-t2a/body-edit/candidate/docs/a.md +6 -0
  10. package/ci/fixtures/553-t2c/derived-regenerate-must/base/docs/adr/EVID-001-verify-all-evidence.md +11 -0
  11. package/ci/fixtures/553-t2c/derived-regenerate-must/base/docs/governed-index.md +19 -0
  12. package/ci/fixtures/553-t2c/derived-regenerate-must/candidate/docs/adr/EVID-001-verify-all-evidence.md +11 -0
  13. package/ci/fixtures/553-t2c/derived-regenerate-must/candidate/docs/governed-index.md +19 -0
  14. package/ci/fixtures/553-t2c/derived-regenerate-must/config.json +17 -0
  15. package/ci/fixtures/doc-obligations/derive/regression-pins.json +153 -0
  16. package/ci/fixtures/state-persist-post-tool-use/harness.js +206 -0
  17. package/ci/fixtures/state-persist-post-tool-use/off-handoff-golden.json +16 -0
  18. package/ci/fixtures/state-persist-post-tool-use/payload-post-tool-use-success.json +13 -0
  19. package/ci/fixtures/stop/fail-session-writes.js +109 -0
  20. package/ci/fixtures/workflow-contract/cases.json +3355 -0
  21. package/ci/fixtures/workflow-contract/wiring-cases.json +560 -0
  22. package/ci/lib/doc-reconciliation-prep-fixtures.js +4 -9
  23. package/ci/mechanism-2an-workflow-replay.test.js +324 -0
  24. package/ci/mechanism-2ax-doc-lifecycle.test.js +132 -0
  25. package/ci/mechanism-325-3a-doc-evidence.test.js +73 -0
  26. package/ci/mechanism-325-3a-doc-obligations.test.js +61 -0
  27. package/ci/mechanism-325-3b-preparation.test.js +208 -49
  28. package/ci/mechanism-325-3b-s1-review.test.js +20 -828
  29. package/ci/mechanism-325-3b-s3-providers.test.js +59 -0
  30. package/ci/mechanism-325-f3-derived-views.test.js +140 -0
  31. package/ci/mechanism-341-opencode-lane.test.js +164 -284
  32. package/ci/mechanism-35-verification-contract.test.js +246 -0
  33. package/ci/mechanism-365-step-edit-accounting.test.js +5 -6
  34. package/ci/mechanism-383-doc-glob-line-terminators.test.js +0 -30
  35. package/ci/mechanism-397-opencode-observations.test.js +151 -18
  36. package/ci/mechanism-553-e1-unhook-credit.test.js +328 -0
  37. package/ci/mechanism-553-p2a-claude-hooks.test.js +98 -0
  38. package/ci/mechanism-553-p3-plan-start.test.js +212 -0
  39. package/ci/mechanism-553-state-persist-post-tool-use.test.js +307 -0
  40. package/ci/mechanism-553-stop.test.js +427 -0
  41. package/ci/mechanism-553-t2a-derive.test.js +110 -0
  42. package/ci/mechanism-553-t2c-derive.test.js +94 -0
  43. package/ci/mechanism-e1-derived-regenerate.test.js +45 -206
  44. package/ci/mechanism-outline-sanitizer.test.js +0 -8
  45. package/ci/mechanism-pr-a-conflict-check.test.js +38 -305
  46. package/ci/mechanism-prb-outline-review.test.js +101 -3283
  47. package/docs/adr/DOCS-006-reconciliation-pilot.md +4 -2
  48. package/docs/adr/DOCS-008-obligation-abstraction-bounded-consumer.md +3 -3
  49. package/docs/doc-workflow-reconciliation.md +17 -2
  50. package/docs/document-lifecycle.md +6 -2
  51. package/docs/platform-capabilities.md +35 -5
  52. package/hooks/hooks.json +0 -46
  53. package/hooks/scripts/lib/workflow-obligations.js +0 -55
  54. package/hooks/scripts/state-persist.js +7 -95
  55. package/hooks/scripts/workflow-disposition.js +0 -2
  56. package/hooks/scripts/workflow-stop-gate.js +17 -30
  57. package/opencode-plugin/index.mjs +6 -70
  58. package/opencode-plugin/plugin.json +1 -1
  59. package/package.json +1 -1
  60. package/plugins/harness-everything/.antigravity-plugin/plugin.json +1 -1
  61. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  62. package/plugins/harness-everything/hooks/scripts/lib/workflow-obligations.js +0 -55
  63. package/plugins/harness-everything/hooks/scripts/state-persist.js +7 -95
  64. package/plugins/harness-everything/hooks/scripts/workflow-disposition.js +0 -2
  65. package/plugins/harness-everything/hooks/scripts/workflow-stop-gate.js +17 -30
  66. package/plugins/harness-everything/plugin.json +1 -1
  67. package/sbom.cdx.json +7 -7
  68. package/ci/fixtures/doc-obligations/reconciliation-s1/cases.json +0 -6854
  69. package/ci/fixtures/doc-obligations/reconciliation-s1/fail-session-writes.js +0 -116
  70. package/ci/fixtures/doc-obligations/reconciliation-s2a/harness.js +0 -507
  71. package/ci/fixtures/doc-obligations/reconciliation-s2a/run13-workflow-requirements.json +0 -42
  72. package/ci/fixtures/doc-obligations/reconciliation-s2a/vectors.json +0 -617
  73. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/harness.js +0 -415
  74. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-post-tool-use-success-minimal.json +0 -9
  75. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-start.json +0 -7
  76. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-stop-freetext-reject.json +0 -11
  77. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-stop-reject.json +0 -11
  78. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-stop.json +0 -11
  79. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-task-result.json +0 -19
  80. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/off-capture-only.json +0 -99
  81. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/off-legacy.json +0 -67
  82. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-concurrent-writers.json +0 -62
  83. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-lookalikes-runtime-mutations.json +0 -67
  84. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-malformed.json +0 -85
  85. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-normal-session.json +0 -74
  86. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-runtime-drift-later-npm-test.json +0 -58
  87. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-valid-direct-quoted-review.json +0 -85
  88. package/ci/fixtures/doc-obligations/reconciliation-s2b/f4/cases.json +0 -2267
  89. package/ci/fixtures/doc-obligations/reconciliation-s2b/wiring/cases.json +0 -1110
  90. package/ci/lib/doc-reconciliation-file-spy.js +0 -23
  91. package/ci/lib/doc-reconciliation-qualification-preload.js +0 -37
  92. package/ci/lib/doc-reconciliation-replay.js +0 -104
  93. package/ci/lib/doc-reconciliation-staged-tree.js +0 -102
  94. package/ci/mechanism-325-3b-h1-qualification.test.js +0 -206
  95. package/ci/mechanism-325-3b-s1.test.js +0 -188
  96. package/ci/mechanism-325-3b-s2a-core.test.js +0 -840
  97. package/ci/mechanism-325-3b-s2a-producer.test.js +0 -564
  98. package/ci/mechanism-325-3b-s2b-capture.test.js +0 -566
  99. package/ci/mechanism-325-3b-s2b-wiring.test.js +0 -679
  100. package/ci/mechanism-325-f4-invariants.test.js +0 -606
  101. package/ci/mechanism-325-f4-projections.test.js +0 -392
  102. package/ci/mechanism-325-f4-qualification.test.js +0 -228
  103. package/ci/mechanism-325-f4-trust-boundary.test.js +0 -880
  104. package/ci/mechanism-e1-dependency-artifact-scope.test.js +0 -657
  105. package/hooks/scripts/lib/doc-reconciliation-capture.sanitized.jsonl +0 -26
  106. package/hooks/scripts/lib/doc-reconciliation-core.js +0 -336
  107. package/hooks/scripts/lib/doc-reconciliation-events.js +0 -292
  108. package/hooks/scripts/lib/doc-reconciliation-outline-capture.sanitized.jsonl +0 -24
  109. package/hooks/scripts/lib/doc-reconciliation-pilot.js +0 -482
  110. package/hooks/scripts/lib/doc-reconciliation-producer.js +0 -468
  111. package/hooks/scripts/lib/doc-reconciliation-provider.js +0 -3304
  112. package/hooks/scripts/lib/doc-reconciliation-qualification.json +0 -54
  113. package/hooks/scripts/w6-state-operations.js +0 -239
  114. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-capture.sanitized.jsonl +0 -26
  115. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-core.js +0 -336
  116. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-events.js +0 -292
  117. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-outline-capture.sanitized.jsonl +0 -24
  118. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-pilot.js +0 -482
  119. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-producer.js +0 -468
  120. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-provider.js +0 -3304
  121. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-qualification.json +0 -54
  122. package/plugins/harness-everything/hooks/scripts/w6-state-operations.js +0 -239
  123. package/scripts/system-one-eval-laya.js +0 -112
  124. /package/ci/fixtures/{doc-obligations/reconciliation-s2b/capture → state-persist-post-tool-use}/payload-post-tool-use-failure.json +0 -0
  125. /package/ci/fixtures/{doc-obligations/reconciliation-s2b/wiring → workflow-contract}/legacy-off-golden.json +0 -0
@@ -20,7 +20,6 @@ const ROOT = path.resolve(__dirname, '..');
20
20
  const PREP_DIR = path.join(__dirname, 'fixtures', 'doc-obligations', 'reconciliation-prep');
21
21
  const RUNNER = path.join(__dirname, 'archive', '325-prep', 'doc-reconciliation-red.js');
22
22
  const corpus = fx.readCaseCorpus(path.join(PREP_DIR, 'cases.json'));
23
- const registry = JSON.parse(fs.readFileSync(path.join(PREP_DIR, 'pending-red.json'), 'utf8'));
24
23
  const workDir = fs.mkdtempSync(path.join(os.tmpdir(), 'doc-recon-prep-suite-'));
25
24
 
26
25
  const ALLOWED_OPS = new Set(['route', 'plan', 'start', 'binding', 'step', 'obligation', 'stop', 'provideEvidence', 'mutateIdentity', 'timestampHints']);
@@ -30,7 +29,6 @@ const SHARED_FILES = [
30
29
  ['hooks/scripts/lib/workflow-obligations.js', 'plugins/harness-everything/hooks/scripts/lib/workflow-obligations.js'],
31
30
  ['hooks/scripts/workflow-disposition.js', 'plugins/harness-everything/hooks/scripts/workflow-disposition.js'],
32
31
  ['hooks/scripts/workflow-stop-gate.js', 'plugins/harness-everything/hooks/scripts/workflow-stop-gate.js'],
33
- ['hooks/scripts/lib/doc-reconciliation-pilot.js', 'plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-pilot.js'],
34
32
  ];
35
33
 
36
34
  let failed = 0;
@@ -44,6 +42,33 @@ function checkCase(name, runCase) {
44
42
  function runRunner(args) {
45
43
  return spawnSync(process.execPath, [RUNNER, ...args], { cwd: ROOT, encoding: 'utf8' });
46
44
  }
45
+ const SCRATCH_COPY_PATHS = ['ci', 'hooks', 'harness-everything', 'plugins/harness-everything', 'scripts', '.agents/plugins', 'package.json'];
46
+ function copyScratchTree(destination) {
47
+ fs.mkdirSync(destination, { recursive: true });
48
+ for (const relative of SCRATCH_COPY_PATHS) {
49
+ const source = path.join(ROOT, relative);
50
+ const target = path.join(destination, relative);
51
+ fs.mkdirSync(path.dirname(target), { recursive: true });
52
+ fs.cpSync(source, target, { recursive: true, dereference: true });
53
+ }
54
+ }
55
+ function scratchTreeSnapshot(root) {
56
+ const files = [];
57
+ const walk = dir => {
58
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
59
+ const full = path.join(dir, entry.name);
60
+ if (entry.isDirectory()) walk(full);
61
+ else files.push([path.relative(root, full).split(path.sep).join('/'), crypto.createHash('sha256').update(fs.readFileSync(full)).digest('hex')]);
62
+ }
63
+ };
64
+ walk(root);
65
+ return files;
66
+ }
67
+ function runScratchRunner(root, args) {
68
+ return spawnSync(process.execPath, [path.join(root, 'ci', 'archive', '325-prep', 'doc-reconciliation-red.js'), ...args], {
69
+ cwd: root, encoding: 'utf8', timeout: 90000, killSignal: 'SIGKILL'
70
+ });
71
+ }
47
72
 
48
73
  console.log('=== #325 3b preparation: corpus, legacy controls and infrastructure bounds (H1+H2) ===');
49
74
 
@@ -69,24 +94,40 @@ checkCase('inventory: the H2 corpus covers P01-P07 with the L1 field shape', ()
69
94
  }
70
95
  });
71
96
 
72
- // Infrastructure rule: an abnormal action result is never a qualified gap. The controls start from one healthy replay
73
- // set of P01 and change only the ON route result, so every other fault and assertion is the unmodified replay's.
97
+ // Infrastructure rule: an abnormal action result is never a qualified gap. These controls start from one healthy OFF
98
+ // replay per P06 distribution and change only the route result.
74
99
  const p01 = corpus.cases.find(item => item.id === 'P01');
75
- const p01Entries = registry.entries.filter(entry => entry.caseId === 'P01');
76
- const healthyP01 = runner.replayAll(p01);
77
- const injectIntoRoute = (patch, legs = ['source', 'packaged']) => {
78
- const injected = JSON.parse(JSON.stringify(healthyP01));
79
- for (const leg of legs) Object.assign(injected.on[leg].actions.route, patch);
100
+ const p06 = corpus.cases.find(item => item.id === 'P06');
101
+ const healthyP06 = {
102
+ off: {
103
+ source: fx.scrubReplay(fx.replayCase(p06, 'source')),
104
+ packaged: fx.scrubReplay(fx.replayCase(p06, 'packaged'))
105
+ },
106
+ on: {}
107
+ };
108
+ const injectIntoRoute = patch => {
109
+ const injected = JSON.parse(JSON.stringify(healthyP06));
110
+ for (const leg of ['source', 'packaged']) Object.assign(injected.off[leg].actions.route, patch);
80
111
  return injected;
81
112
  };
113
+ const assertRouteInfrastructure = (result, expected) => {
114
+ assert.strictEqual(result.status, 'INFRASTRUCTURE', `status ${result.status}`);
115
+ assert.deepStrictEqual(result.infrastructure, expected);
116
+ assert.deepStrictEqual(result.offending, {
117
+ leg: 'source', mode: 'off', actionId: 'route',
118
+ fault: expected[0].replace(/^source\.off\.route: /, '')
119
+ });
120
+ assert.deepStrictEqual(result.assertions, [], 'no assertion is qualified or classified for an infrastructure case');
121
+ assert.strictEqual(runner.exitCodeFor({ cases: [result] }, 'expect-red'), 2, 'expected-RED mode exits 2');
122
+ };
82
123
 
83
- // locks: C — "unavailable observations ... cannot become a false PASS"; control: P01
84
- checkCase('negative control: an abnormal route in P01 is infrastructure, and --expect-red exits nonzero though later assertions still match', () => {
124
+ // locks: C — "unavailable observations ... cannot become a false PASS"; control: P06
125
+ checkCase('negative control: an abnormal OFF route in P06 is infrastructure while later plan/start/verify/Stop assertions stay unchanged', () => {
85
126
  const injected = injectIntoRoute({ exitCode: 1 });
86
- const later = p01.expectations.on.filter(assertion => assertion.id.startsWith('verify-obligation') || assertion.id.startsWith('stop-'));
127
+ const later = p06.expectations.off.filter(assertion => /^(?:plan|start|verify|stop)-/.test(assertion.id));
87
128
  for (const leg of ['source', 'packaged']) {
88
- const before = fx.evaluateAll(healthyP01.on[leg], later);
89
- const after = fx.evaluateAll(injected.on[leg], later);
129
+ const before = fx.evaluateAll(healthyP06.off[leg], later);
130
+ const after = fx.evaluateAll(injected.off[leg], later);
90
131
  assert.deepStrictEqual(after.map(item => [item.id, item.pass, item.actual]), before.map(item => [item.id, item.pass, item.actual]),
91
132
  `${leg}: the later assertions evaluate exactly as in the unmodified replay`);
92
133
  for (const item of after) {
@@ -94,34 +135,42 @@ checkCase('negative control: an abnormal route in P01 is infrastructure, and --e
94
135
  `${leg}: ${item.id} remains strict S1 GREEN, so only the infrastructure rule can stop the replay`);
95
136
  }
96
137
  }
97
- const result = runner.classifyCase(p01, injected, p01Entries);
98
- assert.strictEqual(result.status, 'INFRASTRUCTURE', `status ${result.status}`);
99
- assert.deepStrictEqual(result.infrastructure, ['source.on.route: exit 1 outside policy [0]', 'packaged.on.route: exit 1 outside policy [0]']);
100
- assert.deepStrictEqual(result.offending, { leg: 'source', mode: 'on', actionId: 'route', fault: 'exit 1 outside policy [0]' });
101
- assert.deepStrictEqual(result.assertions, [], 'no assertion is qualified or classified for an infrastructure case');
102
- assert.strictEqual(runner.exitCodeFor({ cases: [result] }, 'expect-red'), 2, 'expected-RED mode exits nonzero');
138
+ const result = runner.classifyCase(p06, injected, []);
139
+ assertRouteInfrastructure(result, [
140
+ 'source.off.route: exit 1 outside policy [0]',
141
+ 'packaged.off.route: exit 1 outside policy [0]'
142
+ ]);
103
143
  });
104
144
 
105
- // locks: C — "unavailable observations ... cannot become a false PASS"; control: P01
106
- checkCase('negative control: a route killed by a signal or without an exit status is infrastructure', () => {
107
- const result = runner.classifyCase(p01, injectIntoRoute({ exitCode: null, signal: 'SIGTERM' }), p01Entries);
108
- assert.strictEqual(result.status, 'INFRASTRUCTURE');
109
- assert.ok(result.infrastructure.includes('source.on.route: terminated by signal SIGTERM'), result.infrastructure.join('; '));
110
- assert.ok(result.infrastructure.includes('source.on.route: no exit status'), result.infrastructure.join('; '));
145
+ // locks: C — "unavailable observations ... cannot become a false PASS"; control: P06
146
+ checkCase('negative control: an OFF route killed by a signal or without an exit status is infrastructure', () => {
147
+ const result = runner.classifyCase(p06, injectIntoRoute({ exitCode: null, signal: 'SIGTERM' }), []);
148
+ assertRouteInfrastructure(result, [
149
+ 'source.off.route: terminated by signal SIGTERM',
150
+ 'source.off.route: no exit status',
151
+ 'packaged.off.route: terminated by signal SIGTERM',
152
+ 'packaged.off.route: no exit status'
153
+ ]);
111
154
  });
112
155
 
113
- // locks: C — "unavailable observations ... cannot become a false PASS"; control: P01
114
- checkCase('negative control: a spawn error on the route is infrastructure', () => {
115
- const result = runner.classifyCase(p01, injectIntoRoute({ exitCode: null, error: 'spawnSync node ENOENT' }), p01Entries);
116
- assert.strictEqual(result.status, 'INFRASTRUCTURE');
117
- assert.ok(result.infrastructure.includes('source.on.route: spawn error spawnSync node ENOENT'), result.infrastructure.join('; '));
156
+ // locks: C — "unavailable observations ... cannot become a false PASS"; control: P06
157
+ checkCase('negative control: a spawn error on the OFF route is infrastructure', () => {
158
+ const result = runner.classifyCase(p06, injectIntoRoute({ exitCode: null, error: 'spawnSync node ENOENT' }), []);
159
+ assertRouteInfrastructure(result, [
160
+ 'source.off.route: spawn error spawnSync node ENOENT',
161
+ 'source.off.route: no exit status',
162
+ 'packaged.off.route: spawn error spawnSync node ENOENT',
163
+ 'packaged.off.route: no exit status'
164
+ ]);
118
165
  });
119
166
 
120
- // locks: C — "unavailable observations ... cannot become a false PASS"; control: P01
121
- checkCase('negative control: an accepted route exit without the routing checkpoint is malformed required output', () => {
122
- const result = runner.classifyCase(p01, injectIntoRoute({ stdout: 'routing unavailable' }), p01Entries);
123
- assert.strictEqual(result.status, 'INFRASTRUCTURE');
124
- assert.ok(result.infrastructure.includes('source.on.route: malformed required output'), result.infrastructure.join('; '));
167
+ // locks: C — "unavailable observations ... cannot become a false PASS"; control: P06
168
+ checkCase('negative control: an accepted OFF route exit without the routing checkpoint is malformed required output', () => {
169
+ const result = runner.classifyCase(p06, injectIntoRoute({ stdout: 'routing unavailable' }), []);
170
+ assertRouteInfrastructure(result, [
171
+ 'source.off.route: malformed required output',
172
+ 'packaged.off.route: malformed required output'
173
+ ]);
125
174
  });
126
175
 
127
176
  // locks: C — "unavailable observations ... cannot become a false PASS"; control: P01
@@ -135,6 +184,129 @@ checkCase('--expect-red exits nonzero from the CLI when a real route exit falls
135
184
  assert.ok(run.stdout.includes('INFRASTRUCTURE'), run.stdout);
136
185
  });
137
186
 
187
+ // The scratch tree contains copied real source/package entries, not stubbed runtime modules. Missing only the retired
188
+ // pilot fingerprint file must still reach the replay child and the original infrastructure/classification path.
189
+ checkCase('the archived runner reaches real replay and fault classification when its retired pilot fingerprint is absent', () => {
190
+ const scratchRoot = path.join(workDir, 'missing-pilot-tree');
191
+ copyScratchTree(scratchRoot);
192
+ const scratchPrepDir = path.join(scratchRoot, 'ci', 'fixtures', 'doc-obligations', 'reconciliation-prep');
193
+ const casesFile = path.join(scratchPrepDir, 'scratch-cases.json');
194
+ const timeoutCasesFile = path.join(scratchPrepDir, 'scratch-timeout-cases.json');
195
+ const registryFile = path.join(scratchPrepDir, 'scratch-registry.json');
196
+ const stopOnly = {
197
+ ...p01,
198
+ actions: [{ id: 'stop', op: 'stop' }],
199
+ expectations: {
200
+ off: [{ id: 'stop-exit', path: ['actions', 'stop', 'exitCode'], operator: 'equals', expected: 0 }],
201
+ on: [{ id: 'stop-exit', path: ['actions', 'stop', 'exitCode'], operator: 'equals', expected: 1 }]
202
+ }
203
+ };
204
+ const timeoutStopOnly = { ...stopOnly, childLimits: { timeoutMs: 1 } };
205
+ const historicalRegistry = JSON.parse(fs.readFileSync(path.join(PREP_DIR, 'pending-red.json'), 'utf8'));
206
+ const scratchRegistry = {
207
+ schemaVersion: 1,
208
+ baselineSha: historicalRegistry.baselineSha,
209
+ runtimeFingerprint: '0'.repeat(64), // syntactically valid scratch-only pin; the historical registry is untouched
210
+ entries: ['source', 'packaged'].map(distribution => ({
211
+ caseId: 'P01', assertionId: 'P01.on.stop-exit', distribution,
212
+ baselineSha: historicalRegistry.baselineSha, actual: 0, desired: 1,
213
+ blocker: '#341 E0', reasonCode: 'scratch-stop-control'
214
+ }))
215
+ };
216
+ fs.writeFileSync(casesFile, JSON.stringify({ cases: [stopOnly] }), 'utf8');
217
+ fs.writeFileSync(timeoutCasesFile, JSON.stringify({ cases: [timeoutStopOnly] }), 'utf8');
218
+ fs.writeFileSync(registryFile, JSON.stringify(scratchRegistry), 'utf8');
219
+
220
+ const sourcePilot = path.join(scratchRoot, 'hooks', 'scripts', 'lib', 'doc-reconciliation-pilot.js');
221
+ const packagedPilot = path.join(scratchRoot, 'plugins', 'harness-everything', 'hooks', 'scripts', 'lib', 'doc-reconciliation-pilot.js');
222
+ const sourceStopGate = path.join(scratchRoot, 'hooks', 'scripts', 'workflow-stop-gate.js');
223
+ const packagedStopGate = path.join(scratchRoot, 'plugins', 'harness-everything', 'hooks', 'scripts', 'workflow-stop-gate.js');
224
+ assert.deepStrictEqual(fs.readFileSync(sourceStopGate), fs.readFileSync(path.join(ROOT, 'hooks', 'scripts', 'workflow-stop-gate.js')));
225
+ assert.deepStrictEqual(fs.readFileSync(packagedStopGate), fs.readFileSync(path.join(ROOT, 'plugins', 'harness-everything', 'hooks', 'scripts', 'workflow-stop-gate.js')));
226
+ fs.rmSync(sourcePilot, { force: true });
227
+ fs.rmSync(packagedPilot, { force: true });
228
+ assert.ok(!fs.existsSync(sourcePilot) && !fs.existsSync(packagedPilot), 'both retired pilot files are absent in the scratch tree');
229
+ const beforeRuns = scratchTreeSnapshot(scratchRoot);
230
+ const args = ['--expect-red', '--json', '--cases', path.relative(scratchRoot, casesFile), '--registry', path.relative(scratchRoot, registryFile)];
231
+
232
+ const first = runScratchRunner(scratchRoot, args);
233
+ const second = runScratchRunner(scratchRoot, args);
234
+ for (const [index, run] of [first, second].entries()) {
235
+ assert.ok(!run.error, `run ${index + 1} spawned: ${run.error}`);
236
+ assert.strictEqual(run.signal, null, `run ${index + 1} exited without a signal`);
237
+ assert.strictEqual(run.status, 1, `run ${index + 1} fails closed after the real replay: status=${run.status}; stdout=${run.stdout.replace(/\s+/g, ' ')}; stderr=${run.stderr}`);
238
+ const report = JSON.parse(run.stdout);
239
+ const result = report.cases[0];
240
+ assert.strictEqual(report.runtimeFingerprintAvailable, false);
241
+ assert.strictEqual(report.runtimeFingerprintMatches, false);
242
+ assert.strictEqual(report.replaysRun, 4, 'source and packaged Stop-gate children ran in both modes');
243
+ assert.strictEqual(result.assertions.length, 4, 'the real Stop-gate action was classified in every replay');
244
+ assert.ok(result.assertions.every(entry => entry.actual === 0), 'all source/package Stop-gate children returned their real exit code');
245
+ assert.strictEqual(result.status, 'FAIL');
246
+ assert.strictEqual(result.qualifiedGaps, 0, 'the scratch registry entries cannot qualify without a fingerprint');
247
+ assert.strictEqual(result.parity, 'match', 'the un-stubbed source and packaged Stop gates agree');
248
+ assert.strictEqual(result.reason, 'runtime fingerprint unavailable because the retired pilot file is missing');
249
+ assert.ok(!result.assertions.some(entry => entry.status === 'gap-qualified'));
250
+ assert.strictEqual(result.assertions.filter(entry => entry.status === 'gap-unqualified').length, 2);
251
+ assert.strictEqual(report.pilotCredit, false);
252
+ assert.strictEqual(Object.hasOwn(report, 'recaptureCommand'), false, 'unavailable is not a recapture invitation');
253
+ assert.ok(!/recapture/i.test(run.stderr), run.stderr);
254
+ assert.deepStrictEqual(scratchTreeSnapshot(scratchRoot), beforeRuns, 'replays leave the scratch tree unchanged');
255
+ }
256
+ assert.deepStrictEqual(JSON.parse(second.stdout), JSON.parse(first.stdout), 'two clean equivalent replays have identical reports');
257
+
258
+ const faultArgs = [...args];
259
+ faultArgs[faultArgs.indexOf(path.relative(scratchRoot, casesFile))] = path.relative(scratchRoot, timeoutCasesFile);
260
+ const faultFirst = runScratchRunner(scratchRoot, faultArgs);
261
+ const faultSecond = runScratchRunner(scratchRoot, faultArgs);
262
+ for (const [index, run] of [faultFirst, faultSecond].entries()) {
263
+ assert.ok(!run.error, `fault run ${index + 1} spawned: ${run.error}`);
264
+ assert.strictEqual(run.signal, null, `fault run ${index + 1} exited without a signal`);
265
+ assert.strictEqual(run.status, 2, `fault run ${index + 1} is classified as infrastructure: ${run.stdout} ${run.stderr}`);
266
+ const report = JSON.parse(run.stdout);
267
+ const result = report.cases[0];
268
+ assert.strictEqual(report.replaysRun, 1, 'the real timed-out Stop-gate child is recorded');
269
+ assert.strictEqual(result.status, 'INFRASTRUCTURE');
270
+ assert.strictEqual(result.actionsRun, 1);
271
+ assert.deepStrictEqual(result.offending, {
272
+ leg: 'source', mode: 'off', actionId: 'stop', fault: 'timed out at the child deadline (ETIMEDOUT)'
273
+ });
274
+ assert.strictEqual(result.qualifiedGaps, 0);
275
+ assert.strictEqual(Object.hasOwn(report, 'recaptureCommand'), false);
276
+ assert.ok(!/recapture/i.test(run.stderr), run.stderr);
277
+ assert.deepStrictEqual(scratchTreeSnapshot(scratchRoot), beforeRuns, 'faulted replays leave the scratch tree unchanged');
278
+ }
279
+ assert.deepStrictEqual(JSON.parse(faultSecond.stdout), JSON.parse(faultFirst.stdout), 'two clean equivalent fault runs have identical reports');
280
+
281
+ const malformedRegistry = JSON.parse(JSON.stringify(scratchRegistry));
282
+ delete malformedRegistry.entries[0].reasonCode;
283
+ const malformedRegistryFile = path.join(scratchPrepDir, 'scratch-malformed-registry.json');
284
+ fs.writeFileSync(malformedRegistryFile, JSON.stringify(malformedRegistry), 'utf8');
285
+ const malformedArgs = [...args];
286
+ malformedArgs[malformedArgs.indexOf(path.relative(scratchRoot, registryFile))] = path.relative(scratchRoot, malformedRegistryFile);
287
+ const malformed = runScratchRunner(scratchRoot, malformedArgs);
288
+ assert.strictEqual(malformed.status, 2, 'malformed registry remains an infrastructure error');
289
+ assert.strictEqual(malformed.stdout, '', 'malformed registry fails before replay');
290
+ assert.ok(malformed.stderr.includes('must have exactly the keys'), malformed.stderr);
291
+
292
+ const candidateFile = path.join(scratchPrepDir, 'scratch-candidate.json');
293
+ const recapture = runScratchRunner(scratchRoot, [
294
+ '--recapture-candidate', path.relative(scratchRoot, candidateFile),
295
+ '--baseline-sha', historicalRegistry.baselineSha,
296
+ '--cases', path.relative(scratchRoot, casesFile)
297
+ ]);
298
+ assert.strictEqual(recapture.status, 2, 'candidate recapture is refused without the fingerprint');
299
+ assert.ok(recapture.stderr.includes('runtime fingerprint unavailable'), recapture.stderr);
300
+ assert.ok(!fs.existsSync(candidateFile), 'no candidate registry is written');
301
+
302
+ const otherFingerprintFile = path.join(scratchRoot, 'hooks', 'scripts', 'lib', 'workflow-obligations.js');
303
+ fs.rmSync(otherFingerprintFile);
304
+ const otherIo = runScratchRunner(scratchRoot, args);
305
+ assert.strictEqual(otherIo.status, 2, 'a missing non-pilot fingerprint file remains an infrastructure error');
306
+ assert.strictEqual(otherIo.stdout, '', 'other fingerprint I/O errors fail before replay');
307
+ assert.ok(otherIo.stderr.includes('workflow-obligations.js') && otherIo.stderr.includes('ENOENT'), otherIo.stderr);
308
+ });
309
+
138
310
  // Real process boundary: a substituted child (hung or flooding) under a short deadline runs through the CLI. The
139
311
  // outer SIGKILL deadline turns a regression (the runner never returns) into a failed check instead of a hung suite.
140
312
  const OUTER_DEADLINE_MS = 90000;
@@ -290,19 +462,6 @@ checkCase('F-a: Windows-shaped source and packaged paths normalize identically',
290
462
  assert.strictEqual(sameAfterFold, sourceTmp, 'POSIX and Windows spellings of one path normalize identically');
291
463
  });
292
464
 
293
- // F-b: a per-action switch override must not reach an OFF replay.
294
- // locks: unresolved — OFF replay carries no per-action switch; the I2 invariant is not in the A/B/C/R3 table
295
- checkCase('F-b: an OFF replay of P05 carries no per-action switch; the ON replay keeps its overrides', () => {
296
- const item = corpus.cases.find(candidate => candidate.id === 'P05');
297
- const off = fx.replayCase(item, 'source');
298
- for (const [id, action] of Object.entries(off.actions)) {
299
- assert.strictEqual(action.pilot, undefined, `OFF replay action ${id} has no switch value`);
300
- }
301
- const on = fx.replayCase(item, 'source', { pilot: '1' });
302
- assert.strictEqual(on.actions['stop-on-1'].pilot, '1', 'an ON replay keeps the ON action value');
303
- assert.strictEqual(on.actions['stop-off'].pilot, '0', 'an ON replay keeps the explicit OFF action value');
304
- });
305
-
306
465
  fs.rmSync(workDir, { recursive: true, force: true });
307
466
  console.log(failed ? `\n${failed} preparation check(s) failed` : '\nAll preparation checks passed');
308
467
  process.exitCode = failed ? 1 : 0;