harness-everything 0.22.0 → 0.23.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 (56) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +12 -0
  4. package/README.md +30 -0
  5. package/benchmarks/fixtures/system-one-holdout-draft.json +2039 -0
  6. package/benchmarks/fixtures/system-one-holdout-reviews.json +1587 -0
  7. package/benchmarks/fixtures/system-one-holdout.json +7315 -0
  8. package/benchmarks/results/system-one/cua-s1-forms-resident-async-cpu-2026-09-23/README.md +87 -0
  9. package/benchmarks/results/system-one/cua-s1-forms-resident-async-cpu-2026-09-23/paired-latency.json +107 -0
  10. package/benchmarks/results/system-one/cua-s1-forms-resident-async-cpu-2026-09-23/report.json +856 -0
  11. package/benchmarks/results/system-one/lexical-baseline-reviewed-holdout-2026-09-23/README.md +47 -0
  12. package/benchmarks/results/system-one/lexical-baseline-reviewed-holdout-2026-09-23/report.json +5222 -0
  13. package/benchmarks/results/system-one/pre-merge-review-2026-09-23/README.md +92 -0
  14. package/benchmarks/results/system-one/pre-merge-review-2026-09-23/haiku-spec-conformance.md +241 -0
  15. package/benchmarks/results/system-one/pre-merge-review-2026-09-23/luna-adversarial.md +212 -0
  16. package/benchmarks/results/system-one/pre-merge-review-2026-09-23/skill-top1-probe.js +83 -0
  17. package/benchmarks/results/system-one/pre-merge-review-2026-09-23/skill-top1-probe.json +7700 -0
  18. package/ci/fixtures/system-one-worker-probe.js +15 -0
  19. package/ci/mechanism-system-one-corpus.test.js +154 -0
  20. package/ci/mechanism-system-one-resident.test.js +114 -3
  21. package/ci/mechanism-system-one-router.test.js +25 -0
  22. package/docs/platform-capabilities.md +7 -2
  23. package/docs/system-one-corpus.md +103 -0
  24. package/docs/system-one-routing.md +25 -5
  25. package/evals/pilot-router-nonsoftware/graders/no-tier-language.md +6 -0
  26. package/evals/pilot-router-nonsoftware/graders/skill-not-fired.md +9 -0
  27. package/evals/pilot-router-nonsoftware/prompt.md +8 -0
  28. package/evals/pilot-router-tier3/graders/skill-fired.md +6 -0
  29. package/evals/pilot-router-tier3/prompt.md +8 -0
  30. package/evals/pilot-tdd-bugfix/graders/skill-fired.md +6 -0
  31. package/evals/pilot-tdd-bugfix/prompt.md +8 -0
  32. package/evals/pilot-tdd-trivia/graders/no-red-phase-claim.md +7 -0
  33. package/evals/pilot-tdd-trivia/graders/skill-not-fired.md +9 -0
  34. package/evals/pilot-tdd-trivia/prompt.md +8 -0
  35. package/evals/pilot-verify-discussion/graders/no-verification-claim.md +7 -0
  36. package/evals/pilot-verify-discussion/graders/skill-not-fired.md +9 -0
  37. package/evals/pilot-verify-discussion/prompt.md +8 -0
  38. package/evals/pilot-verify-preship/graders/skill-fired.md +6 -0
  39. package/evals/pilot-verify-preship/prompt.md +8 -0
  40. package/harness-everything/SKILL.md +1 -1
  41. package/harness-everything/scripts/system-one/provider.js +14 -2
  42. package/harness-everything/scripts/system-one/resident.js +26 -2
  43. package/harness-everything/scripts/system-one/router.js +17 -1
  44. package/harness-everything/scripts/tier-router.js +13 -4
  45. package/opencode-plugin/plugin.json +1 -1
  46. package/package.json +1 -1
  47. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  48. package/plugins/harness-everything/plugin.json +1 -1
  49. package/plugins/harness-everything/skills/harness-everything/SKILL.md +1 -1
  50. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/provider.js +14 -2
  51. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/resident.js +26 -2
  52. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/router.js +17 -1
  53. package/plugins/harness-everything/skills/harness-everything/scripts/tier-router.js +13 -4
  54. package/sbom.cdx.json +7 -7
  55. package/scripts/evaluate-system-one.js +6 -6
  56. package/scripts/system-one-corpus.js +99 -0
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+ // Preload (NODE_OPTIONS --require) that proves which System One client path ran.
3
+ // HARNESS_TEST_WORKER_MODE=deny makes every worker thread fail to start; =count records
4
+ // how many were started into HARNESS_TEST_WORKER_COUNT_FILE when the process exits.
5
+ const fs = require('node:fs');
6
+ const threads = require('node:worker_threads');
7
+ const mode = process.env.HARNESS_TEST_WORKER_MODE;
8
+ const Original = threads.Worker;
9
+ let count = 0;
10
+ if (mode === 'deny') {
11
+ threads.Worker = class { constructor() { throw new Error('worker-disabled-by-test'); } };
12
+ } else if (mode === 'count') {
13
+ threads.Worker = class extends Original { constructor(...args) { count += 1; super(...args); } };
14
+ process.on('exit', () => fs.writeFileSync(process.env.HARNESS_TEST_WORKER_COUNT_FILE, String(count)));
15
+ }
@@ -0,0 +1,154 @@
1
+ 'use strict';
2
+ const { test } = require('node:test');
3
+ const assert = require('node:assert/strict');
4
+ const fs = require('node:fs');
5
+ const os = require('node:os');
6
+ const path = require('node:path');
7
+ const { createHash } = require('node:crypto');
8
+ const { spawnSync } = require('node:child_process');
9
+ const { validateDraft, validateReviews, build, promptHash } = require('../scripts/system-one-corpus');
10
+ const { validateCorpus } = require('../harness-everything/scripts/system-one/evaluate');
11
+ const root = path.resolve(__dirname, '..');
12
+ const draftPath = path.join(root, 'benchmarks/fixtures/system-one-holdout-draft.json');
13
+
14
+ const draftCase = (id, language = 'en', proposedGold = 'tier1', prompt = `commit the change for case ${id}`) => ({
15
+ id, family: `family-${id}`, language, source: 'synthetic:authored', prompt, proposedGold, rationale: 'bounded git operation' });
16
+ const draft = () => ({ schemaVersion: 1, cases: [draftCase('a'), draftCase('b', 'zh-TW', null, '繼續'), draftCase('c', 'en', 'tier2', 'fix the failing parser test and rerun it')] });
17
+ const decision = (c, kind = 'accept', gold = c.proposedGold) => ({ id: c.id, promptHash: promptHash(c.prompt), decision: kind, gold, reviewer: 'human:repository-owner' });
18
+ const reviews = decisions => ({ schemaVersion: 1, decisions });
19
+
20
+ test('S1-K01 an unreviewed draft assembles into a valid corpus that cannot pass the review gate', () => {
21
+ const { corpus, summary } = build(draft(), null);
22
+ assert.equal(validateCorpus(corpus), true);
23
+ assert.ok(corpus.cases.every(c => c.reviewed === false && c.split === 'holdout'));
24
+ assert.deepEqual(corpus.cases.map(c => c.gold), ['tier1', null, 'tier2']);
25
+ assert.equal(corpus.cases[1].request.context, '繼續');
26
+ assert.equal(summary.unreviewed, 3);
27
+ assert.equal(summary.reviewedHoldoutGate, false);
28
+ assert.equal(promptHash('繼續'), createHash('sha256').update('繼續', 'utf8').digest('hex'));
29
+ assert.deepEqual(build(draft(), null), build(draft(), null));
30
+ });
31
+
32
+ test('S1-K02 accept, relabel and reject apply exactly; the reviewer gold wins', () => {
33
+ const d = draft();
34
+ const { corpus, summary } = build(d, reviews([decision(d.cases[0]), decision(d.cases[1], 'relabel', 'tier1'), decision(d.cases[2], 'reject', null)]));
35
+ assert.deepEqual(corpus.cases.map(c => [c.id, c.gold, c.reviewed]), [['a', 'tier1', true], ['b', 'tier1', true]]);
36
+ assert.equal(summary.rejected, 1);
37
+ assert.equal(summary.reviewed, 2);
38
+ });
39
+
40
+ test('S1-K03 a decision for changed prompt text is stale and never counts as review', () => {
41
+ const d = draft();
42
+ const r = reviews([decision(d.cases[0], 'relabel', 'tier2')]);
43
+ d.cases[0].prompt = 'commit and push the change for case a';
44
+ const { corpus, summary } = build(d, r);
45
+ assert.equal(corpus.cases[0].reviewed, false);
46
+ assert.equal(corpus.cases[0].gold, 'tier1');
47
+ assert.equal(summary.stale, 1);
48
+ });
49
+
50
+ test('S1-K04 malformed reviews are rejected instead of silently applied', () => {
51
+ const d = draft();
52
+ const bad = [
53
+ r => { r.decisions.push({ ...r.decisions[0] }); },
54
+ r => { r.decisions[0].id = 'unknown'; },
55
+ r => { r.decisions[0].decision = 'approve'; },
56
+ r => { r.decisions[0].gold = 'tier3'; },
57
+ r => { r.decisions[0] = decision(d.cases[0], 'relabel', 'tier1'); },
58
+ r => { r.decisions[0] = decision(d.cases[0], 'reject', 'tier1'); },
59
+ r => { r.decisions[0].reviewer = 'claude'; },
60
+ r => { r.decisions[0].reviewer = 'human:someone@example.com'; },
61
+ r => { r.decisions[0].extra = true; },
62
+ r => { r.decisions[0].promptHash = 'abc'; },
63
+ r => { r.schemaVersion = 2; },
64
+ ];
65
+ for (const mutate of bad) {
66
+ const r = reviews([decision(d.cases[0])]);
67
+ mutate(r);
68
+ assert.throws(() => build(d, r));
69
+ }
70
+ assert.equal(validateReviews(reviews([decision(d.cases[0])])), true);
71
+ });
72
+
73
+ test('S1-K05 draft validation: exact fields, unique ids and prompts, known sources, no private data', () => {
74
+ assert.equal(validateDraft(draft()), true);
75
+ const bad = [
76
+ d => { d.cases[1].id = 'a'; },
77
+ d => { d.cases[1].prompt = d.cases[0].prompt; },
78
+ d => { d.cases[0].source = 'real:history'; },
79
+ d => { d.cases[0].language = 'ja'; },
80
+ d => { d.cases[0].proposedGold = 'unclassified'; },
81
+ d => { d.cases[0].rationale = ''; },
82
+ d => { d.cases[0].extra = 1; },
83
+ d => { d.cases = []; },
84
+ d => { d.cases[0].prompt = 'mail the report to dev.lead@example.com'; },
85
+ d => { d.cases[0].prompt = 'open C:\\Users\\alice\\repo\\notes.md and fix it'; },
86
+ d => { d.cases[0].prompt = 'read /home/alice/project/config.yaml'; },
87
+ d => { d.cases[0].prompt = 'read /Users/alice/project/config.yaml'; },
88
+ ];
89
+ for (const mutate of bad) { const d = draft(); mutate(d); assert.throws(() => validateDraft(d)); }
90
+ });
91
+
92
+ test('S1-K06 the gate passes only with >=200 reviewed cases and >=50 per language', () => {
93
+ const make = (en, zh) => ({ schemaVersion: 1, cases: [
94
+ ...Array.from({ length: en }, (_, i) => draftCase(`en-${i}`, 'en', 'tier1', `rename variable number ${i} in the parser`)),
95
+ ...Array.from({ length: zh }, (_, i) => draftCase(`zh-${i}`, 'zh-TW', 'tier1', `把第 ${i} 個變數改名`)),
96
+ ] });
97
+ const all = d => reviews(d.cases.map(c => decision(c)));
98
+ const pass = make(150, 50);
99
+ assert.equal(build(pass, all(pass)).summary.reviewedHoldoutGate, true);
100
+ const fewZh = make(160, 49);
101
+ assert.equal(build(fewZh, all(fewZh)).summary.reviewedHoldoutGate, false);
102
+ const partial = make(150, 50);
103
+ assert.equal(build(partial, reviews(all(partial).decisions.slice(1))).summary.reviewedHoldoutGate, false);
104
+ });
105
+
106
+ test('S1-K07 CLI builds a corpus file and fails closed on invalid input', () => {
107
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-s1-corpus-'));
108
+ try {
109
+ const cli = path.join(root, 'scripts/system-one-corpus.js');
110
+ const input = path.join(dir, 'draft.json'); const review = path.join(dir, 'reviews.json'); const out = path.join(dir, 'corpus.json');
111
+ const d = draft();
112
+ fs.writeFileSync(input, JSON.stringify(d));
113
+ fs.writeFileSync(review, JSON.stringify(reviews([decision(d.cases[0])])));
114
+ const ok = spawnSync(process.execPath, [cli, 'build', input, review, out], { encoding: 'utf8' });
115
+ assert.equal(ok.status, 0, ok.stderr);
116
+ assert.equal(JSON.parse(ok.stdout).reviewed, 1);
117
+ assert.equal(validateCorpus(JSON.parse(fs.readFileSync(out, 'utf8'))), true);
118
+ const none = spawnSync(process.execPath, [cli, 'build', input, '-', out], { encoding: 'utf8' });
119
+ assert.equal(none.status, 0, none.stderr);
120
+ assert.equal(JSON.parse(none.stdout).reviewed, 0);
121
+ fs.writeFileSync(review, '{"schemaVersion":1,"decisions":[{"id":"zzz"}]}');
122
+ assert.equal(spawnSync(process.execPath, [cli, 'build', input, review, out], { encoding: 'utf8' }).status, 1);
123
+ assert.equal(spawnSync(process.execPath, [cli, 'bogus'], { encoding: 'utf8' }).status, 1);
124
+ } finally { fs.rmSync(dir, { recursive: true, force: true }); }
125
+ });
126
+
127
+ test('S1-K08 the committed holdout draft meets size, language, class and length requirements', () => {
128
+ const d = JSON.parse(fs.readFileSync(draftPath, 'utf8'));
129
+ assert.equal(validateDraft(d), true);
130
+ const { corpus } = build(d, null);
131
+ assert.equal(validateCorpus(corpus), true);
132
+ assert.ok(d.cases.length >= 220, 'headroom above 200 for rejected cases');
133
+ for (const lang of ['en', 'zh-TW']) assert.ok(d.cases.filter(c => c.language === lang).length >= 60, lang);
134
+ for (const gold of ['tier1', 'tier2', 'tier3', null]) assert.ok(d.cases.filter(c => c.proposedGold === gold).length >= 40, String(gold));
135
+ const bytes = d.cases.map(c => Buffer.byteLength(c.prompt, 'utf8'));
136
+ assert.ok(bytes.filter(b => b > 224).length / bytes.length >= 0.15, 'long prompts are represented');
137
+ assert.ok(bytes.filter(b => b <= 40).length / bytes.length >= 0.1, 'short prompts are represented');
138
+ assert.ok(d.cases.some(c => c.source === 'derived:local-history') && d.cases.some(c => c.source === 'synthetic:authored'));
139
+ assert.ok(new Set(d.cases.map(c => c.family)).size >= 40, 'enough distinct families');
140
+ });
141
+
142
+ test('S1-K09 the committed reviewed holdout is reproducible from owner decisions and meets the gate', () => {
143
+ const read = name => JSON.parse(fs.readFileSync(path.join(root, 'benchmarks/fixtures', name), 'utf8'));
144
+ const d = read('system-one-holdout-draft.json');
145
+ const r = read('system-one-holdout-reviews.json');
146
+ assert.equal(validateReviews(r), true);
147
+ assert.deepEqual(r.decisions.map(x => x.id).sort(), d.cases.map(c => c.id).sort(), 'every draft case has exactly one owner decision');
148
+ const { corpus, summary } = build(d, r);
149
+ assert.equal(summary.stale, 0);
150
+ assert.equal(summary.unreviewed, 0);
151
+ assert.equal(summary.reviewedHoldoutGate, true);
152
+ assert.deepEqual(read('system-one-holdout.json'), corpus, 'committed corpus equals the rebuild');
153
+ for (const gold of ['tier1', 'tier2', 'tier3', null]) assert.ok(corpus.cases.filter(c => c.gold === gold).length >= 15, String(gold));
154
+ });
@@ -33,6 +33,16 @@ function cleanup(f) {
33
33
  try { resident.stop(f.manifest, f.manifestPath); } catch (_) { /* best effort */ }
34
34
  fs.rmSync(f.dir, { recursive: true, force: true });
35
35
  }
