harness-everything 0.20.7 → 0.22.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 (50) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +26 -0
  4. package/benchmarks/fixtures/system-one-routing.json +549 -0
  5. package/benchmarks/results/system-one/cua-s1-forms-cpu-2026-09-23/README.md +62 -0
  6. package/benchmarks/results/system-one/cua-s1-forms-cpu-2026-09-23/report.json +856 -0
  7. package/benchmarks/results/system-one/cua-s1-forms-resident-cpu-2026-09-23/README.md +74 -0
  8. package/benchmarks/results/system-one/cua-s1-forms-resident-cpu-2026-09-23/report.json +856 -0
  9. package/ci/fixtures/system-one-provider.cjs +13 -0
  10. package/ci/fixtures/system-one-resident-stub.py +28 -0
  11. package/ci/mechanism-packaging-bytecode.test.js +61 -0
  12. package/ci/mechanism-system-one-contract.test.js +48 -0
  13. package/ci/mechanism-system-one-evaluation.test.js +87 -0
  14. package/ci/mechanism-system-one-install.test.js +106 -0
  15. package/ci/mechanism-system-one-provider.test.js +63 -0
  16. package/ci/mechanism-system-one-resident.test.js +185 -0
  17. package/ci/mechanism-system-one-router.test.js +101 -0
  18. package/ci/system-one-adapter-test.py +222 -0
  19. package/docs/platform-capabilities.md +14 -0
  20. package/docs/system-one-routing.md +271 -0
  21. package/harness-everything/SKILL.md +1 -1
  22. package/harness-everything/scripts/system-one/contract.js +45 -0
  23. package/harness-everything/scripts/system-one/cua_adapter.py +353 -0
  24. package/harness-everything/scripts/system-one/evaluate.js +98 -0
  25. package/harness-everything/scripts/system-one/install.js +161 -0
  26. package/harness-everything/scripts/system-one/provider.js +79 -0
  27. package/harness-everything/scripts/system-one/resident.js +176 -0
  28. package/harness-everything/scripts/system-one/router.js +37 -0
  29. package/harness-everything/scripts/tier-router.js +16 -0
  30. package/opencode-plugin/plugin.json +1 -1
  31. package/package.json +2 -1
  32. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  33. package/plugins/harness-everything/plugin.json +1 -1
  34. package/plugins/harness-everything/scripts/lib/packaging-noise.js +6 -0
  35. package/plugins/harness-everything/scripts/lib/skills.js +2 -0
  36. package/plugins/harness-everything/skills/harness-everything/SKILL.md +1 -1
  37. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/contract.js +45 -0
  38. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/cua_adapter.py +353 -0
  39. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/evaluate.js +98 -0
  40. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/install.js +161 -0
  41. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/provider.js +79 -0
  42. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/resident.js +176 -0
  43. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/router.js +37 -0
  44. package/plugins/harness-everything/skills/harness-everything/scripts/tier-router.js +16 -0
  45. package/sbom.cdx.json +7 -7
  46. package/scripts/build-openai-submission.js +2 -0
  47. package/scripts/evaluate-system-one.js +66 -0
  48. package/scripts/lib/packaging-noise.js +6 -0
  49. package/scripts/lib/skills.js +2 -0
  50. package/scripts/sync-openai-plugin.js +2 -1
