harness-everything 0.52.0 → 0.53.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 (34) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +20 -0
  4. package/benchmarks/results/live-host/opencode-2026-11-15-workspace/README.md +7 -0
  5. package/benchmarks/results/live-host/opencode-2026-11-15-workspace/live-workspace-probe.js +16 -0
  6. package/benchmarks/results/live-host/opencode-2026-11-15-workspace/live-workspace-trace-2026-11-15.jsonl +4 -0
  7. package/ci/mechanism-2n-opencode-plugin.test.js +1 -1
  8. package/ci/mechanism-2p-opencode-v2-entrypoint.test.js +18 -3
  9. package/ci/mechanism-338-opencode-async.test.js +20 -3
  10. package/ci/mechanism-341-opencode-lane.test.js +7 -1
  11. package/ci/mechanism-397-cycle-import.test.js +399 -0
  12. package/ci/mechanism-397-host-acceptance.test.js +119 -0
  13. package/ci/mechanism-397-opencode-observations.test.js +1922 -0
  14. package/ci/mechanism-system-one-curves.test.js +17 -0
  15. package/ci/mechanism-system-one-cycle.test.js +621 -2
  16. package/docs/platform-capabilities.md +13 -6
  17. package/docs/system-one-cycle.md +12 -3
  18. package/docs/system-one-observations.md +35 -4
  19. package/hooks/scripts/lib/observations.js +5 -3
  20. package/opencode-plugin/README.md +22 -8
  21. package/opencode-plugin/index.mjs +424 -44
  22. package/opencode-plugin/plugin.json +1 -1
  23. package/package.json +1 -1
  24. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  25. package/plugins/harness-everything/hooks/scripts/lib/observations.js +5 -3
  26. package/plugins/harness-everything/plugin.json +1 -1
  27. package/sbom.cdx.json +7 -7
  28. package/scripts/system-one-curves.js +154 -14
  29. package/scripts/system-one-cycle/collect.js +20 -3
  30. package/scripts/system-one-cycle/common.js +39 -1
  31. package/scripts/system-one-cycle/evaluate.js +8 -5
  32. package/scripts/system-one-cycle.js +7 -2
  33. package/scripts/system-one-observations-export.js +29 -0
  34. package/scripts/system-one-observations-import-store.js +128 -0
