harness-everything 0.51.0 → 0.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.github/workflows/ci.yml +23 -0
  4. package/CHANGELOG.md +34 -0
  5. package/benchmarks/results/doc-evidence-e1/cycle-2026-11-11-a-evid-001.md +123 -0
  6. package/benchmarks/results/doc-evidence-e1/cycle-2026-11-11-b-route-001.md +130 -0
  7. package/ci/mechanism-2am-observations-session-import.test.js +4 -1
  8. package/ci/mechanism-34-observations.test.js +127 -23
  9. package/ci/mechanism-349-ci-change-scope.test.js +260 -0
  10. package/ci/mechanism-handoff-file.test.js +121 -0
  11. package/ci/mechanism-system-one-contract.test.js +9 -2
  12. package/ci/mechanism-system-one-curves.test.js +206 -0
  13. package/ci/mechanism-system-one-cycle.test.js +585 -0
  14. package/ci/mechanism-system-one-evaluation.test.js +32 -5
  15. package/ci/mechanism-system-one-handoff-input.test.js +208 -0
  16. package/ci/mechanism-system-one-install.test.js +202 -77
  17. package/ci/mechanism-system-one-live.test.js +361 -0
  18. package/ci/mechanism-system-one-relevance.test.js +11 -1
  19. package/ci/mechanism-system-one-train.test.js +136 -53
  20. package/ci/system-one-adapter-test.py +331 -0
  21. package/ci/system-one-train-test.py +116 -24
  22. package/docs/adr/EVID-001.md +123 -0
  23. package/docs/adr/ROUTE-001-error-lesson-delivery.md +305 -0
  24. package/docs/governed-index.md +2 -0
  25. package/docs/routing.md +2 -2
  26. package/docs/system-one-cycle.md +68 -0
  27. package/docs/system-one-observations.md +9 -8
  28. package/docs/system-one-routing.md +163 -115
  29. package/docs/system-one-suggestion-gates.md +6 -8
  30. package/docs/system-one-training.md +44 -7
  31. package/docs/workflow-runtime.md +19 -0
  32. package/harness-everything/SKILL.md +1 -1
  33. package/harness-everything/scripts/kernel-router.js +2 -1
  34. package/harness-everything/scripts/system-one/contract.js +19 -15
  35. package/harness-everything/scripts/system-one/cua_adapter.py +211 -17
  36. package/harness-everything/scripts/system-one/evaluate.js +4 -9
  37. package/harness-everything/scripts/system-one/handoff-input.js +76 -0
  38. package/harness-everything/scripts/system-one/install.js +281 -113
  39. package/harness-everything/scripts/system-one/manifest.js +58 -0
  40. package/harness-everything/scripts/system-one/provider.js +96 -2
  41. package/harness-everything/scripts/system-one/resident.js +47 -1
  42. package/harness-everything/scripts/system-one/router.js +80 -1
  43. package/harness-everything/scripts/tier-router.js +21 -6
  44. package/hooks/scripts/lib/observations.js +43 -4
  45. package/opencode-plugin/plugin.json +1 -1
  46. package/package.json +1 -1
  47. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  48. package/plugins/harness-everything/hooks/scripts/lib/observations.js +43 -4
  49. package/plugins/harness-everything/plugin.json +1 -1
  50. package/plugins/harness-everything/scripts/handoff-file.js +223 -0
  51. package/plugins/harness-everything/skills/harness-everything/SKILL.md +1 -1
  52. package/plugins/harness-everything/skills/harness-everything/scripts/kernel-router.js +2 -1
  53. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/contract.js +19 -15
  54. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/cua_adapter.py +211 -17
  55. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/evaluate.js +4 -9
  56. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/handoff-input.js +76 -0
  57. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/install.js +281 -113
  58. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/manifest.js +58 -0
  59. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/provider.js +96 -2
  60. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/resident.js +47 -1
  61. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/router.js +80 -1
  62. package/plugins/harness-everything/skills/harness-everything/scripts/tier-router.js +21 -6
  63. package/sbom.cdx.json +7 -7
  64. package/scripts/ci-change-scope.js +59 -0
  65. package/scripts/handoff-file.js +223 -0
  66. package/scripts/sync-openai-plugin.js +4 -0
  67. package/scripts/system-one-calibrate.js +108 -41
  68. package/scripts/system-one-curves.js +332 -0
  69. package/scripts/system-one-cycle/adjudication-input.js +65 -0
  70. package/scripts/system-one-cycle/build.js +165 -0
  71. package/scripts/system-one-cycle/collect.js +50 -0
  72. package/scripts/system-one-cycle/common.js +137 -0
  73. package/scripts/system-one-cycle/engines.js +62 -0
  74. package/scripts/system-one-cycle/evaluate.js +70 -0
  75. package/scripts/system-one-cycle/judge.js +106 -0
  76. package/scripts/system-one-cycle/label.js +59 -0
  77. package/scripts/system-one-cycle/package.js +173 -0
  78. package/scripts/system-one-cycle/score.py +111 -0
  79. package/scripts/system-one-cycle/train.js +136 -0
  80. package/scripts/system-one-cycle.js +131 -0
  81. package/scripts/system-one-observations-export.js +29 -6
  82. package/scripts/system-one-observations-review.js +4 -5
  83. package/scripts/system-one-train.py +117 -61