@@ -0,0 +1,79 @@
1
+ 'use strict';
2
+ const fs = require('node:fs');
3
+ const path = require('node:path');
4
+ const { spawnSync } = require('node:child_process');
5
+ const { validateRequest } = require('./contract');
6
+ // Upstream cua_s1 source revision documented in docs/system-one-routing.md.
7
+ const PINNED_CUA_S1_REVISION = 'b7f7e2d8714609853a29c7d049140bc46aec0954';
8
+ const ADAPTER = path.join(__dirname, 'cua_adapter.py');
9
+ const unavailable = reason => ({ status: 'unavailable', reason });
10
+ const exact = (value, keys) => value && typeof value === 'object' && !Array.isArray(value)
11
+ && Object.keys(value).length === keys.length && keys.every(k => Object.hasOwn(value, k));
12
+ const label = value => typeof value === 'string' && value.length > 0 && value.length <= 128 && !/[\u0000-\u001f]/.test(value);
13
+ function validateManifest(m) {
14
+ const required = ['schemaVersion', 'python', 'checkpoint', 'weightsSha256', 'configSha256', 'modelId', 'revision', 'domain'];
15
+ if (!m || typeof m !== 'object' || Array.isArray(m) || required.some(k => !Object.hasOwn(m, k))
16
+ || Object.keys(m).some(k => ![...required, 'timeoutMs', 'transport', 'idleTimeoutMs'].includes(k)) || m.schemaVersion !== 1
17
+ || ['python', 'modelId', 'revision', 'domain'].some(k => typeof m[k] !== 'string' || !m[k].trim() || m[k].length > 4096 || m[k].includes('\0'))
18
+ || typeof m.checkpoint !== 'string' || !path.isAbsolute(m.checkpoint) || path.extname(m.checkpoint) !== '.safetensors'
19
+ || ['weightsSha256', 'configSha256'].some(k => typeof m[k] !== 'string' || !/^[a-f0-9]{64}$/.test(m[k]))
20
+ || (m.timeoutMs !== undefined && (!Number.isInteger(m.timeoutMs) || m.timeoutMs < 1 || m.timeoutMs > 10000))
21
+ || (m.transport !== undefined && !['oneshot', 'resident'].includes(m.transport))
22
+ || (m.idleTimeoutMs !== undefined && (!Number.isInteger(m.idleTimeoutMs) || m.idleTimeoutMs < 60000 || m.idleTimeoutMs > 14400000))
23
+ || (m.modelId === 'cua-ai/cua-s1-forms' && m.domain !== 'forms-v1')) throw new TypeError('invalid-manifest');
24
+ return true;
25
+ }
26
+ function readManifest(manifestPath) {
27
+ if (typeof manifestPath !== 'string' || !path.isAbsolute(manifestPath) || fs.statSync(manifestPath).size > 65536) throw new Error();
28
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
29
+ validateManifest(manifest);
30
+ return manifest;
31
+ }
32
+ function spawnJson(executable, args, input, timeoutMs) {
33
+ let result;
34
+ try {
35
+ result = spawnSync(executable, args, { input, encoding: 'utf8', shell: false,
36
+ timeout: timeoutMs, killSignal: 'SIGKILL', maxBuffer: 1024 * 1024, windowsHide: true });
37
+ } catch (_) { return unavailable('provider-unavailable'); }
38
+ if (result.error) return unavailable(result.error.code === 'ETIMEDOUT' ? 'provider-timeout'
39
+ : result.error.code === 'ENOBUFS' ? 'provider-output-limit' : 'provider-unavailable');
40
+ if (result.status !== 0) return unavailable('provider-exit');
41
+ try { return { status: 'ok', value: JSON.parse(result.stdout) }; }
42
+ catch (_) { return unavailable('provider-json'); }
43
+ }
44
+ function runProvider(request, executable, args, timeoutMs = 2000) {
45
+ validateRequest(request);
46
+ const result = spawnJson(executable, args, JSON.stringify(request), timeoutMs);
47
+ return result.status === 'ok' ? { status: 'scored', response: result.value } : result;
48
+ }
49
+ function score(request, manifestPath) {
50
+ validateRequest(request);
51
+ let manifest;
52
+ try { manifest = readManifest(manifestPath); } catch (_) { return unavailable('provider-config'); }
53
+ if (manifest.transport === 'resident') return require('./resident').score({ ...request }, manifest, manifestPath);
54
+ // Send the exact validated manifest to the child on stdin: no config reread race.
55
+ return runProvider({ ...request }, manifest.python, [ADAPTER, JSON.stringify(manifest)], manifest.timeoutMs || 2000);
56
+ }
57
+ // The probe reports what is installed; only a PEP 610 VCS commit counts as a source revision.
58
+ function validateProvenance(p) {
59
+ if (!exact(p, ['schemaVersion', 'python', 'cuaS1', 'torch']) || p.schemaVersion !== 1
60
+ || !exact(p.python, ['implementation', 'version']) || !label(p.python.implementation) || !label(p.python.version)
61
+ || !exact(p.cuaS1, ['distribution', 'version', 'sourceRevision'])
62
+ || ![p.cuaS1.distribution, p.cuaS1.version, p.torch].every(v => v === null || label(v))
63
+ || (p.cuaS1.sourceRevision !== null && !(typeof p.cuaS1.sourceRevision === 'string' && /^[0-9a-f]{40}$/.test(p.cuaS1.sourceRevision)))) {
64
+ throw new TypeError('invalid-provenance');
65
+ }
66
+ const revision = p.cuaS1.sourceRevision;
67
+ return { python: { ...p.python }, torch: p.torch, cuaS1: { ...p.cuaS1, pinnedRevision: PINNED_CUA_S1_REVISION,
68
+ sourceRevisionStatus: revision === null ? 'unavailable' : revision === PINNED_CUA_S1_REVISION ? 'pinned' : 'mismatch' } };
69
+ }
70
+ function provenance(manifestPath) {
71
+ let manifest;
72
+ try { manifest = readManifest(manifestPath); } catch (_) { return unavailable('provider-config'); }
73
+ // Metadata scans can exceed the per-score budget; use the manifest cap. No model is loaded.
74
+ const result = spawnJson(manifest.python, [ADAPTER, '--provenance'], '', 10000);
75
+ if (result.status !== 'ok') return result;
76
+ try { return { status: 'recorded', provenance: validateProvenance(result.value) }; }
77
+ catch (_) { return unavailable('provider-json'); }
78
+ }
79
+ module.exports = { score, runProvider, validateManifest, readManifest, provenance, validateProvenance, PINNED_CUA_S1_REVISION };
@@ -0,0 +1,176 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ // Resident System One client: one verified model stays loaded in a loopback server.
4
+ // A score never blocks on model loading; a cold start returns provider-starting (lexical route wins).
5
+ const fs = require('node:fs');
6
+ const path = require('node:path');
7
+ const { createHash } = require('node:crypto');
8
+ const { spawn } = require('node:child_process');
9
+ const { Worker } = require('node:worker_threads');
10
+ const { validateRequest } = require('./contract');
11
+
12
+ const ADAPTER = path.join(__dirname, 'cua_adapter.py');
13
+ const LOCK_TTL_MS = 60000;
14
+ const CALL_TIMEOUT_MS = 1000;
15
+ const MAX_REPLY_BYTES = 1024 * 1024;
16
+ const unavailable = reason => ({ status: 'unavailable', reason });
17
+ const sleep = ms => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
18
+ const exact = (value, keys) => value && typeof value === 'object' && !Array.isArray(value)
19
+ && Object.keys(value).length === keys.length && keys.every(k => Object.hasOwn(value, k));
20
+ const defaultCommand = manifest => [manifest.python, [ADAPTER, '--serve']];
21
+
22
+ function stateFiles(manifest, manifestPath) {
23
+ const digest = createHash('sha256').update(JSON.stringify(manifest)).digest('hex').slice(0, 16);
24
+ const base = path.join(path.dirname(manifestPath), `system-one-resident-${digest}`);
25
+ return { state: `${base}.json`, lock: `${base}.starting` };
26
+ }
27
+ function readState(file) {
28
+ try {
29
+ const s = JSON.parse(fs.readFileSync(file, 'utf8'));
30
+ if (exact(s, ['schemaVersion', 'pid', 'port', 'token', 'startedAt']) && s.schemaVersion === 1
31
+ && Number.isInteger(s.pid) && s.pid > 0 && Number.isInteger(s.port) && s.port > 0 && s.port < 65536
32
+ && typeof s.token === 'string' && /^[0-9a-f]{64}$/.test(s.token) && Number.isFinite(s.startedAt)) return s;
33
+ } catch (_) { /* absent or unreadable state means no usable server */ }
34
+ return null;
35
+ }
36
+ function lockInfo(file) {
37
+ try {
38
+ const ageMs = Date.now() - fs.statSync(file).mtimeMs;
39
+ let failed = null;
40
+ try { const body = JSON.parse(fs.readFileSync(file, 'utf8')); if (typeof body.failed === 'string') failed = body.failed; } catch (_) { /* partial write */ }
41
+ return { ageMs, failed };
42
+ } catch (_) { return null; }
43
+ }
44
+ function pidAlive(pid) {
45
+ try { process.kill(pid, 0); return true; } catch (err) { return err.code === 'EPERM'; }
46
+ }
47
+ function removeIfSame(file, state) {
48
+ const current = readState(file);
49
+ if (current && current.pid === state.pid && current.token === state.token) { try { fs.unlinkSync(file); } catch (_) { /* raced */ } }
50
+ }
51
+
52
+ // One socket round trip on a worker thread; the caller blocks with Atomics.wait (router API is synchronous).
53
+ const WORKER = `
54
+ const net = require('node:net');
55
+ const { workerData } = require('node:worker_threads');
56
+ const { port, payload, signal, out } = workerData;
57
+ const view = new Uint8Array(out); const chunks = []; let size = 0; let done = false;
58
+ const finish = (code, buf) => {
59
+ if (done) return; done = true;
60
+ if (buf) { view.set(buf); Atomics.store(signal, 1, buf.length); }
61
+ Atomics.store(signal, 0, code); Atomics.notify(signal, 0);
62
+ };
63
+ const socket = net.connect({ port, host: '127.0.0.1' }, () => socket.end(payload));
64
+ socket.on('data', c => { size += c.length; if (size > view.length) { finish(4); socket.destroy(); } else chunks.push(c); });
65
+ socket.on('end', () => finish(1, Buffer.concat(chunks)));
66
+ socket.on('error', e => finish(e.code === 'ECONNREFUSED' ? 2 : 3));
67
+ `;
68
+ function callSync(port, message, timeoutMs = CALL_TIMEOUT_MS) {
69
+ const signal = new Int32Array(new SharedArrayBuffer(8));
70
+ const out = new SharedArrayBuffer(MAX_REPLY_BYTES);
71
+ let worker;
72
+ try {
73
+ worker = new Worker(WORKER, { eval: true, workerData: { port, payload: `${JSON.stringify(message)}\n`, signal, out } });
74
+ worker.unref();
75
+ } catch (_) { return { error: 'io' }; }
76
+ Atomics.wait(signal, 0, 0, timeoutMs);
77
+ const code = Atomics.load(signal, 0);
78
+ worker.terminate();
79
+ if (code === 0) return { error: 'timeout' };
80
+ if (code !== 1) return { error: code === 2 ? 'refused' : code === 4 ? 'limit' : 'io' };
81
+ try { return { reply: JSON.parse(Buffer.from(out, 0, Atomics.load(signal, 1)).toString('utf8')) }; }
82
+ catch (_) { return { error: 'json' }; }
83
+ }
84
+
85
+ function start(manifest, files, deps) {
86
+ const lock = lockInfo(files.lock);
87
+ if (lock && lock.ageMs < LOCK_TTL_MS) return unavailable(lock.failed ? 'provider-unavailable' : 'provider-starting');
88
+ if (lock) { try { fs.unlinkSync(files.lock); } catch (_) { /* another caller replaced it */ } }
89
+ try { fs.writeFileSync(files.lock, JSON.stringify({ createdAt: Date.now() }), { flag: 'wx', mode: 0o600 }); }
90
+ catch (_) { return unavailable('provider-starting'); }
91
+ let child = null;
92
+ try {
93
+ const [exe, prefix] = (deps.command || defaultCommand)(manifest);
94
+ child = spawn(exe, [...prefix, JSON.stringify(manifest), files.state, files.lock],
95
+ { detached: true, stdio: 'ignore', windowsHide: true, shell: false });
96
+ child.on('error', () => { /* recorded synchronously below: a failed spawn has no pid */ });
97
+ child.unref();
98
+ } catch (_) { child = null; }
99
+ // The async 'error' event cannot run while callers block in Atomics.wait, so record the failure now.
100
+ if (!child || !child.pid) {
101
+ try { fs.writeFileSync(files.lock, JSON.stringify({ createdAt: Date.now(), failed: 'spawn-failed' })); } catch (_) { /* best effort */ }
102
+ return unavailable('provider-unavailable');
103
+ }
104
+ return unavailable('provider-starting');
105
+ }
106
+ // Returns a live server state, or null after removing state that provably belongs to a dead server.
107
+ function liveState(files) {
108
+ const state = readState(files.state);
109
+ if (state && !pidAlive(state.pid)) { removeIfSame(files.state, state); return null; }
110
+ return state;
111
+ }
112
+ function score(request, manifest, manifestPath, deps = {}) {
113
+ validateRequest(request);
114
+ const files = stateFiles(manifest, manifestPath);
115
+ const state = liveState(files);
116
+ if (!state) return start(manifest, files, deps);
117
+ const result = callSync(state.port, { token: state.token, op: 'score', request });
118
+ if (result.reply) {
119
+ if (result.reply.ok === true && Object.hasOwn(result.reply, 'response')) return { status: 'scored', response: result.reply.response };
120
+ if (result.reply.ok === false) return unavailable(result.reply.reason === 'unauthorized' ? 'provider-unavailable' : 'provider-exit');
121
+ return unavailable('provider-json');
122
+ }
123
+ if (result.error === 'refused') { removeIfSame(files.state, state); return start(manifest, files, deps); }
124
+ return unavailable({ timeout: 'provider-timeout', limit: 'provider-output-limit', json: 'provider-json' }[result.error] || 'provider-unavailable');
125
+ }
126
+ function ping(state) {
127
+ const result = callSync(state.port, { token: state.token, op: 'ping' });
128
+ return result.reply && result.reply.ok === true ? result.reply : null;
129
+ }
130
+ function ensureReady(manifest, manifestPath, waitMs, deps = {}) {
131
+ const files = stateFiles(manifest, manifestPath);
132
+ const deadline = Date.now() + waitMs;
133
+ while (Date.now() < deadline) {
134
+ const state = liveState(files);
135
+ if (state && ping(state)) return true;
136
+ if (!state) {
137
+ const lock = lockInfo(files.lock);
138
+ if (lock && lock.failed && lock.ageMs < LOCK_TTL_MS) return false;
139
+ if (!lock || lock.ageMs >= LOCK_TTL_MS) start(manifest, files, deps);
140
+ }
141
+ sleep(100);
142
+ }
143
+ return false;
144
+ }
145
+ function status(manifest, manifestPath) {
146
+ const state = liveState(stateFiles(manifest, manifestPath));
147
+ const reply = state && ping(state);
148
+ return reply ? { running: true, pid: state.pid, port: state.port, startedAt: state.startedAt, model: reply.model } : { running: false };
149
+ }
150
+ function stop(manifest, manifestPath) {
151
+ const files = stateFiles(manifest, manifestPath);
152
+ const state = liveState(files);
153
+ if (!state) return false;
154
+ const result = callSync(state.port, { token: state.token, op: 'shutdown' });
155
+ if (!(result.reply && result.reply.ok === true)) {
156
+ try { process.kill(state.pid); } catch (_) { /* already exited */ }
157
+ removeIfSame(files.state, state);
158
+ }
159
+ return true;
160
+ }
161
+
162
+ if (require.main === module) {
163
+ const [op, manifestPath, extra] = process.argv.slice(2);
164
+ let manifest = null;
165
+ try {
166
+ if (!['start', 'status', 'stop'].includes(op) || extra) throw new Error('usage');
167
+ manifest = require('./provider').readManifest(manifestPath);
168
+ } catch (_) {
169
+ console.error('Usage: resident.js start|status|stop <absolute manifest path>');
170
+ process.exit(2);
171
+ }
172
+ if (op === 'start') process.exitCode = ensureReady(manifest, manifestPath, 60000) ? 0 : 1;
173
+ if (op === 'stop') stop(manifest, manifestPath);
174
+ process.stdout.write(`${JSON.stringify(status(manifest, manifestPath))}\n`);
175
+ }
176
+ module.exports = { stateFiles, readState, callSync, score, ensureReady, status, stop, LOCK_TTL_MS, CALL_TIMEOUT_MS };
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+ const { createRequest, decide } = require('./contract');
3
+ const provider = require('./provider');
4
+ const TIER_OPTIONS = Object.freeze([
5
+ { id: 'tier1', text: 'A small bounded edit or operation with clear scope.' },
6
+ { id: 'tier2', text: 'Implementation or bug fix needing iterative testing.' },
7
+ { id: 'tier3', text: 'Architecture, repository-wide change or multi-stage engineering.' },
8
+ { id: 'unclassified', text: 'Unclear intent, insufficient context or outside these categories.' },
9
+ ].map(Object.freeze));
10
+ const LABELS = { tier1: 'Tier 1 (Trivial)', tier2: 'Tier 2 (Standard Task)', tier3: 'Tier 3 (Macro Task)' };
11
+ const RANK = { tier1: 1, tier2: 2, tier3: 3 };
12
+ // input.floor is the deterministic structural minimum; a scorer may raise the tier, never lower it below the floor.
13
+ function selectTier(input, env = process.env, scorer = provider.score) {
14
+ const mode = env.HARNESS_SYSTEM_ONE_MODE || 'off';
15
+ if (mode === 'off') return { tier: input.tier, diagnostic: null };
16
+ const fallback = (reason, status = 'unavailable') => ({ tier: input.tier, diagnostic: { mode: ['shadow', 'prefer'].includes(mode) ? mode : 'invalid', status, reason } });
17
+ if (!['shadow', 'prefer'].includes(mode)) return fallback('invalid-mode');
18
+ if (input.floor != null && !Object.hasOwn(RANK, input.floor)) return fallback('invalid-request');
19
+ let request;
20
+ try { request = createRequest('tier', input.prompt, TIER_OPTIONS); }
21
+ catch (_) { return fallback('invalid-request'); }
22
+ let result;
23
+ try { result = scorer(request, env.HARNESS_SYSTEM_ONE_CONFIG); }
24
+ catch (_) { return fallback('provider-unavailable'); }
25
+ if (!result || result.status !== 'scored') {
26
+ const allowed = ['provider-timeout', 'provider-output-limit', 'provider-exit', 'provider-json', 'provider-config', 'provider-unavailable', 'provider-starting'];
27
+ return fallback(allowed.includes(result?.reason) ? result.reason : 'provider-unavailable');
28
+ }
29
+ const decision = decide(request, result.response);
30
+ if (decision.selectedId === 'unclassified') Object.assign(decision, { selectedId: null, status: 'abstain', reason: 'unclassified' });
31
+ const accepted = decision.status === 'accepted';
32
+ const belowFloor = accepted && input.floor != null && RANK[decision.selectedId] < RANK[input.floor];
33
+ const applied = mode === 'prefer' && accepted && !input.explicit && !belowFloor;
34
+ const reason = input.explicit && accepted ? 'explicit-precedence' : belowFloor ? 'structural-floor' : decision.reason;
35
+ return { tier: applied ? LABELS[decision.selectedId] : input.tier, diagnostic: { mode, ...decision, applied, reason } };
36
+ }
37
+ module.exports = { selectTier, TIER_OPTIONS };
@@ -313,6 +313,19 @@ function run(userPrompt, context) {
313
313
  }
