harness-everything 0.50.0 → 0.52.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 (97) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.github/workflows/ci.yml +23 -0
  4. package/CHANGELOG.md +174 -115
  5. package/benchmarks/results/doc-evidence-e1/cycle-2026-11-11-a-evid-001.md +123 -0
  6. package/benchmarks/results/doc-evidence-e1/cycle-2026-11-11-b-route-001.md +130 -0
  7. package/ci/mechanism-2am-observations-session-import.test.js +4 -1
  8. package/ci/mechanism-34-observations.test.js +127 -23
  9. package/ci/mechanism-349-ci-change-scope.test.js +260 -0
  10. package/ci/mechanism-handoff-file.test.js +121 -0
  11. package/ci/mechanism-prb-outline-review.test.js +783 -107
  12. package/ci/mechanism-system-one-contract.test.js +9 -2
  13. package/ci/mechanism-system-one-curves.test.js +206 -0
  14. package/ci/mechanism-system-one-cycle.test.js +585 -0
  15. package/ci/mechanism-system-one-evaluation.test.js +32 -5
  16. package/ci/mechanism-system-one-handoff-input.test.js +208 -0
  17. package/ci/mechanism-system-one-install.test.js +202 -77
  18. package/ci/mechanism-system-one-live.test.js +361 -0
  19. package/ci/mechanism-system-one-relevance.test.js +11 -1
  20. package/ci/mechanism-system-one-train.test.js +136 -53
  21. package/ci/release-unreleased-heading.test.js +24 -0
  22. package/ci/system-one-adapter-test.py +331 -0
  23. package/ci/system-one-train-test.py +116 -24
  24. package/docs/adr/EVID-001.md +123 -0
  25. package/docs/adr/ROUTE-001-error-lesson-delivery.md +305 -0
  26. package/docs/doc-workflow-reconciliation.md +29 -16
  27. package/docs/governed-index.md +2 -0
  28. package/docs/platform-capabilities.md +2 -0
  29. package/docs/routing.md +2 -2
  30. package/docs/system-one-cycle.md +68 -0
  31. package/docs/system-one-observations.md +9 -8
  32. package/docs/system-one-routing.md +163 -115
  33. package/docs/system-one-suggestion-gates.md +6 -8
  34. package/docs/system-one-training.md +44 -7
  35. package/docs/workflow-runtime.md +19 -0
  36. package/harness-everything/SKILL.md +1 -1
  37. package/harness-everything/scripts/kernel-router.js +2 -1
  38. package/harness-everything/scripts/system-one/contract.js +19 -15
  39. package/harness-everything/scripts/system-one/cua_adapter.py +211 -17
  40. package/harness-everything/scripts/system-one/evaluate.js +4 -9
  41. package/harness-everything/scripts/system-one/handoff-input.js +76 -0
  42. package/harness-everything/scripts/system-one/install.js +281 -113
  43. package/harness-everything/scripts/system-one/manifest.js +58 -0
  44. package/harness-everything/scripts/system-one/provider.js +96 -2
  45. package/harness-everything/scripts/system-one/resident.js +47 -1
  46. package/harness-everything/scripts/system-one/router.js +80 -1
  47. package/harness-everything/scripts/tier-router.js +21 -6
  48. package/hooks/scripts/lib/doc-reconciliation-pilot.js +12 -0
  49. package/hooks/scripts/lib/doc-reconciliation-provider.js +575 -12
  50. package/hooks/scripts/lib/observations.js +43 -4
  51. package/hooks/scripts/lib/workflow-obligations.js +8 -4
  52. package/hooks/scripts/state-persist.js +26 -7
  53. package/hooks/scripts/w6-state-operations.js +239 -0
  54. package/opencode-plugin/plugin.json +1 -1
  55. package/package.json +2 -2
  56. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  57. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-pilot.js +12 -0
  58. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-provider.js +575 -12
  59. package/plugins/harness-everything/hooks/scripts/lib/observations.js +43 -4
  60. package/plugins/harness-everything/hooks/scripts/lib/workflow-obligations.js +8 -4
  61. package/plugins/harness-everything/hooks/scripts/state-persist.js +26 -7
  62. package/plugins/harness-everything/hooks/scripts/w6-state-operations.js +239 -0
  63. package/plugins/harness-everything/plugin.json +1 -1
  64. package/plugins/harness-everything/scripts/handoff-file.js +223 -0
  65. package/plugins/harness-everything/skills/harness-everything/SKILL.md +1 -1
  66. package/plugins/harness-everything/skills/harness-everything/scripts/kernel-router.js +2 -1
  67. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/contract.js +19 -15
  68. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/cua_adapter.py +211 -17
  69. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/evaluate.js +4 -9
  70. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/handoff-input.js +76 -0
  71. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/install.js +281 -113
  72. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/manifest.js +58 -0
  73. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/provider.js +96 -2
  74. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/resident.js +47 -1
  75. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/router.js +80 -1
  76. package/plugins/harness-everything/skills/harness-everything/scripts/tier-router.js +21 -6
  77. package/sbom.cdx.json +7 -7
  78. package/scripts/ci-change-scope.js +59 -0
  79. package/scripts/handoff-file.js +223 -0
  80. package/scripts/sync-openai-plugin.js +4 -0
  81. package/scripts/system-one-calibrate.js +108 -41
  82. package/scripts/system-one-curves.js +332 -0
  83. package/scripts/system-one-cycle/adjudication-input.js +65 -0
  84. package/scripts/system-one-cycle/build.js +165 -0
  85. package/scripts/system-one-cycle/collect.js +50 -0
  86. package/scripts/system-one-cycle/common.js +137 -0
  87. package/scripts/system-one-cycle/engines.js +62 -0
  88. package/scripts/system-one-cycle/evaluate.js +70 -0
  89. package/scripts/system-one-cycle/judge.js +106 -0
  90. package/scripts/system-one-cycle/label.js +59 -0
  91. package/scripts/system-one-cycle/package.js +173 -0
  92. package/scripts/system-one-cycle/score.py +111 -0
  93. package/scripts/system-one-cycle/train.js +136 -0
  94. package/scripts/system-one-cycle.js +131 -0
  95. package/scripts/system-one-observations-export.js +29 -6
  96. package/scripts/system-one-observations-review.js +4 -5
  97. package/scripts/system-one-train.py +117 -61
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
  const { test } = require('node:test');
