harness-everything 1.5.0 → 1.5.1
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/.github/workflows/ci.yml +16 -0
- package/CHANGELOG.md +8 -0
- package/benchmarks/results/error-ledger-oracle-484-pilot/README.md +57 -0
- package/benchmarks/results/error-ledger-oracle-484-pilot/candidates.json +22802 -0
- package/benchmarks/results/error-ledger-oracle-484-pilot/labels.json +131 -0
- package/benchmarks/results/error-ledger-oracle-484-pilot/oracle.json +362 -0
- package/benchmarks/results/error-ledger-oracle-484-pilot/rows.json +648 -0
- package/benchmarks/results/error-ledger-oracle-484-pilot/sample.json +215 -0
- package/benchmarks/results/error-ledger-oracle-484-pilot/select.js +127 -0
- package/ci/mechanism-349-ci-change-scope.test.js +69 -1
- package/ci/mechanism-548-bigint-identity.test.js +1 -1
- package/ci/mechanism-571-fit-guard.test.js +165 -0
- package/ci/mechanism-571-nll-labels.test.js +79 -0
- package/ci/mechanism-system-one-curves.test.js +11 -5
- package/ci/mechanism-system-one-cycle.test.js +73 -0
- package/harness-everything/SKILL.md +1 -1
- package/harness-everything/scripts/system-one/layer.py +11 -1
- package/opencode-plugin/plugin.json +1 -1
- package/package.json +1 -1
- package/plugins/harness-everything/.antigravity-plugin/plugin.json +1 -1
- package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
- package/plugins/harness-everything/plugin.json +1 -1
- package/plugins/harness-everything/skills/harness-everything/SKILL.md +1 -1
- package/plugins/harness-everything/skills/harness-everything/scripts/system-one/layer.py +11 -1
- package/sbom.cdx.json +7 -7
- package/scripts/system-one-curves.js +72 -15
- package/scripts/system-one-cycle/evaluate.js +25 -13
- package/scripts/system-one-cycle/train.js +67 -25
- package/scripts/system-one-fit-layer.py +11 -1
|
@@ -93,6 +93,18 @@ function runGuarded(command, args, { maxRssMb = 6144, threads = 4, pollMs = 500,
|
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
function runGuardedSync(command, args, options) {
|
|
97
|
+
const script = `const { runGuarded } = require(${JSON.stringify(__filename)});
|
|
98
|
+
runGuarded(process.argv[1], JSON.parse(process.argv[2]), JSON.parse(process.argv[3])).then(
|
|
99
|
+
result => process.stdout.write(JSON.stringify(result)),
|
|
100
|
+
error => { process.stderr.write(error.message); process.exitCode = 1; });`;
|
|
101
|
+
const result = spawnSync(process.execPath, ['-e', script, command, JSON.stringify(args), JSON.stringify(options)], {
|
|
102
|
+
cwd: REPO, encoding: 'utf8', windowsHide: true,
|
|
103
|
+
});
|
|
104
|
+
if (result.error || result.status !== 0) throw new Error(`resource guard failed${result.status === null ? '' : ` (${result.status})`}`);
|
|
105
|
+
return JSON.parse(result.stdout);
|
|
106
|
+
}
|
|
107
|
+
|
|
96
108
|
function pythonExecutable() {
|
|
97
109
|
return process.env.PYTHON || (process.platform === 'win32' ? 'python' : 'python3');
|
|
98
110
|
}
|
|
@@ -173,7 +185,7 @@ function validateFitStage({ runDir, task, dataDir, checkpointPath, checkpointCon
|
|
|
173
185
|
try {
|
|
174
186
|
outcome = JSON.parse(fs.readFileSync(outcomePath, 'utf8'));
|
|
175
187
|
calibration = JSON.parse(fs.readFileSync(calibrationPath, 'utf8'));
|
|
176
|
-
} catch { throw new Error(`${task} fit outcome or calibration is missing or
|
|
188
|
+
} catch { throw new Error(`${task} fit outcome or calibration is missing, invalid, or stale`); }
|
|
177
189
|
const checkpoint = checkpointPath || path.join(runDir, 'harness-routing-v1.safetensors');
|
|
178
190
|
const checkpointConfig = checkpointConfigPath || path.join(runDir, 'harness-routing-v1.json');
|
|
179
191
|
const input = outcome.outcome === 'layer' ? 'val-scores-layered.jsonl' : 'val-scores.jsonl';
|
|
@@ -221,7 +233,7 @@ function validateFitStage({ runDir, task, dataDir, checkpointPath, checkpointCon
|
|
|
221
233
|
return { report, outcome, calibration, scorePath };
|
|
222
234
|
}
|
|
223
235
|
|
|
224
|
-
function fitLayerStage({ dataDir, runDir, task }) {
|
|
236
|
+
function fitLayerStage({ dataDir, runDir, task, run, maxRssMb = 6144, threads = 4, pollMs = 500, rssReader }) {
|
|
225
237
|
const fitter = path.join(REPO, 'scripts', 'system-one-fit-layer.py');
|
|
226
238
|
const calibrator = path.join(REPO, 'scripts', 'system-one-calibrate.js');
|
|
227
239
|
const bundle = dataPath(dataDir, 'training', task === 'validity' ? 'v1-validity' : 'v1');
|
|
@@ -256,28 +268,58 @@ function fitLayerStage({ dataDir, runDir, task }) {
|
|
|
256
268
|
}
|
|
257
269
|
} catch { /* Refit incomplete or stale stage artifacts below. */ }
|
|
258
270
|
}
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
271
|
+
const finishFit = () => {
|
|
272
|
+
const outcome = JSON.parse(fs.readFileSync(outcomeFile, 'utf8'));
|
|
273
|
+
if (!['layer', 'keep-base'].includes(outcome.outcome)) throw new Error(`layer fit for ${task} has no explicit outcome`);
|
|
274
|
+
const scores = outcome.outcome === 'layer' ? 'val-scores-layered.jsonl' : 'val-scores.jsonl';
|
|
275
|
+
if (outcome.outcome === 'layer' && (!fs.existsSync(path.join(runDir, 'layer.json'))
|
|
276
|
+
|| !fs.existsSync(path.join(runDir, scores)))) throw new Error(`layer fit for ${task} is incomplete`);
|
|
277
|
+
runNode(calibrator, [path.join(runDir, scores), path.join(runDir, 'calibration.json'), '--task', task,
|
|
278
|
+
'--catalog', path.join(runDir, 'train-report.json')]);
|
|
279
|
+
if (outcome.outcome === 'layer' && (!fs.existsSync(path.join(runDir, 'layer.json'))
|
|
280
|
+
|| !fs.existsSync(path.join(runDir, 'val-scores-layered.jsonl')))) throw new Error(`layer fit for ${task} is incomplete`);
|
|
281
|
+
outcome.calibrationInput = scores;
|
|
282
|
+
outcome.calibrationInputSha256 = sha256(path.join(runDir, scores));
|
|
283
|
+
outcome.calibrationSha256 = sha256(path.join(runDir, 'calibration.json'));
|
|
284
|
+
if (outcome.outcome === 'layer' && outcome.oofScoreSpace !== 'h-transform-v2')
|
|
285
|
+
throw new Error(`layer fit for ${task} does not prove corrected OOF score space`);
|
|
286
|
+
if (outcome.outcome === 'keep-base' && outcome.oofScoreSpace !== null)
|
|
287
|
+
throw new Error(`layer fit for ${task} has an invalid keep-base score-space marker`);
|
|
288
|
+
writeJson(outcomeFile, outcome);
|
|
289
|
+
validateFitStage({ runDir, task, dataDir });
|
|
290
|
+
return outcome;
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
const removeOutcome = () => fs.rmSync(outcomeFile, { force: true });
|
|
294
|
+
const discardFailedFit = () => writeJson(outcomeFile, { schemaVersion: 0, task, failedFit: true });
|
|
295
|
+
const completeGuardedFit = result => {
|
|
296
|
+
if (result.killedForLimit) {
|
|
297
|
+
discardFailedFit();
|
|
298
|
+
throw new Error(`layer fit for ${task} exceeded the ${maxRssMb} MB RSS limit`);
|
|
299
|
+
}
|
|
300
|
+
if (result.monitorFailed) {
|
|
301
|
+
discardFailedFit();
|
|
302
|
+
throw new Error(`system-one-fit-layer.py failed (RSS monitoring failed)`);
|
|
303
|
+
}
|
|
304
|
+
if (result.exitCode !== 0) {
|
|
305
|
+
discardFailedFit();
|
|
306
|
+
throw new Error(`system-one-fit-layer.py failed${result.exitCode === null ? '' : ` (${result.exitCode})`}`);
|
|
307
|
+
}
|
|
308
|
+
try { return finishFit(); }
|
|
309
|
+
catch (error) { discardFailedFit(); throw error; }
|
|
310
|
+
};
|
|
311
|
+
removeOutcome();
|
|
312
|
+
let guarded;
|
|
313
|
+
try {
|
|
314
|
+
guarded = (run || runGuardedSync)(pythonExecutable(), [fitter, '--run-dir', runDir, '--data-dir', bundle,
|
|
315
|
+
'--task', task, '--holdout', holdout], { maxRssMb, threads, pollMs, rssReader });
|
|
316
|
+
} catch (error) {
|
|
317
|
+
discardFailedFit();
|
|
318
|
+
throw error;
|
|
319
|
+
}
|
|
320
|
+
if (guarded && typeof guarded.then === 'function')
|
|
321
|
+
return guarded.then(completeGuardedFit, error => { discardFailedFit(); throw error; });
|
|
322
|
+
return completeGuardedFit(guarded);
|
|
281
323
|
}
|
|
282
324
|
|
|
283
325
|
async function trainCycle({ dataDir, version, threads = 4, maxRssMb = 6144, run = runGuarded }) {
|
|
@@ -312,7 +354,7 @@ async function trainCycle({ dataDir, version, threads = 4, maxRssMb = 6144, run
|
|
|
312
354
|
trained++;
|
|
313
355
|
}
|
|
314
356
|
if (!hasTrainerReport(out, task)) throw new Error(`training ${task} has no valid trainer report`);
|
|
315
|
-
const outcome = fitLayerStage({ dataDir: privateDir, runDir: out, task });
|
|
357
|
+
const outcome = await fitLayerStage({ dataDir: privateDir, runDir: out, task, run, threads, maxRssMb });
|
|
316
358
|
validateFitStage({ runDir: out, task, dataDir: privateDir });
|
|
317
359
|
if (fs.existsSync(guardFile)) outputs.push(`training/runs/${version}/${task}/resource-guard.json`);
|
|
318
360
|
if (outcome) {
|
|
@@ -58,6 +58,14 @@ def row_nll(rows, predictions, task):
|
|
|
58
58
|
return loss / len(rows)
|
|
59
59
|
|
|
60
60
|
|
|
61
|
+
def nll_evidence(selected, rows, oof_predictions, task):
|
|
62
|
+
"""Name recipe-selection loss separately from cross-fit validation loss."""
|
|
63
|
+
return {'fitNll': selected['nll'], 'fitNllSource': 'full-validation-recipe-selection',
|
|
64
|
+
'baseFitNll': selected['baseNll'], 'baseFitNllSource': 'full-validation-base-scores',
|
|
65
|
+
'oofNll': row_nll(rows, oof_predictions, task),
|
|
66
|
+
'oofNllSource': 'two-fold-cross-fit-validation'}
|
|
67
|
+
|
|
68
|
+
|
|
61
69
|
def _layered_scores(logits, row, task, recipe, knn, layer_api, neighbor_distribution=None):
|
|
62
70
|
q = layer_api.transform(logits, task, recipe['temperature'], recipe['bias'])
|
|
63
71
|
if recipe['alpha']:
|
|
@@ -318,6 +326,7 @@ def fit_layer(run_dir, data_dir, task, holdout):
|
|
|
318
326
|
neighbor_distributions = precompute_knn(rows, task, knn, logits_by_id)
|
|
319
327
|
recipes, oof = cross_fit(rows, logits_by_id, task, knn, layer_api, fit_temp_bias, neighbor_distributions)
|
|
320
328
|
final = select_recipe(rows, logits_by_id, task, knn, layer_api, fit_temp_bias, neighbor_distributions)
|
|
329
|
+
evidence = nll_evidence(final, rows, oof, task)
|
|
321
330
|
output_rows = score_rows(rows, report['catalog'], task, oof)
|
|
322
331
|
output = Path(run_dir)
|
|
323
332
|
write_private(output / 'val-scores-layered.jsonl', ''.join(json.dumps(row, separators=(',', ':')) + '\n' for row in output_rows))
|
|
@@ -329,6 +338,7 @@ def fit_layer(run_dir, data_dir, task, holdout):
|
|
|
329
338
|
'validationIds': [row['id'] for row in rows], 'folds': recipes,
|
|
330
339
|
'candidate': final['candidate'], 'temperature': final['temperature'], 'alpha': final['alpha'],
|
|
331
340
|
'baseNll': final['baseNll'], 'selectedNll': final['nll'],
|
|
341
|
+
**evidence,
|
|
332
342
|
'oofScoreSpace': oof_score_space(final['candidate'])}
|
|
333
343
|
if final['candidate'] == 'keep-base':
|
|
334
344
|
for filename in ('layer.json', 'val-scores-layered.jsonl'):
|
|
@@ -341,7 +351,7 @@ def fit_layer(run_dir, data_dir, task, holdout):
|
|
|
341
351
|
'temperature': final['temperature'], 'bias': final['bias'], 'alpha': final['alpha'],
|
|
342
352
|
'k': 15, 'ngrams': [3, 4, 5], 'maxChars': 2000, 'index': index,
|
|
343
353
|
'fit': {'candidate': final['candidate'], 'heldOutRows': len(rows), 'nll': final['nll'],
|
|
344
|
-
'baseNll': final['baseNll'], 'oof': True}}
|
|
354
|
+
'baseNll': final['baseNll'], 'oof': True, **evidence}}
|
|
345
355
|
write_private(output / 'layer.json', json.dumps(layer, separators=(',', ':')) + '\n')
|
|
346
356
|
outcome['outcome'] = 'layer'
|
|
347
357
|
outcome['layerSha256'] = trainer.sha256_file(output / 'layer.json')
|