314
314
  }
315
315
 
316
+ const { selectTier } = require('./system-one/router');
317
+ const structuralFloor = hasMacroSignal ? 'tier3'
318
+ : !isTrivialDocsEdit && hasMultipleTasks && hasMultipleSentences ? 'tier2' : null;
319
+ const semantic = selectTier({ prompt: userPrompt, tier: recommendedTier, floor: structuralFloor,
320
+ explicit: Boolean(detectExplicitStrategy(userPrompt, detectFableModel(userPrompt))) });
321
+ if (semantic.diagnostic) console.log(`\n=> SYSTEM ONE: ${JSON.stringify(semantic.diagnostic)}`);
322
+ if (semantic.diagnostic?.applied) {
323
+ recommendedTier = semantic.tier;
324
+ rationale = 'System One selected a tier from the fixed catalog; deterministic policy remains authoritative.';
325
+ reasonCodes.splice(loadedConfig.reasonCodes.length);
326
+ addReason(reasonCodes, 'system-one-tier');
327
+ }
328
+
316
329
  console.log(`\n=> RECOMMENDED TIER: ${recommendedTier}`);
317
330
  console.log(`=> RATIONALE: ${rationale}`);
318
331
 
@@ -447,6 +460,7 @@ function run(userPrompt, context) {
447
460
  return contract;
448
461
  }