@@ -43,6 +43,7 @@ A turn runs from `UserPromptSubmit` to `Stop`. Its record:
43
43
  | `prompt` | `UserPromptSubmit` | stored in the private text store only (see Storage) |
44
44
  | `previous` | the last assistant message before the prompt | truncated to 2 KB; text store only |
45
45
  | `router` | kernel-router output | lexical tier, strategy, normalized knowledge signals, active step/stage bindings; System One shadow scores when present |
46
+ | `router.systemOne` | `workflow-run.json` → `workflowPlan.systemOne` | bounded version, hash, mode, scores and decision; unknown keys are dropped, scores are clamped to 0..1, and malformed or missing input is stored as `null`. Scores remain in the private store only. |
46
47
  | `behavior` | `PostToolUse`, `PostToolUseFailure` | counts and categories, never arguments: files written, distinct repositories written, files created, commands by class (git, gh, test, build, package, shell), skills loaded or read, subagents started. Failed attempts are counted separately (`toolFailures`, `failedWrites`, `failedSkillLoads`) and never count as a write or a load. `null` means the capture source did not observe tool events; it is not a zero count. |
47
48
  | `workflow` | `workflow-run.json` / `workflow-disposition` | selected and confirmed strategy |
48
49
  | `selfReport` | label line in the final message | see below; `null` if missing or invalid |
@@ -54,13 +55,12 @@ At the end of the final message of each turn the agent writes one line,
54
55
  which is invisible in rendered Markdown:
55
56
 
56
57
  ```
57
- <!-- harness-label {"v":1,"validity":"actionable","contextDependent":false,"tier":"tier2","intents":["fix","test"],"workflow":"iterative-single","skills":["tdd"]} -->
58
+ <!-- harness-label {"v":1,"validity":"actionable","tier":"tier2","intents":["fix","test"],"workflow":"iterative-single","skills":["tdd"]} -->
58
59
  ```
59
60
 
60
61
  | Key | Values |
61
62
  | --- | --- |
62
- | `validity` | `actionable` or `invalid` (continuation, feedback on earlier work, pointer to earlier content, paste or chatter) |
63
- | `contextDependent` | `true` when the prompt text alone would not have been enough to know the task |
63
+ | `validity` | `actionable` or `invalid`; invalid means the prompt cannot be understood from its own text and needs conversation context. Agent-written dispatches and worker instructions are ordinary prompts. |
64
64
  | `tier` | `tier1` (no file change), `tier2` (bounded file change: code, config or docs), `tier3` (feature, refactor, redefinition, cross-component) or `null` (only for `invalid`), under tier rules v2 |
65
65
  | `intents` | up to 3 of the 12 intent ids, strongest first |
66
66
  | `workflow` | a router strategy id or `null` |
@@ -76,13 +76,13 @@ accepted when it ends the message.
76
76
 
77
77
  ## Labels and how much to trust them
78
78
 
79
- The label is the host LLM's own judgement. It saw the whole conversation and
80
- did the work, so no fixed rule replaces it (owner decision, 2026-09-27: no
81
- file-count threshold for tier).
79
+ Validity is judged from the prompt text alone, even when the agent saw the
80
+ whole conversation. The other keys are the host LLM's own judgement; no
81
+ fixed rule replaces tier (owner decision, 2026-09-27: no file-count threshold).
82
82
 
83
83
  | Label | Source | Override |
84
84
  | --- | --- | --- |
85
- | validity, contextDependent | self-report | owner review |
85
+ | validity | self-report, judged from prompt text alone | owner review |
86
86
  | intents | self-report | — |
87
87
  | tier | self-report (tier rules v2) | owner review |
88
88
  | workflow | self-report, else the confirmed strategy | — |
@@ -201,7 +201,8 @@ The importer accepts only valid label lines, applies the same email/home-path re
201
201
  repository:
202
202
 
203
203
  - `prompts-observed.jsonl`: `{id, family, source: "observation", split, text}`
204
- - `labels-observed.jsonl`: `{id, validity, contextDependent, tier, tierSource, intents, workflow, skills, behaviorEvidence, contradictions}`
204
+ - `labels-observed.jsonl`: `{id, validity, tier, tierSource, intents, workflow, skills, behaviorEvidence, contradictions, systemOne}`. `systemOne` is `{version, sha256, mode, decision}` or `null`; score maps stay in the private observation store.
205
+ - `export-report.json`: `systemOne.versions[version]` counts exported rows for each version and reports tier agreement (`matches`, `comparisons`, `rate`) between the router decision and self-report. Comparisons include only rows where both tiers are known.
205
206
 
206
207
  `family` groups near-duplicate prompts. The split is by time: the newest 15%
207
208
  is validation. The existing holdouts stay frozen and separate. Observed data
@@ -1,12 +1,12 @@
1
1
  # System One routing migration
2
2
 
