harness-everything 1.5.4 → 1.6.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 (45) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.github/ISSUE_TEMPLATE/bug_report.yml +68 -0
  4. package/.github/ISSUE_TEMPLATE/config.yml +8 -0
  5. package/.github/ISSUE_TEMPLATE/feature_request.yml +33 -0
  6. package/.github/ISSUE_TEMPLATE/platform_compatibility.yml +80 -0
  7. package/.github/PULL_REQUEST_TEMPLATE.md +19 -0
  8. package/.github/dependabot.yml +13 -0
  9. package/.github/workflows/ci.yml +2 -2
  10. package/.github/workflows/release.yml +1 -1
  11. package/CHANGELOG.md +18 -0
  12. package/PRIVACY.md +34 -14
  13. package/README.md +76 -311
  14. package/ROADMAP.md +50 -0
  15. package/SECURITY.md +29 -8
  16. package/SUPPORT.md +4 -4
  17. package/TERMS.md +3 -3
  18. package/benchmarks/results/live-host/opencode-2026-12-02-450-steering/README.md +20 -0
  19. package/benchmarks/results/live-host/opencode-2026-12-02-450-steering/lifecycle.sanitized.jsonl +14 -0
  20. package/benchmarks/results/live-host/opencode-2026-12-02-450-steering/observations.sanitized.json +20 -0
  21. package/bin/cli.js +30 -7
  22. package/ci/action-gate.test.js +186 -0
  23. package/ci/installer-roundtrip.test.js +20 -0
  24. package/ci/lib/opencode-v2-driver.js +3 -1
  25. package/ci/mechanism-2aa-codex-action-gate-policy.test.js +21 -0
  26. package/ci/mechanism-2ap-sbom.test.js +6 -6
  27. package/ci/mechanism-2x-release-commit-message.test.js +34 -23
  28. package/ci/mechanism-341-opencode-lane.test.js +5 -1
  29. package/ci/mechanism-397-cycle-import.test.js +5 -1
  30. package/ci/mechanism-397-opencode-observations.test.js +260 -24
  31. package/ci/mechanism-552-ledger-pairs.test.js +2 -0
  32. package/ci/mechanism-task-git-authorization.test.js +14 -0
  33. package/docs/README.md +81 -0
  34. package/docs/codex-action-gate.md +1 -1
  35. package/docs/platform-capabilities.md +9 -4
  36. package/docs/platform-compatibility.json +3 -3
  37. package/hooks/scripts/action-gate.js +82 -2
  38. package/opencode-plugin/index.mjs +97 -35
  39. package/opencode-plugin/plugin.json +1 -1
  40. package/package.json +15 -2
  41. package/plugins/harness-everything/.antigravity-plugin/plugin.json +1 -1
  42. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  43. package/plugins/harness-everything/hooks/scripts/action-gate.js +82 -2
  44. package/plugins/harness-everything/plugin.json +1 -1
  45. package/sbom.cdx.json +7 -7
