harness-everything 1.5.4 → 1.6.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.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.github/ISSUE_TEMPLATE/bug_report.yml +68 -0
- package/.github/ISSUE_TEMPLATE/config.yml +8 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +33 -0
- package/.github/ISSUE_TEMPLATE/platform_compatibility.yml +80 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +19 -0
- package/.github/dependabot.yml +13 -0
- package/.github/workflows/ci.yml +2 -2
- package/.github/workflows/release.yml +1 -1
- package/CHANGELOG.md +27 -0
- package/PRIVACY.md +34 -14
- package/README.md +76 -311
- package/ROADMAP.md +50 -0
- package/SECURITY.md +29 -8
- package/SUPPORT.md +4 -4
- package/TERMS.md +3 -3
- package/behavioral-evals/paired-benchmark.js +2 -2
- package/behavioral-evals/run-with-plugin.js +8 -3
- package/behavioral-evals/run.js +5 -3
- package/benchmarks/results/live-host/opencode-2026-12-02-450-steering/README.md +20 -0
- package/benchmarks/results/live-host/opencode-2026-12-02-450-steering/lifecycle.sanitized.jsonl +14 -0
- package/benchmarks/results/live-host/opencode-2026-12-02-450-steering/observations.sanitized.json +20 -0
- package/bin/cli.js +30 -7
- package/ci/ab-test-harness.js +2 -2
- package/ci/action-gate.test.js +186 -0
- package/ci/installer-roundtrip.test.js +20 -0
- package/ci/lib/opencode-v2-driver.js +3 -1
- package/ci/mechanism-2aa-codex-action-gate-policy.test.js +21 -0
- package/ci/mechanism-2ap-sbom.test.js +6 -6
- package/ci/mechanism-2j-behavioral-runner.test.js +45 -1
- package/ci/mechanism-2j-fixture-entrypoints.test.js +39 -0
- package/ci/mechanism-2x-release-commit-message.test.js +34 -23
- package/ci/mechanism-32-paired-benchmark.test.js +38 -0
- package/ci/mechanism-341-opencode-lane.test.js +5 -1
- package/ci/mechanism-397-cycle-import.test.js +5 -1
- package/ci/mechanism-397-opencode-observations.test.js +260 -24
- package/ci/mechanism-468-dispatch-cli.test.js +23 -0
- package/ci/mechanism-552-ledger-pairs.test.js +2 -0
- package/ci/mechanism-system-one-curves.test.js +26 -3
- package/ci/mechanism-system-one-cycle.test.js +5 -4
- package/ci/mechanism-system-one-live.test.js +6 -1
- package/ci/mechanism-task-git-authorization.test.js +14 -0
- package/docs/README.md +81 -0
- package/docs/codex-action-gate.md +1 -1
- package/docs/platform-capabilities.md +9 -4
- package/docs/platform-compatibility.json +3 -3
- package/docs/system-one-cycle.md +5 -5
- package/docs/system-one-routing.md +10 -7
- package/docs/system-one-training.md +4 -5
- package/harness-everything/SKILL.md +1 -1
- package/harness-everything/scripts/system-one/router.js +0 -1
- package/hooks/scripts/action-gate.js +82 -2
- package/opencode-plugin/index.mjs +97 -35
- package/opencode-plugin/plugin.json +1 -1
- package/package.json +15 -2
- package/plugins/harness-everything/.antigravity-plugin/plugin.json +1 -1
- package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
- package/plugins/harness-everything/hooks/scripts/action-gate.js +82 -2
- package/plugins/harness-everything/plugin.json +1 -1
- package/plugins/harness-everything/skills/harness-everything/SKILL.md +1 -1
- package/plugins/harness-everything/skills/harness-everything/scripts/system-one/router.js +0 -1
- package/sbom.cdx.json +7 -7
- package/scripts/dispatch.js +3 -2
- package/scripts/system-one-curves.js +4 -32
|
@@ -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.
|
|
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.
|
|
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.
|
|
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.
|
|
525
|
+
f.completeTurn('session-b', 'turn-b');
|
|
523
526
|
await waitFor(() => recordList(f.store).length === 1);
|
|
524
|
-
f.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
-
|
|
856
|
-
const
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
2238
|
+
completion = f.completeTurn(sessionID, `d2-${outcome}`);
|
|
2003
2239
|
await waitFor(() => recordList(f.store).length === 1);
|
|
2004
2240
|
await completion;
|
|
2005
2241
|
|
|
@@ -578,6 +578,29 @@ try {
|
|
|
578
578
|
assert.match(result.stdout, /total tokens incl\. cache: 14/);
|
|
579
579
|
assert.ok(fs.readFileSync(testCase.report, 'utf8').endsWith('STATUS: DONE\n'));
|
|
580
580
|
});
|
|
581
|
+
check('466 human long diagnostic is capped while JSON and measured budget remain unchanged', () => {
|
|
582
|
+
const reason = 'x'.repeat(1200);
|
|
583
|
+
const telemetry = { input_tokens: 30_000_000, cached_input_tokens: 12_000_000, output_tokens: 1 };
|
|
584
|
+
const usage = { totalTokens: 30_000_001, mark: 'OVER-BUDGET' };
|
|
585
|
+
|
|
586
|
+
const humanCase = makeCase('human long diagnostic');
|
|
587
|
+
const human = cli([...argsFor(humanCase, 'codex')], humanCase, {
|
|
588
|
+
rawOverride: `Fixture blocked the packet.\nSTATUS: BLOCKED: ${reason}\n`,
|
|
589
|
+
extraEnv: { DISPATCH_FIXTURE_USAGE: JSON.stringify(telemetry) },
|
|
590
|
+
});
|
|
591
|
+
const diagnostic = `dispatch: worker delivered a valid BLOCKED report: ${reason}`;
|
|
592
|
+
assert.equal(human.status, 17, human.stdout);
|
|
593
|
+
assert.equal(human.stdout, '');
|
|
594
|
+
assert.equal(human.stderr.trimEnd(), `dispatch: ${diagnostic.slice('dispatch: '.length).slice(0, 1000)}`);
|
|
595
|
+
|
|
596
|
+
const jsonCase = makeCase('JSON long diagnostic');
|
|
597
|
+
const json = jsonResponse(cli([...argsFor(jsonCase, 'codex'), '--json'], jsonCase, {
|
|
598
|
+
rawOverride: `Fixture blocked the packet.\nSTATUS: BLOCKED: ${reason}\n`,
|
|
599
|
+
extraEnv: { DISPATCH_FIXTURE_USAGE: JSON.stringify(telemetry) },
|
|
600
|
+
}), 17, 'WORKER_BLOCKED');
|
|
601
|
+
assert.equal(json.message, diagnostic.slice('dispatch: '.length).slice(0, 1000));
|
|
602
|
+
assert.deepEqual(json.usage, usage);
|
|
603
|
+
});
|
|
581
604
|
check('468 completed telemetry is retained when a valid BLOCKED report is delivered', () => {
|
|
582
605
|
const telemetry = { input_tokens: 30_000_000, cached_input_tokens: 12_000_000, output_tokens: 1 };
|
|
583
606
|
const doneCase = makeCase('done report with same usage');
|
|
@@ -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;
|
|
@@ -99,6 +99,13 @@ test('better ranking with worse calibration does not auto-promote', t => {
|
|
|
99
99
|
['a', 0.95, 0.1], ['b', 0.1, 0.95], ['a', 0.95, 0.1], ['b', 0.95, 0.9],
|
|
100
100
|
]) });
|
|
101
101
|
assert.equal(trend.verdict, 'hold');
|
|
102
|
+
assert.deepEqual(trend.compared, ['v0', 'v1']);
|
|
103
|
+
assert.deepEqual(trend.reasons.slice(0, 4), [
|
|
104
|
+
'tier coverage-accuracy AUC delta +0.250000 vs v0',
|
|
105
|
+
'tier log-loss delta -0.246765 vs v0',
|
|
106
|
+
'tier ECE delta +0.125000 vs v0',
|
|
107
|
+
'old-holdout floor unknown; promotion requires a checked floor',
|
|
108
|
+
]);
|
|
102
109
|
assert.ok(curves.stages.tier.ece > 0);
|
|
103
110
|
assert.ok(trend.reasons.some(reason => reason.includes('coverage-accuracy AUC delta +')));
|
|
104
111
|
assert.ok(trend.reasons.some(reason => reason.includes('ECE delta +')));
|
|
@@ -341,7 +348,7 @@ test('validity reference-only invalid keeps its established semantics (unchanged
|
|
|
341
348
|
assert.deepEqual(curve[25], [0.25, 1, 0.5]);
|
|
342
349
|
});
|
|
343
350
|
|
|
344
|
-
test('active trend
|
|
351
|
+
test('active trend remains unknown after two worsening candidate comparisons', t => {
|
|
345
352
|
const f = fixture(t);
|
|
346
353
|
const cycles = [
|
|
347
354
|
validityRows([['invalid', 0.8], ['invalid', 0.8], ['actionable', 0.2], ['actionable', 0.2]]),
|
|
@@ -350,6 +357,22 @@ test('active trend rolls back after two consecutive worsening cycles', t => {
|
|
|
350
357
|
];
|
|
351
358
|
cycles.forEach((val, i) => f.run({ version: `v${i}`, val }));
|
|
352
359
|
const { trend } = f.run({ version: 'v3', val: cycles[2] });
|
|
353
|
-
assert.equal(trend.verdict, '
|
|
354
|
-
assert.ok(trend.reasons.some(reason => reason.includes('
|
|
360
|
+
assert.equal(trend.verdict, 'hold');
|
|
361
|
+
assert.ok(trend.reasons.some(reason => reason.includes('active trend is unknown')));
|
|
362
|
+
assert.ok(!trend.reasons.some(reason => reason.includes('two consecutive')));
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
test('active trend stays unknown when held candidate rows are unbound to active identity', t => {
|
|
366
|
+
const f = fixture(t);
|
|
367
|
+
const activeA = validityRows([['invalid', 0.8], ['invalid', 0.8], ['actionable', 0.2], ['actionable', 0.2]]);
|
|
368
|
+
const heldB = validityRows([['invalid', 0.9], ['invalid', 0.9], ['actionable', 0.9], ['actionable', 0.9]]);
|
|
369
|
+
const rejectedC = validityRows([['invalid', 0.6], ['invalid', 0.6], ['actionable', 0.9], ['actionable', 0.9]]);
|
|
370
|
+
f.run({ version: 'active-a', val: activeA });
|
|
371
|
+
assert.equal(f.run({ version: 'held-b', val: heldB }).trend.verdict, 'hold');
|
|
372
|
+
assert.equal(f.run({ version: 'rejected-c', val: rejectedC }).trend.verdict, 'hold');
|
|
373
|
+
|
|
374
|
+
const { trend } = f.run({ version: 'next', val: rejectedC });
|
|
375
|
+
assert.equal(trend.verdict, 'hold');
|
|
376
|
+
assert.ok(trend.reasons.some(reason => reason.includes('active trend is unknown')));
|
|
377
|
+
assert.ok(!trend.reasons.some(reason => reason.includes('active curve worsened')));
|
|
355
378
|
});
|
|
@@ -1228,8 +1228,9 @@ test('446 cross-cycle: four evaluations detect two worsening transitions across
|
|
|
1228
1228
|
}
|
|
1229
1229
|
|
|
1230
1230
|
const { trend } = evaluation446(monthB.dataDir, 'v3');
|
|
1231
|
-
assert.equal(trend.verdict, '
|
|
1232
|
-
assert.ok(trend.reasons.some(reason => reason.includes('
|
|
1231
|
+
assert.equal(trend.verdict, 'hold');
|
|
1232
|
+
assert.ok(trend.reasons.some(reason => reason.includes('active trend is unknown')));
|
|
1233
|
+
assert.ok(!trend.reasons.some(reason => reason.includes('two consecutive cycles')));
|
|
1233
1234
|
assert.deepEqual(rows446(history).map(row => row.version), ['v0', 'v1', 'v2', 'v3']);
|
|
1234
1235
|
});
|
|
1235
1236
|
|
|
@@ -1510,7 +1511,7 @@ test('446 H2: rejects stale predecessor metrics and reordered trend rows before
|
|
|
1510
1511
|
for (const [fixture, version, quality] of [
|
|
1511
1512
|
[monthA, 'v0', 0.9], [monthB, 'v1', 0.8], [monthB, 'v2', 0.7], [monthB, 'v3', 0.6],
|
|
1512
1513
|
]) assert.equal(run446Cycle(fixture, version, { history: originalHistory, quality, all: true }).status, 0);
|
|
1513
|
-
assert.equal(evaluation446(monthB.dataDir, 'v3').trend.verdict, '
|
|
1514
|
+
assert.equal(evaluation446(monthB.dataDir, 'v3').trend.verdict, 'hold');
|
|
1514
1515
|
|
|
1515
1516
|
const changedHistory = path.join(tmp, 'changed-prior-history.jsonl');
|
|
1516
1517
|
const changedB = setup446Cycle(t, path.join(tmp, 'changed-b'), [
|
|
@@ -1528,7 +1529,7 @@ test('446 H2: rejects stale predecessor metrics and reordered trend rows before
|
|
|
1528
1529
|
path.join(monthB.dataDir, 'cycle-state.json'), monthB.callLog];
|
|
1529
1530
|
const changedBefore = snapshot446(changedPaths);
|
|
1530
1531
|
const changed = run446Cycle(monthB, 'v3', { history: changedHistory, quality: 0.6 });
|
|
1531
|
-
assert.notEqual(changed.status, 0, 'same baseline with changed prior comparison rows must reject
|
|
1532
|
+
assert.notEqual(changed.status, 0, 'same baseline with changed prior comparison rows must reject stale saved trend output');
|
|
1532
1533
|
assertSnapshot446(changedBefore);
|
|
1533
1534
|
assert.equal(fs.readFileSync(changedHistory, 'utf8'), changedBytes);
|
|
1534
1535
|
|
|
@@ -272,9 +272,14 @@ test('S1-L04 workflow plan carries the fixed object and user output labels score
|
|
|
272
272
|
version: 'v1', sha256: '0123456789abcdef',
|
|
273
273
|
stageScores: { validity: { invalid: 0.1 }, intent: intentScores(), tier: { tier1: 0.2, tier2: 0.76, tier3: 0.9 } },
|
|
274
274
|
thresholds: { validity: { invalid: 0.55 }, intent: stages.intent.thresholds, tier: stages.tier.thresholds },
|
|
275
|
+
referenceOnly: { validity: [], intent: ['unclassified'], tier: [] },
|
|
275
276
|
};
|
|
276
277
|
const contract = run('fixture request with clear scope', null, { systemOneResult: result });
|
|
277
|
-
assert.deepEqual(Object.keys(contract.workflowPlan.systemOne), ['version', 'sha256', 'mode', 'inputEnrichment', '
|
|
278
|
+
assert.deepEqual(Object.keys(contract.workflowPlan.systemOne), ['version', 'sha256', 'mode', 'inputEnrichment', 'validity', 'intents', 'tier', 'decision']);
|
|
279
|
+
const referencePrefix = '=> SYSTEM ONE REFERENCE CONFIDENCE (not a verdict): ';
|
|
280
|
+
const referenceLine = lines.find(line => line.includes(referencePrefix));
|
|
281
|
+
assert.deepEqual(JSON.parse(referenceLine.slice(referenceLine.indexOf(referencePrefix) + referencePrefix.length)).referenceOnlyOptions,
|
|
282
|
+
[{ stage: 'intent', id: 'unclassified', probability: 0.99 }]);
|
|
278
283
|
assert.deepEqual(contract.workflowPlan.systemOne.inputEnrichment, { handoffFiles: 0 });
|
|
279
284
|
assert.deepEqual(contract.workflowPlan.systemOne.decision, { validity: 'actionable', intents: ['feature', 'fix', 'docs'], tier: 'tier3' });
|
|
280
285
|
assert.deepEqual(JSON.parse(fs.readFileSync(env.HARNESS_ROUTER_CONTRACT_PATH, 'utf8')).workflowPlan.systemOne, contract.workflowPlan.systemOne);
|
|
@@ -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');
|