@@ -0,0 +1,119 @@
1
+ 'use strict';
2
+
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 { test } = require('node:test');
8
+ const observations = require('../hooks/scripts/lib/observations');
9
+ const { collect } = require('../scripts/system-one-cycle/collect');
10
+
11
+ const ROOT = path.resolve(__dirname, '..');
12
+ const VALID = '<!-- harness-label {"v":1,"validity":"actionable","tier":"tier2","intents":["fix"],"workflow":"iterative-single","skills":[]} -->';
13
+ const VALID_INVALID = '<!-- harness-label {"v":1,"validity":"invalid","tier":null,"intents":[],"workflow":null,"skills":[]} -->';
14
+ const MALFORMED = '<!-- harness-label {"v":1,"validity":"unknown","tier":"tier2","intents":[],"workflow":null,"skills":[]} -->';
15
+
16
+ function capture(store, host, session, prompt, final, turnId = `${session}-turn`) {
17
+ const env = {
18
+ HARNESS_OBSERVATIONS: 'on',
19
+ HARNESS_OBSERVATIONS_DIR: store,
20
+ };
21
+ const base = { host, session_id: session, turn_id: turnId, cwd: store };
22
+ observations.handle({ ...base, hook_event_name: 'UserPromptSubmit', prompt }, env);
23
+ observations.handle({ ...base, hook_event_name: 'Stop', last_assistant_message: final }, env);
24
+ }
25
+
26
+ function atTime(timestamp, callback) {
27
+ const NativeDate = global.Date;
28
+ global.Date = class extends NativeDate {
29
+ constructor(...args) { super(...(args.length ? args : [timestamp])); }
30
+ static now() { return timestamp; }
31
+ };
32
+ try { callback(); } finally { global.Date = NativeDate; }
33
+ }
34
+
35
+ function jsonl(file) {
36
+ return fs.readFileSync(file, 'utf8').split(/\r?\n/).filter(Boolean).map(JSON.parse);
37
+ }
38
+
39
+ test('collect retains unique, date-scoped per-host label acceptance before training filters', { concurrency: false }, () => {
40
+ const dir = fs.mkdtempSync(path.join(process.env.TMPDIR || os.tmpdir(), 'system-one-host-acceptance-'));
41
+ const relative = path.relative(fs.realpathSync.native(ROOT), fs.realpathSync.native(dir));
42
+ assert.ok(relative === '..' || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative), 'fixtures stay outside the checkout');
43
+ const dataDir = path.join(dir, 'cycle');
44
+ const training = path.join(dataDir, 'training');
45
+ const store = path.join(training, 'observation-store');
46
+ const sessions = path.join(dir, 'empty-codex-sessions');
47
+ const tmp = path.join(dir, 'tmp');
48
+ fs.mkdirSync(sessions, { recursive: true });
49
+ fs.mkdirSync(tmp);
50
+
51
+ const envKeys = ['HOME', 'USERPROFILE', 'CODEX_HOME', 'HARNESS_STATE_HOME', 'HARNESS_OBSERVATIONS_DIR', 'HARNESS_OBSERVATIONS', 'TMPDIR', 'TEMP', 'TMP'];
52
+ const previousEnv = Object.fromEntries(envKeys.map(key => [key, process.env[key]]));
53
+ const home = path.join(dir, 'home');
54
+ fs.mkdirSync(home);
55
+ Object.assign(process.env, {
56
+ HOME: home,
57
+ USERPROFILE: home,
58
+ CODEX_HOME: path.join(home, '.codex'),
59
+ HARNESS_STATE_HOME: path.join(home, '.harness-state'),
60
+ HARNESS_OBSERVATIONS_DIR: store,
61
+ HARNESS_OBSERVATIONS: 'on',
62
+ TMPDIR: tmp,
63
+ TEMP: tmp,
64
+ TMP: tmp,
65
+ });
66
+
67
+ try {
68
+ const since = new Date().toISOString().slice(0, 10);
69
+ const cutoff = Date.parse(`${since}T00:00:00.000Z`);
70
+ atTime(cutoff - 1000, () => capture(store, 'codex', 'before-cutoff', 'PRE_CUTOFF_PROMPT_397', VALID));
71
+
72
+ capture(store, 'opencode', 'valid-one', 'PROMPT_SENTINEL_397', `FINAL_MESSAGE_SENTINEL_397 SECRET_SENTINEL_397\n${VALID}`, 'valid-one-turn');
73
+ capture(store, 'opencode', 'valid-two', 'accepted-invalid-validity', VALID_INVALID);
74
+ capture(store, 'opencode', 'malformed', 'malformed-label-prompt', MALFORMED);
75
+ capture(store, 'opencode', 'missing', 'missing-label-prompt', 'FINAL_MESSAGE_SENTINEL_397 without a label');
76
+ capture(store, 'opencode', 'valid-one', 'PROMPT_SENTINEL_397 replay', `FINAL_MESSAGE_SENTINEL_397 SECRET_SENTINEL_397\n${VALID}`, 'valid-one-turn');
77
+ capture(store, 'claude', 'claude-missing-one', 'claude-missing-one-prompt', 'No label');
78
+ capture(store, 'claude', 'claude-missing-two', 'claude-missing-two-prompt', 'No label');
79
+
80
+ const index = JSON.parse(fs.readFileSync(path.join(store, 'observations-index.json'), 'utf8'));
81
+ assert.equal(index.records.length, 7, 'replaying a turn does not create a second stored row');
82
+
83
+ const sinceNextDay = new Date(cutoff + 86_400_000).toISOString().slice(0, 10);
84
+ const result = collect({ dataDir, since, sessionsDir: sessions });
85
+ const observed = path.join(training, 'observed');
86
+ const reportBytes = fs.readFileSync(path.join(observed, 'export-report.json'), 'utf8');
87
+ const report = JSON.parse(reportBytes);
88
+ const expected = {
89
+ opencode: { eligible: 4, valid: 2, invalid: 1, missing: 1, acceptanceRate: 0.5 },
90
+ claude: { eligible: 2, valid: 0, invalid: 0, missing: 2, acceptanceRate: 0 },
91
+ codex: { eligible: 0, valid: 0, invalid: 0, missing: 0, acceptanceRate: null },
92
+ };
93
+
94
+ assert.deepEqual(report.hostAcceptance, { population: 'stored-observations', byHost: expected });
95
+ assert.equal(result.prompts, 2, 'only the two labeled, text-available OpenCode rows enter training');
96
+ assert.equal(jsonl(path.join(observed, 'prompts-observed.jsonl')).length, 2);
97
+ assert.doesNotMatch(reportBytes, /PROMPT_SENTINEL_397|PRE_CUTOFF_PROMPT_397|FINAL_MESSAGE_SENTINEL_397|SECRET_SENTINEL_397/);
98
+
99
+ const validRecord = index.records.find(record => record.writer.sessionId === 'valid-one');
100
+ fs.unlinkSync(path.join(store, 'text', `${validRecord.contentSha256}.json`));
101
+ const afterTextRemoval = collect({ dataDir, since, sessionsDir: sessions });
102
+ const retained = JSON.parse(fs.readFileSync(path.join(observed, 'export-report.json'), 'utf8'));
103
+ assert.deepEqual(retained.hostAcceptance, report.hostAcceptance, 'coverage remains independent of text availability');
104
+ assert.equal(afterTextRemoval.prompts, 1, 'training rows fall when one prompt text is unavailable');
105
+ assert.equal(retained.exported, 1);
106
+
107
+ const emptySince = collect({ dataDir, since: sinceNextDay, sessionsDir: sessions });
108
+ assert.equal(emptySince.prompts, 0);
109
+ const emptyReport = JSON.parse(fs.readFileSync(path.join(observed, 'export-report.json'), 'utf8'));
110
+ assert.deepEqual(emptyReport.hostAcceptance.byHost.opencode,
111
+ { eligible: 0, valid: 0, invalid: 0, missing: 0, acceptanceRate: null }, 'zero eligible rows produce a null acceptance rate');
112
+ } finally {
113
+ for (const [key, value] of Object.entries(previousEnv)) {
114
+ if (value === undefined) delete process.env[key];
115
+ else process.env[key] = value;
116
+ }
117
+ fs.rmSync(dir, { recursive: true, force: true });
118
+ }
119
+ });