@@ -23,15 +23,20 @@ assert.ok(currentLines.every(line => line.length <= 100), 'release commit must r
23
23
 
24
24
  const temp = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-release-commitlint-'));
25
25
  const currentFile = path.join(temp, 'current-message.txt');
26
- const legacyFile = path.join(temp, 'legacy-message.txt');
26
+ const longReleaseFile = path.join(temp, 'long-release-message.txt');
27
+ const invalidFile = path.join(temp, 'invalid-message.txt');
28
+ const strictConfigFile = path.join(temp, 'commitlint.config.json');
29
+ // Disable default ignores only when testing release-message formatting rules.
30
+ fs.writeFileSync(strictConfigFile, JSON.stringify({
31
+ extends: [path.join(ROOT, 'commitlint.config.js')],
32
+ defaultIgnores: false
33
+ }));
27
34
  fs.writeFileSync(currentFile, `${currentMessage}\n`);
28
35
 
29
- // Negative control: this reproduces the production failure from release run
30
- // 34970424994. Generated notes contain long Markdown links, so copying them
31
- // into the Git commit body violates body-max-line-length/footer constraints.
32
- const longReleaseNote = `* **behavioral-evals:** ${'x'.repeat(110)} ([90e36c2](https://github.com/dyphn1/Harness-everything/commit/90e36c2071fb5a71e16cdc99b1060cd3d699c43b)), closes #52`;
33
- const legacyMessage = `chore(release): 0.4.0 [skip ci]\n\n${longReleaseNote}\n`;
34
- fs.writeFileSync(legacyFile, legacyMessage);
36
+ // Unlike the historical notes in #115, this fixture has no URL that could exempt the line.
37
+ const longReleaseNote = `* **behavioral-evals:** ${'x'.repeat(110)}`;
38
+ fs.writeFileSync(longReleaseFile, `${currentMessage}\n\n${longReleaseNote}\n`);
39
+ fs.writeFileSync(invalidFile, 'fix: UPPERCASE SUBJECT\n');
35
40
 
36
41
  const commitlintPackageFile = require.resolve('@commitlint/cli/package.json');
37
42
  const commitlintPackage = JSON.parse(fs.readFileSync(commitlintPackageFile, 'utf8'));
@@ -41,26 +46,32 @@ const commitlintBin = typeof commitlintPackage.bin === 'string'
41
46
  assert.ok(commitlintBin, '@commitlint/cli must expose a commitlint executable');
42
47
  const commitlintCli = path.resolve(path.dirname(commitlintPackageFile), commitlintBin);
43
48
 
44
- function commitlint(file) {
45
- return spawnSync(process.execPath, [commitlintCli, '--edit', file], {
49
+ function commitlint(file, options = []) {
50
+ return spawnSync(process.execPath, [commitlintCli, '--edit', file, ...options], {
46
51
  cwd: ROOT,
47
52
  encoding: 'utf8'
48
53
  });
49
54
  }
50
55
 
51
- const currentResult = commitlint(currentFile);
52
- assert.strictEqual(
53
- currentResult.status,
54
- 0,
55
- `current semantic-release commit must pass commitlint:\n${currentResult.stdout}\n${currentResult.stderr}`
56
- );
56
+ try {
57
+ const strictOptions = ['--config', strictConfigFile];
58
+ const productionResult = commitlint(currentFile);
59
+ assert.strictEqual(productionResult.status, 0,
60
+ `release commit must pass the repository config:\n${productionResult.stdout}\n${productionResult.stderr}`);
57
61
 
58
- const legacyResult = commitlint(legacyFile);
59
- assert.notStrictEqual(legacyResult.status, 0, 'legacy release-notes-in-commit behavior must fail commitlint');
60
- assert.match(
61
- `${legacyResult.stdout}\n${legacyResult.stderr}`,
62
- /body-max-line-length|footer-max-line-length/,
63
- 'negative control must fail for the same long-line class seen in production'
64
- );
62
+ const strictResult = commitlint(currentFile, strictOptions);
63
+ assert.strictEqual(strictResult.status, 0,
64
+ `release commit must pass with default ignores disabled:\n${strictResult.stdout}\n${strictResult.stderr}`);
65
65
 
66
- console.log('Release commit contract verified: compact message passes commitlint and legacy release-note embedding is rejected.');
66
+ const longReleaseResult = commitlint(longReleaseFile, strictOptions);
67
+ assert.strictEqual(longReleaseResult.status, 1);
68
+ assert.match(`${longReleaseResult.stdout}\n${longReleaseResult.stderr}`, /body-max-line-length|footer-max-line-length/);
69
+
70
+ const invalidResult = commitlint(invalidFile);
71
+ assert.strictEqual(invalidResult.status, 1);
72
+ assert.match(`${invalidResult.stdout}\n${invalidResult.stderr}`, /subject-case/);
73
+
74
+ console.log('Release commit contract verified with repository and strict test configs.');
75
+ } finally {
76
+ fs.rmSync(temp, { recursive: true, force: true });
77
+ }
@@ -172,12 +172,16 @@ test('V2 execute.after writes no E1 journal while ordinary telemetry, edit, obse
172
172
  const sessionId = `native-v2-unhooked-${label}`;
173
173
  const { sessionDir } = seedWorkflow(d.workspace, sessionId);
174
174
  const observationsDir = process.env.HARNESS_OBSERVATIONS_DIR;
175
+ const messageID = `turn-${label}`;
175
176
 
176
177
  await d.sessionHook('prompt')({
177
178
  sessionID: sessionId,
178
- messageID: `turn-${label}`,
179
+ messageID,
179
180
  prompt: { text: 'update retry doc and verify' },
180
181
  });
182
+ d.emit('session.execution.started', sessionId);
183
+ d.emit('session.inbox.delivered', sessionId, { inboxID: messageID });
184
+ await d.settled({ quietMs: 0 });
181
185
 
182
186
  const skillEvent = { tool: 'skill', sessionID: sessionId, id: 'call-skill', messageID: 'msg-skill', input: { skill: 'tdd' } };
183
187
  await d.toolHook('execute.before')(skillEvent);
@@ -9,6 +9,7 @@ const { test } = require('node:test');
9
9
  const { collect } = require('../scripts/system-one-cycle/collect');
10
10
  const { importStore } = require('../scripts/system-one-observations-import-store');
11
11
  const observations = require('../hooks/scripts/lib/observations');
12
+ const { v2Event } = require('./lib/opencode-v2-driver');
12
13
 
13
14
  const ROOT = path.resolve(__dirname, '..');
14
15
  const PLUGIN = path.join(ROOT, 'opencode-plugin', 'index.mjs');
@@ -201,7 +202,10 @@ test('cycle collect imports production OpenCode captures into private prompt/lab
201
202
  const messageID = 'shared-turn';
202
203
  f.setTurn(messageID, turn.prompt, LABELS[index]);
203
204
  await f.sessionHooks.get('prompt')({ sessionID: turn.sessionID, messageID, prompt: { text: turn.prompt } });
204
- f.push({ type: 'session.execution.succeeded', data: { sessionID: turn.sessionID } });
205
+ const sessionID = turn.sessionID;
206
+ f.push(v2Event('session.execution.started', sessionID));
207
+ f.push(v2Event('session.inbox.delivered', sessionID, { inboxID: messageID }));
208
+ f.push(v2Event('session.execution.succeeded', sessionID));
205
209
  await waitFor(() => recordList(f.store).length === index + 1);
206
210
  }
207
211
 
@@ -7,6 +7,7 @@ const os = require('node:os');
7
7
  const path = require('node:path');
8
8
  const { spawnSync } = require('node:child_process');
9
9
  const { pathToFileURL } = require('node:url');
10
+ const { v2Event } = require('./lib/opencode-v2-driver');
10
11
  const observations = require('../hooks/scripts/lib/observations');
11
12
  const exporter = require('../scripts/system-one-observations-export');
12
13
  const workspaceState = require('../scripts/lib/workspace');
@@ -21,13 +22,6 @@ const VALID_LABEL = '<!-- harness-label {"v":1,"validity":"actionable","contextD
21
22
  const SECOND_LABEL = '<!-- harness-label {"v":1,"validity":"actionable","contextDependent":false,"tier":"tier2","intents":["edit"],"workflow":"iterative-single","skills":[]} -->';
22
23
  assert.ok(Number.isFinite(VERIFY_KILL_GRACE_MS), 'the verification runner exposes its process-group grace in source');
23
24
 
24
- // OpenCode 2.x events are flat: {id, created, type, durable, [location], data},
25
- // the session id lives at data.sessionID, and a completed turn ends with
26
- // session.execution.succeeded because V2 hosts do not send session.idle.
27
- function v2Event(type, sessionID, data = {}) {
28
- return { id: `evt-${type}-${sessionID}`, created: Date.now(), type, durable: true, data: { sessionID, ...data } };
29
- }
30
-
31
25
  function fixture(observationMode = 'on') {
32
26
  const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'opencode-observations-'));
33
27
  const workspace = path.join(dir, 'workspace');
@@ -131,8 +125,17 @@ function fixture(observationMode = 'on') {
131
125
  });
132
126
  };
133
127
 
128
+ const startExecution = (sessionID, inboxID) => {
129
+ push(v2Event('session.execution.started', sessionID));
130
+ return push(v2Event('session.inbox.delivered', sessionID, { inboxID }));
131
+ };
132
+
134
133
  return {
135
- dir, workspace, store, ctx, sessionHooks, toolHooks, push,
134
+ dir, workspace, store, ctx, sessionHooks, toolHooks, push, startExecution,
135
+ completeTurn(sessionID, inboxID) {
136
+ startExecution(sessionID, inboxID);
137
+ return push(v2Event('session.execution.succeeded', sessionID));
138
+ },
136
139
  setFinal(text) { finalText = text; },
137
140
  setSessionLookup(lookup) { sessionLookup = lookup; },
138
141
  sessionLookupCount() { return sessionLookups; },
@@ -378,7 +381,7 @@ test('record: OpenCode prompt, tool and idle events append one host-tagged recor
378
381
  await f.toolHooks.get('execute.after')({
379
382
  status: 'completed', tool: 'edit', sessionID: 'record-session', id: 'call-1', input: { filePath: 'changed.js' }, result: {},
380
383
  });
381
- f.push(v2Event('session.execution.succeeded', 'record-session'));
384
+ f.completeTurn('record-session', 'record-turn');
382
385
  await waitFor(() => recordList(f.store).length === 1);
383
386
  const [record] = recordList(f.store);
384
387
  assert.equal(record.host, 'opencode');
@@ -424,7 +427,7 @@ test('workspace: V2 prompt and observations bind to the session directory when s
424
427
  await f.toolHooks.get('execute.after')({
425
428
  status: 'completed', tool: 'edit', sessionID, id: 'cross-workspace-call', input: { filePath: 'changed.js' }, result: {},
426
429
  });
427
- f.push(v2Event('session.execution.succeeded', sessionID));
430
+ f.completeTurn(sessionID, messageID);
428
431
  await waitFor(() => recordList(f.store).length === 1);
429
432
 
430
433
  const [record] = recordList(f.store);
@@ -481,7 +484,7 @@ test('workspace: session directory is used when setup provides no location', { c
481
484
  dispose = await install(f);
482
485
  const sessionID = 'session-without-setup-location';
483
486
  await f.sessionHooks.get('prompt')({ sessionID, messageID: 'without-setup-turn', prompt: { text: 'use the host session directory' } });
484
- f.push(v2Event('session.execution.succeeded', sessionID));
487
+ f.completeTurn(sessionID, 'without-setup-turn');
485
488
  await waitFor(() => recordList(f.store).length === 1);
486
489
 
487
490
  const artifactPaths = [f.workspace, sessionWorkspace, serverWorkspace].map(workspace => routerArtifact(workspace, sessionID));
@@ -519,9 +522,9 @@ test('workspace: interleaved sessions keep their own router, tool and completion
519
522
  status: 'completed', tool: 'edit', sessionID, id: `call-${sessionID}`, input: { filePath: `${sessionID}.js` }, result: {},
520
523
  });
521
524
  }
522
- f.push(v2Event('session.execution.succeeded', 'session-b'));
525
+ f.completeTurn('session-b', 'turn-b');
523
526
  await waitFor(() => recordList(f.store).length === 1);
524
- f.push(v2Event('session.execution.succeeded', 'session-a'));
527
+ f.completeTurn('session-a', 'turn-a');
525
528
  await waitFor(() => recordList(f.store).length === 2);
526
529
 
527
530
  const bySession = Object.fromEntries(recordList(f.store).map(record => [record.writer.sessionId, record]));
@@ -687,7 +690,7 @@ test('malformed: invalid labels remain null with a reason and export counts are
687
690
  dispose = await install(f);
688
691
  f.setFinal('Done.\n<!-- harness-label {"validity":"valid","tier":3,"skills_used":[]} -->');
689
692
  await f.sessionHooks.get('prompt')({ sessionID: 'malformed-opencode', messageID: 'bad-opencode', prompt: { text: 'record an invalid label' } });
690
- f.push(v2Event('session.execution.succeeded', 'malformed-opencode'));
693
+ f.completeTurn('malformed-opencode', 'bad-opencode');
691
694
  await waitFor(() => recordList(f.store).length === 1);
692
695
  assert.equal(recordList(f.store)[0].selfReport, null);
693
696
  assert.equal(recordList(f.store)[0].selfReportReason, 'label-invalid');
@@ -723,7 +726,7 @@ test('opt-out: HARNESS_OBSERVATIONS=off disables capture while prompt routing st
723
726
  const context = { sessionID: 'optout-session', kind: 'primary', system: [], messages: [] };
724
727
  await f.sessionHooks.get('context')(context);
725
728
  assert.match(context.system.map(part => part.text || '').join('\n'), /=> ROUTER WORKFLOW PLAN/);
726
- await f.push(v2Event('session.execution.succeeded', 'optout-session'));
729
+ await f.completeTurn('optout-session', 'optout-turn');
727
730
  assert.deepEqual(recordList(f.store), []);
728
731
  } finally {
729
732
  if (dispose) await dispose();
@@ -739,6 +742,7 @@ test('record: a V2 flat session.execution.succeeded after the prompt hook closes
739
742
  await f.sessionHooks.get('prompt')({ sessionID: 'v2-session', messageID: 'v2-turn-1', prompt: { text: 'close the observed v2 turn' } });
740
743
  // Witness stream: session.step.ended then session.execution.succeeded, flat
741
744
  // events with the session id at data.sessionID.
745
+ await f.startExecution('v2-session', 'v2-turn-1');
742
746
  f.push(v2Event('session.step.ended', 'v2-session', { assistantMessageID: 'assistant-message', finish: 'stop', rawFinish: 'stop', cost: 0, tokens: {} }));
743
747
  f.push(v2Event('session.execution.succeeded', 'v2-session'));
744
748
  await waitFor(() => recordList(f.store).length === 1);
@@ -769,6 +773,7 @@ test('record: V2 context uses the final text after tool steps and anchors it to
769
773
  { id: 'idle', time: { created: 0 }, type: 'idle', outcome: 'success' },
770
774
  ];
771
775
  await f.sessionHooks.get('prompt')({ sessionID: 'v2-context', messageID: 'v2-context-turn', prompt: { text: 'record the final V2 message' } });
776
+ await f.startExecution('v2-context', 'v2-context-turn');
772
777
  f.push(v2Event('session.step.ended', 'v2-context', { assistantMessageID: 'final-assistant', finish: 'stop', rawFinish: 'stop', cost: 0, tokens: {} }));
773
778
  f.push(v2Event('session.execution.succeeded', 'v2-context'));
774
779
  await waitFor(() => recordList(f.store).length === 1);
@@ -796,7 +801,7 @@ test('control: V2 context never reuses an assistant label from before the prompt
796
801
  { id: 'idle', time: { created: 0 }, type: 'idle', outcome: 'success' },
797
802
  ];
798
803
  await f.sessionHooks.get('prompt')({ sessionID: 'v2-no-final', messageID: 'v2-no-final-turn', prompt: { text: 'do not reuse a previous label' } });
799
- f.push(v2Event('session.execution.succeeded', 'v2-no-final'));
804
+ f.completeTurn('v2-no-final', 'v2-no-final-turn');
800
805
  await waitFor(() => recordList(f.store).length === 1);
801
806
 
802
807
  const [record] = recordList(f.store);
@@ -814,12 +819,12 @@ test('record: two consecutive V2 turns in one session each produce a completed r
814
819
  try {
815
820
  dispose = await install(f);
816
821
  await f.sessionHooks.get('prompt')({ sessionID: 'v2-multi', messageID: 'v2-multi-1', prompt: { text: 'first observed v2 turn' } });
817
- f.push(v2Event('session.execution.succeeded', 'v2-multi'));
822
+ f.completeTurn('v2-multi', 'v2-multi-1');
818
823
  await waitFor(() => recordList(f.store).length === 1);
819
824
 
820
825
  await f.sessionHooks.get('prompt')({ sessionID: 'v2-multi', messageID: 'v2-multi-2', prompt: { text: 'second observed v2 turn' } });
821
826
  f.setFinal(SECOND_LABEL);
822
- f.push(v2Event('session.execution.succeeded', 'v2-multi'));
827
+ f.completeTurn('v2-multi', 'v2-multi-2');
823
828
  await waitFor(() => recordList(f.store).length === 2);
824
829
 
825
830
  const records = recordList(f.store);
@@ -832,6 +837,235 @@ test('record: two consecutive V2 turns in one session each produce a completed r
832
837
  }
833
838
  });
834
839
 
840
+ test('450: the V2.4.1 steering trace gives both prompts an unknown label and preserves the next execution', async t => {
841
+ const f = fixture();
842
+ let dispose;
843
+ t.after(async () => {
844
+ if (dispose) await dispose();
845
+ f.restore();
846
+ });
847
+ dispose = await install(f);
848
+ const sessionID = 'steering-session';
849
+ const traceFile = path.join(ROOT, 'benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/steering-trace.jsonl');
850
+ const trace = fs.readFileSync(traceFile, 'utf8').trim().split('\n').map(line => JSON.parse(line));
851
+ const users = trace.filter(row => row.hook === 'prompt').map(row => row.mid);
852
+ const [a, b, c] = users;
853
+ assert.equal(users.length, 3);
854
+ const started = 'session.execution.started';
855
+ const delivered = 'session.inbox.delivered';
856
+ const succeeded = 'session.execution.succeeded';
857
+ const events = trace.filter(row => [started, delivered, succeeded].includes(row.event));
858
+ assert.deepEqual(events.map(row => row.event), [started, delivered, delivered, succeeded, started, delivered, succeeded]);
859
+ const eventAt = (index, inboxID) => ({
860
+ ...v2Event(events[index].event, sessionID, inboxID ? { inboxID } : {}),
861
+ id: `steering-${index}`, created: events[index].dt_ms,
862
+ durable: { aggregateID: sessionID, seq: index },
863
+ });
864
+ const admit = messageID => f.sessionHooks.get('prompt')({
865
+ sessionID, messageID, delivery: 'steer', prompt: { text: `steering fixture ${messageID}` },
866
+ });
867
+ const steeredMessages = trace.find(row => row.hook === 'context'
868
+ && row.messages?.some(message => message.id === b)).messages;
869
+ const steeringContext = steeredMessages.filter(message => message.id).map(message => ({
870
+ type: message.role, id: message.id,
871
+ }));
872
+ const secondFinal = { id: 'steer-final', type: 'assistant', content: [{ type: 'text', text: SECOND_LABEL }] };
873
+ f.ctx.session.context = async () => [...steeringContext, secondFinal];
874
+
875
+ await admit(a);
876
+ await f.push(eventAt(0));
877
+ await f.push(eventAt(1, a));
878
+ await admit(b);
879
+ await f.sessionHooks.get('context')({ sessionID, system: [], messages: steeringContext });
880
+ await f.push(eventAt(2, b));
881
+ const sharedCompletion = eventAt(3);
882
+ await f.push(sharedCompletion);
883
+ await f.push(sharedCompletion);
884
+ await waitFor(() => recordList(f.store).length === 2);
885
+ assert.deepEqual(recordList(f.store).map(row => [row.writer.turnId, row.selfReportReason, row.selfReport]), [
886
+ [a, 'final-message-unavailable', null],
887
+ [b, 'final-message-unavailable', null],
888
+ ]);
889
+
890
+ await admit(c);
891
+ await f.push(sharedCompletion);
892
+ await f.push(eventAt(4));
893
+ await f.push(eventAt(5, c));
894
+ await f.push(sharedCompletion);
895
+ f.ctx.session.context = async () => [
896
+ ...steeringContext, secondFinal,
897
+ { type: 'user', id: c },
898
+ { type: 'assistant', id: 'control-final', content: [{ type: 'text', text: VALID_LABEL }] },
899
+ ];
900
+ await f.push(eventAt(6));
901
+ await waitFor(() => recordList(f.store).length === 3);
902
+ assert.deepEqual(recordList(f.store)[2].selfReport?.intents, ['fix', 'test']);
903
+ assert.equal(recordList(f.store)[2].writer.turnId, c);
904
+ });
905
+
906
+ test('450: interrupting the active execution leaves a queued prompt available for its own completion', async t => {
907
+ const f = fixture();
908
+ let dispose;
909
+ t.after(async () => {
910
+ if (dispose) await dispose();
911
+ f.restore();
912
+ });
913
+ dispose = await install(f);
914
+ const sessionID = 'queued-session';
915
+ const send = (type, seq, data = {}) => f.push({
916
+ ...v2Event(`session.${type}`, sessionID, data),
917
+ id: `queued-${seq}`, durable: { aggregateID: sessionID, seq },
918
+ });
919
+ await f.sessionHooks.get('prompt')({
920
+ sessionID, messageID: 'active', delivery: 'steer', prompt: { text: 'active fixture' },
921
+ });
922
+ await send('execution.started', 1);
923
+ await send('inbox.delivered', 2, { inboxID: 'active' });
924
+ await f.sessionHooks.get('prompt')({
925
+ sessionID, messageID: 'queued', delivery: 'queue', prompt: { text: 'queued fixture' },
926
+ });
927
+ await f.toolHooks.get('execute.after')({
928
+ status: 'completed', tool: 'edit', sessionID, id: 'active-edit', input: { filePath: 'active-only.js' }, result: {},
929
+ });
930
+ await send('execution.interrupted', 3);
931
+ await send('execution.started', 4);
932
+ await send('inbox.delivered', 5, { inboxID: 'queued' });
933
+ await send('execution.succeeded', 6);
934
+ await waitFor(() => recordList(f.store).length === 2);
935
+ const [interrupted, queued] = recordList(f.store);
936
+ assert.equal(interrupted.writer.turnId, 'active');
937
+ assert.equal(interrupted.selfReportReason, 'final-message-unavailable');
938
+ assert.equal(queued.writer.turnId, 'queued');
939
+ assert.equal(queued.behavior.filesWritten, 0);
940
+ assert.deepEqual(queued.selfReport?.intents, ['fix', 'test']);
941
+ });
942
+
943
+ test('450: a new context hook can precede delivery of the old durable completion', async t => {
944
+ const f = fixture();
945
+ let dispose;
946
+ t.after(async () => {
947
+ if (dispose) await dispose();
948
+ f.restore();
949
+ });
950
+ dispose = await install(f);
951
+ const sessionID = 'delayed-terminal-session';
952
+ const send = (type, seq, data = {}) => f.push({
953
+ ...v2Event(`session.${type}`, sessionID, data),
954
+ id: `delayed-${seq}`, durable: { aggregateID: sessionID, seq },
955
+ });
956
+ const admit = messageID => f.sessionHooks.get('prompt')({
957
+ sessionID, messageID, prompt: { text: `delayed terminal fixture ${messageID}` },
958
+ });
959
+ await admit('first');
960
+ await send('execution.started', 1);
961
+ await send('inbox.delivered', 2, { inboxID: 'first' });
962
+
963
+ // The hook transport can report the new context before the event iterator
964
+ // consumes the old terminal. The durable log still orders the next delivery.
965
+ await admit('second');
966
+ await f.sessionHooks.get('context')({ sessionID, system: [], messages: [{ type: 'user', id: 'second' }] });
967
+ await send('execution.succeeded', 3);
968
+ await send('execution.started', 4);
969
+ await send('inbox.delivered', 5, { inboxID: 'second' });
970
+ await send('execution.succeeded', 6);
971
+ await waitFor(() => recordList(f.store).length === 2);
972
+ const [first, second] = recordList(f.store);
973
+ assert.equal(first.writer.turnId, 'first');
974
+ assert.equal(first.selfReport, null);
975
+ assert.equal(second.writer.turnId, 'second');
976
+ assert.deepEqual(second.selfReport?.intents, ['fix', 'test']);
977
+ });
978
+
979
+ test('450: a late context read for an old completion cannot consume the new prompt', async t => {
980
+ const f = fixture();
981
+ let dispose;
982
+ t.after(async () => {
983
+ if (dispose) await dispose();
984
+ f.restore();
985
+ });
986
+ dispose = await install(f);
987
+ const sessionID = 'late-context-session';
988
+ const admit = messageID => f.sessionHooks.get('prompt')({
989
+ sessionID, messageID, prompt: { text: `late context fixture ${messageID}` },
990
+ });
991
+ const normalContext = f.ctx.session.context;
992
+ let resolveOld;
993
+ f.ctx.session.context = () => new Promise(resolve => { resolveOld = resolve; });
994
+ await admit('old');
995
+ await f.completeTurn(sessionID, 'old');
996
+ assert.equal(await waitUntil(() => Boolean(resolveOld)), true);
997
+
998
+ f.ctx.session.context = normalContext;
999
+ await admit('new');
1000
+ f.setFinal(SECOND_LABEL);
1001
+ resolveOld(await normalContext());
1002
+ await new Promise(resolve => setImmediate(resolve));
1003
+ await f.completeTurn(sessionID, 'new');
1004
+ await waitFor(() => recordList(f.store).length === 2);
1005
+
1006
+ const [first, second] = recordList(f.store);
1007
+ assert.equal(first.writer.turnId, 'old');
1008
+ assert.equal(first.selfReport, null);
1009
+ assert.equal(second.writer.turnId, 'new');
1010
+ assert.deepEqual(second.selfReport?.intents, ['edit']);
1011
+ });
1012
+
1013
+ test('450: terminals without a durable sequence cannot consume the current prompt', async t => {
1014
+ const f = fixture();
1015
+ const dispose = await install(f);
1016
+ t.after(async () => {
1017
+ await dispose();
1018
+ f.restore();
1019
+ });
1020
+ const sessionID = 'unsequenced-terminal';
1021
+ const admit = messageID => f.sessionHooks.get('prompt')({
1022
+ sessionID, messageID, prompt: { text: `terminal replay fixture ${messageID}` },
1023
+ });
1024
+ const send = (type, seq, data = {}) => f.push({
1025
+ ...v2Event(type, sessionID, data),
1026
+ id: `ordered-${seq}`, durable: { aggregateID: sessionID, seq, version: 1 },
1027
+ });
1028
+ const terminal = { ...v2Event('session.execution.succeeded', sessionID), durable: true };
1029
+ const normalContext = f.ctx.session.context;
1030
+ let contextReads = 0;
1031
+ f.ctx.session.context = (...args) => {
1032
+ contextReads++;
1033
+ return normalContext(...args);
1034
+ };
1035
+
1036
+ await admit('first');
1037
+ await f.push(terminal);
1038
+ assert.equal(contextReads, 0, 'a terminal-only event cannot read the prompt context');
1039
+ assert.deepEqual(recordList(f.store), []);
1040
+ await send('session.execution.started', 1);
1041
+ await send('session.inbox.delivered', 2, { inboxID: 'first' });
1042
+ await send('session.execution.succeeded', 3);
1043
+ await waitFor(() => recordList(f.store).length === 1);
1044
+
1045
+ await admit('second');
1046
+ const pending = path.join(f.store, 'sessions', `${observations.sha(sessionID, 32)}.json`);
1047
+ const pendingBefore = fs.readFileSync(pending, 'utf8');
1048
+ await f.push(terminal);
1049
+ await send('session.execution.started', 4);
1050
+ await send('session.inbox.delivered', 5, { inboxID: 'second' });
1051
+ await f.push(terminal);
1052
+ assert.equal(contextReads, 1, 'a replay cannot read the next prompt context');
1053
+ assert.equal(recordList(f.store).length, 1);
1054
+ assert.equal(fs.readFileSync(pending, 'utf8'), pendingBefore);
1055
+ const context = { sessionID, system: [] };
1056
+ f.sessionHooks.get('context')(context);
1057
+ assert.ok(context.system.length > 0, 'the next prompt route is still injectable');
1058
+
1059
+ f.setFinal(SECOND_LABEL);
1060
+ await send('session.execution.succeeded', 6);
1061
+ await waitFor(() => recordList(f.store).length === 2);
1062
+ assert.equal(contextReads, 2);
1063
+ assert.deepEqual(recordList(f.store).map(record => [record.writer.turnId, record.selfReport?.intents]), [
1064
+ ['first', ['fix', 'test']],
1065
+ ['second', ['edit']],
1066
+ ]);
1067
+ });
1068
+
835
1069
  test('control: a V2 turn end without a prompt route records nothing', { concurrency: false }, async () => {
836
1070
  const f = fixture();
837
1071
  let dispose;
@@ -852,15 +1086,17 @@ test('control: repeated V2 session.execution.succeeded events for one turn recor
852
1086
  try {
853
1087
  dispose = await install(f);
854
1088
  await f.sessionHooks.get('prompt')({ sessionID: 'dedupe', messageID: 'dedupe-1', prompt: { text: 'dedupe the turn end' } });
855
- const firstDone = f.push({ ...v2Event('session.execution.succeeded', 'dedupe'), id: 'evt-dedupe-1' });
856
- const secondDone = f.push({ ...v2Event('session.execution.succeeded', 'dedupe'), id: 'evt-dedupe-2' });
1089
+ await f.startExecution('dedupe', 'dedupe-1');
1090
+ const terminal = v2Event('session.execution.succeeded', 'dedupe');
1091
+ const firstDone = f.push(terminal);
1092
+ const secondDone = f.push(terminal);
857
1093
  await Promise.all([firstDone, secondDone]);
858
1094
  await waitFor(() => recordList(f.store).some(record => record.writer.sessionId === 'dedupe'));
859
1095
 
860
1096
  // Positive control in the same fixture: a second session completes and
861
1097
  // flushes the async observation path without duplicating the first turn.
862
1098
  await f.sessionHooks.get('prompt')({ sessionID: 'dedupe-control', messageID: 'dedupe-control-1', prompt: { text: 'flush the observation path' } });
863
- await f.push(v2Event('session.execution.succeeded', 'dedupe-control'));
1099
+ await f.completeTurn('dedupe-control', 'dedupe-control-1');
864
1100
  await waitFor(() => recordList(f.store).some(record => record.writer.sessionId === 'dedupe-control'));
865
1101
 
866
1102
  const dedupeRecords = recordList(f.store).filter(record => record.writer.sessionId === 'dedupe');
@@ -1897,7 +2133,7 @@ for (const outcome of ['resolved', 'rejected']) {
1897
2133
  await f.sessionHooks.get('prompt')({
1898
2134
  sessionID, messageID: 'd1-completion', prompt: { text: 'hold completion context across disposal' },
1899
2135
  });
1900
- completion = f.push(v2Event('session.execution.succeeded', sessionID));
2136
+ completion = f.completeTurn(sessionID, 'd1-completion');
1901
2137
  assert.equal(await waitUntil(() => contextStarted), true, 'the completion observation is waiting on host context');
1902
2138
 
1903
2139
  disposing = dispose();
@@ -1947,7 +2183,7 @@ test('D2 disposal: pending completion context detaches before the host read sett
1947
2183
  await f.sessionHooks.get('prompt')({
1948
2184
  sessionID, messageID: 'd2-completion', prompt: { text: 'detach pending completion context on disposal' },
1949
2185
  });
1950
- completion = f.push(v2Event('session.execution.succeeded', sessionID));
2186
+ completion = f.completeTurn(sessionID, 'd2-completion');
1951
2187
  assert.equal(await waitUntil(() => contextStarted), true, 'the real V2 observer entered the unresolved host read');
1952
2188
 
1953
2189
  disposing = dispose();
@@ -1999,7 +2235,7 @@ for (const outcome of ['throw', 'reject']) {
1999
2235
  await f.sessionHooks.get('prompt')({
2000
2236
  sessionID, messageID: `d2-${outcome}`, prompt: { text: 'context errors remain fail open while live' },
2001
2237
  });
2002
- completion = f.push(v2Event('session.execution.succeeded', sessionID));
2238
+ completion = f.completeTurn(sessionID, `d2-${outcome}`);
2003
2239
  await waitFor(() => recordList(f.store).length === 1);
2004
2240
  await completion;
2005
2241
 
@@ -87,6 +87,8 @@ test('OpenCode context probe strips baseline fragment and passes treatment fragm
87
87
  fs.mkdirSync(out);
88
88
  installOpenCodeCarrierProbe(setup, out, arm);
89
89
  const pluginPath = path.join(setup.repo, '.opencode/plugins/zz-ledger-probe.js');
90
+ // Node 22.0.0 needs an explicit module type to import the OpenCode fixture.
91
+ fs.writeFileSync(path.join(path.dirname(pluginPath), 'package.json'), '{"type":"module"}\n');
90
92
  const { default: plugin } = await import(`${pathToFileURL(pluginPath).href}?arm=${arm}`);
91
93
  let contextHook;
92
94
  let toolHook;
@@ -143,6 +143,20 @@ try {
143
143
  assert.match(denied.stderr, /structured-mutate/);
144
144
  }
145
145
 
146
+ for (const tool of ['mcp__codex_apps__github__create_issue', 'mcp__codex_apps__github_create_issue', 'mcp__github__create_issue']) {
147
+ const ok = run(payload(tool, { repository_full_name: 'acme/repo', title: 'Track follow-up', body: 'Details' }));
148
+ assert.strictEqual(ok.status, 0, `${tool} routine create_issue stdin payload must be host-deferred`);
149
+ assert.strictEqual(ok.stdout.trim(), '', `${tool} deferral must emit no permission decision`);
150
+ const bad = run(payload(tool, { repository_full_name: 'acme/repo', title: 'Bad extra', state: 'closed' }));
151
+ assert.strictEqual(bad.status, 2, `${tool} with extra key must fail closed`);
152
+ assert.match(bad.stderr, /structured-mutate/);
153
+ }
154
+ for (const tool of ['mcp__demo__create_issue', 'mcp__get_provider__create_issue', 'mcp__demo__create_issues', 'mcp__demo__foo_create_issue', 'create_issue']) {
155
+ const blocked = run(payload(tool, { repository_full_name: 'acme/repo', title: 'Spoofed' }));
156
+ assert.strictEqual(blocked.status, 2, `${tool} must remain a Codex block`);
157
+ assert.match(blocked.stderr, /structured-mutate/, `${tool} must remain a structured-mutate block`);
158
+ }
159
+
146
160
  // Genuine mutations remain blocked, but the fixed-format approval protocol is retired.
147
161
  const legacyMutation = run(payload('mcp__demo__update_issue', { issue_id: 1, title: 'changed' }));
148
162
  assert.strictEqual(legacyMutation.status, 2, 'genuine mutation must remain blocked on Codex');
package/docs/README.md ADDED
@@ -0,0 +1,81 @@
1
+ # Harness Documentation
2
+
3
+ Role- and task-oriented navigation portal for Harness. Each section links to the existing canonical documents without duplicating their content.
4
+
5
+ ```mermaid
6
+ flowchart LR
7
+ Start["New to Harness"] --> GS["Getting Started"]
8
+ GS --> UG["User Guide & Workflows"]
9
+ UG --> Arch["Architecture & Philosophy"]
10
+ UG --> Trust["Trust, Security & Evidence"]
11
+ Contrib["Contributing or Operating"] --> Dev["Development & Governance"]
12
+ Research["Exploring Experimental Work"] --> Res["Research & Experimental"]
13
+ ```
14
+
15
+ ## Getting Started
16
+
17
+ | Topic | Document | What it covers |
18
+ | --- | --- | --- |
19
+ | Overview & installation | [README.md](../README.md) | Problem statement, quick start, and install paths |
20
+ | Platform capability matrix | [platform-capabilities.md](platform-capabilities.md) | Supported hosts, install scopes, and live-host evidence boundaries |
21
+ | Machine-readable matrix | [platform-compatibility.json](platform-compatibility.json) | Structured host capability and verification statuses |
22
+ | Troubleshooting | [troubleshooting.md](troubleshooting.md) | Common setup, hook, and host-surface diagnostics |
23
+ | Support & issue reporting | [SUPPORT.md](../SUPPORT.md) | Where to report issues and what diagnostics to include |
24
+
25
+ ## User Guide & Workflows
26
+
27
+ | Topic | Document | What it covers |
28
+ | --- | --- | --- |
29
+ | Routing | [routing.md](routing.md) | Keyword routing signals, tier selection, and turn label line |
30
+ | Workflow runtime | [workflow-runtime.md](workflow-runtime.md) | Ordered requirement steps, bindings, and isolation rules |
31
+ | Audit | [audit.md](audit.md) | Self-audit checks and hook mechanism verification |
32
+ | Enforcement & locks | [enforcement-locks.md](enforcement-locks.md) | Active permission/safety boundaries and retired lock behavior |
33
+ | Contract integrity | [contract-integrity.md](contract-integrity.md) | Workflow and skill contract verification |
34
+ | OpenAI / Codex plugin | [openai-plugin.md](openai-plugin.md) | Local `.codex-plugin` setup vs. public Skills-only submission |
35
+ | Codex action gate | [codex-action-gate.md](codex-action-gate.md) | Codex-specific action-gate rules and deferred PR metadata policy |
36
+
37
+ ## Architecture & Philosophy
38
+
39
+ | Topic | Document | What it covers |
40
+ | --- | --- | --- |
41
+ | Philosophy | [philosophy.md](philosophy.md) | Minimal-rails design and `MUST` / `SHOULD` / `MAY` contract strength |
42
+ | Architecture | [architecture.md](architecture.md) | Core runtime components, hooks, and skill routing architecture |
43
+ | Mechanism-first skill mesh | [mechanism-first-skill-mesh.md](mechanism-first-skill-mesh.md) | Mechanism-first composition of skills and runtime checks |
44
+ | Reflection | [reflection.md](reflection.md) | Agent-initiated reassessment and zoom-out design |
45
+ | Architecture Decision Records | [adr/](adr/) | Accepted, proposed, and superseded ADRs |
46
+
47
+ ## Trust, Security & Evidence
48
+
49
+ | Topic | Document | What it covers |
50
+ | --- | --- | --- |
51
+ | Security policy | [SECURITY.md](../SECURITY.md) | Vulnerability reporting and hook security scope |
52
+ | Security audit | [security-audit.md](security-audit.md) | Repository security review notes and boundaries |
53
+ | Privacy notice | [PRIVACY.md](../PRIVACY.md) | Data handling, local-only state, and observation opt-out |
54
+ | Telemetry | [telemetry.md](telemetry.md) | Telemetry policy and local observation boundaries |
55
+ | System One observations | [system-one-observations.md](system-one-observations.md) | Local turn observation schema and redaction rules |
56
+ | Benchmarks | [benchmarks/README.md](../benchmarks/README.md) | Paired behavioral benchmark status and recording workflow |
57
+ | Release evidence | [release-evidence.md](release-evidence.md) | Observed npm/GitHub release verification ledger |
58
+ | Verifier boundaries | [verifier-boundaries.md](verifier-boundaries.md) | Path containment and exact execution evidence contracts |
59
+
60
+ ## Development & Governance
61
+
62
+ | Topic | Document | What it covers |
63
+ | --- | --- | --- |
64
+ | Contributing | [CONTRIBUTING.md](../CONTRIBUTING.md) | Local dev setup, quality gates, and PR expectations |
65
+ | Agent operating guide | [AGENTS.md](../AGENTS.md) | Repository layout, change rules, and verification commands |
66
+ | Repository contract | [repository-contract.md](repository-contract.md) | Generated Node runtime, workflow, and gate summary |
67
+ | Document lifecycle | [document-lifecycle.md](document-lifecycle.md) | Governance tiers, placement rules, and lifecycle checks |
68
+ | Governed document index | [governed-index.md](governed-index.md) | Active governed documents and ADR status index |
69
+ | Document-evidence boundary | [doc-evidence-boundary.md](doc-evidence-boundary.md) | Read-boundary enforcement for document evidence |
70
+
71
+ ## Research & Experimental
72
+
73
+ | Topic | Document | What it covers |
74
+ | --- | --- | --- |
75
+ | System One cycle | [system-one-cycle.md](system-one-cycle.md) | Monthly local observation, labeling, training, and publish runbook |
76
+ | System One routing | [system-one-routing.md](system-one-routing.md) | Experimental routing model integration and output contract |
77
+ | System One observations | [system-one-observations.md](system-one-observations.md) | Local observation store used by the training cycle |
78
+ | System One training | [system-one-training.md](system-one-training.md) | Classifier training stages and evaluation setup |
79
+ | System One corpus | [system-one-corpus.md](system-one-corpus.md) | Corpus construction and holdout structure |
80
+ | System One intent | [system-one-intent.md](system-one-intent.md) | Intent classification taxonomy and gating |
81
+ | Public roadmap | [ROADMAP.md](../ROADMAP.md) | Maturity tiers and linked GitHub Issues |