harness-everything 0.55.1 → 0.55.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +15 -0
- package/ci/invariant-routing.test.js +6 -1
- package/ci/mechanism-397-opencode-observations.test.js +58 -2
- package/ci/mechanism-check-packet-write-set.test.js +163 -8
- package/ci/mechanism-report-writer.test.js +43 -9
- package/ci/mechanism-system-one-curves.test.js +47 -6
- package/ci/mechanism-system-one-install.test.js +40 -4
- package/ci/router-workflow-plan.test.js +8 -8
- package/code-review/SKILL.md +1 -1
- package/code-review/templates/finding.template.md +17 -1
- package/docs/error-handling/details/e0002-report-writer.md +1 -1
- package/docs/platform-capabilities.md +2 -1
- package/harness-everything/SKILL.md +1 -1
- package/harness-everything/scripts/system-one/manifest.js +1 -0
- package/hooks/scripts/lib/observations.js +1 -1
- package/opencode-plugin/README.md +6 -0
- package/opencode-plugin/index.mjs +31 -12
- package/opencode-plugin/plugin.json +1 -1
- package/package.json +1 -1
- package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
- package/plugins/harness-everything/hooks/scripts/lib/observations.js +1 -1
- package/plugins/harness-everything/plugin.json +1 -1
- package/plugins/harness-everything/skills/code-review/SKILL.md +1 -1
- package/plugins/harness-everything/skills/code-review/templates/finding.template.md +17 -1
- package/plugins/harness-everything/skills/harness-everything/SKILL.md +1 -1
- package/plugins/harness-everything/skills/harness-everything/scripts/system-one/manifest.js +1 -0
- package/sbom.cdx.json +7 -7
- package/scripts/check-packet-write-set.js +76 -1
- package/scripts/report-writer.js +2 -1
- package/scripts/system-one-curves.js +7 -4
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"name": "harness-everything",
|
|
11
11
|
"source": "./",
|
|
12
12
|
"description": "Harness OS: an orchestrated agent operating system — tier routing, circuit breaker guardrails, verification gates, WAL session memory, and self-evolving workspace rules.",
|
|
13
|
-
"version": "0.55.
|
|
13
|
+
"version": "0.55.3",
|
|
14
14
|
"author": {
|
|
15
15
|
"name": "Miya Daniel"
|
|
16
16
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "harness-everything",
|
|
3
3
|
"description": "Harness OS: an orchestrated agent operating system — tier routing, circuit breaker guardrails, verification gates, WAL session memory, and self-evolving workspace rules.",
|
|
4
|
-
"version": "0.55.
|
|
4
|
+
"version": "0.55.3",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Miya Daniel"
|
|
7
7
|
},
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.55.3](https://github.com/dyphn1/Harness-everything/compare/v0.55.2...v0.55.3) (2026-11-20)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
* address four bounded Harness regressions ([fb27a44](https://github.com/dyphn1/Harness-everything/commit/fb27a4478890848038bec61d8c549ac9bc4eb4e6)), closes [#413](https://github.com/dyphn1/Harness-everything/issues/413) [#469](https://github.com/dyphn1/Harness-everything/issues/469) [#470](https://github.com/dyphn1/Harness-everything/issues/470) [#451](https://github.com/dyphn1/Harness-everything/issues/451)
|
|
10
|
+
* batch sparse checkout rule checks ([eb3bfa0](https://github.com/dyphn1/Harness-everything/commit/eb3bfa08f68d1514efc23528194ec958556e7361))
|
|
11
|
+
* distinguish in-cone sparse deletions ([ec602ab](https://github.com/dyphn1/Harness-everything/commit/ec602ab7b6c3c8eecf36c5fcb2b78341dac20718))
|
|
12
|
+
* encode sparse path checks with NUL delimiters ([d52d63f](https://github.com/dyphn1/Harness-everything/commit/d52d63f31991d15482a7e5877d1b5b319667fce3))
|
|
13
|
+
|
|
14
|
+
## [0.55.2](https://github.com/dyphn1/Harness-everything/compare/v0.55.1...v0.55.2) (2026-11-20)
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* align second-stage evaluation and report contracts ([#491](https://github.com/dyphn1/Harness-everything/issues/491)) ([aae6403](https://github.com/dyphn1/Harness-everything/commit/aae6403aaabd3588b2ff6e4343f07659f1d40be2))
|
|
19
|
+
|
|
5
20
|
## [0.55.1](https://github.com/dyphn1/Harness-everything/compare/v0.55.0...v0.55.1) (2026-11-20)
|
|
6
21
|
|
|
7
22
|
### Bug Fixes
|
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
const fs=require('fs'),path=require('path'),{spawnSync:spawnNodeSync}=require('child_process');
|
|
4
4
|
function spawnSync(command,args,options={}){
|
|
5
5
|
const {systemOneMode='off',...spawnOptions}=options;
|
|
6
|
-
|
|
6
|
+
const inheritedEnv = Object.fromEntries(Object.entries(process.env)
|
|
7
|
+
.filter(([key]) => !key.toUpperCase().startsWith('HARNESS_')));
|
|
8
|
+
return spawnNodeSync(command, args, {
|
|
9
|
+
...spawnOptions,
|
|
10
|
+
env: { ...inheritedEnv, ...spawnOptions.env, HARNESS_SYSTEM_ONE_MODE: systemOneMode },
|
|
11
|
+
});
|
|
7
12
|
}
|
|
8
13
|
const ROOT=path.resolve(__dirname,'..');let failed=0;
|
|
9
14
|
function check(c,m){if(c)console.log(' PASS '+m);else{console.error(' FAIL '+m);failed++;}}
|
|
@@ -148,8 +148,8 @@ function fixture(observationMode = 'on') {
|
|
|
148
148
|
};
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
async function install(f) {
|
|
152
|
-
const mod = await import(pathToFileURL(
|
|
151
|
+
async function install(f, plugin = PLUGIN) {
|
|
152
|
+
const mod = await import(pathToFileURL(plugin).href);
|
|
153
153
|
return mod.default.setup(f.ctx);
|
|
154
154
|
}
|
|
155
155
|
|
|
@@ -286,6 +286,8 @@ test('inject: the documented OpenCode hooks deliver the kernel router output and
|
|
|
286
286
|
test('runtime: a non-Node host binary still runs the router on Node and injects its output', { concurrency: false }, async () => {
|
|
287
287
|
const f = fixture();
|
|
288
288
|
let dispose;
|
|
289
|
+
const warnings = [];
|
|
290
|
+
const originalWarn = console.warn;
|
|
289
291
|
const originalExecPath = process.execPath;
|
|
290
292
|
const hadBun = Object.hasOwn(process.versions, 'bun');
|
|
291
293
|
const originalBun = process.versions.bun;
|
|
@@ -299,16 +301,20 @@ test('runtime: a non-Node host binary still runs the router on Node and injects
|
|
|
299
301
|
fs.writeFileSync(stubRuntime, process.platform === 'win32' ? '@exit /b 1\r\n' : '#!/bin/sh\nexit 1\n', { mode: 0o755 });
|
|
300
302
|
Object.defineProperty(process, 'execPath', { value: stubRuntime, configurable: true, writable: true });
|
|
301
303
|
Object.defineProperty(process.versions, 'bun', { value: '1.2.0', configurable: true });
|
|
304
|
+
console.warn = message => warnings.push(String(message));
|
|
302
305
|
|
|
303
306
|
dispose = await install(f);
|
|
307
|
+
assert.deepEqual(warnings, [], 'setup without traffic produces no warnings');
|
|
304
308
|
const prompt = { sessionID: 'runtime-session', messageID: 'runtime-turn', prompt: { text: 'add a small behavior change' } };
|
|
305
309
|
await f.sessionHooks.get('prompt')(prompt);
|
|
306
310
|
const context = { sessionID: 'runtime-session', kind: 'primary', system: [], messages: [] };
|
|
307
311
|
await f.sessionHooks.get('context')(context);
|
|
308
312
|
const injected = context.system.map(part => part.text || '').join('\n');
|
|
309
313
|
assert.match(injected, /=> ROUTER WORKFLOW PLAN/, 'the router ran on Node despite a non-Node host binary');
|
|
314
|
+
assert.deepEqual(warnings, []);
|
|
310
315
|
} finally {
|
|
311
316
|
if (dispose) await dispose();
|
|
317
|
+
console.warn = originalWarn;
|
|
312
318
|
Object.defineProperty(process, 'execPath', { value: originalExecPath, configurable: true, writable: true });
|
|
313
319
|
if (hadBun) Object.defineProperty(process.versions, 'bun', { value: originalBun, configurable: true });
|
|
314
320
|
else delete process.versions.bun;
|
|
@@ -316,6 +322,56 @@ test('runtime: a non-Node host binary still runs the router on Node and injects
|
|
|
316
322
|
}
|
|
317
323
|
});
|
|
318
324
|
|
|
325
|
+
for (const reason of ['spawn-failed', 'runtime-failed', 'runtime-missing']) {
|
|
326
|
+
test(`runtime: ${reason} warns without prompt content and admits the prompt`, async () => {
|
|
327
|
+
const f = fixture('off');
|
|
328
|
+
const originalExecPath = process.execPath;
|
|
329
|
+
const originalWarn = console.warn;
|
|
330
|
+
const warnings = [];
|
|
331
|
+
let dispose;
|
|
332
|
+
try {
|
|
333
|
+
let plugin = PLUGIN;
|
|
334
|
+
if (reason === 'spawn-failed') {
|
|
335
|
+
// Exercise the same ENOENT as a missing Node on PATH, including on
|
|
336
|
+
// Windows where executable lookup can also use the host directory.
|
|
337
|
+
Object.defineProperty(process, 'execPath', {
|
|
338
|
+
value: path.join(f.dir, 'missing-node'), configurable: true, writable: true,
|
|
339
|
+
});
|
|
340
|
+
} else {
|
|
341
|
+
plugin = path.join(f.dir, 'opencode-plugin', 'index.mjs');
|
|
342
|
+
fs.mkdirSync(path.dirname(plugin));
|
|
343
|
+
fs.copyFileSync(PLUGIN, plugin);
|
|
344
|
+
if (reason === 'runtime-failed') {
|
|
345
|
+
const router = path.join(f.dir, 'harness-everything/scripts/kernel-router.js');
|
|
346
|
+
const observationsFile = path.join(f.dir, 'hooks/scripts/lib/observations.js');
|
|
347
|
+
fs.mkdirSync(path.dirname(router), { recursive: true });
|
|
348
|
+
fs.mkdirSync(path.dirname(observationsFile), { recursive: true });
|
|
349
|
+
fs.writeFileSync(router, "console.log('PRIVATE-ROUTER-OUTPUT'); require('./missing-router-runtime');\n");
|
|
350
|
+
fs.writeFileSync(observationsFile, 'module.exports = { enabled: () => false };\n');
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
console.warn = message => warnings.push(String(message));
|
|
354
|
+
dispose = await install(f, plugin);
|
|
355
|
+
assert.deepEqual(warnings, []);
|
|
356
|
+
for (const count of [1, 2]) {
|
|
357
|
+
const sessionID = 'private-router-failure-session';
|
|
358
|
+
const prompt = { sessionID, messageID: `private-turn-${count}`, prompt: { text: 'private prompt text' } };
|
|
359
|
+
await assert.doesNotReject(() => f.sessionHooks.get('prompt')(prompt));
|
|
360
|
+
const context = { sessionID, kind: 'primary', system: [], messages: [] };
|
|
361
|
+
await f.sessionHooks.get('context')(context);
|
|
362
|
+
assert.deepEqual(context.system, [], 'failed output is never injected');
|
|
363
|
+
assert.equal(warnings.length, count);
|
|
364
|
+
assert.equal(warnings.at(-1), `[Harness] OpenCode router-unavailable (${reason}; count=${count})`);
|
|
365
|
+
}
|
|
366
|
+
} finally {
|
|
367
|
+
if (dispose) await dispose();
|
|
368
|
+
console.warn = originalWarn;
|
|
369
|
+
Object.defineProperty(process, 'execPath', { value: originalExecPath, configurable: true, writable: true });
|
|
370
|
+
f.restore();
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
|
|
319
375
|
test('record: OpenCode prompt, tool and idle events append one host-tagged record to the shared store', { concurrency: false }, async () => {
|
|
320
376
|
const f = fixture();
|
|
321
377
|
let dispose;
|
|
@@ -81,7 +81,7 @@ function makeRepo(t) {
|
|
|
81
81
|
return { repo, tempRoot };
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
function runChecker(repo, tempRoot, { base, head, allow = [], allowFile } = {}) {
|
|
84
|
+
function runChecker(repo, tempRoot, { base, head, allow = [], allowFile } = {}, extraEnv = {}) {
|
|
85
85
|
const args = [CHECKER_SOURCE, '--base', base];
|
|
86
86
|
if (head) args.push('--head', head);
|
|
87
87
|
for (const pattern of allow) args.push('--allow', pattern);
|
|
@@ -89,12 +89,48 @@ function runChecker(repo, tempRoot, { base, head, allow = [], allowFile } = {})
|
|
|
89
89
|
const result = spawnSync(process.execPath, args, {
|
|
90
90
|
cwd: repo,
|
|
91
91
|
encoding: 'utf8',
|
|
92
|
-
env: gitEnv(tempRoot),
|
|
92
|
+
env: { ...gitEnv(tempRoot), ...extraEnv },
|
|
93
93
|
});
|
|
94
94
|
assert.equal(result.error, undefined, result.error && result.error.message);
|
|
95
95
|
return result;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
function sparseRuleCounter(tempRoot, { fail = false } = {}) {
|
|
99
|
+
const directory = path.join(tempRoot, 'git counter');
|
|
100
|
+
fs.mkdirSync(directory, { recursive: true });
|
|
101
|
+
const log = path.join(directory, 'check-rules calls');
|
|
102
|
+
const realGit = execFileSync('which', ['git'], { encoding: 'utf8' }).trim();
|
|
103
|
+
const wrapper = path.join(directory, 'git');
|
|
104
|
+
fs.writeFileSync(wrapper, [
|
|
105
|
+
'#!/usr/bin/env node',
|
|
106
|
+
"'use strict';",
|
|
107
|
+
"const fs = require('node:fs');",
|
|
108
|
+
"const { spawnSync } = require('node:child_process');",
|
|
109
|
+
`const realGit = ${JSON.stringify(realGit)};`,
|
|
110
|
+
'const args = process.argv.slice(2);',
|
|
111
|
+
"const checkRules = args.includes('sparse-checkout') && args.includes('check-rules');",
|
|
112
|
+
'if (checkRules) {',
|
|
113
|
+
" if (process.env.WRITE_SET_FAIL_CHECK_RULES === '1') {",
|
|
114
|
+
" process.stderr.write('injected check-rules failure\\n');",
|
|
115
|
+
' process.exit(1);',
|
|
116
|
+
' }',
|
|
117
|
+
" fs.appendFileSync(process.env.WRITE_SET_CHECK_RULES_LOG, 'x');",
|
|
118
|
+
'}',
|
|
119
|
+
"const child = spawnSync(realGit, args, { stdio: 'inherit' });",
|
|
120
|
+
"if (child.error) { console.error(child.error.message); process.exitCode = 1; }",
|
|
121
|
+
'else process.exitCode = child.status ?? 1;',
|
|
122
|
+
'',
|
|
123
|
+
].join('\n'), { mode: 0o755 });
|
|
124
|
+
return {
|
|
125
|
+
env: {
|
|
126
|
+
PATH: `${directory}${path.delimiter}${process.env.PATH}`,
|
|
127
|
+
WRITE_SET_CHECK_RULES_LOG: log,
|
|
128
|
+
WRITE_SET_FAIL_CHECK_RULES: fail ? '1' : '0',
|
|
129
|
+
},
|
|
130
|
+
count: () => fs.existsSync(log) ? fs.readFileSync(log, 'utf8').length : 0,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
98
134
|
function outOfSetPaths(result) {
|
|
99
135
|
return result.stdout.split(/\r?\n/).filter(line => line.startsWith('OUT_OF_SET '))
|
|
100
136
|
.map(line => JSON.parse(line.slice('OUT_OF_SET '.length)));
|
|
@@ -217,13 +253,132 @@ test('compares only the requested commits when --head is not the worktree HEAD',
|
|
|
217
253
|
const head = commitAll(repo, tempRoot, 'requested head');
|
|
218
254
|
write(repo, 'later.txt', 'after requested head\n');
|
|
219
255
|
commitAll(repo, tempRoot, 'worktree HEAD');
|
|
220
|
-
|
|
256
|
+
runGit(repo, tempRoot, ['update-index', '--assume-unchanged', '--', 'base.txt']);
|
|
257
|
+
try {
|
|
258
|
+
write(repo, 'base.txt', 'hidden workspace-only change\n');
|
|
259
|
+
write(repo, 'dirty.txt', 'uncommitted\n');
|
|
221
260
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
261
|
+
const result = runChecker(repo, tempRoot, { base, head, allow: ['allowed.txt'] });
|
|
262
|
+
assert.equal(result.status, 0, result.stderr);
|
|
263
|
+
assert.deepEqual(outOfSetPaths(result), []);
|
|
264
|
+
assert.match(result.stdout, /commits only/i);
|
|
265
|
+
assert.doesNotMatch(result.stdout, /base\.txt|later\.txt|dirty\.txt/);
|
|
266
|
+
} finally {
|
|
267
|
+
runGit(repo, tempRoot, ['update-index', '--no-assume-unchanged', '--', 'base.txt']);
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
test('batches sparse-rule checks and distinguishes hidden deletions from omissions', { skip: process.platform === 'win32' }, t => {
|
|
272
|
+
const { repo, tempRoot } = makeRepo(t);
|
|
273
|
+
const includedPath = 'included/tracked\nname.txt';
|
|
274
|
+
const omittedPaths = ['omitted/space name.txt', 'omitted/new\nline.txt'];
|
|
275
|
+
write(repo, includedPath, 'inside sparse cone\n');
|
|
276
|
+
for (const file of omittedPaths) write(repo, file, `outside sparse cone: ${file}\n`);
|
|
277
|
+
const base = commitAll(repo, tempRoot, 'baseline');
|
|
278
|
+
write(repo, 'later.txt', 'committed after the requested head\n');
|
|
279
|
+
commitAll(repo, tempRoot, 'later commit');
|
|
280
|
+
|
|
281
|
+
runGit(repo, tempRoot, ['sparse-checkout', 'set', 'included']);
|
|
282
|
+
for (const file of omittedPaths) assert.equal(fs.existsSync(path.join(repo, ...file.split('/'))), false, `${file} is outside the sparse cone`);
|
|
283
|
+
runGit(repo, tempRoot, ['update-index', '--skip-worktree', '--', includedPath]);
|
|
284
|
+
fs.rmSync(path.join(repo, ...includedPath.split('/')));
|
|
285
|
+
assert.equal(gitText(repo, tempRoot, 'status', '--porcelain'), '', 'Git hides the in-cone deletion');
|
|
286
|
+
|
|
287
|
+
const counter = sparseRuleCounter(tempRoot);
|
|
288
|
+
const before = snapshotTree(repo);
|
|
289
|
+
const result = runChecker(repo, tempRoot, { base, allow: ['later.txt'] }, counter.env);
|
|
290
|
+
assert.equal(result.status, 1, result.stderr);
|
|
291
|
+
assert.deepEqual(outOfSetPaths(result), [includedPath]);
|
|
292
|
+
for (const file of omittedPaths) assert.ok(!result.stdout.includes(JSON.stringify(file)), `${file} is not reported`);
|
|
293
|
+
assert.equal(counter.count(), 1, 'all sparse candidates use one check-rules subprocess');
|
|
294
|
+
assert.deepEqual(snapshotTree(repo), before, 'inspection preserves the index flags and repository state');
|
|
295
|
+
|
|
296
|
+
const allowed = runChecker(repo, tempRoot, { base, head: 'HEAD', allow: [includedPath, 'later.txt'] }, counter.env);
|
|
297
|
+
assert.equal(allowed.status, 0, allowed.stderr);
|
|
298
|
+
assert.ok(allowed.stdout.includes(`ALLOWED ${JSON.stringify(includedPath)}`));
|
|
299
|
+
assert.equal(counter.count(), 2, 'the second candidate batch also uses one subprocess');
|
|
300
|
+
assert.deepEqual(snapshotTree(repo), before, 'allowed inspection preserves the index flags and repository state');
|
|
301
|
+
|
|
302
|
+
const historical = runChecker(repo, tempRoot, { base, head: base, allow: ['later.txt'] }, counter.env);
|
|
303
|
+
assert.equal(historical.status, 0, historical.stderr);
|
|
304
|
+
assert.match(historical.stdout, /commits only/);
|
|
305
|
+
assert.equal(counter.count(), 2, 'a non-current --head does not inspect sparse worktree paths');
|
|
306
|
+
|
|
307
|
+
const cleanFixture = makeRepo(t);
|
|
308
|
+
write(cleanFixture.repo, 'included/only.txt', 'present\n');
|
|
309
|
+
const cleanBase = commitAll(cleanFixture.repo, cleanFixture.tempRoot, 'baseline');
|
|
310
|
+
runGit(cleanFixture.repo, cleanFixture.tempRoot, ['sparse-checkout', 'set', 'included']);
|
|
311
|
+
const cleanCounter = sparseRuleCounter(cleanFixture.tempRoot);
|
|
312
|
+
const clean = runChecker(cleanFixture.repo, cleanFixture.tempRoot, { base: cleanBase, allow: ['included/**'] }, cleanCounter.env);
|
|
313
|
+
assert.equal(clean.status, 0, clean.stderr);
|
|
314
|
+
assert.equal(cleanCounter.count(), 0, 'no sparse-rule process is needed without missing skip-worktree paths');
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
test('fails closed when batched sparse-rule inspection fails', { skip: process.platform === 'win32' }, t => {
|
|
318
|
+
const { repo, tempRoot } = makeRepo(t);
|
|
319
|
+
write(repo, 'included/deleted.txt', 'inside sparse cone\n');
|
|
320
|
+
write(repo, 'omitted/hidden.txt', 'outside sparse cone\n');
|
|
321
|
+
const base = commitAll(repo, tempRoot, 'baseline');
|
|
322
|
+
runGit(repo, tempRoot, ['sparse-checkout', 'set', 'included']);
|
|
323
|
+
runGit(repo, tempRoot, ['update-index', '--skip-worktree', '--', 'included/deleted.txt']);
|
|
324
|
+
fs.rmSync(path.join(repo, 'included', 'deleted.txt'));
|
|
325
|
+
assert.equal(gitText(repo, tempRoot, 'status', '--porcelain'), '');
|
|
326
|
+
const before = snapshotTree(repo);
|
|
327
|
+
|
|
328
|
+
const counter = sparseRuleCounter(tempRoot, { fail: true });
|
|
329
|
+
const result = runChecker(repo, tempRoot, { base, allow: ['allowed/**'] }, counter.env);
|
|
330
|
+
assert.equal(result.status, 2, result.stdout);
|
|
331
|
+
assert.match(result.stderr, /git sparse-checkout failed/);
|
|
332
|
+
assert.equal(counter.count(), 0, 'the injected failing inspection is not recorded as a successful invocation');
|
|
333
|
+
assert.deepEqual(snapshotTree(repo), before, 'failed inspection does not mutate the index or worktree');
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
for (const flag of ['assume-unchanged', 'skip-worktree']) {
|
|
337
|
+
test(`checks actual worktree content hidden by --${flag}`, t => {
|
|
338
|
+
const { repo, tempRoot } = makeRepo(t);
|
|
339
|
+
const file = process.platform === 'win32' ? 'hidden [file].txt' : 'hidden [file]\nname.txt';
|
|
340
|
+
write(repo, file, 'before\n');
|
|
341
|
+
const base = commitAll(repo, tempRoot, 'baseline');
|
|
342
|
+
runGit(repo, tempRoot, ['update-index', `--${flag}`, '--', file]);
|
|
343
|
+
try {
|
|
344
|
+
const clean = runChecker(repo, tempRoot, { base, allow: ['allowed/**'] });
|
|
345
|
+
assert.equal(clean.status, 0, clean.stderr);
|
|
346
|
+
assert.equal(clean.stdout, '');
|
|
347
|
+
|
|
348
|
+
write(repo, file, 'after!\n');
|
|
349
|
+
assert.equal(gitText(repo, tempRoot, 'status', '--porcelain'), '', 'Git hides the edit');
|
|
350
|
+
const before = snapshotTree(repo);
|
|
351
|
+
const rejected = runChecker(repo, tempRoot, { base, allow: ['allowed/**'] });
|
|
352
|
+
assert.equal(rejected.status, 1, rejected.stderr);
|
|
353
|
+
assert.deepEqual(outOfSetPaths(rejected), [file]);
|
|
354
|
+
|
|
355
|
+
const allowed = runChecker(repo, tempRoot, { base, head: 'HEAD', allow: [file] });
|
|
356
|
+
assert.equal(allowed.status, 0, allowed.stderr);
|
|
357
|
+
assert.ok(allowed.stdout.includes(`ALLOWED ${JSON.stringify(file)}`));
|
|
358
|
+
assert.deepEqual(snapshotTree(repo), before, 'inspection preserves the index flags');
|
|
359
|
+
} finally {
|
|
360
|
+
runGit(repo, tempRoot, ['update-index', `--no-${flag}`, '--', file]);
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
test('reports a flagged-file inspection error when Git cannot clean its content', t => {
|
|
366
|
+
const { repo, tempRoot } = makeRepo(t);
|
|
367
|
+
const file = 'hidden.txt';
|
|
368
|
+
write(repo, '.gitattributes', 'hidden.txt filter=broken\n');
|
|
369
|
+
write(repo, file, 'tracked\n');
|
|
370
|
+
const base = commitAll(repo, tempRoot, 'baseline');
|
|
371
|
+
runGit(repo, tempRoot, ['update-index', '--assume-unchanged', '--', file]);
|
|
372
|
+
try {
|
|
373
|
+
runGit(repo, tempRoot, ['config', 'filter.broken.clean', 'exit 1']);
|
|
374
|
+
runGit(repo, tempRoot, ['config', 'filter.broken.required', 'true']);
|
|
375
|
+
const result = runChecker(repo, tempRoot, { base, allow: ['allowed/**'] });
|
|
376
|
+
assert.equal(result.status, 2, result.stderr);
|
|
377
|
+
assert.match(result.stderr, /git hash-object failed/);
|
|
378
|
+
} finally {
|
|
379
|
+
runGit(repo, tempRoot, ['config', '--remove-section', 'filter.broken']);
|
|
380
|
+
runGit(repo, tempRoot, ['update-index', '--no-assume-unchanged', '--', file]);
|
|
381
|
+
}
|
|
227
382
|
});
|
|
228
383
|
|
|
229
384
|
test('returns usage errors for an unknown base and a missing allow list', t => {
|
|
@@ -9,6 +9,10 @@ const { test } = require('node:test');
|
|
|
9
9
|
|
|
10
10
|
const ROOT = path.resolve(__dirname, '..');
|
|
11
11
|
const CLI = path.join(ROOT, 'scripts', 'report-writer.js');
|
|
12
|
+
// Existing Codex acceptance example in ci/mechanism-397-host-acceptance.test.js.
|
|
13
|
+
const CODEX_LABEL = { v: 1, validity: 'actionable', tier: 'tier2', intents: ['fix'], workflow: 'iterative-single', skills: [] };
|
|
14
|
+
const labelLine = value => `<!-- harness-label ${JSON.stringify(value)} -->`;
|
|
15
|
+
const VALID_LABEL = labelLine(CODEX_LABEL);
|
|
12
16
|
|
|
13
17
|
function tempDir(t) {
|
|
14
18
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-report-writer-'));
|
|
@@ -122,7 +126,7 @@ test('strips only one valid terminal host label and reports the extraction', t =
|
|
|
122
126
|
const dir = tempDir(t);
|
|
123
127
|
const raw = path.join(dir, 'raw.txt');
|
|
124
128
|
const output = path.join(dir, 'report.md');
|
|
125
|
-
const rawBytes = Buffer.from(
|
|
129
|
+
const rawBytes = Buffer.from(`Summary\nSTATUS: DONE\n${VALID_LABEL}\n`);
|
|
126
130
|
fs.writeFileSync(raw, rawBytes);
|
|
127
131
|
const result = run(writeArgs(output, 'DONE', ['--from-codex-output', raw]));
|
|
128
132
|
assertOk(result);
|
|
@@ -152,7 +156,7 @@ test('assembles BLOCKED from a raw body, blank line, and one EOF host label', t
|
|
|
152
156
|
const dir = tempDir(t);
|
|
153
157
|
const raw = path.join(dir, 'raw.txt');
|
|
154
158
|
const output = path.join(dir, 'report.md');
|
|
155
|
-
const rawBytes = Buffer.from(
|
|
159
|
+
const rawBytes = Buffer.from(`Summary\n\nEvidence\n\n${labelLine({ ...CODEX_LABEL, intents: ['fix', 'lookup'], contextDependent: false })}`);
|
|
156
160
|
const body = rawBytes.subarray(0, rawBytes.lastIndexOf(Buffer.from('<!-- harness-label')));
|
|
157
161
|
fs.writeFileSync(raw, rawBytes);
|
|
158
162
|
|
|
@@ -208,6 +212,37 @@ test('rejects missing, blank, multiline, or unused outcome reasons without chang
|
|
|
208
212
|
}
|
|
209
213
|
});
|
|
210
214
|
|
|
215
|
+
test('464 rejects unrecognized terminal label schemas before touching report or raw evidence', t => {
|
|
216
|
+
const dir = tempDir(t);
|
|
217
|
+
const raw = path.join(dir, 'raw.txt');
|
|
218
|
+
const output = path.join(dir, 'report.md');
|
|
219
|
+
const before = Buffer.from('Keep this report\nSTATUS: DONE\n');
|
|
220
|
+
fs.writeFileSync(output, before);
|
|
221
|
+
const invalid = [
|
|
222
|
+
{},
|
|
223
|
+
{ note: 'unrelated' },
|
|
224
|
+
{ v: 1 },
|
|
225
|
+
{ validity: 'actionable' },
|
|
226
|
+
{ ...CODEX_LABEL, v: 2 },
|
|
227
|
+
{ ...CODEX_LABEL, validity: 'unknown' },
|
|
228
|
+
{ ...CODEX_LABEL, tier: 'tier9' },
|
|
229
|
+
{ ...CODEX_LABEL, workflow: 'unknown' },
|
|
230
|
+
{ ...CODEX_LABEL, intents: 'fix' },
|
|
231
|
+
{ ...CODEX_LABEL, skills: [42] },
|
|
232
|
+
[],
|
|
233
|
+
];
|
|
234
|
+
for (const [label, reason] of [
|
|
235
|
+
...invalid.map(value => [labelLine(value), /recognized.*harness-label/]),
|
|
236
|
+
['<!-- harness-label {bad json} -->', /valid JSON/],
|
|
237
|
+
]) {
|
|
238
|
+
const rawBytes = Buffer.from(`Summary\nSTATUS: DONE\n${label}\n`);
|
|
239
|
+
fs.writeFileSync(raw, rawBytes);
|
|
240
|
+
assertRejected(run(writeArgs(output, 'DONE', ['--from-codex-output', raw])), reason);
|
|
241
|
+
assert.deepEqual(fs.readFileSync(raw), rawBytes);
|
|
242
|
+
assert.deepEqual(fs.readFileSync(output), before);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
|
|
211
246
|
test('rejects mismatched, malformed, duplicate, or trailing Codex controls and preserves both files', t => {
|
|
212
247
|
const dir = tempDir(t);
|
|
213
248
|
const raw = path.join(dir, 'raw.txt');
|
|
@@ -222,13 +257,12 @@ test('rejects mismatched, malformed, duplicate, or trailing Codex controls and p
|
|
|
222
257
|
['Summary\nSTATUS: DONE\nSTATUS: DONE\n', 'DONE'],
|
|
223
258
|
['Summary\nSTATUS: DONE\n\n', 'DONE'],
|
|
224
259
|
['Summary\nSTATUS: DONE\ntext after status\n', 'DONE'],
|
|
225
|
-
[
|
|
226
|
-
[
|
|
227
|
-
[
|
|
228
|
-
[
|
|
229
|
-
[
|
|
230
|
-
['Summary\nSTATUS: DONE\n<!--
|
|
231
|
-
['Summary <!-- harness-label {"v":1} -->\nSTATUS: DONE\n', 'DONE'],
|
|
260
|
+
[`Summary\nSTATUS: DONE\n\n${VALID_LABEL}`, 'DONE'],
|
|
261
|
+
[`Summary\nSTATUS: DONE\ntext\n${VALID_LABEL}`, 'DONE'],
|
|
262
|
+
[`Summary\nSTATUS: DONE\n${VALID_LABEL}\n${VALID_LABEL}\n`, 'DONE'],
|
|
263
|
+
[`Summary\nSTATUS: DONE\n${VALID_LABEL}\ntrailing text`, 'DONE'],
|
|
264
|
+
[`Summary ${VALID_LABEL}\nSTATUS: DONE\n`, 'DONE'],
|
|
265
|
+
['Summary\nSTATUS: DONE\n<!-- unrelated metadata -->\n', 'DONE'],
|
|
232
266
|
];
|
|
233
267
|
for (const [contents, status, ...extra] of invalidRaw) {
|
|
234
268
|
const rawBytes = Buffer.from(contents);
|
|
@@ -14,7 +14,6 @@ function fixture(t, { stage = 'validity', options = ['invalid'], referenceOnly =
|
|
|
14
14
|
const versionDir = path.join(dir, 'version');
|
|
15
15
|
fs.mkdirSync(versionDir);
|
|
16
16
|
const history = path.join(dir, 'history.jsonl');
|
|
17
|
-
const out = path.join(dir, 'out');
|
|
18
17
|
const writeVersion = version => {
|
|
19
18
|
const catalogs = { validity: ['invalid'], intent: ['fix'], tier: ['tier1'] };
|
|
20
19
|
catalogs[stage] = options;
|
|
@@ -36,15 +35,19 @@ function fixture(t, { stage = 'validity', options = ['invalid'], referenceOnly =
|
|
|
36
35
|
fs.writeFileSync(path.join(versionDir, 'manifest.json'), JSON.stringify(manifest));
|
|
37
36
|
return manifest;
|
|
38
37
|
};
|
|
39
|
-
function run({ version = 'v1', val,
|
|
38
|
+
function run({ version = 'v1', val, otherVal = {}, holdout, mutateManifest,
|
|
39
|
+
expectFailure = false, out = path.join(dir, 'out') } = {}) {
|
|
40
40
|
const manifest = writeVersion(version);
|
|
41
41
|
if (mutateManifest) {
|
|
42
42
|
mutateManifest(manifest);
|
|
43
43
|
fs.writeFileSync(path.join(versionDir, 'manifest.json'), JSON.stringify(manifest));
|
|
44
44
|
}
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
const args = [cli, '--version', version, '--version-dir', versionDir, '--history', history, '--out', out];
|
|
46
|
+
for (const [name, rows] of Object.entries({ [stage]: val, ...otherVal })) {
|
|
47
|
+
const file = path.join(dir, `${version}-${name}-val.jsonl`);
|
|
48
|
+
fs.writeFileSync(file, rows.map(row => JSON.stringify(row)).join('\n') + '\n');
|
|
49
|
+
args.push('--val-scores', `${name}=${file}`);
|
|
50
|
+
}
|
|
48
51
|
if (holdout) {
|
|
49
52
|
const holdoutFile = path.join(dir, `${version}-holdout.jsonl`);
|
|
50
53
|
fs.writeFileSync(holdoutFile, holdout.map(row => JSON.stringify(row)).join('\n') + '\n');
|
|
@@ -52,7 +55,9 @@ function fixture(t, { stage = 'validity', options = ['invalid'], referenceOnly =
|
|
|
52
55
|
}
|
|
53
56
|
const child = spawnSync(process.execPath, args, { cwd: root, encoding: 'utf8', env: { ...process.env, HARNESS_SYSTEM_ONE_HOME: dir } });
|
|
54
57
|
if (expectFailure) {
|
|
55
|
-
assert.notEqual(child.status, 0, child.stdout
|
|
58
|
+
assert.notEqual(child.status, 0, JSON.stringify({ stdout: child.stdout,
|
|
59
|
+
compared: fs.existsSync(path.join(out, 'trend.json'))
|
|
60
|
+
? JSON.parse(fs.readFileSync(path.join(out, 'trend.json'), 'utf8')).compared : null }));
|
|
56
61
|
return child;
|
|
57
62
|
}
|
|
58
63
|
assert.equal(child.status, 0, child.stderr || child.stdout);
|
|
@@ -122,6 +127,42 @@ test('one successful run appends exactly one history line', t => {
|
|
|
122
127
|
assert.deepEqual(JSON.parse(lines[1]), second.curves);
|
|
123
128
|
});
|
|
124
129
|
|
|
130
|
+
test('458 rejects a recorded version in a fresh cycle before writing artifacts', t => {
|
|
131
|
+
const f = fixture(t);
|
|
132
|
+
const original = path.join(f.dir, 'original-cycle');
|
|
133
|
+
const fresh = path.join(f.dir, 'fresh-cycle');
|
|
134
|
+
fs.mkdirSync(fresh);
|
|
135
|
+
const scores = {
|
|
136
|
+
val: validityRows([['invalid', 0.8], ['actionable', 0.2]]),
|
|
137
|
+
otherVal: {
|
|
138
|
+
intent: [{ id: 'i0', gold: ['fix'], scores: { fix: 0.8 } }],
|
|
139
|
+
tier: [{ id: 't0', gold: 'tier1', scores: { tier1: 0.8 } }],
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
f.run({ version: 'v0', ...scores, out: original });
|
|
143
|
+
assert.deepEqual(f.run({ version: 'v1', ...scores, out: original }).trend.compared, ['v0', 'v1']);
|
|
144
|
+
const saved = ['curves.json', 'trend.json'].map(name => fs.readFileSync(path.join(original, name)));
|
|
145
|
+
const history = fs.readFileSync(f.history);
|
|
146
|
+
|
|
147
|
+
const refusal = f.run({ version: 'v1', ...scores, out: fresh, expectFailure: true });
|
|
148
|
+
assert.equal(refusal.status, 1, refusal.stderr);
|
|
149
|
+
assert.match(refusal.stderr, /version already recorded/);
|
|
150
|
+
assert.deepEqual(fs.readdirSync(fresh), []);
|
|
151
|
+
|
|
152
|
+
const resumed = spawnSync(process.execPath, [cli, '--version', 'v1', '--version-dir', path.join(f.dir, 'version'),
|
|
153
|
+
'--history', f.history, '--out', original, '--resume-curves', path.join(original, 'curves.json')],
|
|
154
|
+
{ cwd: root, encoding: 'utf8', env: { ...process.env, HARNESS_SYSTEM_ONE_HOME: f.dir } });
|
|
155
|
+
assert.equal(resumed.status, 0, resumed.stderr);
|
|
156
|
+
assert.deepEqual(JSON.parse(resumed.stdout), { resumed: true, version: 'v1' });
|
|
157
|
+
assert.deepEqual(fs.readFileSync(f.history), history);
|
|
158
|
+
assert.deepEqual(['curves.json', 'trend.json'].map(name => fs.readFileSync(path.join(original, name))), saved);
|
|
159
|
+
|
|
160
|
+
assert.deepEqual(f.run({ version: 'v2', ...scores, out: fresh }).trend.compared, ['v0', 'v1', 'v2']);
|
|
161
|
+
const after = fs.readFileSync(f.history);
|
|
162
|
+
assert.deepEqual(after.subarray(0, history.length), history);
|
|
163
|
+
assert.deepEqual(after.toString().trimEnd().split('\n').map(line => JSON.parse(line).version), ['v0', 'v1', 'v2']);
|
|
164
|
+
});
|
|
165
|
+
|
|
125
166
|
test('446 H2: empty, LF, and CRLF histories append readable rows without rewriting prior bytes', t => {
|
|
126
167
|
const f = fixture(t);
|
|
127
168
|
const first = f.run({ version: 'v0', val: validityRows([['invalid', 0.8], ['actionable', 0.2]]) });
|
|
@@ -7,7 +7,8 @@ const path = require('node:path');
|
|
|
7
7
|
const { createHash } = require('node:crypto');
|
|
8
8
|
const { spawnSync } = require('node:child_process');
|
|
9
9
|
const install = require('../harness-everything/scripts/system-one/install');
|
|
10
|
-
const { PINNED_CUA_S1_REVISION } = require('../harness-everything/scripts/system-one/provider');
|
|
10
|
+
const { PINNED_CUA_S1_REVISION, readActive } = require('../harness-everything/scripts/system-one/provider');
|
|
11
|
+
const { validateVersionManifest } = require('../harness-everything/scripts/system-one/manifest');
|
|
11
12
|
const script = path.join(__dirname, '../harness-everything/scripts/system-one/install.js');
|
|
12
13
|
const sha = buf => createHash('sha256').update(buf).digest('hex');
|
|
13
14
|
const stages = ['validity', 'intent', 'tier'];
|
|
@@ -17,17 +18,17 @@ function tempDir(prefix) {
|
|
|
17
18
|
return fs.realpathSync.native(dir);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
function makeRepo(root, version = 'v1') {
|
|
21
|
+
function makeRepo(root, version = 'v1', weightsExtension = '.weights') {
|
|
21
22
|
const checkpoint = path.join(root, 'models', 'cua-s1', version);
|
|
22
23
|
fs.mkdirSync(checkpoint, { recursive: true });
|
|
23
24
|
const manifest = { schemaVersion: 1, version, createdAt: '2026-11-14T00:00:00.000Z', stages: {}, evaluation: 'evaluation.json' };
|
|
24
25
|
for (const stage of stages) {
|
|
25
26
|
const weights = Buffer.from(`${stage}-weights`);
|
|
26
27
|
const config = Buffer.from(JSON.stringify({ stage, format: 'fixture' }));
|
|
27
|
-
fs.writeFileSync(path.join(checkpoint, `${stage}
|
|
28
|
+
fs.writeFileSync(path.join(checkpoint, `${stage}${weightsExtension}`), weights);
|
|
28
29
|
fs.writeFileSync(path.join(checkpoint, `${stage}.json`), config);
|
|
29
30
|
manifest.stages[stage] = {
|
|
30
|
-
weights: `${stage}
|
|
31
|
+
weights: `${stage}${weightsExtension}`, config: `${stage}.json`, sha256: sha(weights),
|
|
31
32
|
options: [`${stage}-a`, `${stage}-b`], thresholds: { [`${stage}-a`]: 0.5, [`${stage}-b`]: 0.6 },
|
|
32
33
|
};
|
|
33
34
|
}
|
|
@@ -103,6 +104,41 @@ test('install accepts referenceOnly only when its option threshold is one', () =
|
|
|
103
104
|
} finally { remove(root, home); }
|
|
104
105
|
});
|
|
105
106
|
|
|
107
|
+
test('447 rejects nested live stage paths at install while flat stages and nested evaluation still work', t => {
|
|
108
|
+
const root = tempDir('harness-s1-repo-');
|
|
109
|
+
const home = tempDir('harness-s1-home-');
|
|
110
|
+
t.after(() => remove(root, home));
|
|
111
|
+
const source = makeRepo(root, 'v1', '.safetensors');
|
|
112
|
+
const manifestFile = path.join(source, 'manifest.json');
|
|
113
|
+
const manifest = JSON.parse(fs.readFileSync(manifestFile, 'utf8'));
|
|
114
|
+
const artifacts = path.join(source, 'artifacts');
|
|
115
|
+
fs.mkdirSync(artifacts);
|
|
116
|
+
fs.renameSync(path.join(source, manifest.evaluation), path.join(artifacts, manifest.evaluation));
|
|
117
|
+
manifest.evaluation = 'artifacts/evaluation.json';
|
|
118
|
+
|
|
119
|
+
for (const field of ['weights', 'config']) {
|
|
120
|
+
const name = manifest.stages.intent[field];
|
|
121
|
+
fs.copyFileSync(path.join(source, name), path.join(artifacts, name));
|
|
122
|
+
const nested = structuredClone(manifest);
|
|
123
|
+
nested.stages.intent[field] = `artifacts/${name}`;
|
|
124
|
+
fs.writeFileSync(manifestFile, JSON.stringify(nested));
|
|
125
|
+
assert.throws(() => validateVersionManifest(nested), /intent weights and config must be flat filenames/);
|
|
126
|
+
assert.throws(() => install.installVersion(root, 'v1', home), /intent weights and config must be flat filenames/);
|
|
127
|
+
assert.equal(fs.existsSync(path.join(home, 'versions')), false);
|
|
128
|
+
assert.equal(fs.existsSync(path.join(home, 'active.json')), false);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
fs.writeFileSync(manifestFile, JSON.stringify(manifest));
|
|
132
|
+
assert.equal(validateVersionManifest(manifest), manifest);
|
|
133
|
+
const installed = install.installVersion(root, 'v1', home);
|
|
134
|
+
install.activate('v1', home);
|
|
135
|
+
const active = readActive({ HARNESS_SYSTEM_ONE_HOME: home });
|
|
136
|
+
assert.equal(active?.version, 'v1');
|
|
137
|
+
assert.equal(active.stages.intent.weightsPath, path.join(installed.dir, manifest.stages.intent.weights));
|
|
138
|
+
assert.equal(active.stages.intent.configPath, path.join(installed.dir, manifest.stages.intent.config));
|
|
139
|
+
assert.equal(fs.readFileSync(path.join(installed.dir, manifest.evaluation), 'utf8'), '{"samples":2}');
|
|
140
|
+
});
|
|
141
|
+
|
|
106
142
|
test('S1-I03 activation and rollback round-trip through the previous pointer', () => {
|
|
107
143
|
const root = tempDir('harness-s1-repo-'); const home = tempDir('harness-s1-home-');
|
|
108
144
|
try {
|
|
@@ -7,10 +7,12 @@ const { spawnSync: spawnNodeSync } = require('child_process');
|
|
|
7
7
|
|
|
8
8
|
function spawnSync(command, args, options = {}) {
|
|
9
9
|
const { systemOneMode = 'off', ...spawnOptions } = options;
|
|
10
|
+
const inheritedEnv = Object.fromEntries(Object.entries(process.env)
|
|
11
|
+
.filter(([key]) => !key.toUpperCase().startsWith('HARNESS_')));
|
|
10
12
|
return spawnNodeSync(command, args, {
|
|
11
13
|
...spawnOptions,
|
|
12
14
|
env: {
|
|
13
|
-
...
|
|
15
|
+
...inheritedEnv,
|
|
14
16
|
...(spawnOptions.env || {}),
|
|
15
17
|
HARNESS_SYSTEM_ONE_MODE: systemOneMode,
|
|
16
18
|
},
|
|
@@ -65,7 +67,6 @@ function runTier(prompt, options = {}) {
|
|
|
65
67
|
encoding: 'utf8',
|
|
66
68
|
input: context ? JSON.stringify({ ...context, prompt }) : undefined,
|
|
67
69
|
env: {
|
|
68
|
-
...process.env,
|
|
69
70
|
...(options.env || {}),
|
|
70
71
|
HARNESS_ROUTER_CONTRACT_PATH: contractPath,
|
|
71
72
|
},
|
|
@@ -488,7 +489,7 @@ const kernelNotificationPersistFailure = spawnSync(process.execPath, [kernelRout
|
|
|
488
489
|
hook_event_name: 'UserPromptSubmit',
|
|
489
490
|
prompt: '<task-notification><task-id>background-1</task-id><status>completed</status></task-notification>',
|
|
490
491
|
}),
|
|
491
|
-
env: {
|
|
492
|
+
env: { HARNESS_STATE_HOME: notificationStateFile, HARNESS_WORKSPACE_ROOT: ROOT },
|
|
492
493
|
});
|
|
493
494
|
check(kernelNotificationPersistFailure.status === 0, 'host notification persistence failure stays fail-open');
|
|
494
495
|
check(kernelNotificationPersistFailure.stdout.includes('Host notification: no active execution contract; ignored for routing.'), 'host notification remains a routing no-op when state persistence fails');
|
|
@@ -510,18 +511,17 @@ check(!kernelIterative.stdout.includes('evaluate-suggestions-before-skip'), 'leg
|
|
|
510
511
|
|
|
511
512
|
const retainedStateHome = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-router-retained-step-'));
|
|
512
513
|
const retainedSession = 'issue297-retained-step';
|
|
513
|
-
const retainedEnv =
|
|
514
|
-
...process.env,
|
|
514
|
+
const retainedEnv = {
|
|
515
515
|
HARNESS_STATE_HOME: retainedStateHome,
|
|
516
516
|
HARNESS_WORKSPACE_ROOT: ROOT,
|
|
517
|
-
}
|
|
517
|
+
};
|
|
518
518
|
const retainedInput = prompt => JSON.stringify({ session_id: retainedSession, cwd: ROOT, hook_event_name: 'UserPromptSubmit', prompt });
|
|
519
|
-
const initialRetainedRoute = spawnSync(process.execPath, [kernelRouter], {
|
|
519
|
+
const initialRetainedRoute = withInheritedSystemOneLive(() => spawnSync(process.execPath, [kernelRouter], {
|
|
520
520
|
cwd: ROOT,
|
|
521
521
|
encoding: 'utf8',
|
|
522
522
|
input: retainedInput('Fix this checkout bug and add a regression test.'),
|
|
523
523
|
env: retainedEnv,
|
|
524
|
-
});
|
|
524
|
+
}));
|
|
525
525
|
check(initialRetainedRoute.status === 0, 'retained workflow fixture routes successfully');
|
|
526
526
|
check(!initialRetainedRoute.stdout.includes('SYSTEM ONE REFERENCE CONFIDENCE'), 'retained kernel route ignores inherited live mode');
|
|
527
527
|
check(initialRetainedRoute.stdout.includes('PLANNING STEP: decompose → compose'), 'new selected workflow exposes its planning step');
|
package/code-review/SKILL.md
CHANGED
|
@@ -9,9 +9,25 @@
|
|
|
9
9
|
- Prior rounds (findings per decision class, for re-review):
|
|
10
10
|
- Changed files and relevant callers/consumers:
|
|
11
11
|
- CI state and commands observed:
|
|
12
|
-
- Counterexample categories covered:
|
|
13
12
|
- Risks not examined / evidence limits:
|
|
14
13
|
|
|
14
|
+
### Counterexample categories covered
|
|
15
|
+
|
|
16
|
+
Derive the families from the scope anchor and the implementation's supported syntax. Include equivalent spellings or transformations and unknown syntax that could affect the scoped decision. Keep unverified families visible as `UNCHECKED`.
|
|
17
|
+
|
|
18
|
+
| family | representative / equivalent spelling | expected | actual per implementation | evidence tier or UNCHECKED |
|
|
19
|
+
| --- | --- | --- | --- | --- |
|
|
20
|
+
| <family from scope> | <representative inputs> | <expected decision> | <observed or source-traced decision, or blank> | <tier and evidence reference, or UNCHECKED> |
|
|
21
|
+
|
|
22
|
+
<!--
|
|
23
|
+
Illustrative example for a scope that treats inputs as literal strings (fictional contract and implementation):
|
|
24
|
+
|
|
25
|
+
| family | representative / equivalent spelling | expected | actual per implementation | evidence tier or UNCHECKED |
|
|
26
|
+
| --- | --- | --- | --- | --- |
|
|
27
|
+
| Repeated literal | `abc` compared with `abc` | Equal | Equal via the example implementation's `left === right` | source-traced (illustrative expression) |
|
|
28
|
+
| Unknown escape syntax | `\a` compared with `a` | Distinct literals | | UNCHECKED |
|
|
29
|
+
-->
|
|
30
|
+
|
|
15
31
|
## Findings
|
|
16
32
|
|
|
17
33
|
### [P1/P2/P3] <Short, specific title>
|
|
@@ -77,7 +77,7 @@ The same subcommands and flags work with `node scripts/report-writer.js`.
|
|
|
77
77
|
| Scope | Operate on explicitly designated report output only; do not rewrite unrelated files, judge semantic success, touch the Ledger, or automatically change permissions |
|
|
78
78
|
| Revision | Re-run `write` using the edited body + true status; never mutate the terminal report with ordinary append commands |
|
|
79
79
|
|
|
80
|
-
In `--from-codex-output` mode, the writer can remove one terminal
|
|
80
|
+
In `--from-codex-output` mode, the writer can remove one terminal comment that conforms to the [Observations v1 harness-label contract](../../system-one-observations.md#label-line). If the raw input already includes a STATUS line, it must match the requested status and be terminal or immediately precede the label. Invalid input returns nonzero and preserves the raw file.
|
|
81
81
|
|
|
82
82
|
## Interaction with other Actions and existing facilities
|
|
83
83
|
|
|
@@ -201,7 +201,8 @@ sessions whose directories matched setup; it establishes field availability,
|
|
|
201
201
|
not mismatch handling or V2 hook behavior ([trace notes](../benchmarks/results/live-host/opencode-2026-11-15-workspace/README.md)). The adapter itself has deterministic mechanism
|
|
202
202
|
coverage (`ci/mechanism-2n-opencode-plugin.test.js`, V1 shapes;
|
|
203
203
|
`ci/mechanism-2p-opencode-v2-entrypoint.test.js`, V2 lifecycle shapes;
|
|
204
|
-
`ci/mechanism-397-opencode-observations.test.js`, router injection,
|
|
204
|
+
`ci/mechanism-397-opencode-observations.test.js`, router injection, fail-open
|
|
205
|
+
router diagnostics on launch or runtime failure, turn capture,
|
|
205
206
|
malformed-label export counts and opt-out). The injection/capture path has
|
|
206
207
|
mechanism evidence only; no live-host hook-fire or mismatch-handling artifact
|
|
207
208
|
exists. Retained
|
|
@@ -38,6 +38,7 @@ function validateVersionManifest(manifest, expectedVersion) {
|
|
|
38
38
|
|| Object.values(stage.thresholds).some(value => typeof value !== 'number' || !Number.isFinite(value) || value < 0 || value > 1)) {
|
|
39
39
|
fail(`malformed ${name} stage`);
|
|
40
40
|
}
|
|
41
|
+
if (stage.weights.includes('/') || stage.config.includes('/')) fail(`${name} weights and config must be flat filenames`);
|
|
41
42
|
if (Object.hasOwn(stage, 'referenceOnly')
|
|
42
43
|
&& (!Array.isArray(stage.referenceOnly) || new Set(stage.referenceOnly).size !== stage.referenceOnly.length
|
|
43
44
|
|| stage.referenceOnly.some(id => !stage.options.includes(id) || stage.thresholds[id] !== 1))) {
|
|
@@ -692,7 +692,7 @@ function handle(payload, env = process.env) {
|
|
|
692
692
|
}
|
|
693
693
|
|
|
694
694
|
module.exports = {
|
|
695
|
-
INTENTS, TIERS, STRATEGIES, RETENTION_MS, PREVIOUS_BYTES, enabled, storeRoot, redact, parseLabelLine, stripLabels, tailBytes, sha, normalizeSystemOne, classifyCommand, labelTier, contradictions,
|
|
695
|
+
INTENTS, TIERS, STRATEGIES, RETENTION_MS, PREVIOUS_BYTES, enabled, storeRoot, redact, validLabel, parseLabelLine, stripLabels, tailBytes, sha, normalizeSystemOne, classifyCommand, labelTier, contradictions,
|
|
696
696
|
normalizeTerms, transcriptMessage, recordTool, emptyBehavior, mergeBehavior, toolFailed, handle, readJson, appendRecord, appendRecordDetailed, observationTurnMatch, findObservationTurnMatch, markSessionBackfillBehaviorUnobserved,
|
|
697
697
|
expired, recordText, sweep,
|
|
698
698
|
};
|
|
@@ -121,6 +121,12 @@ enforcement logic is shared, not duplicated.
|
|
|
121
121
|
The prompt/context routing and System One observation hooks are V2-only. The
|
|
122
122
|
V1 factory keeps its existing enforcement hooks; it does not capture turns.
|
|
123
123
|
|
|
124
|
+
When OpenCode runs on Bun, its Harness router needs `node` on the OpenCode
|
|
125
|
+
process's `PATH`. Run `node --version` from the same environment that launches
|
|
126
|
+
OpenCode and check it against the [Harness Node.js baseline](../docs/repository-contract.md).
|
|
127
|
+
If the router cannot start or load, OpenCode still admits prompts and logs a
|
|
128
|
+
`router-unavailable` warning with a reason and per-plugin count.
|
|
129
|
+
|
|
124
130
|
Direction:
|
|
125
131
|
named factory (V1 hosts/tests) → default-export setup adapter → V2 domains.
|
|
126
132
|
|
|
@@ -89,11 +89,15 @@ function harnessRuntime() {
|
|
|
89
89
|
return process.versions.bun ? "node" : process.execPath
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
function runKernelRouter(payload, signal) {
|
|
93
|
-
if (
|
|
92
|
+
function runKernelRouter(payload, signal, unavailable) {
|
|
93
|
+
if (signal?.aborted) return Promise.resolve(null)
|
|
94
|
+
if (!ROUTER_FILE) {
|
|
95
|
+
unavailable("runtime-missing")
|
|
96
|
+
return Promise.resolve(null)
|
|
97
|
+
}
|
|
94
98
|
return new Promise(resolveOutput => {
|
|
95
99
|
let stdout = ""
|
|
96
|
-
let child, timeout, termination,
|
|
100
|
+
let child, timeout, termination, failureReason, timedOut = false, settled = false
|
|
97
101
|
const terminate = () => {
|
|
98
102
|
if (!termination && child) termination = terminateVerificationChild(child)
|
|
99
103
|
}
|
|
@@ -101,11 +105,19 @@ function runKernelRouter(payload, signal) {
|
|
|
101
105
|
if (settled) return
|
|
102
106
|
settled = true
|
|
103
107
|
clearTimeout(timeout)
|
|
104
|
-
signal?.removeEventListener("abort",
|
|
108
|
+
signal?.removeEventListener("abort", terminate)
|
|
105
109
|
if (termination) await termination
|
|
106
|
-
|
|
110
|
+
if (signal?.aborted || timedOut) {
|
|
111
|
+
resolveOutput(null)
|
|
112
|
+
return
|
|
113
|
+
}
|
|
114
|
+
if (failureReason || code !== 0) {
|
|
115
|
+
unavailable(failureReason || "runtime-failed")
|
|
116
|
+
resolveOutput(null)
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
resolveOutput(stdout.trim())
|
|
107
120
|
}
|
|
108
|
-
const abort = () => { cancelled = true; terminate() }
|
|
109
121
|
try {
|
|
110
122
|
child = spawn(harnessRuntime(), [ROUTER_FILE], {
|
|
111
123
|
cwd: payload.cwd || HARNESS_ROOT,
|
|
@@ -115,21 +127,22 @@ function runKernelRouter(payload, signal) {
|
|
|
115
127
|
windowsHide: true,
|
|
116
128
|
})
|
|
117
129
|
} catch {
|
|
130
|
+
unavailable("spawn-failed")
|
|
118
131
|
resolveOutput(null)
|
|
119
132
|
return
|
|
120
133
|
}
|
|
121
134
|
child.stdout.on("data", chunk => { stdout += chunk })
|
|
122
|
-
child.stdin.on("error", () => {
|
|
135
|
+
child.stdin.on("error", () => { failureReason ||= "runtime-failed"; terminate() })
|
|
123
136
|
child.once("error", () => {
|
|
124
|
-
|
|
137
|
+
failureReason = child.pid ? "runtime-failed" : "spawn-failed"
|
|
125
138
|
if (!child.pid) void finish(null)
|
|
126
139
|
else terminate()
|
|
127
140
|
})
|
|
128
141
|
child.once("close", code => { void finish(code) })
|
|
129
|
-
signal?.addEventListener("abort",
|
|
130
|
-
if (signal?.aborted)
|
|
142
|
+
signal?.addEventListener("abort", terminate, { once: true })
|
|
143
|
+
if (signal?.aborted) terminate()
|
|
131
144
|
timeout = setTimeout(() => { timedOut = true; terminate() }, 5000)
|
|
132
|
-
try { child.stdin.end(JSON.stringify(payload)) } catch {
|
|
145
|
+
try { child.stdin.end(JSON.stringify(payload)) } catch { failureReason ||= "runtime-failed"; terminate() }
|
|
133
146
|
})
|
|
134
147
|
}
|
|
135
148
|
|
|
@@ -1344,7 +1357,13 @@ export default {
|
|
|
1344
1357
|
return pending
|
|
1345
1358
|
}
|
|
1346
1359
|
let unresolvedIdentityCount = 0
|
|
1360
|
+
const routerUnavailableCounts = new Map()
|
|
1347
1361
|
|
|
1362
|
+
const routerUnavailable = reason => {
|
|
1363
|
+
const count = (routerUnavailableCounts.get(reason) || 0) + 1
|
|
1364
|
+
routerUnavailableCounts.set(reason, count)
|
|
1365
|
+
try { console.warn(`[Harness] OpenCode router-unavailable (${reason}; count=${count})`) } catch {}
|
|
1366
|
+
}
|
|
1348
1367
|
const unresolvedIdentity = reason => {
|
|
1349
1368
|
unresolvedIdentityCount++
|
|
1350
1369
|
try { console.warn(`[Harness] OpenCode session workspace unresolved (${reason}; count=${unresolvedIdentityCount}); workspace-dependent handling skipped.`) } catch {}
|
|
@@ -1483,7 +1502,7 @@ export default {
|
|
|
1483
1502
|
if (events.signal.aborted) return
|
|
1484
1503
|
const routerPayload = { host: "opencode", session_id: event.sessionID,
|
|
1485
1504
|
...(prompt.messageID ? { turn_id: prompt.messageID } : {}), cwd: prompt.workspace, prompt: event.prompt.text }
|
|
1486
|
-
const routerOutput = await runKernelRouter(routerPayload, events.signal)
|
|
1505
|
+
const routerOutput = await runKernelRouter(routerPayload, events.signal, routerUnavailable)
|
|
1487
1506
|
if (!events.signal.aborted && promptRoutes.get(event.sessionID) === prompt) prompt.routerOutput = routerOutput
|
|
1488
1507
|
})
|
|
1489
1508
|
await prompt.routerPromise
|
package/package.json
CHANGED
|
@@ -692,7 +692,7 @@ function handle(payload, env = process.env) {
|
|
|
692
692
|
}
|
|
693
693
|
|
|
694
694
|
module.exports = {
|
|
695
|
-
INTENTS, TIERS, STRATEGIES, RETENTION_MS, PREVIOUS_BYTES, enabled, storeRoot, redact, parseLabelLine, stripLabels, tailBytes, sha, normalizeSystemOne, classifyCommand, labelTier, contradictions,
|
|
695
|
+
INTENTS, TIERS, STRATEGIES, RETENTION_MS, PREVIOUS_BYTES, enabled, storeRoot, redact, validLabel, parseLabelLine, stripLabels, tailBytes, sha, normalizeSystemOne, classifyCommand, labelTier, contradictions,
|
|
696
696
|
normalizeTerms, transcriptMessage, recordTool, emptyBehavior, mergeBehavior, toolFailed, handle, readJson, appendRecord, appendRecordDetailed, observationTurnMatch, findObservationTurnMatch, markSessionBackfillBehaviorUnobserved,
|
|
697
697
|
expired, recordText, sweep,
|
|
698
698
|
};
|
|
@@ -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.55.
|
|
4
|
+
"version": "0.55.3",
|
|
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",
|
|
@@ -9,9 +9,25 @@
|
|
|
9
9
|
- Prior rounds (findings per decision class, for re-review):
|
|
10
10
|
- Changed files and relevant callers/consumers:
|
|
11
11
|
- CI state and commands observed:
|
|
12
|
-
- Counterexample categories covered:
|
|
13
12
|
- Risks not examined / evidence limits:
|
|
14
13
|
|
|
14
|
+
### Counterexample categories covered
|
|
15
|
+
|
|
16
|
+
Derive the families from the scope anchor and the implementation's supported syntax. Include equivalent spellings or transformations and unknown syntax that could affect the scoped decision. Keep unverified families visible as `UNCHECKED`.
|
|
17
|
+
|
|
18
|
+
| family | representative / equivalent spelling | expected | actual per implementation | evidence tier or UNCHECKED |
|
|
19
|
+
| --- | --- | --- | --- | --- |
|
|
20
|
+
| <family from scope> | <representative inputs> | <expected decision> | <observed or source-traced decision, or blank> | <tier and evidence reference, or UNCHECKED> |
|
|
21
|
+
|
|
22
|
+
<!--
|
|
23
|
+
Illustrative example for a scope that treats inputs as literal strings (fictional contract and implementation):
|
|
24
|
+
|
|
25
|
+
| family | representative / equivalent spelling | expected | actual per implementation | evidence tier or UNCHECKED |
|
|
26
|
+
| --- | --- | --- | --- | --- |
|
|
27
|
+
| Repeated literal | `abc` compared with `abc` | Equal | Equal via the example implementation's `left === right` | source-traced (illustrative expression) |
|
|
28
|
+
| Unknown escape syntax | `\a` compared with `a` | Distinct literals | | UNCHECKED |
|
|
29
|
+
-->
|
|
30
|
+
|
|
15
31
|
## Findings
|
|
16
32
|
|
|
17
33
|
### [P1/P2/P3] <Short, specific title>
|
|
@@ -38,6 +38,7 @@ function validateVersionManifest(manifest, expectedVersion) {
|
|
|
38
38
|
|| Object.values(stage.thresholds).some(value => typeof value !== 'number' || !Number.isFinite(value) || value < 0 || value > 1)) {
|
|
39
39
|
fail(`malformed ${name} stage`);
|
|
40
40
|
}
|
|
41
|
+
if (stage.weights.includes('/') || stage.config.includes('/')) fail(`${name} weights and config must be flat filenames`);
|
|
41
42
|
if (Object.hasOwn(stage, 'referenceOnly')
|
|
42
43
|
&& (!Array.isArray(stage.referenceOnly) || new Set(stage.referenceOnly).size !== stage.referenceOnly.length
|
|
43
44
|
|| stage.referenceOnly.some(id => !stage.options.includes(id) || stage.thresholds[id] !== 1))) {
|
package/sbom.cdx.json
CHANGED
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
"$schema": "https://cyclonedx.org/schema/bom-1.7.schema.json",
|
|
3
3
|
"bomFormat": "CycloneDX",
|
|
4
4
|
"specVersion": "1.7",
|
|
5
|
-
"serialNumber": "urn:uuid:
|
|
5
|
+
"serialNumber": "urn:uuid:357f2bfc-3684-5644-89c6-2434fe189716",
|
|
6
6
|
"version": 1,
|
|
7
7
|
"metadata": {
|
|
8
|
-
"timestamp": "2026-11-
|
|
8
|
+
"timestamp": "2026-11-20T15:47:31.044Z",
|
|
9
9
|
"tools": [
|
|
10
10
|
{
|
|
11
11
|
"vendor": "Harness Everything",
|
|
12
12
|
"name": "generate-sbom.js",
|
|
13
|
-
"version": "0.55.
|
|
13
|
+
"version": "0.55.3"
|
|
14
14
|
}
|
|
15
15
|
],
|
|
16
16
|
"component": {
|
|
17
17
|
"type": "application",
|
|
18
|
-
"bom-ref": "pkg:npm/harness-everything@0.55.
|
|
18
|
+
"bom-ref": "pkg:npm/harness-everything@0.55.3",
|
|
19
19
|
"name": "harness-everything",
|
|
20
|
-
"version": "0.55.
|
|
21
|
-
"purl": "pkg:npm/harness-everything@0.55.
|
|
20
|
+
"version": "0.55.3",
|
|
21
|
+
"purl": "pkg:npm/harness-everything@0.55.3"
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"components": [
|
|
@@ -2033,7 +2033,7 @@
|
|
|
2033
2033
|
]
|
|
2034
2034
|
},
|
|
2035
2035
|
{
|
|
2036
|
-
"ref": "pkg:npm/harness-everything@0.55.
|
|
2036
|
+
"ref": "pkg:npm/harness-everything@0.55.3",
|
|
2037
2037
|
"dependsOn": [
|
|
2038
2038
|
"pkg:npm/%40commitlint/cli@19.8.1",
|
|
2039
2039
|
"pkg:npm/%40commitlint/config-conventional@19.8.1",
|
|
@@ -32,7 +32,7 @@ function parseArgs(argv) {
|
|
|
32
32
|
return options;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
function git(args, cwd = process.cwd()) {
|
|
35
|
+
function git(args, cwd = process.cwd(), input) {
|
|
36
36
|
const env = Object.fromEntries(Object.entries(process.env).filter(([key]) => !key.startsWith('GIT_')));
|
|
37
37
|
if (process.env.GIT_CONFIG_GLOBAL !== undefined) env.GIT_CONFIG_GLOBAL = process.env.GIT_CONFIG_GLOBAL;
|
|
38
38
|
Object.assign(env, {
|
|
@@ -43,6 +43,7 @@ function git(args, cwd = process.cwd()) {
|
|
|
43
43
|
const result = spawnSync('git', ['-c', 'core.fsmonitor=false', '-c', 'core.untrackedCache=false', ...args], {
|
|
44
44
|
cwd,
|
|
45
45
|
encoding: null,
|
|
46
|
+
input,
|
|
46
47
|
shell: false,
|
|
47
48
|
env,
|
|
48
49
|
maxBuffer: 16 * 1024 * 1024,
|
|
@@ -110,6 +111,79 @@ function readAllowPatterns(options) {
|
|
|
110
111
|
});
|
|
111
112
|
}
|
|
112
113
|
|
|
114
|
+
function gitBooleanConfig(repo, key, fallback) {
|
|
115
|
+
const args = ['config', '--bool', '--get', key];
|
|
116
|
+
const result = git(args, repo);
|
|
117
|
+
if (result.status === 1 && !result.stderr.length) return fallback;
|
|
118
|
+
return pathsFrom(result, args)[0]?.trim() === 'true';
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function sparseCheckoutIncludes(repo, files) {
|
|
122
|
+
const args = ['sparse-checkout', 'check-rules', '-z'];
|
|
123
|
+
const input = Buffer.from(`${files.join('\0')}\0`);
|
|
124
|
+
return new Set(pathsFrom(git(args, repo, input), args));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function flaggedWorkingTreeChanges(repo) {
|
|
128
|
+
const args = ['ls-files', '-v', '--stage', '-z'];
|
|
129
|
+
const changes = [];
|
|
130
|
+
const sparseRuleCandidates = [];
|
|
131
|
+
let sparseCheckout;
|
|
132
|
+
for (const entry of pathsFrom(git(args, repo), args)) {
|
|
133
|
+
// Lowercase tags mark assume-unchanged; S/s marks skip-worktree.
|
|
134
|
+
if (!/^[a-zS] /.test(entry)) continue;
|
|
135
|
+
const separator = entry.indexOf('\t');
|
|
136
|
+
const [tag, mode, oid, stage] = entry.slice(0, separator).split(' ');
|
|
137
|
+
if (stage !== '0') continue;
|
|
138
|
+
const file = entry.slice(separator + 1);
|
|
139
|
+
const absolute = path.join(repo, file);
|
|
140
|
+
const stat = fs.lstatSync(absolute, { throwIfNoEntry: false });
|
|
141
|
+
if (!stat) {
|
|
142
|
+
// Skip only paths excluded by the active sparse rules; an in-cone deletion
|
|
143
|
+
// can also carry the skip-worktree bit.
|
|
144
|
+
if (tag.toUpperCase() === 'S'
|
|
145
|
+
&& (sparseCheckout ??= gitBooleanConfig(repo, 'core.sparseCheckout', false))) {
|
|
146
|
+
sparseRuleCandidates.push(file);
|
|
147
|
+
} else {
|
|
148
|
+
changes.push(file);
|
|
149
|
+
}
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
let hashArgs;
|
|
154
|
+
let hashCwd = repo;
|
|
155
|
+
let input;
|
|
156
|
+
if (mode === '160000' && stat.isDirectory()) {
|
|
157
|
+
// An uninitialized submodule has no checked-out commit to compare.
|
|
158
|
+
if (!fs.lstatSync(path.join(absolute, '.git'), { throwIfNoEntry: false })) continue;
|
|
159
|
+
hashArgs = ['rev-parse', '--verify', 'HEAD'];
|
|
160
|
+
hashCwd = absolute;
|
|
161
|
+
} else if (mode === '120000' && stat.isSymbolicLink()) {
|
|
162
|
+
hashArgs = ['hash-object', '--stdin'];
|
|
163
|
+
input = fs.readlinkSync(absolute, { encoding: 'buffer' });
|
|
164
|
+
} else if (mode === '120000' && stat.isFile() && !gitBooleanConfig(repo, 'core.symlinks', true)) {
|
|
165
|
+
// Git can check out a symlink as a plain file containing its target.
|
|
166
|
+
hashArgs = ['hash-object', '--no-filters', '--', file];
|
|
167
|
+
} else if (mode.startsWith('100') && stat.isFile()) {
|
|
168
|
+
// Apply Git's clean filters just as when comparing normal tracked files.
|
|
169
|
+
hashArgs = ['hash-object', `--path=${file}`, '--', file];
|
|
170
|
+
} else {
|
|
171
|
+
changes.push(file);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
const actual = pathsFrom(git(hashArgs, hashCwd, input), hashArgs)[0]?.trim();
|
|
175
|
+
if (!actual) throw new Error(`could not compare tracked path ${JSON.stringify(file)}`);
|
|
176
|
+
if (actual !== oid) changes.push(file);
|
|
177
|
+
}
|
|
178
|
+
if (sparseRuleCandidates.length) {
|
|
179
|
+
const included = sparseCheckoutIncludes(repo, sparseRuleCandidates);
|
|
180
|
+
for (const file of sparseRuleCandidates) {
|
|
181
|
+
if (included.has(file)) changes.push(file);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return changes;
|
|
185
|
+
}
|
|
186
|
+
|
|
113
187
|
function changedPaths(base, head, includeWorkingTree, repo) {
|
|
114
188
|
const paths = new Set();
|
|
115
189
|
const diffs = [['diff', '--no-ext-diff', '--no-textconv', '--no-renames', '--name-only', '-z', base, head]];
|
|
@@ -123,6 +197,7 @@ function changedPaths(base, head, includeWorkingTree, repo) {
|
|
|
123
197
|
if (includeWorkingTree) {
|
|
124
198
|
const untrackedArgs = ['ls-files', '--others', '--exclude-standard', '-z'];
|
|
125
199
|
for (const file of pathsFrom(git(untrackedArgs, repo), untrackedArgs)) paths.add(file);
|
|
200
|
+
for (const file of flaggedWorkingTreeChanges(repo)) paths.add(file);
|
|
126
201
|
}
|
|
127
202
|
return [...paths].sort();
|
|
128
203
|
}
|
package/scripts/report-writer.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
const crypto = require('node:crypto');
|
|
5
5
|
const fs = require('node:fs');
|
|
6
6
|
const path = require('node:path');
|
|
7
|
+
const { validLabel } = require('../hooks/scripts/lib/observations');
|
|
7
8
|
|
|
8
9
|
const USAGE = 'usage: report-writer write --output <path> --status <DONE|BLOCKED|0|nonzero-int> (--body-file <path>|--context <text>|--from-codex-output <path>) [--reason <text>|--error <text>...] | report-writer check --file <path>';
|
|
9
10
|
const WRITE_OPTIONS = new Set(['--output', '--status', '--reason', '--error', '--body-file', '--context', '--from-codex-output']);
|
|
@@ -109,7 +110,7 @@ function parseHostLabel(line) {
|
|
|
109
110
|
} catch {
|
|
110
111
|
error('terminal host label must contain valid JSON');
|
|
111
112
|
}
|
|
112
|
-
if (!
|
|
113
|
+
if (!validLabel(value)) error('terminal host label must use the recognized harness-label schema');
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
function extractCodexBody(raw, expectedStatus) {
|
|
@@ -10,6 +10,7 @@ const { assertPrivateHistoryFile, appendPrivateHistory } = require('./system-one
|
|
|
10
10
|
const STAGE_SET = new Set(STAGES);
|
|
11
11
|
const EPSILON = 1e-12;
|
|
12
12
|
const LOG_EPSILON = Number.EPSILON;
|
|
13
|
+
const VERSION_ALREADY_RECORDED = 'version already recorded; resume with the original cycle artifacts or use a new version';
|
|
13
14
|
const fail = () => { throw new TypeError('invalid-system-one-curves-input'); };
|
|
14
15
|
const isObject = value => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
15
16
|
const isText = value => typeof value === 'string' && value.trim().length > 0;
|
|
@@ -442,15 +443,15 @@ function run(argv) {
|
|
|
442
443
|
}
|
|
443
444
|
if (Object.keys(holdoutFiles).length && Object.keys(holdoutFiles).length !== Object.keys(valFiles).length) fail();
|
|
444
445
|
const history = readHistory(args.history);
|
|
446
|
+
if (history.some(row => row.version === args.version)) throw new TypeError(VERSION_ALREADY_RECORDED);
|
|
445
447
|
const floor = assessFloor(Object.keys(holdoutMetrics).length ? holdoutMetrics : null, history);
|
|
446
448
|
const curves = { schemaVersion: 1, version: args.version, createdAt: new Date().toISOString(), stages, floor };
|
|
447
|
-
const existing = assertVersionReusable(history, curves);
|
|
448
449
|
validateBaselineReferences(curves, history);
|
|
449
450
|
const trend = decideTrend(curves, history, floor);
|
|
450
451
|
fs.mkdirSync(args.out, { recursive: true });
|
|
451
452
|
fs.writeFileSync(path.join(args.out, 'curves.json'), `${JSON.stringify(curves, null, 2)}\n`);
|
|
452
453
|
fs.writeFileSync(path.join(args.out, 'trend.json'), `${JSON.stringify(trend, null, 2)}\n`);
|
|
453
|
-
|
|
454
|
+
appendHistoryRow(args.history, history, curves);
|
|
454
455
|
const summary = Object.fromEntries(Object.entries(stages).map(([stage, value]) => [stage, {
|
|
455
456
|
rows: readJsonl(valFiles[stage]).length,
|
|
456
457
|
logLoss: value.logLoss,
|
|
@@ -463,8 +464,10 @@ function run(argv) {
|
|
|
463
464
|
}
|
|
464
465
|
|
|
465
466
|
if (require.main === module) {
|
|
466
|
-
try { run(process.argv.slice(2)); } catch (
|
|
467
|
-
|
|
467
|
+
try { run(process.argv.slice(2)); } catch (error) {
|
|
468
|
+
const message = error?.message === VERSION_ALREADY_RECORDED ? VERSION_ALREADY_RECORDED
|
|
469
|
+
: 'invalid arguments, manifest, history, or score input';
|
|
470
|
+
console.error(`system-one-curves: ${message}`);
|
|
468
471
|
process.exitCode = 1;
|
|
469
472
|
}
|
|
470
473
|
}
|