36
+ // A client view whose state file names the live server with a wrong token. The server polls only its own
37
+ // state file and exits once that file stops naming it, so rewriting it would race the wrong-token request.
38
+ function wrongTokenView(f) {
39
+ const good = JSON.parse(fs.readFileSync(resident.stateFiles(f.manifest, f.manifestPath).state, 'utf8'));
40
+ const viewDir = fs.mkdtempSync(path.join(f.dir, 'client-view-'));
41
+ const manifestPath = path.join(viewDir, 'manifest.json');
42
+ fs.writeFileSync(manifestPath, JSON.stringify(f.manifest));
43
+ fs.writeFileSync(resident.stateFiles(f.manifest, manifestPath).state, JSON.stringify({ ...good, token: 'b'.repeat(64) }));
44
+ return manifestPath;
45
+ }
36
46
 
37
47
  test('S1-RS01 manifest transport fields and digest-bound file names', () => {
38
48
  const f = fixture();
@@ -80,10 +90,9 @@ test('S1-RS03 stale state is removed and replaced; a wrong token is rejected wit
80
90
  assert.equal(f.spawns.length, 1);
81
91
  assert.equal(resident.ensureReady(f.manifest, f.manifestPath, 20000, f.deps), true);
82
92
  const good = JSON.parse(fs.readFileSync(state, 'utf8'));
83
- fs.writeFileSync(state, JSON.stringify({ ...good, token: 'b'.repeat(64) }));
84
- assert.deepEqual(resident.score(request, f.manifest, f.manifestPath, f.deps), { status: 'unavailable', reason: 'provider-unavailable' });
93
+ assert.deepEqual(resident.score(request, f.manifest, wrongTokenView(f), f.deps), { status: 'unavailable', reason: 'provider-unavailable' });
85
94
  assert.equal(f.spawns.length, 1);
86
- fs.writeFileSync(state, JSON.stringify(good));
95
+ assert.equal(resident.status(f.manifest, f.manifestPath).running, true, 'a wrong token does not stop the server');
87
96
  for (const bad of ['not-json', JSON.stringify({ ...good, extra: 1 }), JSON.stringify({ ...good, token: 'short' })]) {
88
97
  fs.writeFileSync(state, bad);
89
98
  assert.equal(resident.status(f.manifest, f.manifestPath).running, false);
@@ -183,3 +192,105 @@ test('S1-RS09 a corrupted state file never leaves an orphan server behind', () =
183
192
  assert.equal(resident.status(f.manifest, f.manifestPath).pid, fresh.pid);
184
193
  } finally { cleanup(f); }
185
194
  });
195
+
196
+ test('S1-RS10 scoreAsync matches the sync client and keeps every start/failure mapping', async () => {
197
+ const f = fixture();
198
+ try {
199
+ assert.deepEqual(await resident.scoreAsync(request, f.manifest, f.manifestPath, f.deps), { status: 'unavailable', reason: 'provider-starting' });
200
+ assert.deepEqual(await resident.scoreAsync(request, f.manifest, f.manifestPath, f.deps), { status: 'unavailable', reason: 'provider-starting' });
201
+ assert.deepEqual(f.spawns, ['stub']);
202
+ assert.equal(resident.ensureReady(f.manifest, f.manifestPath, 20000, f.deps), true);
203
+ const sync = resident.score(request, f.manifest, f.manifestPath, f.deps);
204
+ assert.equal(sync.status, 'scored');
205
+ assert.deepEqual(await resident.scoreAsync(request, f.manifest, f.manifestPath, f.deps), sync);
206
+ assert.deepEqual(await resident.scoreAsync(request, f.manifest, f.manifestPath, f.deps), sync);
207
+ assert.deepEqual(await resident.scoreAsync(request, f.manifest, wrongTokenView(f), f.deps), { status: 'unavailable', reason: 'provider-unavailable' });
208
+ await assert.rejects(resident.scoreAsync({ ...request, extra: 1 }, f.manifest, f.manifestPath, f.deps));
209
+ assert.equal(f.spawns.length, 1);
210
+ } finally { cleanup(f); }
211
+ });
212
+
213
+ test('S1-RS10b scoreAsync removes refused state, restarts once, and times out slow servers', async () => {
214
+ const f = fixture();
215
+ // A live PID that is not this test process: cleanup may kill whatever the state file names.
216
+ const sleeper = require('node:child_process').spawn(process.execPath, ['-e', 'setTimeout(() => {}, 60000)'], { stdio: 'ignore' });
217
+ try {
218
+ const net = require('node:net');
219
+ const closed = net.createServer();
220
+ await new Promise(resolve => closed.listen(0, '127.0.0.1', resolve));
221
+ const port = closed.address().port;
222
+ await new Promise(resolve => closed.close(resolve));
223
+ const { state } = resident.stateFiles(f.manifest, f.manifestPath);
224
+ fs.writeFileSync(state, JSON.stringify({ schemaVersion: 1, pid: sleeper.pid, port, token: 'a'.repeat(64), startedAt: 1 }));
225
+ assert.deepEqual(await resident.scoreAsync(request, f.manifest, f.manifestPath, f.deps), { status: 'unavailable', reason: 'provider-starting' });
226
+ assert.deepEqual(f.spawns, ['stub']);
227
+ } finally { sleeper.kill(); cleanup(f); }
228
+ const slow = fixture('stub-slow');
229
+ try {
230
+ assert.equal(resident.ensureReady(slow.manifest, slow.manifestPath, 20000, slow.deps), true);
231
+ const start = Date.now();
232
+ assert.deepEqual(await resident.scoreAsync(request, slow.manifest, slow.manifestPath, slow.deps), { status: 'unavailable', reason: 'provider-timeout' });
233
+ assert.ok(Date.now() - start < 2500);
234
+ assert.equal(slow.spawns.length, 1);
235
+ } finally { cleanup(slow); }
236
+ });
237
+
238
+ test('S1-RS10c provider.scoreAsync dispatches by transport with the sync result shapes', async () => {
239
+ const f = fixture();
240
+ try {
241
+ assert.deepEqual(await provider.scoreAsync(request, path.join(f.dir, 'missing.json')), { status: 'unavailable', reason: 'provider-config' });
242
+ assert.deepEqual(await provider.scoreAsync(request, 'relative.json'), { status: 'unavailable', reason: 'provider-config' });
243
+ assert.equal(resident.ensureReady(f.manifest, f.manifestPath, 20000, f.deps), true);
244
+ assert.deepEqual(await provider.scoreAsync(request, f.manifestPath), provider.score(request, f.manifestPath));
245
+ const oneshot = path.join(f.dir, 'oneshot.json');
246
+ fs.writeFileSync(oneshot, JSON.stringify({ ...f.manifest, transport: 'oneshot' }));
247
+ assert.deepEqual(await provider.scoreAsync(request, oneshot), provider.score(request, oneshot));
248
+ } finally { cleanup(f); }
249
+ });
250
+
251
+ // The probe preload proves which client path ran inside a real child process.
252
+ const probeEnv = (mode, extra = {}) => ({ ...process.env,
253
+ NODE_OPTIONS: `${process.env.NODE_OPTIONS || ''} --require ./ci/fixtures/system-one-worker-probe.js`.trim(),
254
+ HARNESS_TEST_WORKER_MODE: mode, ...extra });
255
+
256
+ test('S1-RS11 the hook entry pre-scores over async IPC: it still scores when worker threads cannot start', () => {
257
+ const f = fixture();
258
+ const root = path.resolve(__dirname, '..');
259
+ try {
260
+ assert.equal(resident.ensureReady(f.manifest, f.manifestPath, 20000, f.deps), true);
261
+ const env = probeEnv('deny', { HARNESS_SYSTEM_ONE_MODE: 'shadow', HARNESS_SYSTEM_ONE_CONFIG: f.manifestPath });
262
+ const kernel = path.join(root, 'harness-everything/scripts/kernel-router-core.js');
263
+ const diagnostic = out => JSON.parse(out.match(/=> SYSTEM ONE: (.*)/)[1]);
264
+ const argv = spawnSync(process.execPath, [kernel, 'fix a typo in README'], { cwd: root, encoding: 'utf8', env });
265
+ assert.equal(argv.status, 0, argv.stderr);
266
+ assert.equal(diagnostic(argv.stdout).status, 'accepted');
267
+ const hook = spawnSync(process.execPath, [kernel], { cwd: root, encoding: 'utf8', env, input: JSON.stringify({ prompt: 'fix a typo in README' }) });
268
+ assert.equal(hook.status, 0, hook.stderr);
269
+ assert.equal(diagnostic(hook.stdout).status, 'accepted');
270
+ const off = spawnSync(process.execPath, [kernel, 'fix a typo in README'], { cwd: root, encoding: 'utf8', env: { ...env, HARNESS_SYSTEM_ONE_MODE: 'off' } });
271
+ assert.equal(off.status, 0, off.stderr);
272
+ assert.doesNotMatch(off.stdout, /SYSTEM ONE/);
273
+ assert.equal(f.spawns.length, 1);
274
+ } finally { cleanup(f); }
275
+ });
276
+
277
+ test('S1-RS12 the evaluator times the async path: no worker thread per warm score', () => {
278
+ const f = fixture();
279
+ const root = path.resolve(__dirname, '..');
280
+ try {
281
+ assert.equal(resident.ensureReady(f.manifest, f.manifestPath, 20000, f.deps), true);
282
+ const countFile = path.join(f.dir, 'workers.txt');
283
+ const output = path.join(f.dir, 'report.json');
284
+ const corpus = path.join(root, 'benchmarks/fixtures/system-one-routing.json');
285
+ const child = spawnSync(process.execPath, [path.join(root, 'scripts/evaluate-system-one.js'), corpus, f.manifestPath, output],
286
+ { cwd: root, encoding: 'utf8', env: probeEnv('count', { HARNESS_TEST_WORKER_COUNT_FILE: countFile }) });
287
+ assert.equal(child.status, 0, child.stderr);
288
+ const report = JSON.parse(fs.readFileSync(output, 'utf8'));
289
+ assert.equal(report.evidence.residentReady, true);
290
+ // Every sample reached the warm server (the seed's one over-limit context is a declined provider-exit).
291
+ const runs = report.records.flatMap(r => r.runs);
292
+ assert.ok(runs.every(run => run.coldStart === false && ['accepted', 'provider-exit'].includes(run.decision.status === 'accepted' ? 'accepted' : run.decision.reason)));
293
+ assert.ok(runs.filter(run => run.decision.status === 'accepted').length >= runs.length - 2);
294
+ assert.ok(Number(fs.readFileSync(countFile, 'utf8')) < report.records.length * 2, 'warm scores must not start a worker thread each');
295
+ } finally { cleanup(f); }
296
+ });
@@ -99,3 +99,28 @@ test('S1-R05 structural floor: a scorer can raise but never lower a deterministi
99
99
  assert.equal(plan.verification.independent, true);
100
100
  } finally { provider.score = original; console.log = log; if (mode === undefined) delete process.env.HARNESS_SYSTEM_ONE_MODE; else process.env.HARNESS_SYSTEM_ONE_MODE = mode; }
101
101
  });