3
3
  const assert = require('node:assert/strict');
4
- const { createRequest, validateRequest, decide } = require('../harness-everything/scripts/system-one/contract');
4
+ const { createRequest, validateRequest, validateResponse, decide } = require('../harness-everything/scripts/system-one/contract');
5
5
  const options = [{ id: 'tier1', text: 'Bounded edit' }, { id: 'tier3', text: 'Architecture' }];
6
6
  const request = () => createRequest('tier', '修正 typo', options);
7
7
  function response(req, p = [0.95, 0.05]) {
@@ -29,12 +29,19 @@ test('S1-C02 rejected input partitions and byte boundaries', () => {
29
29
  const r = request(); mutate(r); assert.throws(() => validateRequest(r));
30
30
  }
31
31
  });
32
+ test('legacy requests reject one option while live validity can opt in', () => {
33
+ const single = [{ id: 'invalid', text: 'Needs context' }];
34
+ assert.throws(() => createRequest('validity', 'current text', single), { code: 'invalid-request' });
35
+ const live = createRequest('validity', 'current text', single, { minOptions: 1 });
36
+ assert.equal(validateRequest(live), true);
37
+ });
32
38
  test('S1-C03 complete output validation and no raw-data leakage', () => {
33
39
  const req = request();
34
- for (const mutate of [r => { r.schemaVersion = 2; }, r => { r.requestHash = 'stale'; }, r => { r.catalogHash = 'stale'; }, r => { r.scores.pop(); }, r => { r.scores.push(r.scores[0]); }, r => { r.scores.reverse(); }, r => { r.scores[1].id = r.scores[0].id; }, r => { r.scores[0].probability = NaN; }, r => { r.scores[0].probability = Infinity; }, r => { r.scores[0].probability = -1; }, r => { r.scores[0].probability = 1.1; }, r => { r.scores[0].probability = '0.95'; }, r => { r.scores[0].probability = 0.8; }, r => { r.scores[0].extra = 'secret'; }, r => { r.model.extra = 'secret'; }, r => { r.model.revision = ''; }, r => { delete r.model; }, r => { r.extra = 'secret'; }]) {
40
+ for (const mutate of [r => { r.schemaVersion = 2; }, r => { r.requestHash = 'stale'; }, r => { r.catalogHash = 'stale'; }, r => { r.scores.pop(); }, r => { r.scores.push(r.scores[0]); }, r => { r.scores.reverse(); }, r => { r.scores[1].id = r.scores[0].id; }, r => { r.scores[0].probability = NaN; }, r => { r.scores[0].probability = Infinity; }, r => { r.scores[0].probability = -1; }, r => { r.scores[0].probability = 1.1; }, r => { r.scores[0].probability = '0.95'; }, r => { r.scores[0].extra = 'secret'; }, r => { r.model.extra = 'secret'; }, r => { r.model.revision = ''; }, r => { delete r.model; }, r => { r.extra = 'secret'; }]) {
35
41
  const res = response(req); mutate(res);
36
42
  assert.deepEqual(decide(req, res), { status: 'invalid-output', reason: 'invalid-response', selectedId: null, confidence: null, margin: null, model: null });
37
43
  }
44
+ assert.equal(validateResponse(req, response(req, [0.8, 0.75])), true);
38
45
  for (const value of [null, [], 'invalid']) assert.equal(decide(req, value).status, 'invalid-output');
39
46
  });
40
47
  test('S1-C04 abstention and policy boundaries', () => {
@@ -0,0 +1,206 @@
1
+ 'use strict';
2
+ const { test } = require('node:test');
3
+ const fs = require('node:fs');
4
+ const os = require('node:os');
5
+ const path = require('node:path');
6
+ const { spawnSync } = require('node:child_process');
7
+ const assert = require('node:assert/strict');
8
+
9
+ const root = path.resolve(__dirname, '..');
10
+ const cli = path.join(root, 'scripts/system-one-curves.js');
11
+ function fixture(t, { stage = 'validity', options = ['invalid'], referenceOnly = [] } = {}) {
12
+ const dir = fs.realpathSync.native(fs.mkdtempSync(path.join(os.tmpdir(), 'harness-s1-curves-')));
13
+ t.after(() => fs.rmSync(dir, { recursive: true, force: true }));
14
+ const versionDir = path.join(dir, 'version');
15
+ fs.mkdirSync(versionDir);
16
+ const history = path.join(dir, 'history.jsonl');
17
+ const out = path.join(dir, 'out');
18
+ const writeVersion = version => {
19
+ const catalogs = { validity: ['invalid'], intent: ['fix'], tier: ['tier1'] };
20
+ catalogs[stage] = options;
21
+ const stages = Object.fromEntries(Object.entries(catalogs).map(([name, ids]) => {
22
+ const weights = `${name}.bin`; const config = `${name}.json`;
23
+ fs.writeFileSync(path.join(versionDir, weights), 'fixture');
24
+ fs.writeFileSync(path.join(versionDir, config), '{}\n');
25
+ const thresholds = Object.fromEntries(ids.map(id => [id, name === stage && referenceOnly.includes(id) ? 1 : 0.5]));
26
+ return [name, { weights, config, sha256: '0'.repeat(64), options: ids, thresholds,
27
+ ...(name === stage && referenceOnly.length ? { referenceOnly } : {}) }];
28
+ }));
29
+ const manifest = {
30
+ schemaVersion: 1,
31
+ version,
32
+ createdAt: '2026-11-14T00:00:00.000Z',
33
+ stages,
34
+ evaluation: null,
35
+ };
36
+ fs.writeFileSync(path.join(versionDir, 'manifest.json'), JSON.stringify(manifest));
37
+ return manifest;
38
+ };
39
+ function run({ version = 'v1', val, holdout, mutateManifest, expectFailure = false } = {}) {
40
+ const manifest = writeVersion(version);
41
+ if (mutateManifest) {
42
+ mutateManifest(manifest);
43
+ fs.writeFileSync(path.join(versionDir, 'manifest.json'), JSON.stringify(manifest));
44
+ }
45
+ const valFile = path.join(dir, `${version}-val.jsonl`);
46
+ fs.writeFileSync(valFile, val.map(row => JSON.stringify(row)).join('\n') + '\n');
47
+ const args = [cli, '--version', version, '--version-dir', versionDir, '--val-scores', `${stage}=${valFile}`, '--history', history, '--out', out];
48
+ if (holdout) {
49
+ const holdoutFile = path.join(dir, `${version}-holdout.jsonl`);
50
+ fs.writeFileSync(holdoutFile, holdout.map(row => JSON.stringify(row)).join('\n') + '\n');
51
+ args.splice(args.indexOf('--history'), 0, '--holdout-scores', `${stage}=${holdoutFile}`);
52
+ }
53
+ const child = spawnSync(process.execPath, args, { cwd: root, encoding: 'utf8', env: { ...process.env, HARNESS_SYSTEM_ONE_HOME: dir } });
54
+ if (expectFailure) {
55
+ assert.notEqual(child.status, 0, child.stdout);
56
+ return child;
57
+ }
58
+ assert.equal(child.status, 0, child.stderr || child.stdout);
59
+ return {
60
+ stdout: child.stdout.trim(),
61
+ curves: JSON.parse(fs.readFileSync(path.join(out, 'curves.json'), 'utf8')),
62
+ trend: JSON.parse(fs.readFileSync(path.join(out, 'trend.json'), 'utf8')),
63
+ };
64
+ }
65
+ return { dir, history, run };
66
+ }
67
+ const validityRows = probabilities => probabilities.map(([gold, p], i) => ({ id: `v${i}`, gold, scores: { invalid: p } }));
68
+ const tierRows = (scores, prefix = 't') => scores.map(([gold, a, b], i) => ({ id: `${prefix}${i}`, gold, scores: { a, b } }));
69
+
70
+ test('hand-computed proper scores average independent options without a sum-to-one rule', t => {
71
+ const f = fixture(t, { stage: 'tier', options: ['a', 'b'] });
72
+ const { curves } = f.run({ val: tierRows([['a', 0.8, 0.3], ['b', 0.2, 0.7]]) });
73
+ assert.ok(Math.abs(curves.stages.tier.logLoss - (-Math.log(0.8) - Math.log(0.7)) / 2) < 1e-12);
74
+ assert.ok(Math.abs(curves.stages.tier.brier - 0.065) < 1e-12);
75
+ assert.equal(curves.stages.tier.coverageCurve.length, 101);
76
+ });
77
+
78
+ test('perfectly calibrated synthetic probabilities have zero ECE', t => {
79
+ const f = fixture(t);
80
+ const rows = [
81
+ ...Array.from({ length: 10 }, (_, i) => [i < 2 ? 'invalid' : 'actionable', 0.2]),
82
+ ...Array.from({ length: 10 }, (_, i) => [i < 8 ? 'invalid' : 'actionable', 0.8]),
83
+ ];
84
+ const { curves } = f.run({ val: validityRows(rows) });
85
+ assert.ok(curves.stages.validity.ece < 1e-12);
86
+ assert.equal(curves.stages.validity.reliability.length, 10);
87
+ });
88
+
89
+ test('better ranking with worse calibration does not auto-promote', t => {
90
+ const f = fixture(t, { stage: 'tier', options: ['a', 'b'] });
91
+ f.run({ version: 'v0', val: tierRows([['a', 0.5, 0.5], ['b', 0.5, 0.5], ['a', 0.5, 0.5], ['b', 0.5, 0.5]]) });
92
+ const { curves, trend } = f.run({ version: 'v1', val: tierRows([
93
+ ['a', 0.95, 0.1], ['b', 0.1, 0.95], ['a', 0.95, 0.1], ['b', 0.95, 0.9],
94
+ ]) });
95
+ assert.equal(trend.verdict, 'hold');
96
+ assert.ok(curves.stages.tier.ece > 0);
97
+ assert.ok(trend.reasons.some(reason => reason.includes('coverage-accuracy AUC delta +')));
98
+ assert.ok(trend.reasons.some(reason => reason.includes('ECE delta +')));
99
+ });
100
+
101
+ test('an old-holdout regression blocks promotion', t => {
102
+ const f = fixture(t, { stage: 'tier', options: ['a', 'b'] });
103
+ const goldRows = [['a', 0.8, 0.2], ['b', 0.2, 0.8], ['a', 0.8, 0.2], ['b', 0.2, 0.8]];
104
+ f.run({ version: 'v0', val: tierRows([['a', 0.5, 0.5], ['b', 0.5, 0.5], ['a', 0.5, 0.5], ['b', 0.5, 0.5]], 'v'), holdout: tierRows(goldRows, 'h') });
105
+ const { curves, trend } = f.run({ version: 'v1', val: tierRows(goldRows, 'v'), holdout: tierRows([
106
+ ['a', 0.1, 0.9], ['b', 0.9, 0.1], ['a', 0.1, 0.9], ['b', 0.9, 0.1],
107
+ ], 'h') });
108
+ assert.equal(curves.floor.oldHoldoutRegression, true);
109
+ assert.equal(trend.verdict, 'hold');
110
+ assert.ok(trend.reasons.some(reason => reason.includes('old-holdout') && reason.includes('regression')));
111
+ });
112
+
113
+ test('one successful run appends exactly one history line', t => {
114
+ const f = fixture(t);
115
+ const first = f.run({ val: validityRows([['invalid', 0.8], ['actionable', 0.2]]) });
116
+ let lines = fs.readFileSync(f.history, 'utf8').trim().split('\n');
117
+ assert.equal(lines.length, 1);
118
+ assert.deepEqual(JSON.parse(lines[0]), first.curves);
119
+ const second = f.run({ version: 'v2', val: validityRows([['invalid', 0.7], ['actionable', 0.3]]) });
120
+ lines = fs.readFileSync(f.history, 'utf8').trim().split('\n');
121
+ assert.equal(lines.length, 2);
122
+ assert.deepEqual(JSON.parse(lines[1]), second.curves);
123
+ });
124
+
125
+ test('intent curves keep reference-only unclassified scores but never use them as the selected option', t => {
126
+ const f = fixture(t, { stage: 'intent', options: ['fix', 'unclassified'], referenceOnly: ['unclassified'] });
127
+ const { curves, trend } = f.run({ val: [
128
+ { id: 'i1', gold: ['fix'], scores: { fix: 0.7, unclassified: 0.99 } },
129
+ ] });
130
+ const metrics = curves.stages.intent;
131
+ assert.deepEqual(metrics.optionDistributions.unclassified, [0.99, 0.99, 0.99, 0.99, 0.99]);
132
+ assert.equal(metrics.coverageCurve[80][1], 0);
133
+ assert.equal(metrics.coverageCurve[70][1], 1);
134
+ assert.equal(trend.verdict, 'hold');
135
+ assert.equal(fs.existsSync(path.join(f.dir, 'out', 'curves.json')), true);
136
+ assert.equal(fs.existsSync(path.join(f.dir, 'out', 'trend.json')), true);
137
+ assert.equal(fs.readFileSync(f.history, 'utf8').trim().split('\n').length, 1);
138
+ });
139
+
140
+ test('curves rejects malformed reference-only metadata and score rows that omit catalog ids', t => {
141
+ const f = fixture(t, { stage: 'intent', options: ['fix', 'unclassified'], referenceOnly: ['unclassified'] });
142
+ const row = { id: 'i1', gold: ['fix'], scores: { fix: 0.7, unclassified: 0.8 } };
143
+ f.run({ val: [row], mutateManifest: manifest => { manifest.stages.intent.referenceOnly = ['missing']; }, expectFailure: true });
144
+ f.run({ val: [row], mutateManifest: manifest => { manifest.stages.intent.thresholds.unclassified = 0.9; }, expectFailure: true });
145
+ f.run({ val: [{ id: 'i2', gold: ['fix'], scores: { fix: 0.7 } }], expectFailure: true });
146
+ });
147
+
148
+ test('curves reports zero coverage when every intent option is reference-only', t => {
149
+ const f = fixture(t, { stage: 'intent', options: ['unclassified'], referenceOnly: ['unclassified'] });
150
+ const { curves } = f.run({ val: [{ id: 'i1', gold: ['unclassified'], scores: { unclassified: 0.99 } }] });
151
+ assert.deepEqual(curves.stages.intent.optionDistributions.unclassified, [0.99, 0.99, 0.99, 0.99, 0.99]);
152
+ assert.ok(curves.stages.intent.coverageCurve.every(([, coverage]) => coverage === 0));
153
+ });
154
+
155
+ // F11 (#442 P1-1): validity correctness is predicted-vs-gold validity equivalence,
156
+ // not membership in the one-option catalog's positive set (Set([]) for gold actionable).
157
+ const validityCell = (t, rows, options) => {
158
+ const f = fixture(t, options);
159
+ const { stdout, curves } = f.run({ val: validityRows(rows) });
160
+ return { point: curves.stages.validity.coverageCurve[80], auc: JSON.parse(stdout).stages.validity.coverageAccuracyAuc };
161
+ };
162
+
163
+ test('validity cell 1: gold invalid, high p(invalid) predicts invalid and is correct', t => {
164
+ const cell = validityCell(t, [['invalid', 0.8]]);
165
+ assert.deepEqual(cell.point, [0.8, 1, 1]);
166
+ assert.equal(cell.auc, 1);
167
+ });
168
+
169
+ test('validity cell 2: gold invalid, low p(invalid) predicts actionable and is wrong', t => {
170
+ const cell = validityCell(t, [['invalid', 0.2]]);
171
+ assert.deepEqual(cell.point, [0.8, 1, 0]);
172
+ assert.equal(cell.auc, 0);
173
+ });
174
+
175
+ test('validity cell 3: gold actionable, low p(invalid) predicts actionable and is correct', t => {
176
+ const cell = validityCell(t, [['actionable', 0.2]]);
177
+ assert.deepEqual(cell.point, [0.8, 1, 1]);
178
+ assert.equal(cell.auc, 1);
179
+ });
180
+
181
+ test('validity cell 4: gold actionable, high p(invalid) predicts invalid and is wrong', t => {
182
+ const cell = validityCell(t, [['actionable', 0.8]]);
183
+ assert.deepEqual(cell.point, [0.8, 1, 0]);
184
+ assert.equal(cell.auc, 0);
185
+ });
186
+
187
+ test('validity reference-only invalid keeps its established semantics (unchanged control)', t => {
188
+ const f = fixture(t, { referenceOnly: ['invalid'] });
189
+ const { curves } = f.run({ val: validityRows([['invalid', 0.75], ['actionable', 0.25]]) });
190
+ const curve = curves.stages.validity.coverageCurve;
191
+ assert.deepEqual(curve[75], [0.75, 0.5, 1]);
192
+ assert.deepEqual(curve[25], [0.25, 1, 0.5]);
193
+ });
194
+
195
+ test('active trend rolls back after two consecutive worsening cycles', t => {
196
+ const f = fixture(t);
197
+ const cycles = [
198
+ validityRows([['invalid', 0.8], ['invalid', 0.8], ['actionable', 0.2], ['actionable', 0.2]]),
199
+ validityRows([['invalid', 0.9], ['invalid', 0.9], ['actionable', 0.9], ['actionable', 0.9]]),
200
+ validityRows([['invalid', 0.6], ['invalid', 0.6], ['actionable', 0.9], ['actionable', 0.9]]),
201
+ ];
202
+ cycles.forEach((val, i) => f.run({ version: `v${i}`, val }));
203
+ const { trend } = f.run({ version: 'v3', val: cycles[2] });
204
+ assert.equal(trend.verdict, 'rollback');
205
+ assert.ok(trend.reasons.some(reason => reason.includes('two consecutive')));
206
+ });