449
462
 
463
+ if (require.main === module) {
450
464
  let userPrompt = process.argv[2] || '';
451
465
  let hookContext = null;
452
466
 
@@ -471,3 +485,5 @@ if (process.argv[2]) {
471
485
  run(userPrompt, hookContext);
472
486
  });
473
487
  }
488
+ }
489
+ module.exports = { run };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "harness-enforcement",
3
3
  "description": "Repository inventory for the opencode enforcement plugin and its standalone helper",
4
- "version": "0.20.7",
4
+ "version": "0.22.0",
5
5
  "runtime": "index.mjs",
6
6
  "hooks": {
7
7
  "verify": "hooks/verify.js"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "harness-everything",
3
- "version": "0.20.7",
3
+ "version": "0.22.0",
4
4
  "description": "Harness OS: An Orchestrated Agent Operating System for AI-driven Development",
5
5
  "main": "harness-everything/scripts/bootstrap.js",
6
6
  "bin": {
@@ -23,6 +23,7 @@
23
23
  "test:release": "node ci/release-consistency-check.js && node ci/mechanism-2x-release-automation.test.js && node ci/mechanism-2x-release-commit-message.test.js && node ci/mechanism-2ap-sbom.test.js",
24
24
  "test:release:semantics": "node ci/semantic-release-analyzer.test.mjs",
25
25
  "test:install": "node scripts/verify-install.js",
26
+ "system-one:install": "node harness-everything/scripts/system-one/install.js",
26
27
  "test:collision": "node ci/description-collision.js",
27
28
  "test:routing:skills": "node ci/skill-routing-check.js",
28
29
  "test:routing": "node ci/routing-check.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "harness-everything",
3
- "version": "0.20.7",
3
+ "version": "0.22.0",
4
4
  "description": "Invariant-first engineering harness for routing, verification, and failure recovery while preserving agent autonomy.",
5
5
  "author": {
6
6
  "name": "Miya Daniel",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "harness-everything",
4
- "version": "0.20.7",
4
+ "version": "0.22.0",
5
5
  "description": "Invariant-first engineering harness for routing, verification, and failure recovery while preserving agent autonomy.",
6
6
  "author": {
7
7
  "name": "Miya Daniel",
@@ -0,0 +1,6 @@
1
+ 'use strict';
2
+ // Untracked local/CI build artifacts that no distribution (installer copy, plugin mirror,
3
+ // public submission) may ship, even when they exist in the working tree.
4
+ const isPackagingNoise = name => name === '__pycache__' || /\.py[co]$/.test(name);
5
+
6
+ module.exports = { isPackagingNoise };
@@ -2,11 +2,13 @@
2
2
  const fs = require('fs');
3
3
  const path = require('path');
4
4
  const manifest = require('./manifest');
5
+ const { isPackagingNoise } = require('./packaging-noise');
5
6
 
6
7
  function copyDir(src, dest) {
7
8
  fs.mkdirSync(dest, { recursive: true });
8
9
  const entries = fs.readdirSync(src, { withFileTypes: true });
9
10
  for (const entry of entries) {
11
+ if (isPackagingNoise(entry.name)) continue;
10
12
  const srcPath = path.join(src, entry.name);
11
13
  const destPath = path.join(dest, entry.name);
12
14
  if (entry.isDirectory()) copyDir(srcPath, destPath);
@@ -4,7 +4,7 @@ description: "Route software/project work through Harness: classify tier/topolog
4
4
  license: Apache-2.0
5
5
  metadata:
6
6
  author: Miya Daniel
7
- version: 0.19.1
7
+ version: 0.22.0
8
8
  ---
9
9
 
10
10
  # Harness Everything
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+ const { createHash } = require('node:crypto');
3
+ const hash = value => createHash('sha256').update(JSON.stringify(value)).digest('hex');
4
+ const exact = (value, keys) => value && typeof value === 'object' && !Array.isArray(value)
5
+ && Object.keys(value).length === keys.length && keys.every(k => Object.hasOwn(value, k));
6
+ const text = (value, max = 4096) => typeof value === 'string' && value.trim().length > 0 && Buffer.byteLength(value, 'utf8') <= max;
7
+ const id = value => typeof value === 'string' && /^[a-z0-9._-]{1,80}$/.test(value);
8
+ const probability = value => typeof value === 'number' && Number.isFinite(value) && value >= 0 && value <= 1;
9
+ function fail(code) { throw Object.assign(new TypeError(code), { code }); }
10
+ function createRequest(task, context, options) {
11
+ if (!id(task) || !text(context, 65536) || !Array.isArray(options) || options.length < 2 || options.length > 256
12
+ || options.some(o => !exact(o, ['id', 'text']) || !id(o.id) || !text(o.text))
13
+ || new Set(options.map(o => o.id)).size !== options.length) fail('invalid-request');
14
+ const copy = options.map(o => ({ id: o.id, text: o.text }));
15
+ const catalogHash = hash({ task, options: copy });
16
+ return { schemaVersion: 1, task, context, options: copy, catalogHash, requestHash: hash({ catalogHash, context }) };
17
+ }
18
+ function validateRequest(req) {
19
+ if (!exact(req, ['schemaVersion', 'task', 'context', 'options', 'catalogHash', 'requestHash']) || req.schemaVersion !== 1) fail('invalid-request');
20
+ const rebuilt = createRequest(req.task, req.context, req.options);
21
+ if (req.catalogHash !== rebuilt.catalogHash || req.requestHash !== rebuilt.requestHash) fail('invalid-request');
22
+ return true;
23
+ }
24
+ function decide(req, res, policy = {}) {
25
+ validateRequest(req);
26
+ if (!policy || typeof policy !== 'object' || Array.isArray(policy)
27
+ || Object.keys(policy).some(k => !['domain', 'minConfidence', 'minMargin'].includes(k))) fail('invalid-policy');
28
+ const { domain = 'harness-routing-v1', minConfidence = 0.9, minMargin = 0.2 } = policy;
29
+ if (!text(domain) || !probability(minConfidence) || !probability(minMargin)) fail('invalid-policy');
30
+ const empty = { status: 'invalid-output', reason: 'invalid-response', selectedId: null, confidence: null, margin: null, model: null };
31
+ if (!exact(res, ['schemaVersion', 'requestHash', 'catalogHash', 'model', 'scores'])
32
+ || res.schemaVersion !== 1 || res.requestHash !== req.requestHash || res.catalogHash !== req.catalogHash
33
+ || !exact(res.model, ['id', 'revision', 'domain']) || !Object.values(res.model).every(v => text(v))
34
+ || !Array.isArray(res.scores) || res.scores.length !== req.options.length
35
+ || res.scores.some((s, i) => !exact(s, ['id', 'probability']) || s.id !== req.options[i].id || !probability(s.probability))
36
+ || Math.abs(res.scores.reduce((s, o) => s + o.probability, 0) - 1) > 1e-6) return empty;
37
+ const ranked = [...res.scores].sort((a, b) => b.probability - a.probability);
38
+ const confidence = ranked[0].probability;
39
+ const margin = confidence - ranked[1].probability;
40
+ const reason = res.model.domain !== domain ? 'domain-mismatch' : margin === 0 ? 'tie'
41
+ : confidence < minConfidence ? 'low-confidence' : margin < minMargin ? 'low-margin' : 'scored';
42
+ return { status: reason === 'scored' ? 'accepted' : 'abstain', reason,
43
+ selectedId: reason === 'scored' ? ranked[0].id : null, confidence, margin, model: { ...res.model } };
44
+ }
45
+ module.exports = { createRequest, validateRequest, decide };