harness-everything 0.22.1 → 0.24.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/CHANGELOG.md +19 -0
- package/benchmarks/fixtures/system-one-holdout-draft.json +2039 -0
- package/benchmarks/fixtures/system-one-holdout-reviews.json +1587 -0
- package/benchmarks/fixtures/system-one-holdout.json +7315 -0
- package/benchmarks/results/system-one/labeler-holdout-check-2026-09-23/README.md +55 -0
- package/benchmarks/results/system-one/labeler-holdout-check-2026-09-23/report.json +1104 -0
- package/benchmarks/results/system-one/lexical-baseline-reviewed-holdout-2026-09-23/README.md +47 -0
- package/benchmarks/results/system-one/lexical-baseline-reviewed-holdout-2026-09-23/report.json +5222 -0
- package/ci/fixtures/system-one-resident-stub.py +3 -0
- package/ci/mechanism-system-one-collect.test.js +129 -0
- package/ci/mechanism-system-one-corpus.test.js +154 -0
- package/ci/mechanism-system-one-label.test.js +101 -0
- package/ci/mechanism-system-one-resident.test.js +36 -2
- package/ci/mechanism-system-one-router.test.js +13 -0
- package/ci/mechanism-system-one-train.test.js +82 -0
- package/ci/system-one-train-test.py +55 -0
- package/docs/system-one-corpus.md +103 -0
- package/docs/system-one-routing.md +10 -2
- package/docs/system-one-training.md +121 -0
- package/harness-everything/SKILL.md +1 -1
- package/harness-everything/scripts/system-one/provider.js +12 -5
- package/harness-everything/scripts/system-one/router.js +1 -1
- 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/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/provider.js +12 -5
- package/plugins/harness-everything/skills/harness-everything/scripts/system-one/router.js +1 -1
- package/sbom.cdx.json +7 -7
- package/scripts/evaluate-system-one.js +1 -1
- package/scripts/system-one-calibrate.js +44 -0
- package/scripts/system-one-collect.js +196 -0
- package/scripts/system-one-corpus.js +99 -0
- package/scripts/system-one-label.js +144 -0
- package/scripts/system-one-train.py +168 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# System One holdout corpus: labeling and review
|
|
2
|
+
|
|
3
|
+
This document defines how the reviewed tier holdout for
|
|
4
|
+
[System One](system-one-routing.md) is written, labeled, reviewed and
|
|
5
|
+
assembled (issue [#233](https://github.com/dyphn1/Harness-everything/issues/233),
|
|
6
|
+
Phase 3). The `reviewedHoldout` gate requires at least 200 holdout cases, at
|
|
7
|
+
least 50 per language, and `reviewed: true` on every case.
|
|
8
|
+
|
|
9
|
+
## Gold labels
|
|
10
|
+
|
|
11
|
+
A gold label answers one question: **which tier should Harness route this prompt
|
|
12
|
+
to, judged from the prompt alone?** The labels follow the tier model in
|
|
13
|
+
[routing.md](routing.md#three-tier-routing-model) and the fixed tier catalog.
|
|
14
|
+
|
|
15
|
+
| Gold | Use when the prompt asks for | Examples of shape |
|
|
16
|
+
| --- | --- | --- |
|
|
17
|
+
| `tier1` | Something answered or done without changing project behavior: Git/GitHub housekeeping (commit, push, open a PR, sync, tag, post given results as a comment), a status check, reading a log or searching and reporting, the smallest doc fix (a typo, a link, an ignore entry), or a reply the assistant can give directly, including non-engineering chores and discussion questions | "commit these changes", "is issue 88 still open?", "find every repo still using the old logging package", "close the other apps" |
|
|
18
|
+
| `tier2` | A bounded change or investigation: any code, configuration or CI edit (a rename, a value, a revert), running tests or a build, filing an issue, explaining code that must be read first, most bug fixes, a focused review or benchmark, planning or synthesis that produces documents (phase plans, an ADR, an overview), and answers that settle open decisions for work in progress | "rename tmp to buffer", "run npm test", "the CLI fails with this error, fix it", "1. agree 2. keep the old name" |
|
|
19
|
+
| `tier3` | New or changed behavior delivered with tests, and anything larger: a new flag or format, a behavior change across producers and tests, a large refactor, a dependency upgrade with breakage, a migration, a repository-wide change, a multi-phase implementation, or delegation to several agents | "add a --verbose flag with tests", "migrate to ESM", "dispatch agents to audit every repo" |
|
|
20
|
+
| `null` | No actionable content: a bare continuation, "do what you said", a vague reaction, a question about what the assistant meant, or pasted status with no request | "go", "yes", "照剛剛說的改", "something is off here" |
|
|
21
|
+
|
|
22
|
+
Rules:
|
|
23
|
+
|
|
24
|
+
1. Label the work the prompt would start. A reply that settles decisions for
|
|
25
|
+
work in progress ("1. agree 2. use hash") is labeled by that work, not `null`.
|
|
26
|
+
Use `null` only when no work can be identified at all.
|
|
27
|
+
2. Label the work requested, not the words used. Searching every repository and
|
|
28
|
+
reporting is `tier1`; changing every repository is `tier3`.
|
|
29
|
+
3. Pick the smallest tier that covers the whole request.
|
|
30
|
+
4. Explicit workflow words ("use fable", "no subagents") do not change the gold.
|
|
31
|
+
Precedence is a router policy, not a label.
|
|
32
|
+
5. Never derive gold from the lexical router or any model output. A reviewer may
|
|
33
|
+
read the proposed gold, but the recorded gold is the reviewer's decision.
|
|
34
|
+
|
|
35
|
+
These definitions are the repository owner's, recorded after the first review
|
|
36
|
+
of the draft: the owner's labels moved many drafted cases one tier up, labeled
|
|
37
|
+
context-dependent replies by their work, and gave non-engineering chores
|
|
38
|
+
`tier1`. The draft's `proposedGold` values predate this and are only
|
|
39
|
+
suggestions. Acknowledgements, reactions, host commands (`/compact`) and meeting
|
|
40
|
+
notes were rejected from the holdout because they never reach routing as tasks.
|
|
41
|
+
|
|
42
|
+
## Cases
|
|
43
|
+
|
|
44
|
+
Each draft case has `id`, `family`, `language` (`en` or `zh-TW`), `source`,
|
|
45
|
+
`prompt`, `proposedGold` and a one-line `rationale`.
|
|
46
|
+
|
|
47
|
+
- **Family.** A family groups prompts that share one task scenario, such as
|
|
48
|
+
"commit and push" or "fix a CLI error from a pasted log". Paraphrases,
|
|
49
|
+
translations and variants of one scenario stay in one family, and a family
|
|
50
|
+
never spans splits. All families in this corpus are `holdout`. Later train or
|
|
51
|
+
validation data must use new families.
|
|
52
|
+
- **Source.** `synthetic:authored` marks a prompt written for the corpus.
|
|
53
|
+
`derived:local-history` marks a prompt rewritten from the shape of a real
|
|
54
|
+
local prompt: same length class, task type and phrasing style, with every
|
|
55
|
+
name, path, product, customer, issue number and pasted log replaced. No real
|
|
56
|
+
prompt text, person, organization or local path is committed.
|
|
57
|
+
- **Length.** The corpus follows the observed length profile of real local
|
|
58
|
+
prompts (median about 90 UTF-8 bytes, about one in five over 224 bytes, a
|
|
59
|
+
long tail with pasted logs), so that length limits are evaluated on realistic
|
|
60
|
+
input, not only short prompts.
|
|
61
|
+
|
|
62
|
+
## Review
|
|
63
|
+
|
|
64
|
+
A human reviewer decides every case on the review page. The possible decisions are:
|
|
65
|
+
|
|
66
|
+
| Decision | Effect |
|
|
67
|
+
| --- | --- |
|
|
68
|
+
| `accept` | Gold is the proposed gold. |
|
|
69
|
+
| `relabel` | Gold is the reviewer's chosen label. |
|
|
70
|
+
| `reject` | The case is dropped: ambiguous even for a human, unrealistic, or it leaks private data. |
|
|
71
|
+
|
|
72
|
+
Each decision records the case ID, the SHA-256 of the exact prompt text it
|
|
73
|
+
reviewed (`promptHash`), the decision, the gold, and the reviewer role. The
|
|
74
|
+
assembler `scripts/system-one-corpus.js` builds the evaluation corpus from the
|
|
75
|
+
draft and the decisions:
|
|
76
|
+
|
|
77
|
+
- A case with a valid decision becomes `reviewed: true` with the reviewer's gold.
|
|
78
|
+
- A case without a decision, or whose prompt changed after review (hash
|
|
79
|
+
mismatch), stays `reviewed: false` with the proposed gold, so the gate cannot
|
|
80
|
+
pass on stale or missing review.
|
|
81
|
+
- A rejected case is omitted.
|
|
82
|
+
- The output passes `validateCorpus`, and the assembler reports per-language and
|
|
83
|
+
per-gold counts plus whether the `reviewedHoldout` gate would pass.
|
|
84
|
+
|
|
85
|
+
The agent that drafts cases never records decisions. `reviewed: true` means a
|
|
86
|
+
human reviewed that exact text. Review records store a role
|
|
87
|
+
(`human:repository-owner`), not a name or account. When a decision contradicts
|
|
88
|
+
the owner's decisions on sibling cases, the agent may ask the owner to confirm
|
|
89
|
+
it. The owner's answer is recorded as the decision, and the agent never changes
|
|
90
|
+
a decision on its own.
|
|
91
|
+
|
|
92
|
+
## Committed files
|
|
93
|
+
|
|
94
|
+
| File | Content |
|
|
95
|
+
| --- | --- |
|
|
96
|
+
| `benchmarks/fixtures/system-one-holdout-draft.json` | Draft cases with proposed gold |
|
|
97
|
+
| `benchmarks/fixtures/system-one-holdout-reviews.json` | Owner decisions (ID, prompt hash, decision, gold, role) |
|
|
98
|
+
| `benchmarks/fixtures/system-one-holdout.json` | Evaluation corpus, rebuilt with `node scripts/system-one-corpus.js build <draft> <reviews> <corpus>` |
|
|
99
|
+
|
|
100
|
+
The reviewed holdout has 215 cases (11 rejected): en 93 and zh-TW 122; gold
|
|
101
|
+
`tier1` 47, `tier2` 97, `tier3` 51 and `null` 20. It meets the `reviewedHoldout`
|
|
102
|
+
gate. It says nothing about model quality until a `harness-routing-v1`
|
|
103
|
+
checkpoint is evaluated on it.
|
|
@@ -41,7 +41,11 @@ never a prompt-supplied executable. No shell or automatic download is used.
|
|
|
41
41
|
The manifest is version 1 with `python` (executable), `checkpoint` (absolute
|
|
42
42
|
`.safetensors` path), `weightsSha256`, `configSha256` (matching `.json` sidecar),
|
|
43
43
|
`modelId`, `revision`, `domain`, and optional `timeoutMs` (1–10000, default 2000).
|
|
44
|
-
All fields are required except the timeout; unknown fields are rejected.
|
|
44
|
+
All fields are required except the timeout; unknown fields are rejected. An
|
|
45
|
+
optional `acceptance` object holds exactly `minConfidence` (0.5–0.99) and
|
|
46
|
+
`minMargin` (0–0.9). These are the thresholds calibrated on validation for this
|
|
47
|
+
checkpoint. A scored result carries them, and the router and the evaluator pass
|
|
48
|
+
them to `decide`. Without the field the Phase 0 defaults apply. Hashes
|
|
45
49
|
must be lowercase SHA-256. Revision and domain are artifact-owner declarations,
|
|
46
50
|
not independently verified quality claims. The known `cua-ai/cua-s1-forms` ID
|
|
47
51
|
must use domain `forms-v1`. No pickle format or remote URL is accepted.
|
|
@@ -227,7 +231,8 @@ The corpus is `{schemaVersion: 1, cases: [...]}`. Each case has exactly `id`,
|
|
|
227
231
|
The complete fixed tier catalog must match. IDs and request hashes are unique;
|
|
228
232
|
no family may span splits. Evaluation uses only holdout, never training labels.
|
|
229
233
|
The committed seed corpus is a mechanism fixture, not an independently reviewed
|
|
230
|
-
holdout.
|
|
234
|
+
holdout. The reviewed holdout is written, labeled and assembled as described in
|
|
235
|
+
[system-one-corpus.md](system-one-corpus.md).
|
|
231
236
|
|
|
232
237
|
The CLI runs the real lexical baseline and the configured provider twice per
|
|
233
238
|
holdout case. Records contain IDs, baseline prediction, decision, model identity,
|
|
@@ -278,6 +283,9 @@ unversioned download during a prompt hook.
|
|
|
278
283
|
| 3 | Corpus and paired evaluator | Leakage checks, coverage/error metrics, repeatability |
|
|
279
284
|
| 4 | Harness training and rollout | Real checkpoint, reviewed holdout, measured host results |
|
|
280
285
|
|
|
286
|
+
Phase 4 training data, labeling, calibration and release are defined in
|
|
287
|
+
[system-one-training.md](system-one-training.md).
|
|
288
|
+
|
|
281
289
|
## Rollout gates
|
|
282
290
|
|
|
283
291
|
Phase 4 requires a separately reviewed, family-disjoint holdout of at least 200
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# System One training data and weights
|
|
2
|
+
|
|
3
|
+
This document defines how the `harness-routing-v1` tier checkpoint for
|
|
4
|
+
[System One](system-one-routing.md) is trained, calibrated and released
|
|
5
|
+
(issue [#233](https://github.com/dyphn1/Harness-everything/issues/233), Phase 4).
|
|
6
|
+
Gold labels follow [system-one-corpus.md](system-one-corpus.md). The owner-reviewed
|
|
7
|
+
holdout in that document is used only for evaluation. It is never used for training,
|
|
8
|
+
threshold selection or labeler tuning.
|
|
9
|
+
|
|
10
|
+
## Pipeline
|
|
11
|
+
|
|
12
|
+
1. **Collect**: copy the owner's own prompts from local assistant histories into a local
|
|
13
|
+
dataset (`scripts/system-one-collect.js`).
|
|
14
|
+
2. **Label**: an LLM labels each prompt against the owner's rules. The labeler is checked
|
|
15
|
+
once against the holdout, and the owner spot-checks a sample
|
|
16
|
+
(`scripts/system-one-label.js`).
|
|
17
|
+
3. **Train**: train a fresh `cua_s1` `tinyx` scorer on the train split and select the epoch
|
|
18
|
+
on the validation split.
|
|
19
|
+
4. **Calibrate**: choose the confidence and margin thresholds on validation.
|
|
20
|
+
5. **Evaluate**: produce one paired report on the holdout.
|
|
21
|
+
6. **Release**: publish the weights as a GitHub release asset. The installer pins them by
|
|
22
|
+
SHA-256.
|
|
23
|
+
|
|
24
|
+
## Sources
|
|
25
|
+
|
|
26
|
+
Only text the owner typed is collected. Injected context, tool output and assistant text are
|
|
27
|
+
never collected.
|
|
28
|
+
|
|
29
|
+
| Source | Location | User text |
|
|
30
|
+
| --- | --- | --- |
|
|
31
|
+
| Claude Code | `~/.claude/projects/*/*.jsonl` | `type: "user"` records that are not meta or sidechain, string content or text parts |
|
|
32
|
+
| Codex | `~/.codex/sessions/**/*.jsonl` | `event_msg` `user_message.message`. Older sessions without it fall back to `response_item` user text |
|
|
33
|
+
| Copilot CLI | `~/.copilot/session-state/*/events.jsonl` | `user.message` `data.content` |
|
|
34
|
+
| VS Code Copilot Chat | `%APPDATA%/Code/User/workspaceStorage/*/chatSessions/*.json(l)` and `globalStorage/emptyWindowChatSessions` | `requests[].message.text` in snapshots (`kind: 0`) and request pushes (`kind: 2`, key `["requests"]`) |
|
|
35
|
+
|
|
36
|
+
The following are dropped:
|
|
37
|
+
|
|
38
|
+
- Text that starts with an injected wrapper tag, such as `<environment_context>`,
|
|
39
|
+
`<system-reminder>`, `<command-…>`, `<task-notification>` or `<ide_…>`.
|
|
40
|
+
- Tool results.
|
|
41
|
+
- Slash commands.
|
|
42
|
+
- Session-continuation summaries ("This session is being continued…").
|
|
43
|
+
- Empty text.
|
|
44
|
+
|
|
45
|
+
Codex sessions include prompts that another agent dispatched. They are kept and tagged with
|
|
46
|
+
their source, because Harness routes them in Codex too.
|
|
47
|
+
|
|
48
|
+
## Filters, families and splits
|
|
49
|
+
|
|
50
|
+
- **Length**: at most 1024 UTF-8 bytes, which matches the checkpoint's `context_tokens`. A
|
|
51
|
+
longer prompt is still refused at inference and falls back to lexical routing. It is never
|
|
52
|
+
truncated.
|
|
53
|
+
- **Deduplication**: exact duplicates after whitespace normalization are dropped. The first
|
|
54
|
+
occurrence is kept.
|
|
55
|
+
- **Holdout leakage**: a prompt is dropped if its character-trigram Jaccard similarity to any
|
|
56
|
+
holdout prompt is at least 0.5. The same applies if either prompt contains the other after
|
|
57
|
+
normalization and the shorter one is more than 12 characters long. This matters because
|
|
58
|
+
the holdout includes rewrites of local prompt shapes.
|
|
59
|
+
- **Family**: the source session. Prompts from one conversation never span splits.
|
|
60
|
+
- **Split**: 15% of families go to `validation`, chosen by a stable SHA-256 of the family ID.
|
|
61
|
+
The rest go to `train`.
|
|
62
|
+
|
|
63
|
+
## Privacy
|
|
64
|
+
|
|
65
|
+
- Collected prompts and labels stay on the local machine under
|
|
66
|
+
`~/.agents/harness-everything/system-one/training/` and are **never committed**. The
|
|
67
|
+
repository holds only the scripts, aggregate statistics and the SHA-256 of each dataset
|
|
68
|
+
file.
|
|
69
|
+
- Email addresses and user home paths are replaced with placeholders before storage. Names
|
|
70
|
+
and product terms are not reliably detectable and remain.
|
|
71
|
+
- The released weights come from a 4-way byte-level classifier with about 0.7M parameters. It
|
|
72
|
+
has no text-generation head, but a trained model can still encode fragments of its data.
|
|
73
|
+
The owner accepted this for their own prompts.
|
|
74
|
+
- Labeling sends the prompts to the Claude API. The owner authorized this.
|
|
75
|
+
|
|
76
|
+
## Labeling
|
|
77
|
+
|
|
78
|
+
- **Labeler**: `claude -p` with Sonnet.
|
|
79
|
+
- Flags: `--setting-sources ""` (no hooks or plugins), `--no-session-persistence` (labeling
|
|
80
|
+
sessions never become collectable history), `--tools ""` and a JSON schema.
|
|
81
|
+
- The instructions contain the gold table and rules from
|
|
82
|
+
[system-one-corpus.md](system-one-corpus.md).
|
|
83
|
+
- Prompts go in batches of 100. Every returned index must be labeled exactly once with
|
|
84
|
+
`tier1`, `tier2`, `tier3` or `null`. A malformed batch is retried once and then
|
|
85
|
+
recorded as failed. It is never partially accepted.
|
|
86
|
+
- **Labeler check**: the labeler labels the 215 holdout prompts once, before any training
|
|
87
|
+
data is labeled. The report gives agreement with the owner's gold and the per-class recall.
|
|
88
|
+
- Labeling proceeds only when agreement is at least 80%.
|
|
89
|
+
- The instructions are never tuned on the holdout. If the check fails, the owner reviews
|
|
90
|
+
the disagreements and decides how to proceed.
|
|
91
|
+
- **Owner spot-check**: a random 5% sample of the labeled training data is reviewed on the
|
|
92
|
+
review page, and the disagreement rate is reported. The owner's decisions replace the LLM
|
|
93
|
+
labels for those cases.
|
|
94
|
+
|
|
95
|
+
## Training and calibration
|
|
96
|
+
|
|
97
|
+
- **Model**: a new `cua_s1` `tinyx` scorer built with `make_system`.
|
|
98
|
+
- Config: `width` 128, `rank` 128, `layers` 2, `heads` 4, `context_tokens` 1024 and
|
|
99
|
+
`option_tokens` 96.
|
|
100
|
+
- Weights are initialized fresh, not from the forms checkpoint, whose domain and
|
|
101
|
+
positional range differ.
|
|
102
|
+
- **Target**: each example is the fixed tier catalog with the index of the gold option.
|
|
103
|
+
`null` maps to `unclassified`.
|
|
104
|
+
- **Optimization**:
|
|
105
|
+
- Cross-entropy, AdamW, a fixed seed and CPU.
|
|
106
|
+
- The epoch with the lowest validation negative log-likelihood is kept.
|
|
107
|
+
- The checkpoint metadata records the dataset hashes, the config and the validation metrics.
|
|
108
|
+
- **Calibration**: `minConfidence` and `minMargin` are chosen on validation to maximize
|
|
109
|
+
coverage, subject to an accepted precision of at least 98%. The router currently uses the
|
|
110
|
+
Phase 0 defaults (0.9 and 0.2). Carrying calibrated thresholds into the manifest is a
|
|
111
|
+
separate contract change.
|
|
112
|
+
|
|
113
|
+
## Evaluation and release
|
|
114
|
+
|
|
115
|
+
- **Evaluation**: `scripts/evaluate-system-one.js` runs once on
|
|
116
|
+
`benchmarks/fixtures/system-one-holdout.json` with the new manifest. The rollout gates and
|
|
117
|
+
the lexical baseline (macro-F1 0.254) decide the result. The report goes under
|
|
118
|
+
`benchmarks/results/system-one/`.
|
|
119
|
+
- **Release**: the `.safetensors` and `.json` files are attached to a GitHub release. The
|
|
120
|
+
installer's pins gain the new model ID, revision, `domain: "harness-routing-v1"` and both
|
|
121
|
+
SHA-256 values. Until every rollout gate passes, the router default stays `off`.
|
|
@@ -10,10 +10,17 @@ const unavailable = reason => ({ status: 'unavailable', reason });
|
|
|
10
10
|
const exact = (value, keys) => value && typeof value === 'object' && !Array.isArray(value)
|
|
11
11
|
&& Object.keys(value).length === keys.length && keys.every(k => Object.hasOwn(value, k));
|
|
12
12
|
const label = value => typeof value === 'string' && value.length > 0 && value.length <= 128 && !/[\u0000-\u001f]/.test(value);
|
|
13
|
+
// Thresholds calibrated on validation for this checkpoint (docs/system-one-training.md).
|
|
14
|
+
const inRange = (v, lo, hi) => typeof v === 'number' && Number.isFinite(v) && v >= lo && v <= hi;
|
|
15
|
+
const validAcceptance = a => exact(a, ['minConfidence', 'minMargin']) && inRange(a.minConfidence, 0.5, 0.99) && inRange(a.minMargin, 0, 0.9);
|
|
16
|
+
// A scored result carries the manifest's thresholds so every caller decides with them.
|
|
17
|
+
const withAcceptance = (result, manifest) => (result && result.status === 'scored' && manifest.acceptance
|
|
18
|
+
? { ...result, acceptance: { ...manifest.acceptance } } : result);
|
|
13
19
|
function validateManifest(m) {
|
|
14
20
|
const required = ['schemaVersion', 'python', 'checkpoint', 'weightsSha256', 'configSha256', 'modelId', 'revision', 'domain'];
|
|
15
21
|
if (!m || typeof m !== 'object' || Array.isArray(m) || required.some(k => !Object.hasOwn(m, k))
|
|
16
|
-
|| Object.keys(m).some(k => ![...required, 'timeoutMs', 'transport', 'idleTimeoutMs'].includes(k)) || m.schemaVersion !== 1
|
|
22
|
+
|| Object.keys(m).some(k => ![...required, 'timeoutMs', 'transport', 'idleTimeoutMs', 'acceptance'].includes(k)) || m.schemaVersion !== 1
|
|
23
|
+
|| (m.acceptance !== undefined && !validAcceptance(m.acceptance))
|
|
17
24
|
|| ['python', 'modelId', 'revision', 'domain'].some(k => typeof m[k] !== 'string' || !m[k].trim() || m[k].length > 4096 || m[k].includes('\0'))
|
|
18
25
|
|| typeof m.checkpoint !== 'string' || !path.isAbsolute(m.checkpoint) || path.extname(m.checkpoint) !== '.safetensors'
|
|
19
26
|
|| ['weightsSha256', 'configSha256'].some(k => typeof m[k] !== 'string' || !/^[a-f0-9]{64}$/.test(m[k]))
|
|
@@ -50,8 +57,8 @@ function score(request, manifestPath) {
|
|
|
50
57
|
validateRequest(request);
|
|
51
58
|
let manifest;
|
|
52
59
|
try { manifest = readManifest(manifestPath); } catch (_) { return unavailable('provider-config'); }
|
|
53
|
-
if (manifest.transport === 'resident') return require('./resident').score({ ...request }, manifest, manifestPath);
|
|
54
|
-
return oneShot(request, manifest);
|
|
60
|
+
if (manifest.transport === 'resident') return withAcceptance(require('./resident').score({ ...request }, manifest, manifestPath), manifest);
|
|
61
|
+
return withAcceptance(oneShot(request, manifest), manifest);
|
|
55
62
|
}
|
|
56
63
|
// Async callers (the hook entry) reach a resident server without the sync worker bridge.
|
|
57
64
|
// One-shot has no server to overlap with, so it runs the same child synchronously.
|
|
@@ -59,8 +66,8 @@ async function scoreAsync(request, manifestPath) {
|
|
|
59
66
|
validateRequest(request);
|
|
60
67
|
let manifest;
|
|
61
68
|
try { manifest = readManifest(manifestPath); } catch (_) { return unavailable('provider-config'); }
|
|
62
|
-
if (manifest.transport === 'resident') return require('./resident').scoreAsync({ ...request }, manifest, manifestPath);
|
|
63
|
-
return oneShot(request, manifest);
|
|
69
|
+
if (manifest.transport === 'resident') return withAcceptance(await require('./resident').scoreAsync({ ...request }, manifest, manifestPath), manifest);
|
|
70
|
+
return withAcceptance(oneShot(request, manifest), manifest);
|
|
64
71
|
}
|
|
65
72
|
// Send the exact validated manifest to the child on stdin: no config reread race.
|
|
66
73
|
function oneShot(request, manifest) {
|
|
@@ -26,7 +26,7 @@ function selectTier(input, env = process.env, scorer = provider.score) {
|
|
|
26
26
|
const allowed = ['provider-timeout', 'provider-output-limit', 'provider-exit', 'provider-json', 'provider-config', 'provider-unavailable', 'provider-starting'];
|
|
27
27
|
return fallback(allowed.includes(result?.reason) ? result.reason : 'provider-unavailable');
|
|
28
28
|
}
|
|
29
|
-
const decision = decide(request, result.response);
|
|
29
|
+
const decision = decide(request, result.response, result.acceptance ? { ...result.acceptance } : {});
|
|
30
30
|
if (decision.selectedId === 'unclassified') Object.assign(decision, { selectedId: null, status: 'abstain', reason: 'unclassified' });
|
|
31
31
|
const accepted = decision.status === 'accepted';
|
|
32
32
|
const belowFloor = accepted && input.floor != null && RANK[decision.selectedId] < RANK[input.floor];
|
package/package.json
CHANGED
|
@@ -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.
|
|
4
|
+
"version": "0.24.0",
|
|
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",
|
|
@@ -10,10 +10,17 @@ const unavailable = reason => ({ status: 'unavailable', reason });
|
|
|
10
10
|
const exact = (value, keys) => value && typeof value === 'object' && !Array.isArray(value)
|
|
11
11
|
&& Object.keys(value).length === keys.length && keys.every(k => Object.hasOwn(value, k));
|
|
12
12
|
const label = value => typeof value === 'string' && value.length > 0 && value.length <= 128 && !/[\u0000-\u001f]/.test(value);
|
|
13
|
+
// Thresholds calibrated on validation for this checkpoint (docs/system-one-training.md).
|
|
14
|
+
const inRange = (v, lo, hi) => typeof v === 'number' && Number.isFinite(v) && v >= lo && v <= hi;
|
|
15
|
+
const validAcceptance = a => exact(a, ['minConfidence', 'minMargin']) && inRange(a.minConfidence, 0.5, 0.99) && inRange(a.minMargin, 0, 0.9);
|
|
16
|
+
// A scored result carries the manifest's thresholds so every caller decides with them.
|
|
17
|
+
const withAcceptance = (result, manifest) => (result && result.status === 'scored' && manifest.acceptance
|
|
18
|
+
? { ...result, acceptance: { ...manifest.acceptance } } : result);
|
|
13
19
|
function validateManifest(m) {
|
|
14
20
|
const required = ['schemaVersion', 'python', 'checkpoint', 'weightsSha256', 'configSha256', 'modelId', 'revision', 'domain'];
|
|
15
21
|
if (!m || typeof m !== 'object' || Array.isArray(m) || required.some(k => !Object.hasOwn(m, k))
|
|
16
|
-
|| Object.keys(m).some(k => ![...required, 'timeoutMs', 'transport', 'idleTimeoutMs'].includes(k)) || m.schemaVersion !== 1
|
|
22
|
+
|| Object.keys(m).some(k => ![...required, 'timeoutMs', 'transport', 'idleTimeoutMs', 'acceptance'].includes(k)) || m.schemaVersion !== 1
|
|
23
|
+
|| (m.acceptance !== undefined && !validAcceptance(m.acceptance))
|
|
17
24
|
|| ['python', 'modelId', 'revision', 'domain'].some(k => typeof m[k] !== 'string' || !m[k].trim() || m[k].length > 4096 || m[k].includes('\0'))
|
|
18
25
|
|| typeof m.checkpoint !== 'string' || !path.isAbsolute(m.checkpoint) || path.extname(m.checkpoint) !== '.safetensors'
|
|
19
26
|
|| ['weightsSha256', 'configSha256'].some(k => typeof m[k] !== 'string' || !/^[a-f0-9]{64}$/.test(m[k]))
|
|
@@ -50,8 +57,8 @@ function score(request, manifestPath) {
|
|
|
50
57
|
validateRequest(request);
|
|
51
58
|
let manifest;
|
|
52
59
|
try { manifest = readManifest(manifestPath); } catch (_) { return unavailable('provider-config'); }
|
|
53
|
-
if (manifest.transport === 'resident') return require('./resident').score({ ...request }, manifest, manifestPath);
|
|
54
|
-
return oneShot(request, manifest);
|
|
60
|
+
if (manifest.transport === 'resident') return withAcceptance(require('./resident').score({ ...request }, manifest, manifestPath), manifest);
|
|
61
|
+
return withAcceptance(oneShot(request, manifest), manifest);
|
|
55
62
|
}
|
|
56
63
|
// Async callers (the hook entry) reach a resident server without the sync worker bridge.
|
|
57
64
|
// One-shot has no server to overlap with, so it runs the same child synchronously.
|
|
@@ -59,8 +66,8 @@ async function scoreAsync(request, manifestPath) {
|
|
|
59
66
|
validateRequest(request);
|
|
60
67
|
let manifest;
|
|
61
68
|
try { manifest = readManifest(manifestPath); } catch (_) { return unavailable('provider-config'); }
|
|
62
|
-
if (manifest.transport === 'resident') return require('./resident').scoreAsync({ ...request }, manifest, manifestPath);
|
|
63
|
-
return oneShot(request, manifest);
|
|
69
|
+
if (manifest.transport === 'resident') return withAcceptance(await require('./resident').scoreAsync({ ...request }, manifest, manifestPath), manifest);
|
|
70
|
+
return withAcceptance(oneShot(request, manifest), manifest);
|
|
64
71
|
}
|
|
65
72
|
// Send the exact validated manifest to the child on stdin: no config reread race.
|
|
66
73
|
function oneShot(request, manifest) {
|
|
@@ -26,7 +26,7 @@ function selectTier(input, env = process.env, scorer = provider.score) {
|
|
|
26
26
|
const allowed = ['provider-timeout', 'provider-output-limit', 'provider-exit', 'provider-json', 'provider-config', 'provider-unavailable', 'provider-starting'];
|
|
27
27
|
return fallback(allowed.includes(result?.reason) ? result.reason : 'provider-unavailable');
|
|
28
28
|
}
|
|
29
|
-
const decision = decide(request, result.response);
|
|
29
|
+
const decision = decide(request, result.response, result.acceptance ? { ...result.acceptance } : {});
|
|
30
30
|
if (decision.selectedId === 'unclassified') Object.assign(decision, { selectedId: null, status: 'abstain', reason: 'unclassified' });
|
|
31
31
|
const accepted = decision.status === 'accepted';
|
|
32
32
|
const belowFloor = accepted && input.floor != null && RANK[decision.selectedId] < RANK[input.floor];
|
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:5f8c3ad1-23b9-55c5-a389-ff6c3877f9dd",
|
|
6
6
|
"version": 1,
|
|
7
7
|
"metadata": {
|
|
8
|
-
"timestamp": "2026-09-
|
|
8
|
+
"timestamp": "2026-09-23T13:40:29.695Z",
|
|
9
9
|
"tools": [
|
|
10
10
|
{
|
|
11
11
|
"vendor": "Harness Everything",
|
|
12
12
|
"name": "generate-sbom.js",
|
|
13
|
-
"version": "0.
|
|
13
|
+
"version": "0.24.0"
|
|
14
14
|
}
|
|
15
15
|
],
|
|
16
16
|
"component": {
|
|
17
17
|
"type": "application",
|
|
18
|
-
"bom-ref": "pkg:npm/harness-everything@0.
|
|
18
|
+
"bom-ref": "pkg:npm/harness-everything@0.24.0",
|
|
19
19
|
"name": "harness-everything",
|
|
20
|
-
"version": "0.
|
|
21
|
-
"purl": "pkg:npm/harness-everything@0.
|
|
20
|
+
"version": "0.24.0",
|
|
21
|
+
"purl": "pkg:npm/harness-everything@0.24.0"
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"components": [
|
|
@@ -1999,7 +1999,7 @@
|
|
|
1999
1999
|
]
|
|
2000
2000
|
},
|
|
2001
2001
|
{
|
|
2002
|
-
"ref": "pkg:npm/harness-everything@0.
|
|
2002
|
+
"ref": "pkg:npm/harness-everything@0.24.0",
|
|
2003
2003
|
"dependsOn": [
|
|
2004
2004
|
"pkg:npm/%40commitlint/cli@19.8.1",
|
|
2005
2005
|
"pkg:npm/%40commitlint/config-conventional@19.8.1",
|
|
@@ -29,7 +29,7 @@ async function run(corpus, manifest) {
|
|
|
29
29
|
for (let i = 0; i < 2; i++) {
|
|
30
30
|
const start = performance.now();
|
|
31
31
|
const result = await scoreAsync(c.request, manifest);
|
|
32
|
-
const decision = result.status === 'scored' ? decide(c.request, result.response) : result;
|
|
32
|
+
const decision = result.status === 'scored' ? decide(c.request, result.response, result.acceptance ? { ...result.acceptance } : {}) : result;
|
|
33
33
|
if (decision.selectedId === 'unclassified') Object.assign(decision, { status: 'abstain', reason: 'unclassified', selectedId: null });
|
|
34
34
|
const scores = ['accepted', 'abstain'].includes(decision.status) ? result.response.scores.map(s => s.probability) : null;
|
|
35
35
|
runs.push({ decision, scores, latencyMs: performance.now() - start, coldStart: !warm });
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
// Chooses System One acceptance thresholds on validation scores (docs/system-one-training.md).
|
|
4
|
+
// The holdout is never used here.
|
|
5
|
+
const fs = require('node:fs');
|
|
6
|
+
|
|
7
|
+
const IDS = ['tier1', 'tier2', 'tier3', 'unclassified'];
|
|
8
|
+
// Same acceptance rule as contract.decide: top probability and top-minus-second margin, unclassified abstains.
|
|
9
|
+
function decideRow(probs, { minConfidence, minMargin }) {
|
|
10
|
+
const order = probs.map((p, i) => [p, i]).sort((a, b) => b[0] - a[0] || a[1] - b[1]);
|
|
11
|
+
const [top, second] = order;
|
|
12
|
+
const margin = top[0] - second[0];
|
|
13
|
+
if (margin === 0 || top[0] < minConfidence || margin < minMargin || IDS[top[1]] === 'unclassified') return null;
|
|
14
|
+
return IDS[top[1]];
|
|
15
|
+
}
|
|
16
|
+
function calibrate(rows, { minPrecision = 0.98 } = {}) {
|
|
17
|
+
let best = null;
|
|
18
|
+
for (let c = 50; c <= 99; c++) {
|
|
19
|
+
for (let m = 0; m <= 90; m += 5) {
|
|
20
|
+
const t = { minConfidence: c / 100, minMargin: m / 100 };
|
|
21
|
+
let accepted = 0; let correct = 0;
|
|
22
|
+
for (const r of rows) { const d = decideRow(r.probs, t); if (d) { accepted++; if (d === (r.gold === null ? 'unclassified' : r.gold)) correct++; } }
|
|
23
|
+
const precision = accepted ? correct / accepted : 0;
|
|
24
|
+
if (!accepted || precision < minPrecision) continue;
|
|
25
|
+
const coverage = accepted / rows.length;
|
|
26
|
+
// Highest coverage wins; ties keep the first (lowest) thresholds scanned.
|
|
27
|
+
if (!best || coverage > best.coverage) best = { ...t, coverage, precision, accepted };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return best ? { feasible: true, rows: rows.length, minPrecision, ...best }
|
|
31
|
+
: { feasible: false, rows: rows.length, minPrecision, minConfidence: null, minMargin: null, coverage: 0, precision: null, accepted: 0 };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (require.main === module) {
|
|
35
|
+
try {
|
|
36
|
+
const [input, output, extra] = process.argv.slice(2);
|
|
37
|
+
if (!input || !output || extra) throw new Error('usage: system-one-calibrate.js <val-scores.jsonl> <calibration.json>');
|
|
38
|
+
const rows = fs.readFileSync(input, 'utf8').split('\n').filter(Boolean).map(l => JSON.parse(l));
|
|
39
|
+
const result = calibrate(rows);
|
|
40
|
+
fs.writeFileSync(output, `${JSON.stringify(result, null, 2)}\n`);
|
|
41
|
+
console.log(JSON.stringify(result));
|
|
42
|
+
} catch (err) { console.error(`system-one-calibrate: ${err.message}`); process.exitCode = 1; }
|
|
43
|
+
}
|
|
44
|
+
module.exports = { decideRow, calibrate };
|