102
+ test('S1-R06 prescoreTier: off loads nothing; a matching request reuses the async result; mismatch and failure keep sync semantics', async () => {
103
+ const { prescoreTier } = require('../harness-everything/scripts/system-one/router');
104
+ const provider = require('../harness-everything/scripts/system-one/provider');
105
+ const forbidden = () => { throw new Error('must not invoke'); };
106
+ for (const env of [{}, { HARNESS_SYSTEM_ONE_MODE: 'off' }, { HARNESS_SYSTEM_ONE_MODE: 'bogus' }]) assert.equal(await prescoreTier('實作功能', env, forbidden), null);
107
+ assert.equal(await prescoreTier('', { HARNESS_SYSTEM_ONE_MODE: 'shadow' }, forbidden), null);
108
+ const env = { HARNESS_SYSTEM_ONE_MODE: 'prefer', HARNESS_SYSTEM_ONE_CONFIG: '/abs/manifest.json' };
109
+ const input = { prompt: '實作功能', tier: 'Unclassified' };
110
+ const configs = [];
111
+ const pre = await prescoreTier(input.prompt, env, async (req, config) => { configs.push(config); return scorer('tier2')(req); });
112
+ assert.deepEqual(configs, ['/abs/manifest.json']);
113
+ assert.deepEqual(selectTier(input, env, pre), selectTier(input, env, scorer('tier2')));
114
+ const original = provider.score;
115
+ try {
116
+ let used = 0;
117
+ provider.score = req => { used += 1; return scorer('tier3')(req); };
118
+ assert.equal(selectTier({ ...input, prompt: 'different prompt' }, env, pre).tier, 'Tier 3 (Macro Task)');
119
+ assert.equal(used, 1);
120
+ } finally { provider.score = original; }
121
+ const failing = await prescoreTier(input.prompt, env, async () => { throw new Error('secret'); });
122
+ const failed = selectTier(input, env, failing);
123
+ assert.deepEqual(failed, selectTier(input, env, () => { throw new Error('secret'); }));
124
+ assert.equal(failed.diagnostic.reason, 'provider-unavailable');
125
+ assert.ok(!JSON.stringify(failed).includes('secret'));
126
+ });
@@ -130,7 +130,12 @@ contract; this establishes no new live-host capability. Python, PyTorch and a
130
130
  compatible local checkpoint are optional external dependencies, not npm payloads;
