harness-everything 1.4.0 → 1.5.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.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.github/workflows/release.yml +16 -5
- package/CHANGELOG.md +25 -0
- package/ci/fixtures/system-one-colab-fit-layer-sitecustomize.py +72 -0
- package/ci/mechanism-2x-release-automation.test.js +17 -0
- package/ci/mechanism-system-one-colab.test.js +83 -5
- package/ci/mechanism-system-one-contract.test.js +30 -0
- package/ci/mechanism-system-one-curves.test.js +85 -0
- package/ci/mechanism-system-one-cycle.test.js +344 -34
- package/ci/mechanism-system-one-install.test.js +47 -0
- package/ci/mechanism-system-one-provider.test.js +2 -0
- package/ci/mechanism-system-one-resident.test.js +69 -0
- package/ci/system-one-adapter-test.py +86 -0
- package/ci/system-one-fit-layer-test.py +371 -0
- package/ci/system-one-layer-test.py +122 -0
- package/harness-everything/SKILL.md +1 -1
- package/harness-everything/scripts/system-one/cua_adapter.py +36 -1
- package/harness-everything/scripts/system-one/install.js +10 -0
- package/harness-everything/scripts/system-one/layer.py +178 -0
- package/harness-everything/scripts/system-one/manifest.js +8 -1
- package/harness-everything/scripts/system-one/provider.js +12 -2
- 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/cua_adapter.py +36 -1
- package/plugins/harness-everything/skills/harness-everything/scripts/system-one/install.js +10 -0
- package/plugins/harness-everything/skills/harness-everything/scripts/system-one/layer.py +178 -0
- package/plugins/harness-everything/skills/harness-everything/scripts/system-one/manifest.js +8 -1
- package/plugins/harness-everything/skills/harness-everything/scripts/system-one/provider.js +12 -2
- package/sbom.cdx.json +7 -7
- package/scripts/system-one-colab.js +6 -4
- package/scripts/system-one-curves.js +52 -8
- package/scripts/system-one-cycle/evaluate.js +56 -5
- package/scripts/system-one-cycle/package.js +61 -3
- package/scripts/system-one-cycle/score.py +23 -2
- package/scripts/system-one-cycle/train.js +212 -20
- package/scripts/system-one-fit-layer.py +369 -0
|
@@ -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": "1.
|
|
13
|
+
"version": "1.5.0",
|
|
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": "1.
|
|
4
|
+
"version": "1.5.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Miya Daniel"
|
|
7
7
|
},
|
|
@@ -16,7 +16,7 @@ permissions:
|
|
|
16
16
|
contents: write
|
|
17
17
|
issues: write
|
|
18
18
|
pull-requests: write
|
|
19
|
-
id-token:
|
|
19
|
+
id-token: none
|
|
20
20
|
|
|
21
21
|
jobs:
|
|
22
22
|
# Release publication waits for the full CI matrix and document governance.
|
|
@@ -29,6 +29,12 @@ jobs:
|
|
|
29
29
|
release:
|
|
30
30
|
needs: [gate, doc-governance]
|
|
31
31
|
runs-on: ubuntu-latest
|
|
32
|
+
# Only the release job may request npm's publishing identity.
|
|
33
|
+
permissions:
|
|
34
|
+
contents: write
|
|
35
|
+
issues: write
|
|
36
|
+
pull-requests: write
|
|
37
|
+
id-token: write
|
|
32
38
|
steps:
|
|
33
39
|
- name: Checkout full release history
|
|
34
40
|
uses: actions/checkout@v7
|
|
@@ -44,8 +50,14 @@ jobs:
|
|
|
44
50
|
uses: actions/setup-node@v7
|
|
45
51
|
with:
|
|
46
52
|
node-version: 24
|
|
47
|
-
|
|
48
|
-
|
|
53
|
+
# Avoid a token-based .npmrc and dependency caching in the release job.
|
|
54
|
+
package-manager-cache: false
|
|
55
|
+
|
|
56
|
+
- name: Verify npm trusted publishing CLI
|
|
57
|
+
run: |
|
|
58
|
+
node --version
|
|
59
|
+
npm --version
|
|
60
|
+
node -e 'const [major, minor, patch] = process.argv[1].split(".").map(Number); if (major < 11 || (major === 11 && (minor < 5 || (minor === 5 && patch < 1)))) { console.error("npm >= 11.5.1 is required for trusted publishing"); process.exit(1); }' "$(npm --version)"
|
|
49
61
|
|
|
50
62
|
- name: Install project dependencies
|
|
51
63
|
run: npm ci
|
|
@@ -71,8 +83,7 @@ jobs:
|
|
|
71
83
|
- name: Calculate, prepare, and publish release
|
|
72
84
|
env:
|
|
73
85
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
74
|
-
|
|
75
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
86
|
+
# npm authentication is provided by trusted publishing (OIDC).
|
|
76
87
|
NPM_CONFIG_PROVENANCE: "true"
|
|
77
88
|
# An SSH repository URL makes semantic-release push with the deploy key
|
|
78
89
|
# (its SSH auth check runs before any token fallback).
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.5.0](https://github.com/dyphn1/Harness-everything/compare/v1.4.0...v1.5.0) (2026-12-01)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **system-one:** [#567](https://github.com/dyphn1/Harness-everything/issues/567) pipeline fits the h layer with out-of-fold calibration and packages it ([35903ee](https://github.com/dyphn1/Harness-everything/commit/35903ee566630f412d2258dc62ca3a1b93acb305))
|
|
10
|
+
* **system-one:** [#567](https://github.com/dyphn1/Harness-everything/issues/567) runtime verifies and applies the per-stage echl h layer ([2294159](https://github.com/dyphn1/Harness-everything/commit/2294159499810471794b46a28eea9352c60b2d79))
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* **system-one:** a new-cycle stage completes only with a validated fit outcome ([ac802b7](https://github.com/dyphn1/Harness-everything/commit/ac802b7fc70a5d740608b1f4af91fdd80c56ed44))
|
|
15
|
+
* **system-one:** bind the checkpoint config bytes to the fit evidence ([9cd2b4d](https://github.com/dyphn1/Harness-everything/commit/9cd2b4de762ccdf3827575cadcfbb9308a962257))
|
|
16
|
+
* **system-one:** fitter reads labels through the trainer and guards base nll parity ([46a1fce](https://github.com/dyphn1/Harness-everything/commit/46a1fce5964bb40d962f41b9b715c2cb28170eca))
|
|
17
|
+
* **system-one:** keep the unlayered curves contract while checking layered provenance ([2a4a9ee](https://github.com/dyphn1/Harness-everything/commit/2a4a9eedec2d188e42d6155f82f8c18173c643a1))
|
|
18
|
+
* **system-one:** layered oof calibration uses one h score space ([50b6360](https://github.com/dyphn1/Harness-everything/commit/50b63600200157d0c646bc8b2f636a8b077aff2b))
|
|
19
|
+
* **system-one:** load the layer module by path so file-loaded adapters import it ([457c60a](https://github.com/dyphn1/Harness-everything/commit/457c60a2174d716a59add1ebc765996815604949))
|
|
20
|
+
* **system-one:** load the layer module without writing bytecode into the shipped tree ([476542e](https://github.com/dyphn1/Harness-everything/commit/476542e799207f73d36df513502cd584ec9126fc))
|
|
21
|
+
|
|
22
|
+
### Performance Improvements
|
|
23
|
+
|
|
24
|
+
* **system-one:** build the layer knn index once at load, not per request ([73f54db](https://github.com/dyphn1/Harness-everything/commit/73f54dbf78816d3a2e63c958675c5eb567a8b291))
|
|
25
|
+
|
|
5
26
|
## [1.4.0](https://github.com/dyphn1/Harness-everything/compare/v1.3.2...v1.4.0) (2026-11-29)
|
|
6
27
|
|
|
7
28
|
### Features
|
|
@@ -317,6 +338,10 @@ Claude-Session: https://claude.ai/code/session_01RPz4xUrN12wGoL19istZUE
|
|
|
317
338
|
|
|
318
339
|
## [Unreleased]
|
|
319
340
|
|
|
341
|
+
### System One external layer (ECHL arm H)
|
|
342
|
+
|
|
343
|
+
* **system-one:** a version may now carry a per-stage `<stage>.layer.json` (temperature, per-option bias and a char-gram kNN blend over the train split) recorded in the manifest as `layer` + `layerSha256`. Install, activation, the provider and the resident verify it like the weights and include it in the active identity; versions without a layer score exactly as before. The cycle fits the layer on the trainer's validation split with two-fold out-of-fold selection, calibrates thresholds on the out-of-fold scores, and packages it (`scripts/system-one-fit-layer.py`). Training data and the kNN index stay private (#567).
|
|
344
|
+
|
|
320
345
|
### System One training on Colab
|
|
321
346
|
|
|
322
347
|
* **system-one:** `scripts/system-one-train.py` accepts `--device cpu|cuda|auto` (default `cpu`, CPU outputs unchanged) and records `device` and `torch` in the checkpoint metadata and `train-report.json`. The new `scripts/system-one-colab.js` runs the cycle `train` stage on a Google Colab VM through `google-colab-cli`: it uploads only the built `training/v1*` files plus the public trainer and catalog fixtures under a sha256 manifest, accepts each stage only from a downloaded `remote-status.json` with per-file hashes, always stops the VM, and leaves a run dir that the unchanged local `evaluate` → `package` path accepts (#563).
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"""Controlled fitter output for the System One Colab launcher mechanism test."""
|
|
2
|
+
import hashlib
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
_FITTER = os.environ.get('S1_COLAB_FIT_LAYER_SCRIPT')
|
|
9
|
+
if (_FITTER and sys.argv and os.path.normcase(os.path.realpath(sys.argv[0]))
|
|
10
|
+
== os.path.normcase(os.path.realpath(_FITTER))
|
|
11
|
+
and os.environ.get('S1_COLAB_FIT_LAYER_FIXTURE') == '1'):
|
|
12
|
+
try:
|
|
13
|
+
names = ('--run-dir', '--data-dir', '--task', '--holdout')
|
|
14
|
+
args = sys.argv[1:]
|
|
15
|
+
if len(args) != len(names) * 2:
|
|
16
|
+
raise ValueError('expected run-dir, data-dir, task, and holdout exactly once')
|
|
17
|
+
values = {}
|
|
18
|
+
for name, value in zip(args[::2], args[1::2]):
|
|
19
|
+
if name not in names or name in values or not value:
|
|
20
|
+
raise ValueError('expected run-dir, data-dir, task, and holdout exactly once')
|
|
21
|
+
values[name] = value
|
|
22
|
+
if set(values) != set(names):
|
|
23
|
+
raise ValueError('expected run-dir, data-dir, task, and holdout exactly once')
|
|
24
|
+
|
|
25
|
+
run_dir = Path(values['--run-dir'])
|
|
26
|
+
data_dir = Path(values['--data-dir'])
|
|
27
|
+
task = values['--task']
|
|
28
|
+
if task not in ('validity', 'intent', 'tier'):
|
|
29
|
+
raise ValueError('unknown fixture task')
|
|
30
|
+
report_path = run_dir / 'train-report.json'
|
|
31
|
+
report = json.loads(report_path.read_text(encoding='utf-8'))
|
|
32
|
+
if report.get('task') != task or not isinstance(report.get('catalog'), list):
|
|
33
|
+
raise ValueError('fixture trainer report is invalid')
|
|
34
|
+
checkpoint_path = run_dir / 'harness-routing-v1.safetensors'
|
|
35
|
+
scores_path = run_dir / 'val-scores.jsonl'
|
|
36
|
+
for required in (checkpoint_path, scores_path, Path(values['--holdout'])):
|
|
37
|
+
if not required.is_file():
|
|
38
|
+
raise ValueError('fixture fitter input is missing')
|
|
39
|
+
|
|
40
|
+
digest = lambda file: hashlib.sha256(Path(file).read_bytes()).hexdigest()
|
|
41
|
+
label_file = 'labels-intent.jsonl' if task == 'intent' else 'labels.jsonl'
|
|
42
|
+
datasets = {name: digest(data_dir / name) for name in ('prompts.jsonl', label_file)}
|
|
43
|
+
validation = [json.loads(line) for line in scores_path.read_text(encoding='utf-8').splitlines() if line.strip()]
|
|
44
|
+
layered_path = run_dir / 'val-scores-layered.jsonl'
|
|
45
|
+
layered_path.write_text(''.join(json.dumps(row, separators=(',', ':')) + '\n' for row in validation), encoding='utf-8')
|
|
46
|
+
layer_path = run_dir / 'layer.json'
|
|
47
|
+
layer_path.write_text(json.dumps({
|
|
48
|
+
'schemaVersion': 1, 'kind': 'echl-h', 'stage': task, 'options': report['catalog'],
|
|
49
|
+
'temperature': 1, 'bias': None, 'alpha': 0, 'k': 15, 'ngrams': [3, 4, 5],
|
|
50
|
+
'maxChars': 2000, 'index': [],
|
|
51
|
+
'fit': {'candidate': 'H-temp', 'heldOutRows': len(validation), 'nll': 0.2, 'baseNll': 0.3, 'oof': True},
|
|
52
|
+
}, separators=(',', ':')) + '\n', encoding='utf-8')
|
|
53
|
+
outcome = {
|
|
54
|
+
'schemaVersion': 1, 'task': task, 'outcome': 'layer', 'datasetSha256': datasets,
|
|
55
|
+
'checkpointSha256': digest(checkpoint_path), 'checkpointConfigSha256': digest(run_dir / 'harness-routing-v1.json'),
|
|
56
|
+
'trainerReportSha256': digest(report_path),
|
|
57
|
+
'holdoutSha256': digest(values['--holdout']), 'validationIds': [row['id'] for row in validation],
|
|
58
|
+
'folds': [], 'candidate': 'H-temp', 'temperature': 1, 'alpha': 0,
|
|
59
|
+
'baseNll': 0.3, 'selectedNll': 0.2, 'layerSha256': digest(layer_path),
|
|
60
|
+
'calibrationInput': 'val-scores-layered.jsonl', 'calibrationInputSha256': digest(layered_path),
|
|
61
|
+
}
|
|
62
|
+
(run_dir / 'layer-outcome.json').write_text(json.dumps(outcome, indent=2) + '\n', encoding='utf-8')
|
|
63
|
+
with open(os.environ['S1_COLAB_FIT_LAYER_LOG'], 'a', encoding='utf-8') as stream:
|
|
64
|
+
stream.write(json.dumps({'task': task, 'runDir': str(run_dir)}) + '\n')
|
|
65
|
+
except Exception as error:
|
|
66
|
+
sys.stderr.write('S1 Colab fixture fitter: ' + str(error) + '\n')
|
|
67
|
+
sys.stderr.flush()
|
|
68
|
+
sys.stdout.flush()
|
|
69
|
+
os._exit(2)
|
|
70
|
+
sys.stdout.flush()
|
|
71
|
+
sys.stderr.flush()
|
|
72
|
+
os._exit(0)
|
|
@@ -14,6 +14,23 @@ assert.deepStrictEqual(config.branches, ['main']);
|
|
|
14
14
|
assert.ok(config.branches.every(branch => typeof branch === 'string'), 'release branches must not declare prerelease channels');
|
|
15
15
|
assert.strictEqual(config.tagFormat, 'v${version}');
|
|
16
16
|
|
|
17
|
+
// The npm release must authenticate through the trusted workflow identity only.
|
|
18
|
+
const releaseWorkflow = require('js-yaml').load(fs.readFileSync(path.join(ROOT, '.github/workflows/release.yml'), 'utf8'));
|
|
19
|
+
const releaseJob = releaseWorkflow.jobs.release;
|
|
20
|
+
assert.strictEqual(releaseWorkflow.permissions['id-token'], 'none', 'non-publishing jobs must not inherit OIDC permission');
|
|
21
|
+
assert.strictEqual(releaseJob.permissions['id-token'], 'write', 'publish job must have OIDC permission');
|
|
22
|
+
const setupNode = releaseJob.steps.find(step => step.uses && step.uses.startsWith('actions/setup-node@'));
|
|
23
|
+
assert.ok(setupNode, 'release Node setup is required');
|
|
24
|
+
assert.strictEqual(setupNode.with['package-manager-cache'], false, 'release build must not use dependency caching');
|
|
25
|
+
assert.ok(!Object.hasOwn(setupNode.with, 'registry-url'), 'setup-node must not create a token-based npmrc for semantic-release');
|
|
26
|
+
const publish = releaseJob.steps.find(step => step.run && step.run.includes('npx --no-install semantic-release'));
|
|
27
|
+
assert.ok(publish, 'semantic-release publish step is required');
|
|
28
|
+
for (const key of ['NPM_TOKEN', 'NODE_AUTH_TOKEN']) {
|
|
29
|
+
assert.ok(!Object.hasOwn(publish.env || {}, key), `publish must not inject ${key}`);
|
|
30
|
+
assert.ok(!Object.hasOwn(releaseJob.env || {}, key), `release job must not inject ${key}`);
|
|
31
|
+
assert.ok(!Object.hasOwn(releaseWorkflow.env || {}, key), `release workflow must not inject ${key}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
17
34
|
const analyzer = config.plugins.find(plugin => Array.isArray(plugin) && plugin[0] === '@semantic-release/commit-analyzer');
|
|
18
35
|
assert.ok(analyzer, 'commit analyzer configuration missing');
|
|
19
36
|
const rules = new Map(analyzer[1].releaseRules.filter(rule => rule.type).map(rule => [rule.type, rule.release]));
|
|
@@ -14,6 +14,8 @@ const { remoteRunner } = require('../scripts/system-one-colab');
|
|
|
14
14
|
const skipNoColabCli = process.platform === 'win32' && 'google-colab-cli supports Linux and macOS only';
|
|
15
15
|
const launcher = path.join(REPO, 'scripts', 'system-one-colab.js');
|
|
16
16
|
const cycleCli = path.join(REPO, 'scripts', 'system-one-cycle.js');
|
|
17
|
+
const fitter = path.join(REPO, 'scripts', 'system-one-fit-layer.py');
|
|
18
|
+
const fitterFixture = path.join(__dirname, 'fixtures', 'system-one-colab-fit-layer-sitecustomize.py');
|
|
17
19
|
const allowed = [
|
|
18
20
|
'training/v1/prompts.jsonl', 'training/v1/labels.jsonl', 'training/v1/labels-intent.jsonl',
|
|
19
21
|
'training/v1-validity/prompts.jsonl', 'training/v1-validity/labels.jsonl',
|
|
@@ -44,6 +46,13 @@ function fixture(t) {
|
|
|
44
46
|
}
|
|
45
47
|
const fakeRoot = path.join(root, 'fake-colab');
|
|
46
48
|
const log = path.join(root, 'colab.jsonl');
|
|
49
|
+
const fitterDir = path.join(root, 'python-fixture');
|
|
50
|
+
const fitterLog = path.join(root, 'fit-layer.jsonl');
|
|
51
|
+
fs.mkdirSync(fitterDir, { recursive: true, mode: 0o700 });
|
|
52
|
+
const fitterSource = fs.readFileSync(fitterFixture, 'utf8').replace(
|
|
53
|
+
"'schemaVersion': 1, 'task': task, 'outcome': 'layer', 'datasetSha256': datasets,",
|
|
54
|
+
"'schemaVersion': 1, 'task': task, 'outcome': 'layer', 'oofScoreSpace': 'h-transform-v2', 'datasetSha256': datasets,");
|
|
55
|
+
fs.writeFileSync(path.join(fitterDir, 'sitecustomize.py'), fitterSource, { mode: 0o600 });
|
|
47
56
|
const bin = path.join(root, 'colab');
|
|
48
57
|
fs.writeFileSync(bin, `#!/usr/bin/env node
|
|
49
58
|
'use strict';
|
|
@@ -103,7 +112,14 @@ if (a[0] === 'upload') {
|
|
|
103
112
|
const validationGold = catalog[0];
|
|
104
113
|
fs.writeFileSync(path.join(out, 'val-scores.jsonl'), JSON.stringify({ id: 'synthetic-validation', gold: validationGold,
|
|
105
114
|
scores: Object.fromEntries(catalog.map(id => [id, id === validationGold ? 0.99 : 0.01])) }) + '\\n');
|
|
106
|
-
|
|
115
|
+
const labelFile = task === 'intent' ? 'labels-intent.jsonl' : 'labels.jsonl';
|
|
116
|
+
const sha256 = file => crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex');
|
|
117
|
+
const trainReport = { schemaVersion: 1, task, target: 'label', catalog, config: {},
|
|
118
|
+
counts: { train: 1, validation: 1, test: 0 }, bestEpoch: 1, history: [], device: 'cpu', torch: 'fixture', datasets: {
|
|
119
|
+
'prompts.jsonl': sha256(remotePath('training/' + (task === 'validity' ? 'v1-validity' : 'v1') + '/prompts.jsonl')),
|
|
120
|
+
[labelFile]: sha256(remotePath('training/' + (task === 'validity' ? 'v1-validity' : 'v1') + '/' + labelFile)),
|
|
121
|
+
} };
|
|
122
|
+
fs.writeFileSync(path.join(out, 'train-report.json'), process.env.FAKE_COLAB_BAD_CATALOG === task ? '{' : JSON.stringify(trainReport));
|
|
107
123
|
const files = ['harness-routing-v1.safetensors','harness-routing-v1.json','val-scores.jsonl','train-report.json'];
|
|
108
124
|
const status = { schemaVersion: 1, ok: true, task, version, invocationId,
|
|
109
125
|
manifestSha256: process.env.FAKE_COLAB_STATUS_MANIFEST_SHA256 || expectedManifestSha256,
|
|
@@ -116,9 +132,17 @@ if (a[0] === 'upload') {
|
|
|
116
132
|
} else { record(); }
|
|
117
133
|
`, { mode: 0o700 });
|
|
118
134
|
const env = { ...process.env, FAKE_COLAB_ROOT: fakeRoot, FAKE_COLAB_LOG: log };
|
|
135
|
+
env.PYTHON = process.platform === 'win32' ? 'python' : 'python3';
|
|
136
|
+
env.PYTHONPATH = fitterDir;
|
|
137
|
+
env.PYTHONNOUSERSITE = '1';
|
|
138
|
+
env.PYTHONDONTWRITEBYTECODE = '1';
|
|
139
|
+
env.S1_COLAB_FIT_LAYER_FIXTURE = '1';
|
|
140
|
+
env.S1_COLAB_FIT_LAYER_SCRIPT = fitter;
|
|
141
|
+
env.S1_COLAB_FIT_LAYER_LOG = fitterLog;
|
|
142
|
+
delete env.PYTHONHOME;
|
|
119
143
|
delete env.HARNESS_SYSTEM_ONE_MODE;
|
|
120
144
|
t.after(() => fs.rmSync(root, { recursive: true, force: true }));
|
|
121
|
-
return { dataDir, fakeRoot, log, bin, env };
|
|
145
|
+
return { dataDir, fakeRoot, log, fitterLog, bin, env };
|
|
122
146
|
}
|
|
123
147
|
|
|
124
148
|
function run(f, extra = []) {
|
|
@@ -134,6 +158,27 @@ function stageDir(f, task) {
|
|
|
134
158
|
return path.join(f.dataDir, 'training', 'runs', 'synthetic-v1', task);
|
|
135
159
|
}
|
|
136
160
|
|
|
161
|
+
function assertLayerOutcome(f, task) {
|
|
162
|
+
const stage = stageDir(f, task);
|
|
163
|
+
const outcome = JSON.parse(fs.readFileSync(path.join(stage, 'layer-outcome.json'), 'utf8'));
|
|
164
|
+
assert.equal(outcome.task, task);
|
|
165
|
+
assert.equal(outcome.outcome, 'layer');
|
|
166
|
+
assert.equal(outcome.oofScoreSpace, 'h-transform-v2');
|
|
167
|
+
assert.equal(outcome.checkpointConfigSha256,
|
|
168
|
+
crypto.createHash('sha256').update(fs.readFileSync(path.join(stage, 'harness-routing-v1.json'))).digest('hex'));
|
|
169
|
+
assert.equal(outcome.calibrationInput, 'val-scores-layered.jsonl');
|
|
170
|
+
assert.equal(outcome.calibrationInputSha256,
|
|
171
|
+
crypto.createHash('sha256').update(fs.readFileSync(path.join(stage, 'val-scores-layered.jsonl'))).digest('hex'));
|
|
172
|
+
assert.equal(outcome.calibrationSha256,
|
|
173
|
+
crypto.createHash('sha256').update(fs.readFileSync(path.join(stage, 'calibration.json'))).digest('hex'));
|
|
174
|
+
assert.equal(JSON.parse(fs.readFileSync(path.join(stage, 'layer.json'), 'utf8')).stage, task);
|
|
175
|
+
assert.equal(JSON.parse(fs.readFileSync(path.join(stage, 'calibration.json'), 'utf8')).task, task);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function fitLayerCalls(f) {
|
|
179
|
+
return fs.readFileSync(f.fitterLog, 'utf8').trim().split(/\r?\n/).filter(Boolean).map(JSON.parse);
|
|
180
|
+
}
|
|
181
|
+
|
|
137
182
|
async function assertIntentRetryReachesTrainCycle(f) {
|
|
138
183
|
const calls = [];
|
|
139
184
|
await assert.rejects(trainCycle({ dataDir: f.dataDir, version: 'synthetic-v1', run: async (_bin, args) => {
|
|
@@ -195,7 +240,8 @@ if sys.argv and os.path.realpath(sys.argv[0]) == os.path.realpath(_SCORE_SCRIPT)
|
|
|
195
240
|
sys.stderr.flush()
|
|
196
241
|
os._exit(0)
|
|
197
242
|
`);
|
|
198
|
-
|
|
243
|
+
fs.appendFileSync(path.join(scorerDir, 'sitecustomize.py'), `\n${fs.readFileSync(fitterFixture, 'utf8')}`);
|
|
244
|
+
const env = { ...f.env, PYTHON: f.env.PYTHON, PYTHONPATH: scorerDir,
|
|
199
245
|
PYTHONNOUSERSITE: '1', PYTHONDONTWRITEBYTECODE: '1' };
|
|
200
246
|
const history = path.join(path.dirname(f.bin), 'synthetic-history.jsonl');
|
|
201
247
|
for (const step of ['evaluate', 'package']) {
|
|
@@ -236,14 +282,46 @@ test('Colab launcher uploads only allow-listed data and produces stages trainCyc
|
|
|
236
282
|
const status = JSON.parse(fs.readFileSync(path.join(f.fakeRoot, 'runs', 'synthetic-v1', task, 'remote-status.json'), 'utf8'));
|
|
237
283
|
assert.match(status.invocationId, /^[0-9a-f-]{36}$/);
|
|
238
284
|
assert.equal(status.manifestSha256, manifestUpload.uploadedManifestSha256);
|
|
285
|
+
assertLayerOutcome(f, task);
|
|
239
286
|
}
|
|
287
|
+
assert.deepEqual(fitLayerCalls(f).map(row => row.task), TASKS);
|
|
240
288
|
const skipped = await trainCycle({ dataDir: f.dataDir, version: 'synthetic-v1', run: () => { throw new Error('unexpected local training'); } });
|
|
241
289
|
assert.equal(skipped.skipped, 3);
|
|
242
290
|
for (const task of TASKS) {
|
|
243
291
|
const stage = path.join(f.dataDir, 'training', 'runs', 'synthetic-v1', task);
|
|
244
|
-
|
|
245
|
-
|
|
292
|
+
const remote = JSON.parse(fs.readFileSync(path.join(stage, 'resource-guard.json'), 'utf8')).remote;
|
|
293
|
+
assert.equal(remote.provider, 'colab');
|
|
294
|
+
assert.equal(remote.gpu, 'T4');
|
|
295
|
+
assert.equal(remote.session, 'fake-session');
|
|
296
|
+
assert.match(remote.invocationId, /^[a-f0-9-]{36}$/);
|
|
297
|
+
assert.match(remote.manifestSha256, /^[a-f0-9]{64}$/);
|
|
298
|
+
assert.deepEqual(Object.keys(remote.files).sort(), ['harness-routing-v1.json', 'harness-routing-v1.safetensors', 'train-report.json', 'val-scores.jsonl']);
|
|
299
|
+
}
|
|
300
|
+
const priorColabCalls = logRows(f).length;
|
|
301
|
+
for (const task of TASKS) {
|
|
302
|
+
const outcomeFile = path.join(stageDir(f, task), 'layer-outcome.json');
|
|
303
|
+
const stale = JSON.parse(fs.readFileSync(outcomeFile, 'utf8'));
|
|
304
|
+
delete stale.oofScoreSpace;
|
|
305
|
+
fs.writeFileSync(outcomeFile, JSON.stringify(stale));
|
|
246
306
|
}
|
|
307
|
+
fs.writeFileSync(f.fitterLog, '');
|
|
308
|
+
const reused = run(f, ['--session', 'fake-session']);
|
|
309
|
+
assert.equal(reused.status, 0, reused.stderr);
|
|
310
|
+
assert.match(reused.stdout, /"trained":0,"skipped":3/);
|
|
311
|
+
assert.equal(logRows(f).length, priorColabCalls, 'complete stages should reuse without contacting Colab');
|
|
312
|
+
assert.deepEqual(fitLayerCalls(f).map(row => row.task), TASKS);
|
|
313
|
+
for (const task of TASKS) assertLayerOutcome(f, task);
|
|
314
|
+
const intentOutcomeFile = path.join(stageDir(f, 'intent'), 'layer-outcome.json');
|
|
315
|
+
const intentOutcome = JSON.parse(fs.readFileSync(intentOutcomeFile, 'utf8'));
|
|
316
|
+
intentOutcome.checkpointConfigSha256 = '0'.repeat(64);
|
|
317
|
+
fs.writeFileSync(intentOutcomeFile, JSON.stringify(intentOutcome));
|
|
318
|
+
fs.writeFileSync(f.fitterLog, '');
|
|
319
|
+
const refitted = run(f, ['--session', 'fake-session']);
|
|
320
|
+
assert.equal(refitted.status, 0, refitted.stderr);
|
|
321
|
+
assert.match(refitted.stdout, /"trained":0,"skipped":3/);
|
|
322
|
+
assert.equal(logRows(f).length, priorColabCalls, 'a stale local fit digest must not contact Colab again');
|
|
323
|
+
assert.deepEqual(fitLayerCalls(f).map(row => row.task), ['intent'], 'a digest mismatch refits through the shared local fitter');
|
|
324
|
+
assertLayerOutcome(f, 'intent');
|
|
247
325
|
assert.doesNotMatch(result.stdout, /synthetic"|PRIVATE-SENTINEL/);
|
|
248
326
|
});
|
|
249
327
|
|
|
@@ -2,13 +2,43 @@
|
|
|
2
2
|
const { test } = require('node:test');
|
|
3
3
|
const assert = require('node:assert/strict');
|
|
4
4
|
const { createRequest, validateRequest, validateResponse, decide } = require('../harness-everything/scripts/system-one/contract');
|
|
5
|
+
const { validateVersionManifest } = require('../harness-everything/scripts/system-one/manifest');
|
|
5
6
|
const options = [{ id: 'tier1', text: 'Bounded edit' }, { id: 'tier3', text: 'Architecture' }];
|
|
7
|
+
const hash = 'a'.repeat(64);
|
|
8
|
+
function versionManifest() {
|
|
9
|
+
const stages = {};
|
|
10
|
+
for (const stage of ['validity', 'intent', 'tier']) stages[stage] = {
|
|
11
|
+
weights: stage + '.safetensors', config: stage + '.json', sha256: hash,
|
|
12
|
+
options: ['a', 'b'], thresholds: { a: 0.5, b: 0.6 },
|
|
13
|
+
};
|
|
14
|
+
return { schemaVersion: 1, version: 'v1', createdAt: '2026-11-14T00:00:00Z', stages, evaluation: null };
|
|
15
|
+
}
|
|
6
16
|
const request = () => createRequest('tier', '修正 typo', options);
|
|
7
17
|
function response(req, p = [0.95, 0.05]) {
|
|
8
18
|
return { schemaVersion: 1, requestHash: req.requestHash, catalogHash: req.catalogHash,
|
|
9
19
|
model: { id: 'test', revision: 'test-v1', domain: 'harness-routing-v1' },
|
|
10
20
|
scores: req.options.map((o, i) => ({ id: o.id, probability: p[i] })) };
|
|
11
21
|
}
|
|
22
|
+
test('version manifest permits paired layer metadata and rejects incomplete or malformed layers', () => {
|
|
23
|
+
const legacy = versionManifest();
|
|
24
|
+
assert.equal(validateVersionManifest(legacy), legacy);
|
|
25
|
+
const layered = versionManifest();
|
|
26
|
+
layered.stages.tier.layer = 'tier.layer.json';
|
|
27
|
+
layered.stages.tier.layerSha256 = hash;
|
|
28
|
+
assert.equal(validateVersionManifest(layered), layered);
|
|
29
|
+
for (const mutate of [
|
|
30
|
+
manifest => { delete manifest.stages.tier.layerSha256; },
|
|
31
|
+
manifest => { manifest.stages.tier.layer = '../tier.layer.json'; },
|
|
32
|
+
manifest => { manifest.stages.tier.layer = 'tier.json'; },
|
|
33
|
+
manifest => { manifest.stages.tier.layerSha256 = 'bad'; },
|
|
34
|
+
]) {
|
|
35
|
+
const malformed = versionManifest();
|
|
36
|
+
malformed.stages.tier.layer = 'tier.layer.json';
|
|
37
|
+
malformed.stages.tier.layerSha256 = hash;
|
|
38
|
+
mutate(malformed);
|
|
39
|
+
assert.throws(() => validateVersionManifest(malformed));
|
|
40
|
+
}
|
|
41
|
+
});
|
|
12
42
|
test('S1-C01 complete response, no mutation and repeatability', () => {
|
|
13
43
|
const req = request(); const res = response(req); const before = JSON.stringify({ req, res });
|
|
14
44
|
assert.deepEqual(decide(req, res), { status: 'accepted', reason: 'scored', selectedId: 'tier1', confidence: 0.95, margin: 0.8999999999999999, model: res.model });
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
const { test } = require('node:test');
|
|
3
3
|
const fs = require('node:fs');
|
|
4
|
+
const crypto = require('node:crypto');
|
|
4
5
|
const os = require('node:os');
|
|
5
6
|
const path = require('node:path');
|
|
6
7
|
const { spawnSync } = require('node:child_process');
|
|
@@ -163,6 +164,90 @@ test('458 rejects a recorded version in a fresh cycle before writing artifacts',
|
|
|
163
164
|
assert.deepEqual(after.toString().trimEnd().split('\n').map(line => JSON.parse(line).version), ['v0', 'v1', 'v2']);
|
|
164
165
|
});
|
|
165
166
|
|
|
167
|
+
test('unlayered evaluations keep the legacy curves record fields', t => {
|
|
168
|
+
const f = fixture(t);
|
|
169
|
+
const { curves } = f.run({ val: validityRows([['invalid', 0.8], ['actionable', 0.2]]) });
|
|
170
|
+
assert.deepEqual(Object.keys(curves).sort(), ['createdAt', 'floor', 'schemaVersion', 'stages', 'version'].sort());
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
function layeredResumeFixture(t) {
|
|
174
|
+
const dir = fs.realpathSync.native(fs.mkdtempSync(path.join(os.tmpdir(), 'harness-s1-layered-curves-')));
|
|
175
|
+
t.after(() => fs.rmSync(dir, { recursive: true, force: true }));
|
|
176
|
+
const versionDir = path.join(dir, 'version');
|
|
177
|
+
const out = path.join(dir, 'out');
|
|
178
|
+
const history = path.join(dir, 'history.jsonl');
|
|
179
|
+
fs.mkdirSync(versionDir);
|
|
180
|
+
const hash = bytes => crypto.createHash('sha256').update(bytes).digest('hex');
|
|
181
|
+
const stages = {};
|
|
182
|
+
for (const [name, options] of Object.entries({ validity: ['invalid'], intent: ['fix'], tier: ['tier1'] })) {
|
|
183
|
+
const weights = `${name}.bin`;
|
|
184
|
+
const config = `${name}.json`;
|
|
185
|
+
fs.writeFileSync(path.join(versionDir, weights), `${name}-weights`);
|
|
186
|
+
fs.writeFileSync(path.join(versionDir, config), '{}\n');
|
|
187
|
+
stages[name] = { weights, config, sha256: hash(fs.readFileSync(path.join(versionDir, weights))), options,
|
|
188
|
+
thresholds: Object.fromEntries(options.map(option => [option, 0.5])) };
|
|
189
|
+
}
|
|
190
|
+
const layerBytes = Buffer.from('layer-v1');
|
|
191
|
+
const layerPath = path.join(versionDir, 'validity.layer.json');
|
|
192
|
+
fs.writeFileSync(layerPath, layerBytes);
|
|
193
|
+
Object.assign(stages.validity, { layer: 'validity.layer.json', layerSha256: hash(layerBytes) });
|
|
194
|
+
fs.writeFileSync(path.join(versionDir, 'manifest.json'), JSON.stringify({ schemaVersion: 1, version: 'v1',
|
|
195
|
+
createdAt: '2026-11-14T00:00:00.000Z', stages, evaluation: null }));
|
|
196
|
+
const valRows = {
|
|
197
|
+
validity: validityRows([['invalid', 0.8], ['actionable', 0.2]]),
|
|
198
|
+
intent: [{ id: 'iv0', gold: ['fix'], scores: { fix: 0.8 } }],
|
|
199
|
+
tier: [{ id: 'tv0', gold: 'tier1', scores: { tier1: 0.8 } }],
|
|
200
|
+
};
|
|
201
|
+
const holdoutRows = {
|
|
202
|
+
validity: validityRows([['invalid', 0.7], ['actionable', 0.3]]).map((row, i) => ({ ...row, id: `hv${i}` })),
|
|
203
|
+
intent: [{ id: 'ih0', gold: ['fix'], scores: { fix: 0.7 } }],
|
|
204
|
+
tier: [{ id: 'th0', gold: 'tier1', scores: { tier1: 0.7 } }],
|
|
205
|
+
};
|
|
206
|
+
const valFiles = {};
|
|
207
|
+
const holdoutFiles = {};
|
|
208
|
+
for (const name of Object.keys(stages)) {
|
|
209
|
+
valFiles[name] = path.join(dir, `${name}-val.jsonl`);
|
|
210
|
+
holdoutFiles[name] = path.join(dir, `${name}-holdout.jsonl`);
|
|
211
|
+
fs.writeFileSync(valFiles[name], `${valRows[name].map(row => JSON.stringify(row)).join('\n')}\n`);
|
|
212
|
+
fs.writeFileSync(holdoutFiles[name], `${holdoutRows[name].map(row => JSON.stringify(row)).join('\n')}\n`);
|
|
213
|
+
}
|
|
214
|
+
const baseArgs = [cli, '--version', 'v1', '--version-dir', versionDir, '--history', history, '--out', out];
|
|
215
|
+
for (const name of Object.keys(stages)) {
|
|
216
|
+
baseArgs.push('--val-scores', `${name}=${valFiles[name]}`);
|
|
217
|
+
baseArgs.push('--holdout-scores', `${name}=${holdoutFiles[name]}`);
|
|
218
|
+
}
|
|
219
|
+
const initial = spawnSync(process.execPath, baseArgs, { cwd: root, encoding: 'utf8', env: { ...process.env, HARNESS_SYSTEM_ONE_HOME: dir } });
|
|
220
|
+
assert.equal(initial.status, 0, initial.stderr);
|
|
221
|
+
const resume = () => spawnSync(process.execPath, [cli, '--version', 'v1', '--version-dir', versionDir,
|
|
222
|
+
'--history', history, '--out', out, '--resume-curves', path.join(out, 'curves.json'),
|
|
223
|
+
...Object.keys(stages).flatMap(name => ['--val-scores', `${name}=${valFiles[name]}`, '--holdout-scores', `${name}=${holdoutFiles[name]}`])],
|
|
224
|
+
{ cwd: root, encoding: 'utf8', env: { ...process.env, HARNESS_SYSTEM_ONE_HOME: dir } });
|
|
225
|
+
return { valFile: valFiles.validity, layerPath, resume };
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
test('layered resume rejects score files that differ from the saved evaluation', t => {
|
|
229
|
+
const { valFile, resume } = layeredResumeFixture(t);
|
|
230
|
+
fs.writeFileSync(valFile, `${JSON.stringify({ id: 'changed', gold: 'invalid', scores: { invalid: 0.8 } })}\n`);
|
|
231
|
+
const result = resume();
|
|
232
|
+
assert.notEqual(result.status, 0);
|
|
233
|
+
assert.match(result.stderr, /invalid arguments, manifest, history, or score input/);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
test('layered resume accepts the original score files and candidate', t => {
|
|
237
|
+
const { resume } = layeredResumeFixture(t);
|
|
238
|
+
const result = resume();
|
|
239
|
+
assert.equal(result.status, 0, result.stderr);
|
|
240
|
+
assert.deepEqual(JSON.parse(result.stdout), { resumed: true, version: 'v1' });
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
test('layered resume rejects a layer whose bytes changed after evaluation', t => {
|
|
244
|
+
const { layerPath, resume } = layeredResumeFixture(t);
|
|
245
|
+
fs.writeFileSync(layerPath, 'tampered layer');
|
|
246
|
+
const result = resume();
|
|
247
|
+
assert.notEqual(result.status, 0);
|
|
248
|
+
assert.match(result.stderr, /invalid arguments, manifest, history, or score input/);
|
|
249
|
+
});
|
|
250
|
+
|
|
166
251
|
test('446 H2: empty, LF, and CRLF histories append readable rows without rewriting prior bytes', t => {
|
|
167
252
|
const f = fixture(t);
|
|
168
253
|
const first = f.run({ version: 'v0', val: validityRows([['invalid', 0.8], ['actionable', 0.2]]) });
|