3
3
  Status: experimental engineering; issue [#233](https://github.com/dyphn1/Harness-everything/issues/233).
4
- The default router stays lexical until a Harness checkpoint passes the rollout gates.
4
+ The default mode stays `off`. `live` is opt-in for machines with an activated private checkpoint; recorded gate values are baselines and do not block that opt-in.
5
5
  Implement each phase in **documentation → failing tests → implementation** order.
6
6
 
7
7
  ## Phase 0: scorer contract
8
8
 
9
- System One scores a complete, caller-owned candidate list in one pass. It cannot
9
+ For each stage, System One scores the complete, caller-owned candidate list in one pass. It cannot
10
10
  generate a workflow, execute actions, authorize tools, or write memory. Policy and
11
11
  contract assembly remain deterministic. This boundary does not add execution locks.
12
12
 
@@ -22,17 +22,18 @@ fingerprint grants permission or authenticates a model.
22
22
  The provider response has exactly `schemaVersion`, `requestHash`, `catalogHash`,
23
23
  `model`, and `scores`. Model has nonempty `id`, `revision`, and `domain` strings.
24
24
  Scores have exactly `{id, probability}` in request order. All candidates occur
25
- exactly once; probabilities are finite numbers in [0, 1], summing to one within
26
- 1e-6. Unknown fields, stale request/catalog hashes, and version mismatches fail.
25
+ exactly once; probabilities are finite values in [0, 1], as a categorical simplex for legacy checkpoints or independent scores for staged checkpoints. Unknown fields, stale request/catalog hashes, and version mismatches fail.
27
26
 
28
27
  `decide(request, response, policy)` returns exactly `status`, `reason`,
29
28
  `selectedId`, `confidence`, `margin`, and `model`. Status is `accepted`, `abstain`,
30
29
  or `invalid-output`; nonaccepted results always have `selectedId: null`.
31
30
  Policy requires a domain (default `harness-routing-v1`), minimum confidence
32
31
  (default 0.9) and minimum margin (default 0.2). Invalid policy is a caller error.
33
- Reject domain mismatch, tied winners, low confidence and low margin. A softmax
34
- score is not calibrated correctness probability. Invalid output returns no raw
35
- response, exception, or prompt. Identical inputs give identical decisions.
32
+ The legacy `decide` path rejects domain mismatch, tied winners, low confidence
33
+ and low margin. Live stages use their own calibrated per-option thresholds.
34
+ Probabilities are reference confidence, not correctness guarantees. Invalid
35
+ output returns no raw response, exception, or prompt. Identical inputs give
36
+ identical decisions.
36
37
 
37
38
  ## Phase 1: local provider
38
39
 
@@ -70,33 +71,42 @@ VCS URL pinned to that commit (not an editable or local-directory install).
70
71
  The status is `pinned` when it matches, `mismatch` otherwise, or `unavailable`
71
72
  when no revision is recorded. Malformed probe output is `provider-json`.
72
73
 
73
- `npm run system-one:install` (or `node harness-everything/scripts/system-one/install.js`)
74
- performs these steps on explicit request; hooks never run it. It selects a
75
- Python 3.11–3.13 interpreter (`--python` overrides; 3.14 is rejected by upstream),
76
- creates `<dir>/venv`, installs CPU-only torch from the PyTorch CPU index, then
77
- installs the pinned `cua_s1` Git URL. It downloads the `cua-ai/cua-s1-forms`
78
- safetensors weights and JSON sidecar at Hugging Face revision
79
- `f54adbf447f4ca6ec259f529ee3f2e3e09f8cc71`, verifies pinned sizes and SHA-256
80
- before an atomic write (the pickle `.pt` is never fetched), and writes
81
- `<dir>/manifest.json` with `timeoutMs: 10000`, `transport: "resident"` and
82
- `idleTimeoutMs: 1800000`. The default `<dir>` is
83
- `~/.agents/harness-everything/system-one`; `--dir` takes an absolute path and
84
- `--dry-run` prints the plan without changes. Acceptance requires a `pinned`
85
- provenance probe and one real warm CPU inference through a resident server that
86
- the installer starts and then stops; otherwise the exit code is 1. Child-process
87
- output goes to stderr; stdout carries only the JSON report.
88
- Torch/numpy/safetensors versions resolve at install time and are recorded by
89
- the probe. The installer does not change the router mode: it prints
90
- `HARNESS_SYSTEM_ONE_MODE=shadow` and the manifest path for the host
91
- environment. This checkpoint declares domain `forms-v1`, so shadow diagnostics
92
- report `domain-mismatch` and prefer never applies it. It also rejects context
93
- above its 224-byte limit (`provider-exit`), so installing it proves the local
94
- inference path only, not Harness routing quality.
74
+ Install a private checkpoint from a local data-repository checkout or its Git
75
+ SSH URL. The checkout must contain
76
+ `models/cua-s1/<id>/manifest.json` with validity, intent and tier stages:
77
+
78
+ ```sh
79
+ node harness-everything/scripts/system-one/install.js install \
80
+ --from /path/to/private-data-repo --version <id>
81
+ node harness-everything/scripts/system-one/install.js install \
82
+ --from git@host:private/data-repo.git --version <id>
83
+ ```
84
+
85
+ The SSH path uses a shallow sparse clone of the requested checkpoint in a
86
+ temporary cache directory; SSH credentials must come from the local SSH
87
+ configuration, not the URL. The installer verifies each stage's `sha256`, then
88
+ copies the manifest, weights, configs and optional evaluation file to
89
+ `~/.agents/harness-everything/system-one/versions/<id>/`. It also creates the
90
+ dedicated Python 3.11–3.13 virtual environment, installs CPU-only torch and the
91
+ pinned `cua_s1` source. `--python` selects the interpreter, `--dir` selects an
92
+ absolute install directory, and `--dry-run` prints the plan without changes.
93
+ The default directory is `~/.agents/harness-everything/system-one`; set
94
+ `HARNESS_SYSTEM_ONE_HOME` to override it.
95
+
96
+ Installation does not activate a checkpoint. Run
97
+ `node harness-everything/scripts/system-one/install.js activate <id>` to switch
98
+ the atomic `active.json` pointer; it records the prior version for
99
+ `rollback`. `status` reports active and previous versions, verifies their
100
+ checkpoint hashes, and prints the `HARNESS_SYSTEM_ONE_MODE=live` opt-in hint.
101
+ The router remains off by default; set `HARNESS_SYSTEM_ONE_MODE=live` only on
102
+ machines where System One is opted in. The public plugin contains the installer
103
+ code but no private weights.
95
104
 
96
105
  The adapter verifies both files before `load_checkpoint(..., 'cpu')`, sets one
97
106
  torch thread and deterministic inference, calls the upstream collator/model,
98
- and returns a probability for every option. It rejects context or option text
99
- that exceeds the loaded byte limits before collation (no silent truncation).
107
+ and applies a sigmoid independently to each option logit. It rejects context
108
+ or option text that exceeds the loaded byte limits before collation (no silent
109
+ truncation).
100
110
  No prompts or model values are written to disk or echoed in error messages.
101
111
 
102
112
  The Node transport has a hard timeout and a 1 MiB stdout/stderr bound; it kills
@@ -234,44 +244,88 @@ it started. Repository tests use a stub scorer behind the real server/protocol
234
244
  code; they prove the mechanism, not host survival of detached processes or model
235
245
  quality. Those require retained evidence.
236
246
 
237
- ## Phase 2: tier integration and rollback
238
-
239
- Set `HARNESS_SYSTEM_ONE_MODE=off|shadow|prefer` in the host environment. Default
240
- is `off`: no provider process, diagnostic, or contract change. Supply an absolute
241
- `HARNESS_SYSTEM_ONE_CONFIG` path to the Phase 1 manifest for the other modes.
242
- An unknown mode reports `invalid-mode` and leaves the lexical result unchanged.
243
- Shadow records the decision but never changes the route. Prefer replaces only
244
- the recommended tier when a valid `harness-routing-v1` result passes Phase 0
245
- thresholds. The full fixed tier catalog (tier1, tier2, tier3, unclassified) is
246
- always scored; it is never filtered using lexical matches. `unclassified` means
247
- abstention and keeps the existing route. Explicit strategy/model requests keep
248
- precedence and prevent model tier replacement. Set mode back to `off` to roll back.
249
-
250
- Prefer can raise a tier but never lower it below the deterministic structural
251
- floor: a macro-scope signal sets floor `tier3`, and multi-task, multi-sentence
252
- structure (other than a trivial docs edit) sets floor `tier2`. An accepted result
253
- below the floor is not applied and reports `structural-floor`, so repository-wide
254
- work keeps its Tier 3 strategy, independent verification and worktree
255
- invariants. Tier-3 keywords are lexical guesses, not structural floors. The
256
- policy assembler still consumes the original structural and risk signals.
257
- Safety, explicit prohibitions, memory ownership, and verification are not model
258
- outputs. This phase does not yet replace guide matching, dynamic
259
- skill triggers, fact-audit reminders, or the structural workflow signals.
260
- The same scorer API can evaluate caller-supplied text options; additional routing
261
- surfaces require their own catalog and held-out evidence before integration.
262
-
263
- When enabled, a single `SYSTEM ONE` JSON diagnostic reports mode, status, reason,
264
- selected candidate, model identity, confidence and margin; it omits prompt text,
265
- score vectors and artifact paths. The existing router contract schema is unchanged.
266
- Kernel/packaged entry points inherit these host environment variables. Prompts
247
+ ## Phase 2: compatibility modes and staged live routing
248
+
249
+ `HARNESS_SYSTEM_ONE_MODE=off` remains the default. Off starts no provider, emits
250
+ no System One text or workflow field, and preserves the lexical route byte for
251
+ byte. The older `shadow` and `prefer` single-tier modes remain for compatibility
252
+ and use an absolute `HARNESS_SYSTEM_ONE_CONFIG` manifest path. `live` reads the
253
+ active version pointer described below; it does not use that legacy manifest.
254
+ Set the mode back to `off` to roll back. Unknown modes keep the lexical result.
255
+
256
+ Live reads `~/.agents/harness-everything/system-one/active.json`; tests can point
257
+ `HARNESS_SYSTEM_ONE_HOME` at another System One home. The pointer has exactly
258
+ `schemaVersion`, `version`, `dir`, `previous`, and `activatedAt`. Its version
259
+ directory contains `manifest.json` with `schemaVersion`, `version`, `createdAt`,
260
+ `stages`, and `evaluation`. `stages` contains `validity`, `intent`, and `tier`;
261
+ each entry names sibling `weights` and `config` files, the weights `sha256`, its
262
+ ordered trainer-catalog `options`, and one per-option `threshold`. The intent
263
+ catalog includes `unclassified`; validity has only `invalid`, and tier has the
264
+ three tier IDs. Calibration, manifest options, and score rows keep the same
265
+ catalog IDs. An optional
266
+ `referenceOnly` list must be a subset of the stage options, and each listed
267
+ option must have threshold `1`. Its score remains visible in the reference
268
+ readout, but it is excluded from automatic decisions. The router verifies the weight
269
+ hash and the CUA-S1 adapter verifies the checkpoint/config pair before loading.
270
+ The workflow hash is the first 16 hex digits of the tier weights hash. A single
271
+ resident process loads all three checkpoints from that version. The public plugin
272
+ contains the loading and training method, not private weights.
273
+
274
+ Live scores the prompt text in order: validity, then intent and tier only when
275
+ validity is actionable. An invalid result stops later scoring. `p(invalid)` at
276
+ or above its threshold marks the prompt invalid. Each option keeps its own
277
+ sigmoid probability. Intent suggestions include options at or above their
278
+ thresholds, sorted by probability and capped at three. The highest-scoring tier
279
+ is returned only when it meets that tier's own threshold; otherwise the tier
280
+ stage abstains. A tie at the top also abstains.
281
+
282
+ Precedence is structural floor and explicit user/workflow choices, then System
283
+ One, then lexical tier when System One abstains, is invalid or unavailable, or
284
+ mode is off. The structural floor can only raise the route. Existing safety,
285
+ explicit prohibitions, memory ownership, and verification remain deterministic.
286
+
287
+ When a valid active version is available, `workflowPlan.systemOne` records the
288
+ fixed version, weight hash, mode, raw stage probabilities, and thresholded
289
+ decision. Unscored stages are `null`. When System One has no active version, the
290
+ field is omitted. User-visible routing text labels the highest stage options
291
+ with their probabilities as reference confidence, never as a verdict; it does
292
+ not print prompt text or artifact paths. Checkpoint activation is opt-in and the
293
+ default mode remains `off`.
294
+
295
+ H1b separately authorized the handoff count enrichment at
296
+ `inputEnrichment.handoffFiles`. F6 authorized `referenceOnly` as optional
297
+ per-stage manifest metadata; it did not explicitly approve a new top-level
298
+ `referenceOnly` output field. The current router includes both fields in
299
+ `workflowPlan.systemOne`, so the top-level `referenceOnly` field remains an
300
+ unresolved discrepancy against shared contract B. The seven-field contract
301
+ shape is:
302
+
303
+ ```json
304
+ {
305
+ "version": "<active version id>",
306
+ "sha256": "<first 16 hex digits of tier weights hash>",
307
+ "mode": "live",
308
+ "validity": { "invalid": 0.12 },
309
+ "intents": {
310
+ "explain": 0.1, "discuss": 0.12, "git": 0.1, "fix": 0.81,
311
+ "edit": 0.2, "feature": 0.54, "refactor": 0.1, "review": 0.1,
312
+ "test": 0.1, "docs": 0.14, "plan": 0.1, "investigate": 0.1
313
+ },
314
+ "tier": { "tier1": 0.1, "tier2": 0.84, "tier3": 0.62 },
315
+ "decision": { "validity": "actionable", "intents": ["fix"], "tier": "tier2" }
316
+ }
317
+ ```
318
+
319
+ `decision.validity` is `actionable`, `invalid`, or `abstain`. `decision.intents`
320
+ contains up to three above-threshold IDs in probability order. `decision.tier` is
321
+ the unique highest above-threshold tier or `null` when the tier stage abstains.
322
+
323
+ Kernel and packaged entry points inherit host environment variables. Prompts
267
324
  and hook payload fields cannot set model configuration or launch executables.
268
325
  Claude Code settings `env` is hot-reloaded and reaches hooks and every command
269
- the agent runs; Codex hooks inherit the `codex` process environment, so a Codex
270
- started from an ordinary terminal needs user/OS-level variables (which then apply
271
- to every program the user starts). The recommended setting is `off` until a
272
- `harness-routing-v1` checkpoint passes the rollout gates.
273
- Repository tests establish mechanism/package evidence only; actual host loading
274
- and semantic quality remain unverified until retained sessions demonstrate them.
326
+ the agent runs; Codex hooks inherit the `codex` process environment. Repository
327
+ tests establish mechanism and package evidence only; live host loading and
328
+ behavioral quality require retained host evidence.
275
329
 
276
330
  ## Phase 3: corpus and paired evaluation
277
331
 
@@ -340,7 +394,7 @@ unversioned download during a prompt hook.
340
394
  | --- | --- | --- |
341
395
  | 0 | Versioned option-scoring boundary | Complete positive/negative contract tests |
342
396
  | 1 | Local CUA-S1 adapter | Bounded subprocess, artifact validation, explicit failures |
343
- | 2 | Router integration | Off/shadow/prefer, existing policy invariants, rollback |
397
+ | 2 | Router integration | Off/shadow/prefer/live, active pointer, precedence, rollback |
344
398
  | 3 | Corpus and paired evaluator | Leakage checks, coverage/error metrics, repeatability |
345
399
  | 4 | Harness training and rollout | Real checkpoint, reviewed holdout, measured host results |
346
400
 
@@ -349,50 +403,44 @@ Phase 4 training data, labeling, calibration and release are defined in
349
403
 
350
404
  ## Staged classification
351
405
 
352
- System One answers three narrow questions in sequence instead of one broad
353
- question. Each stage is its own fixed catalog, scorer request and holdout, so a
354
- small model only has to separate a few options at a time.
355
-
356
- 1. **Tier**: `tier1`, `tier2`, `tier3` or `unclassified`, following
357
- [system-one-corpus.md](system-one-corpus.md).
358
- 2. **Intent**: the kind of work the prompt asks for, drawn from the owner's
359
- fixed catalog in [system-one-intent.md](system-one-intent.md): `explain`,
360
- `discuss`, `git`, `fix`, `edit`, `feature`, `refactor`, `review`, `test`,
361
- `docs`, `plan`, `investigate` or `unclassified`. A prompt has one primary
362
- intent and may have secondary intents.
363
- 3. **Skill relevance**: candidate signals for requirement composition,
364
- scored against canonical skill descriptions. These candidates do not select
365
- paths, trigger loads, or bypass the active-step binding contract.
366
-
367
- Each stage has its own gates, and a stage ships only when it passes them.
368
- The relevance-native plan in
369
- [system-one-suggestion-gates.md](system-one-suggestion-gates.md#readout-per-stage)
370
- adds a validity stage first and runs intent before tier, because tier3 is
371
- composed from the intent scores. Tier was trained first because the
372
- reviewed holdout exists for it. Later stages reuse the
373
- same collector, labeler, trainer and evaluator with a different catalog.
374
- Relevance candidates are advisory inputs to requirement composition: explicit
375
- workflow requests, action gates, memory ownership, the Rule of 3 and
376
- deterministic policy always take precedence. A candidate becomes a skill path
377
- only when a specific ordered requirement declares it as a binding.
378
-
379
- ## Rollout gates
380
-
381
- Model-quality gates for relevance-native candidates are defined in
382
- [system-one-suggestion-gates.md](system-one-suggestion-gates.md), which
383
- supersedes the precision/coverage/latency targets below. The holdout size,
384
- provenance, repeatability and advisory rules below still apply.
385
-
386
- Phase 4 requires a separately reviewed, family-disjoint holdout of at least 200
387
- cases, at least 50 each in English and Traditional Chinese. System One output is
388
- advisory: it informs requirement composition and provides skill-relevance
389
- candidates. It never grants, removes policy, or loads paths. The owner therefore
390
- set the target at accepted precision ≥85% (the
391
- 80–90% band), coverage ≥80%, and macro-F1 at least the lexical baseline. A
392
- probabilistic scorer small enough to ship inside a skills plugin (a few MB, not
393
- hundreds) is not expected to reach 98%.
394
- Policy invariants must remain intact in every case; repeat decisions twice with
395
- 100% agreement. Record checkpoint/source hashes, CPU, OS, runtime, thread count,
396
- cold latency and warm p95 (target ≤100ms). Synthetic fixtures and mock providers
397
- only validate mechanisms. They cannot satisfy these model/behavior gates.
398
- Until measured evidence passes, retain the default, fallback and this open issue.
406
+ Live routing scores three fixed catalogs in order. Validity is `actionable` or
407
+ `invalid`; the intent catalog contains the twelve work intents plus
408
+ `unclassified`; and the tier catalog contains `tier1`, `tier2`, and `tier3`.
409
+ `unclassified` remains in intent score rows and manifest metadata, but is never
410
+ auto-selected or included in the output intent probability map.
411
+
412
+ Invalid prompts receive no intent or tier suggestion. For actionable prompts,
413
+ all intent options are scored independently and up to three above-threshold
414
+ suggestions are reported. Tier uses its own per-option thresholds and abstains
415
+ when no tier meets its threshold. The live tier readout is independent of intent
416
+ scores. System One does not choose workflow strategies or skill paths in this
417
+ contract; explicit workflow requests, action gates, memory ownership, the Rule
418
+ of 3 and the active-step binding contract remain deterministic.
419
+
420
+ In opt-in `live` mode, System One may also read up to three file paths written
421
+ in the prompt: absolute paths, or paths relative to the session working
422
+ directory that stay within it. It considers only existing regular files up to
423
+ 1 MiB and reads at most the first 2 KiB with the shared
424
+ [`handoff-file.js`](../scripts/handoff-file.js) parser. A valid
425
+ `harness-handoff` header adds one `[handoff] kind=... title=... summary=...`
426
+ line per file to the System One scoring input; file bodies are never read.
427
+ The host prompt, lexical routing input and stored prompt observation remain
428
+ unchanged. `workflowPlan.systemOne.inputEnrichment.handoffFiles` records how
429
+ many headers were added. Invalid files and read errors are ignored, and mode
430
+ `off` keeps its existing byte-identical behavior.
431
+
432
+ ## Rollout and evaluation
433
+
434
+ The measurement definitions in
435
+ [system-one-suggestion-gates.md](system-one-suggestion-gates.md) remain useful
436
+ for recording model behavior. For opt-in live routing, their numeric values are
437
+ stored as a baseline and do not block activation. Version comparison and
438
+ rollback follow the long-term optimization curve, not one threshold or metric.
439
+ The default mode stays `off`; private weights are used only by machines with an
440
+ active version pointer, and the public plugin ships the training method rather
441
+ than weights.
442
+
443
+ Evaluation records stage distributions, provenance, repeatability, CPU, OS,
444
+ runtime, thread count, cold latency and warm p95. System One provides reference
445
+ confidence, not absolute answers. Mechanism tests and mock providers establish
446
+ contract behavior only; they do not claim model quality or a live-host result.
@@ -122,14 +122,12 @@ on `actionable` prompts.
122
122
 
123
123
  ### Invalid prompts
124
124
 
125
- Some prompts cannot be judged from their text: a go-ahead (`go`, `好`,
126
- `完成了`), an option pick, a change verb with no object (`修正一下`),
127
- feedback on earlier work (`還是一樣的錯誤`), a pointer to earlier content
128
- (`請依照需求實作`), a paste with no request, or chatter. The small model
129
- does not try to recover the missing context. It marks them `invalid` and
130
- hands them to the host agent (the external LLM), which sees the whole
131
- conversation. Deterministic controls (action gates, scope and memory
132
- ownership, the Rule of 3) apply unchanged. The noise-gate experiment (#265)
125
+ `invalid` means the prompt cannot be understood from its own text and needs
126
+ conversation context. Agent-written dispatch packets and worker instructions
127
+ are ordinary prompts; their audience does not make them invalid. The small
128
+ model judges the prompt text itself, without trying to recover missing
129
+ context. Deterministic controls (action gates, scope and memory ownership,
130
+ the Rule of 3) apply unchanged. The noise-gate experiment (#265)
133
131
  showed that tier labels given to such prompts from session context were
134
132
  what kept a text-only model unsure.
135
133
 
@@ -7,6 +7,8 @@ Gold labels follow [system-one-corpus.md](system-one-corpus.md). The owner-revie
7
7
  holdout in that document is used only for evaluation. It is never used for training,
8
8
  threshold selection or labeler tuning.
9
9
 
10
+ For the owner-started monthly collection-to-package workflow, see [System One monthly training cycle](system-one-cycle.md).
11
+
10
12
  ## Pipeline
11
13
 
12
14
  1. **Collect**: copy the owner's own prompts from local assistant histories into a local
@@ -159,17 +161,25 @@ prompts written by an agent, not by the owner. VS Code terminal notifications
159
161
  same logits, which ranks the intents in relevance order, so the contract's
160
162
  probability vector and the calibration below stay as they are. Handing the absolute
161
163
  relevance bands to the skills stage is a separate contract change.
162
- - The `tinyx` path below is kept for comparison. Its first checkpoint learned little beyond
163
- class priors.
164
- - **Model** (`tinyx`): a new `cua_s1` `tinyx` scorer built with `make_system`.
164
+ - **CUA-S1 trainer**: `scripts/system-one-train.py` builds a new `cua_s1` `tinyx` scorer
165
+ with `make_system`. `--task {validity,intent,tier}` selects the head (default `tier`);
166
+ `--target {label,scores}` selects hard labels or scored intent labels (default `label`).
167
+ `--target scores` requires `--task intent` and reads `labels-intent-scores.jsonl`.
165
168
  - Config: `width` 128, `rank` 128, `layers` 2, `heads` 4, `context_tokens` 1024 and
166
169
  `option_tokens` 96.
167
170
  - Weights are initialized fresh, not from the forms checkpoint, whose domain and
168
171
  positional range differ.
169
- - **Target**: each example is the fixed tier catalog with the index of the gold option.
170
- `null` maps to `unclassified`.
171
- - **Optimization**:
172
- - Cross-entropy, AdamW, a fixed seed and CPU.
172
+ - **Targets**: each option is an independent binary target. The validity head uses all
173
+ `labels.jsonl` rows and scores one `invalid` option: a `null` tier gold maps to 1, and a
174
+ tier gold maps to 0. The tier head uses valid `labels.jsonl` rows, the three options
175
+ `tier1`, `tier2` and `tier3`, and a one-hot target. The intent head uses valid
176
+ `labels-intent.jsonl` rows and the fixed intent catalog; its hard target is multi-hot for
177
+ `gold` plus `secondary`. With `--target scores`, each intent's value from
178
+ `labels-intent-scores.jsonl` is its soft target.
179
+ - **Optimization**: per-option binary cross-entropy with logits, AdamW, a fixed seed and CPU.
180
+ Validation applies sigmoid independently to each option; `val-scores.jsonl` stores rows as
181
+ `{id, gold, scores: {option: probability}}`; option probabilities are independent and do
182
+ not have to sum to one.
173
183
  - The epoch with the lowest validation negative log-likelihood is kept.
174
184
  - The checkpoint metadata records the dataset hashes, the config and the validation metrics.
175
185
  - **Calibration**: `minConfidence` and `minMargin` are chosen on validation to maximize
@@ -191,3 +201,30 @@ prompts written by an agent, not by the owner. VS Code terminal notifications
191
201
  - **Release**: the `.safetensors` and `.json` files are attached to a GitHub release. The
192
202
  installer's pins gain the new model ID, revision, `domain: "harness-routing-v1"` and both
193
203
  SHA-256 values. Until every rollout gate passes, the router default stays `off`.
204
+
205
+ ## Evaluating a version over time
206
+
207
+ Run `scripts/system-one-curves.js` with a version directory, one or more validation score
208
+ files, an optional matching set of holdout score files, a history JSONL file and an output
209
+ directory. Each score row has `{id, gold, scores: {option: probability}}`. Options are
210
+ scored independently: log loss, Brier score and 10-bin ECE use every option-row pair, while
211
+ the confidence curve measures top-choice accuracy as its score threshold sweeps from 0 to 1.
212
+ The report also keeps reliability bins and five score quantiles per option.
213
+
214
+ ```mermaid
215
+ flowchart LR
216
+ V[Validation scores] --> C[Compare AUC, log loss and ECE]
217
+ H[Old holdout scores] --> F{Checked floor has no regression?}
218
+ C --> P{Candidate no worse on all curves?}
219
+ F --> P
220
+ P -->|yes| Promote[Promote]
221
+ P -->|no, two consecutive declines| Rollback[Rollback]
222
+ P -->|otherwise| Hold[Hold]
223
+ ```
224
+
225
+ Promotion requires the candidate to tie or improve the previous version on coverage-accuracy
226
+ area, log loss and ECE, and a checked old-holdout floor with no regression. Missing holdout
227
+ scores leave the floor unknown and block promotion. A rollback requires two consecutive
228
+ history comparisons where the active trend is dominated across those same curves. The
229
+ verdict is based on the whole curve; System One scores remain reference confidence, not
230
+ absolute answers.
@@ -101,6 +101,25 @@ Existing sessions may contain `budget.state = "budget-exhausted"`, old counters,
101
101
 
102
102
  Starting a fresh session remains the cleanest way to discard old evidence, but it is no longer required to recover from numeric budget exhaustion.
103
103
 
104
+ ## Agent hand-off files
105
+
106
+ When one agent hands another a work order, the file is generated by `scripts/handoff-file.js` so the format cannot drift, and its first bytes are a short YAML header that System One reads as its only input (#409 L0). The YAML subset is flat scalars and flat lists; the generator and parser are dependency-free. Keep the header within 2 KB.
107
+
108
+ ```yaml
109
+ ---
110
+ harness-handoff: 1
111
+ kind: implement
112
+ title: Cache fix
113
+ summary: Keep the read cache warm across restarts
114
+ writes: [a.js, b.js]
115
+ gate: node --test passes
116
+ report: reports/R.md
117
+ ---
118
+ ```
119
+
120
+ - `new --kind <implement|test|review|design|question|answer> --title "<text>" --summary "<≤200 chars>" --out <file.md> [--writes a,b] [--gate "<text>"] [--report <path>]` writes the header plus empty `## Scope anchor`, `## Task`, `## Write-set`, `## Verification` and `## Report` sections and a trailing pending-status comment.
121
+ - `header <file.md>` prints the header as JSON; `check <file.md>` validates the kind enum, the ≤ 200-character summary, the ≤ 2 KB header and unknown keys. Both read at most the first 2 KB and fail clearly when the header is absent or invalid.
122
+
104
123
  ## Testing contract
105
124
 
106
125
  Regression tests **MUST** prove:
@@ -4,7 +4,7 @@ description: "Route software/project work through Harness: classify tier/topolog
4
4
  license: Apache-2.0
5
5
  metadata:
6
6
  author: Miya Daniel
7
- version: 0.48.0
7
+ version: 0.52.0
8
8
  ---
9
9
 
10
10
  # Harness Everything
@@ -155,7 +155,8 @@ function activeExecutionFor(persisted, plan) {
155
155
  function printLabelContract() {
156
156
  console.log('\n=> TURN LABEL LINE (MUST, EVERY TURN — short answers, lookups and trivial edits included):');
157
157
  console.log(' - The last line of your final message MUST be one hidden label line with your own post-work judgement, not a copy of the router tier above:');
158
- console.log(' <!-- harness-label {"v":1,"validity":"actionable|invalid","contextDependent":true|false,"tier":"tier1|tier2|tier3|null","intents":["up to 3 of explain,discuss,git,fix,edit,feature,refactor,review,test,docs,plan,investigate"],"workflow":"strategy id or null","skills":["skills used"]} -->');
158
+ console.log(' <!-- harness-label {"v":1,"validity":"actionable|invalid","tier":"tier1|tier2|tier3|null","intents":["up to 3 of explain,discuss,git,fix,edit,feature,refactor,review,test,docs,plan,investigate"],"workflow":"strategy id or null","skills":["skills used"]} -->');
159
+ console.log(' - invalid means the prompt cannot be understood from its own text and needs conversation context; agent-written dispatches and worker instructions are ordinary prompts.');
159
160
  console.log(' - tier1: answer, lookup, status or git operation with no code change; tier2: bounded change; tier3: new feature, refactor, redefinition or cross-component work. Use null only when validity is invalid.');
160
161
  console.log(' - It is invisible in rendered Markdown and records local training data; it never gates routing.');
161
162
  }