harness-everything 0.52.0 → 0.54.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.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/AGENTS.md +3 -1
- package/CHANGELOG.md +38 -0
- package/benchmarks/results/live-host/opencode-2026-11-15-workspace/README.md +7 -0
- package/benchmarks/results/live-host/opencode-2026-11-15-workspace/live-workspace-probe.js +16 -0
- package/benchmarks/results/live-host/opencode-2026-11-15-workspace/live-workspace-trace-2026-11-15.jsonl +4 -0
- package/bin/cli.js +1 -0
- package/ci/invariant-routing.test.js +22 -3
- package/ci/mechanism-2al-codex-hooks-compat.test.js +56 -2
- package/ci/mechanism-2n-opencode-plugin.test.js +1 -1
- package/ci/mechanism-2p-opencode-v2-entrypoint.test.js +18 -3
- package/ci/mechanism-338-opencode-async.test.js +20 -3
- package/ci/mechanism-341-opencode-lane.test.js +7 -1
- package/ci/mechanism-349-ci-change-scope.test.js +78 -57
- package/ci/mechanism-397-cycle-import.test.js +414 -0
- package/ci/mechanism-397-host-acceptance.test.js +119 -0
- package/ci/mechanism-397-opencode-observations.test.js +1922 -0
- package/ci/mechanism-check-packet-write-set.test.js +232 -0
- package/ci/mechanism-codex-prompt-pass-through.test.js +8 -4
- package/ci/mechanism-error-handling-map.test.js +219 -0
- package/ci/mechanism-report-writer.test.js +335 -0
- package/ci/mechanism-system-one-curves.test.js +17 -0
- package/ci/mechanism-system-one-cycle.test.js +621 -2
- package/ci/router-workflow-plan.test.js +50 -7
- package/docs/architecture.md +4 -3
- package/docs/error-handling/README.md +250 -0
- package/docs/error-handling/actions/c1-action-map.md +89 -0
- package/docs/error-handling/actions/c2-action-map.md +22 -0
- package/docs/error-handling/actions/c3-action-map.md +26 -0
- package/docs/error-handling/actions/c5-action-map.md +31 -0
- package/docs/error-handling/actions/c6-action-map.md +37 -0
- package/docs/error-handling/actions/c7-action-map.md +18 -0
- package/docs/error-handling/actions/e0002-action-map.md +101 -0
- package/docs/error-handling/activity.puml +84 -0
- package/docs/error-handling/details/c1-authority-conformance.md +93 -0
- package/docs/error-handling/details/c2-test-root-containment.md +35 -0
- package/docs/error-handling/details/c3-mode-ownership.md +50 -0
- package/docs/error-handling/details/c5-host-replay-contract.md +40 -0
- package/docs/error-handling/details/c6-packet-briefing.md +65 -0
- package/docs/error-handling/details/c7-write-set-check.md +54 -0
- package/docs/error-handling/details/e0002-capture-evidence.md +93 -0
- package/docs/error-handling/details/e0002-report-writer.md +116 -0
- package/docs/error-handling/nodes.yaml +44 -0
- package/docs/error-handling/registry.md +59 -0
- package/docs/error-handling/templates/packet-briefing.md +45 -0
- package/docs/platform-capabilities.md +16 -7
- package/docs/system-one-cycle.md +12 -3
- package/docs/system-one-observations.md +35 -4
- package/hooks/scripts/codex-user-prompt.js +2 -3
- package/hooks/scripts/lib/observations.js +5 -3
- package/opencode-plugin/README.md +22 -8
- package/opencode-plugin/index.mjs +424 -44
- package/opencode-plugin/plugin.json +1 -1
- package/package.json +2 -1
- package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
- package/plugins/harness-everything/hooks/scripts/codex-user-prompt.js +2 -3
- package/plugins/harness-everything/hooks/scripts/lib/observations.js +5 -3
- package/plugins/harness-everything/plugin.json +1 -1
- package/sbom.cdx.json +7 -7
- package/scripts/check-packet-write-set.js +155 -0
- package/scripts/codex-hooks-compat.js +46 -5
- package/scripts/error-handling-map.js +288 -0
- package/scripts/report-writer.js +261 -0
- package/scripts/system-one-curves.js +154 -14
- package/scripts/system-one-cycle/collect.js +20 -3
- package/scripts/system-one-cycle/common.js +39 -1
- package/scripts/system-one-cycle/evaluate.js +8 -5
- package/scripts/system-one-cycle.js +7 -2
- package/scripts/system-one-observations-export.js +29 -0
- package/scripts/system-one-observations-import-store.js +128 -0
|
@@ -18,7 +18,7 @@ const USAGE = `Usage:
|
|
|
18
18
|
node scripts/system-one-cycle.js all --until <step> --data-dir <private cycle directory> [options]
|
|
19
19
|
|
|
20
20
|
Steps: ${STEPS.join(', ')}
|
|
21
|
-
Options: --since YYYY-MM-DD --sessions <Codex sessions dir> --version <id> --threads 4 --max-rss-mb 6144 --holdout <file> (repeatable)`;
|
|
21
|
+
Options: --since YYYY-MM-DD --sessions <Codex sessions dir> --version <id> --threads 4 --max-rss-mb 6144 --holdout <file> (repeatable) --history <private-history.jsonl> (evaluate/all)`;
|
|
22
22
|
|
|
23
23
|
function values(flags, name) {
|
|
24
24
|
const value = flags[name];
|
|
@@ -37,6 +37,11 @@ function numberFlag(flags, name, fallback) {
|
|
|
37
37
|
return value;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
function historyFlag(flags) {
|
|
41
|
+
if (Array.isArray(flags.history)) throw new Error('--history may be supplied only once');
|
|
42
|
+
return flag(flags, 'history');
|
|
43
|
+
}
|
|
44
|
+
|
|
40
45
|
function outputsFor(step, dataDir, version, versionDir, result) {
|
|
41
46
|
switch (step) {
|
|
42
47
|
case 'collect': return ['training/observed/prompts-observed.jsonl', 'training/observed/labels-observed.jsonl'];
|
|
@@ -82,7 +87,7 @@ async function runStep(step, flags, dataDir) {
|
|
|
82
87
|
break;
|
|
83
88
|
case 'evaluate':
|
|
84
89
|
version = validateVersion(required(flags, 'version'));
|
|
85
|
-
result = evaluateCycle({ dataDir, version });
|
|
90
|
+
result = evaluateCycle({ dataDir, version, history: historyFlag(flags) });
|
|
86
91
|
break;
|
|
87
92
|
case 'package':
|
|
88
93
|
version = validateVersion(required(flags, 'version'));
|
|
@@ -82,6 +82,33 @@ function run(args) {
|
|
|
82
82
|
obs.sweep(store);
|
|
83
83
|
const index = obs.readJson(path.join(store, 'observations-index.json'), null);
|
|
84
84
|
if (!index || index.schemaVersion !== 1 || !Array.isArray(index.records)) throw new Error(`no observation index in ${store}`);
|
|
85
|
+
const malformedLabelReasons = new Set(['label-invalid', 'label-unparseable']);
|
|
86
|
+
const acceptanceByHost = {};
|
|
87
|
+
const seenTurns = new Set();
|
|
88
|
+
for (const record of index.records) {
|
|
89
|
+
const host = String(record.host || 'unknown');
|
|
90
|
+
const counts = acceptanceByHost[host] || (acceptanceByHost[host] = { valid: 0, invalid: 0, missing: 0 });
|
|
91
|
+
if (since !== null && (!Number.isFinite(Date.parse(record.observedAt || '')) || Date.parse(record.observedAt) < since)) continue;
|
|
92
|
+
const writer = record.writer || {};
|
|
93
|
+
const sessionId = String(writer.sessionId || '');
|
|
94
|
+
const turnId = String(writer.turnId || '');
|
|
95
|
+
const turn = Number.isInteger(record.turn) ? String(record.turn) : '';
|
|
96
|
+
const uniqueTurn = sessionId && turnId ? `${host}\0${sessionId}\0id:${turnId}`
|
|
97
|
+
: sessionId && turn ? `${host}\0${sessionId}\0ordinal:${turn}` : record.id ? `${host}\0record:${record.id}` : '';
|
|
98
|
+
if (uniqueTurn && seenTurns.has(uniqueTurn)) continue;
|
|
99
|
+
if (uniqueTurn) seenTurns.add(uniqueTurn);
|
|
100
|
+
if (record.selfReport) counts.valid++;
|
|
101
|
+
else if (malformedLabelReasons.has(record.selfReportReason)) counts.invalid++;
|
|
102
|
+
else counts.missing++;
|
|
103
|
+
}
|
|
104
|
+
const hostAcceptanceByHost = Object.fromEntries(Object.entries(acceptanceByHost).sort(([left], [right]) => left.localeCompare(right))
|
|
105
|
+
.map(([host, counts]) => {
|
|
106
|
+
const eligible = counts.valid + counts.invalid + counts.missing;
|
|
107
|
+
return [host, { eligible, ...counts, acceptanceRate: eligible ? counts.valid / eligible : null }];
|
|
108
|
+
}));
|
|
109
|
+
const malformedLabelsByHost = Object.fromEntries(Object.entries(hostAcceptanceByHost)
|
|
110
|
+
.filter(([, counts]) => counts.invalid)
|
|
111
|
+
.map(([host, counts]) => [host, counts.invalid]));
|
|
85
112
|
const rows = [];
|
|
86
113
|
let skippedNoText = 0;
|
|
87
114
|
let skippedBeforeSince = 0;
|
|
@@ -137,6 +164,8 @@ function run(args) {
|
|
|
137
164
|
since: sinceText, selfReportOnly, skippedBeforeSince, skippedUnlabeled,
|
|
138
165
|
skippedNoText, validationRows: validation, withSelfReport: withSelf.length,
|
|
139
166
|
selfReportReasons: count(r => r.record.selfReportReason || 'ok'), hosts: count(r => r.record.host),
|
|
167
|
+
malformedLabelsByHost: Object.fromEntries(Object.entries(malformedLabelsByHost).sort(([left], [right]) => left.localeCompare(right))),
|
|
168
|
+
hostAcceptance: { population: 'stored-observations', byHost: hostAcceptanceByHost },
|
|
140
169
|
validity: count(r => r.label.validity), tiers: count(r => r.label.tier), tierSources: count(r => r.label.tierSource),
|
|
141
170
|
behaviorEvidence: {
|
|
142
171
|
observed: rows.filter(r => r.label.behaviorEvidence === 'observed').length,
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
const obs = require('../hooks/scripts/lib/observations');
|
|
6
|
+
const { assertPrivateDataDir } = require('./system-one-cycle/common');
|
|
7
|
+
|
|
8
|
+
function parseSince(value) {
|
|
9
|
+
if (typeof value !== 'string') throw new Error('invalid-since');
|
|
10
|
+
const text = value;
|
|
11
|
+
const timestamp = Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(text) ? `${text}T00:00:00.000Z` : text);
|
|
12
|
+
if (!Number.isFinite(timestamp)) throw new Error('invalid-since');
|
|
13
|
+
return timestamp;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function bucket(byHost, host) {
|
|
17
|
+
if (!Object.hasOwn(byHost, host)) {
|
|
18
|
+
Object.defineProperty(byHost, host, {
|
|
19
|
+
value: { persisted: 0, duplicate: 0, ambiguous: 0, importFailure: 0 }, enumerable: true, configurable: true, writable: true,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return byHost[host];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function importStore({ sourceRoot = obs.storeRoot(), store, since, lockTimeoutMs } = {}) {
|
|
26
|
+
const report = {
|
|
27
|
+
source: { root: 'configured-private-store', status: 'absent' },
|
|
28
|
+
byHost: {},
|
|
29
|
+
};
|
|
30
|
+
const fail = (host, code) => {
|
|
31
|
+
bucket(report.byHost, host).importFailure++;
|
|
32
|
+
report.source.status = 'error';
|
|
33
|
+
report.source.error ||= code;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
let cutoff;
|
|
37
|
+
try { cutoff = parseSince(since); }
|
|
38
|
+
catch { fail('unknown', 'invalid-since'); return report; }
|
|
39
|
+
|
|
40
|
+
if (typeof store !== 'string' || !store.trim() || !path.isAbsolute(store)
|
|
41
|
+
|| typeof sourceRoot !== 'string' || !sourceRoot.trim()) {
|
|
42
|
+
fail('unknown', typeof store !== 'string' || !store.trim() || !path.isAbsolute(store) ? 'invalid-destination' : 'invalid-source-root');
|
|
43
|
+
return report;
|
|
44
|
+
}
|
|
45
|
+
let destination;
|
|
46
|
+
let source;
|
|
47
|
+
try { destination = assertPrivateDataDir(store); }
|
|
48
|
+
catch { fail('unknown', 'destination-unavailable'); return report; }
|
|
49
|
+
try { source = assertPrivateDataDir(sourceRoot, { create: false }); }
|
|
50
|
+
catch { fail('unknown', 'source-unavailable'); return report; }
|
|
51
|
+
|
|
52
|
+
const destinationIndex = path.join(destination, 'observations-index.json');
|
|
53
|
+
try {
|
|
54
|
+
fs.mkdirSync(destination, { recursive: true, mode: 0o700 });
|
|
55
|
+
try { fs.writeFileSync(destinationIndex, '{"schemaVersion":1,"kind":"system-one-observations","records":[]}\n', { flag: 'wx', mode: 0o600 }); }
|
|
56
|
+
catch (error) { if (error.code !== 'EEXIST') throw error; }
|
|
57
|
+
const existing = JSON.parse(fs.readFileSync(destinationIndex, 'utf8'));
|
|
58
|
+
if (existing.schemaVersion !== 1 || !Array.isArray(existing.records)) throw new Error('invalid destination index');
|
|
59
|
+
} catch { fail('unknown', 'destination-unavailable'); return report; }
|
|
60
|
+
|
|
61
|
+
const sourceIndex = path.join(source, 'observations-index.json');
|
|
62
|
+
if (!fs.existsSync(sourceIndex)) return report;
|
|
63
|
+
|
|
64
|
+
let index;
|
|
65
|
+
try { index = JSON.parse(fs.readFileSync(sourceIndex, 'utf8')); }
|
|
66
|
+
catch { fail('unknown', 'source-index-invalid'); return report; }
|
|
67
|
+
if (!index || index.schemaVersion !== 1 || !Array.isArray(index.records)) {
|
|
68
|
+
fail('unknown', 'source-index-invalid');
|
|
69
|
+
return report;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
report.source.status = 'ok';
|
|
73
|
+
for (const record of index.records) {
|
|
74
|
+
if (!record || typeof record !== 'object' || Array.isArray(record)) {
|
|
75
|
+
fail('unknown', 'source-record-invalid');
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const host = typeof record.host === 'string' && record.host.trim() ? record.host : 'unknown';
|
|
79
|
+
const observedAt = typeof record.observedAt === 'string' ? Date.parse(record.observedAt) : NaN;
|
|
80
|
+
if (!Number.isFinite(observedAt)) { fail(host, 'source-record-invalid'); continue; }
|
|
81
|
+
if (observedAt < cutoff) continue;
|
|
82
|
+
const result = bucket(report.byHost, host);
|
|
83
|
+
const writer = record.writer && typeof record.writer === 'object' ? record.writer : {};
|
|
84
|
+
const sessionId = typeof writer.sessionId === 'string' ? writer.sessionId : '';
|
|
85
|
+
if (typeof record.id !== 'string' || !record.id || typeof record.contentSha256 !== 'string'
|
|
86
|
+
|| !/^[a-f\d]{64}$/i.test(record.contentSha256)) {
|
|
87
|
+
fail(host, 'source-record-invalid');
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (host === 'unknown' || !sessionId || (writer.turnId !== undefined && typeof writer.turnId !== 'string')) {
|
|
91
|
+
result.ambiguous++;
|
|
92
|
+
report.source.status = 'error';
|
|
93
|
+
report.source.error ||= 'ambiguous-records';
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const retained = Number.isFinite(Date.parse(record.validUntil || ''));
|
|
98
|
+
const text = retained ? obs.recordText(source, record) : null;
|
|
99
|
+
if (text !== null && (!text || typeof text.prompt !== 'string'
|
|
100
|
+
|| !(text.previous === undefined || typeof text.previous === 'string'))) {
|
|
101
|
+
fail(host, 'source-text-invalid');
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
let appended;
|
|
105
|
+
try {
|
|
106
|
+
appended = obs.appendRecordDetailed(destination, record, text, {
|
|
107
|
+
dedupeByTurn: true,
|
|
108
|
+
...(lockTimeoutMs === undefined ? {} : { lockTimeoutMs }),
|
|
109
|
+
});
|
|
110
|
+
} catch {
|
|
111
|
+
fail(host, 'append-failed');
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
if (appended.status === 'appended') result.persisted++;
|
|
115
|
+
else if (appended.status === 'duplicate') result.duplicate++;
|
|
116
|
+
else if (appended.status === 'ambiguous') {
|
|
117
|
+
result.ambiguous++;
|
|
118
|
+
report.source.status = 'error';
|
|
119
|
+
report.source.error ||= 'ambiguous-records';
|
|
120
|
+
} else {
|
|
121
|
+
fail(host, 'append-failed');
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return report;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
module.exports = { importStore };
|