131
131
  the explicit `npm run system-one:install` sets them up and hooks never run it.
132
132
  With `transport: "resident"`, an opted-in router hook may spawn one detached
133
- loopback-only Python server per manifest; host survival of that process after
134
- a hook exits is not live-verified.
133
+ loopback-only Python server per manifest. One retained Windows + Claude Code
134
+ headless session showed the hook-spawned server outliving the host; macOS/Linux
135
+ and Codex hosts are not live-verified, and this does not change the matrix.
136
+ Hooks read the mode from the host process environment: Claude Code settings
137
+ `env` reaches hooks and every agent-run command, while a Codex started from an
138
+ ordinary terminal sees it only when set at user/OS level. Keep the mode `off`
139
+ until a Harness-trained checkpoint passes the rollout gates.
135
140
  Public Skills-only artifacts do not acquire lifecycle hooks from this feature.
136
141
  See [System One routing](system-one-routing.md) for limits, rollback and evidence.
@@ -0,0 +1,103 @@
1
+ # System One holdout corpus: labeling and review
2
+
3
+ This document defines how the reviewed tier holdout for
4
+ [System One](system-one-routing.md) is written, labeled, reviewed and
5
+ assembled (issue [#233](https://github.com/dyphn1/Harness-everything/issues/233),
6
+ Phase 3). The `reviewedHoldout` gate requires at least 200 holdout cases, at
7
+ least 50 per language, and `reviewed: true` on every case.
8
+
9
+ ## Gold labels
10
+
11
+ A gold label answers one question: **which tier should Harness route this prompt
12
+ to, judged from the prompt alone?** The labels follow the tier model in
13
+ [routing.md](routing.md#three-tier-routing-model) and the fixed tier catalog.
14
+
15
+ | Gold | Use when the prompt asks for | Examples of shape |
16
+ | --- | --- | --- |
17
+ | `tier1` | Something answered or done without changing project behavior: Git/GitHub housekeeping (commit, push, open a PR, sync, tag, post given results as a comment), a status check, reading a log or searching and reporting, the smallest doc fix (a typo, a link, an ignore entry), or a reply the assistant can give directly, including non-engineering chores and discussion questions | "commit these changes", "is issue 88 still open?", "find every repo still using the old logging package", "close the other apps" |
18
+ | `tier2` | A bounded change or investigation: any code, configuration or CI edit (a rename, a value, a revert), running tests or a build, filing an issue, explaining code that must be read first, most bug fixes, a focused review or benchmark, planning or synthesis that produces documents (phase plans, an ADR, an overview), and answers that settle open decisions for work in progress | "rename tmp to buffer", "run npm test", "the CLI fails with this error, fix it", "1. agree 2. keep the old name" |
19
+ | `tier3` | New or changed behavior delivered with tests, and anything larger: a new flag or format, a behavior change across producers and tests, a large refactor, a dependency upgrade with breakage, a migration, a repository-wide change, a multi-phase implementation, or delegation to several agents | "add a --verbose flag with tests", "migrate to ESM", "dispatch agents to audit every repo" |
20
+ | `null` | No actionable content: a bare continuation, "do what you said", a vague reaction, a question about what the assistant meant, or pasted status with no request | "go", "yes", "照剛剛說的改", "something is off here" |
21
+
22
+ Rules:
23
+
24
+ 1. Label the work the prompt would start. A reply that settles decisions for
25
+ work in progress ("1. agree 2. use hash") is labeled by that work, not `null`.
26
+ Use `null` only when no work can be identified at all.
27
+ 2. Label the work requested, not the words used. Searching every repository and
28
+ reporting is `tier1`; changing every repository is `tier3`.
29
+ 3. Pick the smallest tier that covers the whole request.
30
+ 4. Explicit workflow words ("use fable", "no subagents") do not change the gold.
31
+ Precedence is a router policy, not a label.
32
+ 5. Never derive gold from the lexical router or any model output. A reviewer may
33
+ read the proposed gold, but the recorded gold is the reviewer's decision.
34
+
35
+ These definitions are the repository owner's, recorded after the first review
36
+ of the draft: the owner's labels moved many drafted cases one tier up, labeled
37
+ context-dependent replies by their work, and gave non-engineering chores
38
+ `tier1`. The draft's `proposedGold` values predate this and are only
39
+ suggestions. Acknowledgements, reactions, host commands (`/compact`) and meeting
40
+ notes were rejected from the holdout because they never reach routing as tasks.
41
+
42
+ ## Cases
43
+
44
+ Each draft case has `id`, `family`, `language` (`en` or `zh-TW`), `source`,
45
+ `prompt`, `proposedGold` and a one-line `rationale`.
46
+
47
+ - **Family.** A family groups prompts that share one task scenario, such as
48
+ "commit and push" or "fix a CLI error from a pasted log". Paraphrases,
49
+ translations and variants of one scenario stay in one family, and a family
50
+ never spans splits. All families in this corpus are `holdout`. Later train or
51
+ validation data must use new families.
52
+ - **Source.** `synthetic:authored` marks a prompt written for the corpus.
53
+ `derived:local-history` marks a prompt rewritten from the shape of a real
54
+ local prompt: same length class, task type and phrasing style, with every
55
+ name, path, product, customer, issue number and pasted log replaced. No real
56
+ prompt text, person, organization or local path is committed.
57
+ - **Length.** The corpus follows the observed length profile of real local
58
+ prompts (median about 90 UTF-8 bytes, about one in five over 224 bytes, a
59
+ long tail with pasted logs), so that length limits are evaluated on realistic
60
+ input, not only short prompts.
61
+
62
+ ## Review
63
+
64
+ A human reviewer decides every case on the review page. The possible decisions are:
65
+
66
+ | Decision | Effect |
67
+ | --- | --- |
68
+ | `accept` | Gold is the proposed gold. |
69
+ | `relabel` | Gold is the reviewer's chosen label. |
70
+ | `reject` | The case is dropped: ambiguous even for a human, unrealistic, or it leaks private data. |
71
+
72
+ Each decision records the case ID, the SHA-256 of the exact prompt text it
73
+ reviewed (`promptHash`), the decision, the gold, and the reviewer role. The
74
+ assembler `scripts/system-one-corpus.js` builds the evaluation corpus from the
75
+ draft and the decisions:
76
+
77
+ - A case with a valid decision becomes `reviewed: true` with the reviewer's gold.
78
+ - A case without a decision, or whose prompt changed after review (hash
79
+ mismatch), stays `reviewed: false` with the proposed gold, so the gate cannot
80
+ pass on stale or missing review.
81
+ - A rejected case is omitted.
82
+ - The output passes `validateCorpus`, and the assembler reports per-language and
83
+ per-gold counts plus whether the `reviewedHoldout` gate would pass.
84
+
85
+ The agent that drafts cases never records decisions. `reviewed: true` means a
86
+ human reviewed that exact text. Review records store a role
87
+ (`human:repository-owner`), not a name or account. When a decision contradicts
88
+ the owner's decisions on sibling cases, the agent may ask the owner to confirm
89
+ it. The owner's answer is recorded as the decision, and the agent never changes
90
+ a decision on its own.
91
+
92
+ ## Committed files
93
+
94
+ | File | Content |
95
+ | --- | --- |
96
+ | `benchmarks/fixtures/system-one-holdout-draft.json` | Draft cases with proposed gold |
97
+ | `benchmarks/fixtures/system-one-holdout-reviews.json` | Owner decisions (ID, prompt hash, decision, gold, role) |
98
+ | `benchmarks/fixtures/system-one-holdout.json` | Evaluation corpus, rebuilt with `node scripts/system-one-corpus.js build <draft> <reviews> <corpus>` |
99
+
100
+ The reviewed holdout has 215 cases (11 rejected): en 93 and zh-TW 122; gold
101
+ `tier1` 47, `tier2` 97, `tier3` 51 and `null` 20. It meets the `reviewedHoldout`
102
+ gate. It says nothing about model quality until a `harness-routing-v1`
103
+ checkpoint is evaluated on it.
@@ -148,9 +148,21 @@ format, which Phase 0 validation still checks. Any other failure returns
148
148
  `{ok: false, reason}` with a bounded code; no prompt, traceback, path or score is
149
149
  echoed in errors. The server never executes actions and is not given a driver.
150
150
 
151
- **Client.** The router API is synchronous, so the client performs one socket
152
- round trip on a worker thread and waits with `Atomics.wait` (1000 ms deadline).
153
- Results map to the existing reasons: timeout → `provider-timeout` (no respawn);
151
+ **Client.** The hook entry pre-scores asynchronously. When `tier-router.js` runs
152
+ as a script (the kernel and packaged hooks spawn it) in `shadow` or `prefer`
153
+ mode, it builds the fixed-catalog tier request before routing and makes one
154
+ direct async loopback round trip (`scoreAsync`), with no worker thread. Start,
155
+ lock, stale-state, deadline (1000 ms) and reply-limit (1 MiB) rules are the same
156
+ as the synchronous path. The router uses the pre-scored result only when its
157
+ request hash equals the request the router builds; otherwise it scores
158
+ synchronously. A pre-score error is reported exactly as a synchronous scorer
159
+ error would be. In `off` mode the entry neither pre-scores nor contacts a
160
+ provider. The synchronous `score` API remains for programmatic callers: it
161
+ makes the same round trip on a worker thread and waits with `Atomics.wait`.
162
+ Starting that worker costs 29–41 ms per call on the reference host, which is why
163
+ the hook avoids it. The paired measurements are in
164
+ [cua-s1-forms-resident-async-cpu-2026-09-23](../benchmarks/results/system-one/cua-s1-forms-resident-async-cpu-2026-09-23/README.md).
165
+ Both paths map results to the existing reasons: timeout → `provider-timeout` (no respawn);
154
166
  refused connection or dead PID → stale state removed and a new start
155
167
  (`provider-starting`); `unauthorized` → `provider-unavailable`; any other
156
168
  server-declined request → `provider-exit`; malformed replies → `provider-json`.
@@ -158,7 +170,9 @@ server-declined request → `provider-exit`; malformed replies → `provider-jso
158
170
  **Operators.** `node harness-everything/scripts/system-one/resident.js
159
171
  start|status|stop <absolute manifest>` controls a server explicitly; `start`
160
172
  waits up to 60 s for readiness. The evaluation CLI waits for readiness before
161
- measuring, so resident runs are recorded with `coldStart: false`. The installer
173
+ measuring, so resident runs are recorded with `coldStart: false`. It times
174
+ `scoreAsync`, the path the hook uses, so `warmLatency` measures what a prompt
175
+ actually pays. The installer
162
176
  writes `transport: "resident"`, verifies one resident score, and stops the server
163
177
  it started. Repository tests use a stub scorer behind the real server/protocol
164
178
  code; they prove the mechanism, not host survival of detached processes or model
@@ -195,6 +209,11 @@ selected candidate, model identity, confidence and margin; it omits prompt text,
195
209
  score vectors and artifact paths. The existing router contract schema is unchanged.
196
210
  Kernel/packaged entry points inherit these host environment variables. Prompts
197
211
  and hook payload fields cannot set model configuration or launch executables.
212
+ Claude Code settings `env` is hot-reloaded and reaches hooks and every command
213
+ the agent runs; Codex hooks inherit the `codex` process environment, so a Codex
214
+ started from an ordinary terminal needs user/OS-level variables (which then apply
215
+ to every program the user starts). The recommended setting is `off` until a
216
+ `harness-routing-v1` checkpoint passes the rollout gates.
198
217
  Repository tests establish mechanism/package evidence only; actual host loading
199
218
  and semantic quality remain unverified until retained sessions demonstrate them.
200
219
 
@@ -208,7 +227,8 @@ The corpus is `{schemaVersion: 1, cases: [...]}`. Each case has exactly `id`,
208
227
  The complete fixed tier catalog must match. IDs and request hashes are unique;
209
228
  no family may span splits. Evaluation uses only holdout, never training labels.
210
229
  The committed seed corpus is a mechanism fixture, not an independently reviewed
211
- holdout. Expand and review it separately before making quality claims.
230
+ holdout. The reviewed holdout is written, labeled and assembled as described in
231
+ [system-one-corpus.md](system-one-corpus.md).
212
232
 
213
233
  The CLI runs the real lexical baseline and the configured provider twice per
214
234
  holdout case. Records contain IDs, baseline prediction, decision, model identity,
@@ -0,0 +1,6 @@
1
+ ---
2
+ type: regex
3
+ pattern: '(Tier 1|Tier 2|Tier 3|Routing Checkpoint)'
4
+ match: not_contains
5
+ weight: 1
6
+ ---
@@ -0,0 +1,9 @@
1
+ ---
2
+ type: tool_used
3
+ tool: Skill
4
+ input_match: '"skill"\s*:\s*"(?:[\w-]+:)?harness-everything"'
5
+ min: 0
6
+ max: 0
7
+ arm: both
8
+ weight: 1
9
+ ---
@@ -0,0 +1,8 @@
1
+ ---
2
+ max_turns: 10
3
+ allowed_tools: [Read, Glob, Grep, Skill]
4
+ tags: [pilot, negative-trigger]
5
+ description: "Casual non-software small talk must not engage the harness-everything router."
6
+ ---
7
+
8
+ What's the difference between latte and cappuccino?
@@ -0,0 +1,6 @@
1
+ ---
2
+ type: tool_used
3
+ tool: Skill
4
+ input_match: '"skill"\s*:\s*"(?:[\w-]+:)?harness-everything"'
5
+ weight: 1
6
+ ---
@@ -0,0 +1,8 @@
1
+ ---
2
+ max_turns: 15
3
+ allowed_tools: [Read, Glob, Grep, Skill]
4
+ tags: [pilot, positive-trigger, tier-3]
5
+ description: "Architectural, repo-wide request should route through the harness-everything router and land on Tier 3."
6
+ ---
7
+
8
+ Route this coding request: split our monolith into two services (orders and billing) with an event bus between them; this touches deployment, data migration, and every team's code.
@@ -0,0 +1,6 @@
1
+ ---
2
+ type: tool_used
3
+ tool: Skill
4
+ input_match: '"skill"\s*:\s*"(?:[\w-]+:)?tdd"'
5
+ weight: 1
6
+ ---
@@ -0,0 +1,8 @@
1
+ ---
2
+ max_turns: 15
3
+ allowed_tools: [Read, Glob, Grep, Skill]
4
+ tags: [pilot, positive-trigger]
5
+ description: "A bug-fix request that asks for a regression test should engage the tdd skill's RED/GREEN loop."
6
+ ---
7
+
8
+ Fix a bug with a regression test: the discount calculation rounds wrong for prices ending in .99.
@@ -0,0 +1,7 @@
1
+ ---
2
+ type: regex
3
+ pattern: '(writing a failing test now|entering RED)'
4
+ flags: i
5
+ match: not_contains
6
+ weight: 1
7
+ ---
@@ -0,0 +1,9 @@
1
+ ---
2
+ type: tool_used
3
+ tool: Skill
4
+ input_match: '"skill"\s*:\s*"(?:[\w-]+:)?tdd"'
5
+ min: 0
6
+ max: 0
7
+ arm: both
8
+ weight: 1
9
+ ---
@@ -0,0 +1,8 @@
1
+ ---
2
+ max_turns: 10
3
+ allowed_tools: [Read, Glob, Grep, Skill]
4
+ tags: [pilot, negative-trigger]
5
+ description: "A one-line trivia question about TDD terminology must not start a RED/GREEN test-writing loop."
6
+ ---
7
+
8
+ In one sentence, what does the RED phase of test-driven development mean?
@@ -0,0 +1,7 @@
1
+ ---
2
+ type: regex
3
+ pattern: '(running the verification report|verification passed)'
4
+ flags: i
5
+ match: not_contains
6
+ weight: 1
7
+ ---
@@ -0,0 +1,9 @@
1
+ ---
2
+ type: tool_used
3
+ tool: Skill
4
+ input_match: '"skill"\s*:\s*"(?:[\w-]+:)?verification-loop"'
5
+ min: 0
6
+ max: 0
7
+ arm: both
8
+ weight: 1
9
+ ---
@@ -0,0 +1,8 @@
1
+ ---
2
+ max_turns: 10
3
+ allowed_tools: [Read, Glob, Grep, Skill]
4
+ tags: [pilot, negative-trigger]
5
+ description: "A design discussion with no completed work must not launch the verification-loop skill."
6
+ ---
7
+
8
+ Sketch two possible approaches for caching API responses and list trade-offs. Don't write any code yet.