harness-everything 0.52.0 → 0.53.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 +20 -0
- package/benchmarks/results/live-host/opencode-2026-11-15-workspace/README.md +7 -0
- package/benchmarks/results/live-host/opencode-2026-11-15-workspace/live-workspace-probe.js +16 -0
- package/benchmarks/results/live-host/opencode-2026-11-15-workspace/live-workspace-trace-2026-11-15.jsonl +4 -0
- package/ci/mechanism-2n-opencode-plugin.test.js +1 -1
- package/ci/mechanism-2p-opencode-v2-entrypoint.test.js +18 -3
- package/ci/mechanism-338-opencode-async.test.js +20 -3
- package/ci/mechanism-341-opencode-lane.test.js +7 -1
- package/ci/mechanism-397-cycle-import.test.js +399 -0
- package/ci/mechanism-397-host-acceptance.test.js +119 -0
- package/ci/mechanism-397-opencode-observations.test.js +1922 -0
- package/ci/mechanism-system-one-curves.test.js +17 -0
- package/ci/mechanism-system-one-cycle.test.js +621 -2
- package/docs/platform-capabilities.md +13 -6
- package/docs/system-one-cycle.md +12 -3
- package/docs/system-one-observations.md +35 -4
- package/hooks/scripts/lib/observations.js +5 -3
- package/opencode-plugin/README.md +22 -8
- package/opencode-plugin/index.mjs +424 -44
- package/opencode-plugin/plugin.json +1 -1
- package/package.json +1 -1
- package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
- package/plugins/harness-everything/hooks/scripts/lib/observations.js +5 -3
- package/plugins/harness-everything/plugin.json +1 -1
- package/sbom.cdx.json +7 -7
- package/scripts/system-one-curves.js +154 -14
- package/scripts/system-one-cycle/collect.js +20 -3
- package/scripts/system-one-cycle/common.js +39 -1
- package/scripts/system-one-cycle/evaluate.js +8 -5
- package/scripts/system-one-cycle.js +7 -2
- package/scripts/system-one-observations-export.js +29 -0
- package/scripts/system-one-observations-import-store.js +128 -0
|
@@ -54,7 +54,7 @@ Source and packaged plugin self-evolve entrypoints use installation-relative can
|
|
|
54
54
|
| Codex | `Supported` | `Mechanism verified` | `Partial`: user-hook compatibility capture is live-verified for `UserPromptSubmit` and `Stop` on one Windows Codex CLI host; native plugin hooks remain mechanism-verified | `.agents/skills/`, `AGENTS.md` | `~/.agents/skills/` | [Live evidence](../benchmarks/results/live-host/codex-2026-10-13/README.md) verifies two consecutive turns on Codex CLI 0.162.1; native plugin mounting, other lifecycle events, and other versions remain unverified. |
|
|
55
55
|
| ChatGPT / OpenAI Plugin | `Unknown` for a repository-local standalone path | `Mechanism verified` | `Partial`: local Work/Codex hooks are separate from ordinary Chat | Managed workspace marketplace | Not established | The public Skills-only bundle is mechanically reproducible; import, approval, and live behavior remain `Unknown`. |
|
|
56
56
|
| Claude Code | `Supported` | `Supported` | `Mechanism verified` for Harness configuration | `.claude/skills/` | `~/.claude/skills/` | Native Claude surfaces and the state-specific plugin sync command are mechanically checked; fresh-host execution is not preserved here. |
|
|
57
|
-
| OpenCode | `Supported` | `Partial` live-host loading for the project-scope, `.js`-filename install path on OpenCode 1.18.31 (macOS);
|
|
57
|
+
| OpenCode | `Supported` | `Partial` live-host loading for the project-scope, `.js`-filename install path on OpenCode 1.18.31 (macOS); router injection and observation capture are mechanism-tested on V2 | `Partial` live-host evidence for project-scope `.js` loading and edit/verification state; new prompt/context hooks have mechanism evidence only | `.opencode/skills/`, `.agents/skills/`, `.opencode/plugins/` | `~/.config/opencode/skills/`, `~/.agents/skills/`, `~/.config/opencode/plugins/` | [Retained evidence](../benchmarks/results/live-host/opencode-2026-09-16/README.md): loading and state effects verified in one host session; final snapshot post-reset; hard lock only an interactive observation, with no retained blocked-tool trace, and a post-reset final snapshot; reflection operator-seeded, then agent-rewritten; no raw transcript or behavioral-effectiveness claim. `.mjs` auto-discovery broken (issue #127); global scope, npm-package installation, and other host versions remain unverified; V2 default-export load verified live on OpenCode 2.1.3 (macOS, 2026-10-23, server-log evidence only). A separate [OpenCode 2.1.4/macOS session workspace trace](../benchmarks/results/live-host/opencode-2026-11-15-workspace/README.md) observed `ctx.session.get({sessionID})` returning `location.directory` for two sessions, both matching setup; it did not exercise a mismatch or fire the V2 hooks. Prompt/system injection and observation capture remain mechanism evidence only; no live-host behavior claim is made. |
|
|
58
58
|
| GitHub Copilot agent surfaces | `Supported` | `Unknown` for a Harness-specific plugin install | `Unknown` | `.github/skills/`, `.agents/skills/`, repository instructions | `~/.copilot/skills/`, `~/.agents/skills/` | GitHub Agent Skills paths and installer behavior are checked; no live Copilot session or plugin install is preserved. |
|
|
59
59
|
| Cursor | `Supported` | `Mechanism verified` for the portable package shape | `Unknown` for Harness | `.cursor/skills/`, `.agents/skills/` | `~/.cursor/skills/`, `~/.agents/skills/` | Official paths and package shape are checked; Cursor plugin loading and hooks remain unverified. |
|
|
60
60
|
| Continue.dev | `Unknown` for standalone `SKILL.md` discovery | `Unknown` | `Unknown` | `.continue/rules/` is documented; `.continue/skills/` is only an installer candidate | `~/.continue/skills/` is only an installer candidate | The reviewed official docs establish rules, not an Agent Skills host contract. |
|
|
@@ -169,16 +169,23 @@ The general installer merges shared files only through Harness-owned markers and
|
|
|
169
169
|
|
|
170
170
|
The OpenCode adapter targets the V2 plugin contract: it default-exports
|
|
171
171
|
`{ id: "harness.enforcement", setup(ctx) }` that registers
|
|
172
|
-
`ctx.
|
|
173
|
-
OpenCode 2 plugin context, and keeps the V1-shaped `HarnessEnforcement` factory
|
|
172
|
+
`ctx.session.hook("prompt|context")`, `ctx.tool.hook("execute.before|after")`,
|
|
173
|
+
and `ctx.event.subscribe()` through the OpenCode 2 plugin context, and keeps the V1-shaped `HarnessEnforcement` factory
|
|
174
174
|
for OpenCode 1.x hosts. OpenCode 2 rejects named-export-only plugins with
|
|
175
175
|
`Plugin must export a default definition with an id and an effect or setup
|
|
176
176
|
function`; that failure (observed on OpenCode 2.1.3, macOS) and the recovery
|
|
177
177
|
after the V2 entrypoint were verified live on one host, with retained evidence
|
|
178
178
|
in the OpenCode server log only (loading succeeded after a plugin-file
|
|
179
|
-
reload; no hook-fire artifact).
|
|
179
|
+
reload; no hook-fire artifact). A separate OpenCode 2.1.4/macOS trace observed
|
|
180
|
+
that `ctx.session.get({sessionID})` returns `location.directory` for two
|
|
181
|
+
sessions whose directories matched setup; it establishes field availability,
|
|
182
|
+
not mismatch handling or V2 hook behavior ([trace notes](../benchmarks/results/live-host/opencode-2026-11-15-workspace/README.md)). The adapter itself has deterministic mechanism
|
|
180
183
|
coverage (`ci/mechanism-2n-opencode-plugin.test.js`, V1 shapes;
|
|
181
|
-
`ci/mechanism-2p-opencode-v2-entrypoint.test.js`, V2 shapes
|
|
184
|
+
`ci/mechanism-2p-opencode-v2-entrypoint.test.js`, V2 lifecycle shapes;
|
|
185
|
+
`ci/mechanism-397-opencode-observations.test.js`, router injection, turn capture,
|
|
186
|
+
malformed-label export counts and opt-out). The injection/capture path has
|
|
187
|
+
mechanism evidence only; no live-host hook-fire or mismatch-handling artifact
|
|
188
|
+
exists. Retained
|
|
182
189
|
evidence supports project-scope `.js` loading and edit/verification state on
|
|
183
190
|
OpenCode 1.18.31 (macOS): [live-host evidence](../benchmarks/results/live-host/opencode-2026-09-16/README.md). The
|
|
184
191
|
retained snapshot predates #190 and remains historical evidence only. Current OpenCode removes the permanent post-reflection hard lock; only the third-failure reflection boundary pauses edits. Reflection was operator-seeded, then agent-rewritten, so do not promote this into a behavioral-effectiveness claim. `.mjs` auto-discovery is broken on this host version (issue #127). npm-package installation and behavioral V2-hook fire remain unverified.
|
|
@@ -193,7 +200,7 @@ remain unchanged.
|
|
|
193
200
|
|
|
194
201
|
## Official sources
|
|
195
202
|
|
|
196
|
-
The matrix records the official documentation reviewed for each platform. Important source families include [OpenAI plugin packaging](https://developers.openai.com/plugins/build/plugins), [OpenAI public submission](https://developers.openai.com/plugins/deploy/submission), [Codex skills](https://learn.chatgpt.com/docs/build-skills), [Codex hooks](https://learn.chatgpt.com/docs/hooks), [Claude skills](https://code.claude.com/docs/en/skills), [OpenCode skills](https://opencode.ai/docs/skills), [GitHub Copilot Agent Skills](https://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-cloud-agent/add-skills), [Cursor skills](https://cursor.com/docs/skills), [Continue rules](https://docs.continue.dev/customize/rules), and [Hermes skills](https://hermes-agent.nousresearch.com/docs/user-guide/features/skills).
|
|
203
|
+
The matrix records the official documentation reviewed for each platform. Important source families include [OpenAI plugin packaging](https://developers.openai.com/plugins/build/plugins), [OpenAI public submission](https://developers.openai.com/plugins/deploy/submission), [Codex skills](https://learn.chatgpt.com/docs/build-skills), [Codex hooks](https://learn.chatgpt.com/docs/hooks), [Claude skills](https://code.claude.com/docs/en/skills), [OpenCode skills](https://opencode.ai/docs/skills), [OpenCode plugin hooks](https://opencode.ai/docs/build/plugins/server/), [OpenCode V1 plugin migration](https://opencode.ai/docs/build/plugins/migrate-v1/), [GitHub Copilot Agent Skills](https://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-cloud-agent/add-skills), [Cursor skills](https://cursor.com/docs/skills), [Continue rules](https://docs.continue.dev/customize/rules), and [Hermes skills](https://hermes-agent.nousresearch.com/docs/user-guide/features/skills).
|
|
197
204
|
|
|
198
205
|
When a platform behavior changes, update this page, `docs/platform-compatibility.json`, and every affected current-state surface in the same change. `npm run test:docs:capabilities` and the compatibility mechanism suite enforce the repository-side contract; they do not replace manual live-host evidence.
|
|
199
206
|
# Experimental System One routing
|
package/docs/system-one-cycle.md
CHANGED
|
@@ -16,6 +16,7 @@ flowchart LR
|
|
|
16
16
|
## Before the monthly run
|
|
17
17
|
|
|
18
18
|
- Use a fresh, private directory for this cycle, outside the Harness checkout. On POSIX hosts the scripts set directory permissions to `0700` and data files to `0600`; on Windows, use a user-private directory with a restrictive ACL.
|
|
19
|
+
- For cross-month comparisons, choose one absolute private history file outside the checkout and every cycle directory, then pass the same `--history` path to each month's `evaluate` or `all` command. If omitted, history remains at `<private-cycle-dir>/training/history.jsonl` for compatibility and is cycle-local.
|
|
19
20
|
- Set `--since` to the last completed collection boundary. `collect` requires this date and accepts an optional `--sessions` path for a non-default Codex session directory.
|
|
20
21
|
- Pick a version id containing letters, numbers, dots, underscores, or hyphens. Reuse the same data directory and version id to resume; use a new directory for the next month.
|
|
21
22
|
- Replace the placeholders in the commands below with real paths, dates, and a version id.
|
|
@@ -29,7 +30,7 @@ flowchart LR
|
|
|
29
30
|
| Judge | `node scripts/system-one-cycle.js judge --data-dir "<private-cycle-dir>"` | Self tier and text-only Luna tier disagreements → private `training/adjudication/input.jsonl` and `consensus.jsonl`. Two independent votes are collected from Luna and OpenCode using current text and candidate labels. | Two model calls per batch of up to 20 disagreements; low local memory. | Completed majority and no-majority rows are skipped. Failed batches have no consensus row and are retried. A split vote is dropped during build; it does not request human review. |
|
|
30
31
|
| Build | `node scripts/system-one-cycle.js build --data-dir "<private-cycle-dir>"` | Observed text, Luna labels, consensus, behavior contradictions, and the existing frozen holdouts → consensus-adjusted tier/intent rows under `training/v1/`, raw Luna validity labels under `training/v1-validity/`, and a count-only report. | Usually seconds to minutes; memory grows with the dataset. | Safe to rerun; outputs are rebuilt from the current input files. Validation copies win over normalized train duplicates. |
|
|
31
32
|
| Train | `node scripts/system-one-cycle.js train --data-dir "<private-cycle-dir>" --version <version-id>` | The validity task reads raw Luna labels from `training/v1-validity/`; tier and intent read the consensus-adjusted dataset in `training/v1/`. Outputs CUA-S1 checkpoints, catalog-keyed validation scores, a trainer report with the catalog IDs, calibration, and `resource-guard.json` under `training/runs/<version-id>/`. | CPU training with 4 threads by default and a 6144 MB RSS ceiling. Duration depends on row count and epochs. | Completed stages are reused. If interrupted inside a stage, that stage starts again; earlier completed stages are kept. |
|
|
32
|
-
| Evaluate | `node scripts/system-one-cycle.js evaluate --data-dir "<private-cycle-dir>" --version <version-id
|
|
33
|
+
| Evaluate | `node scripts/system-one-cycle.js evaluate --data-dir "<private-cycle-dir>" --version <version-id> [--history "<absolute-private-history.jsonl>"]` | Candidate checkpoints, validation scores, and the existing frozen holdouts → score files, `curves.json`, and `trend.json` in a candidate version directory. The scorer follows the trainer catalog; curves uses the shared manifest validator and requires each score row's keys to match the stage options. It appends one immutable version row to the selected history file. | CPU scoring at one thread plus the curve calculation; typically seconds to minutes after checkpoint loading. | Cached curves and trend are reused. If the selected history lacks that version row, resume validates and appends the saved curves once without rescoring. Conflicting reuse fails. |
|
|
33
34
|
| Package | `node scripts/system-one-cycle.js package --data-dir "<private-cycle-dir>" --version <version-id>` | Trained candidate and evaluation artifacts → `training/versions/<version-id>/manifest.json` with three stage entries, relative artifact paths, thresholds, and weight SHA-256 values. The trainer catalog is the source of truth: intent includes `unclassified`, and catalog IDs, score keys, manifest options, and threshold keys agree. A `null` calibration threshold becomes `1` and the stage lists that option under `referenceOnly`, so its score stays available while it is excluded from automatic decisions. | A local file copy and hashes; usually seconds. | Safe to rerun. Repackaging an older candidate that omitted only intent `unclassified` metadata restores it as reference-only without retraining. Evaluation references carry forward. |
|
|
34
35
|
| Publish | `node scripts/system-one-cycle.js publish --data-dir "<private-cycle-dir>" --version <version-id>` | `training/versions/<version-id>/` → `models/cua-s1/<version-id>/` in the same private data directory. It prints the published path; it does not use Git. The installer reads this model directory. | A local file copy; usually seconds. | Published version ids are immutable. Use a new id for changed weights; an existing destination is not overwritten. |
|
|
35
36
|
|
|
@@ -45,10 +46,18 @@ shape discrepancy.
|
|
|
45
46
|
Run the full cycle with one command:
|
|
46
47
|
|
|
47
48
|
```sh
|
|
48
|
-
node scripts/system-one-cycle.js all --until publish --data-dir "<private-cycle-dir>" --since <YYYY-MM-DD> --version <version-id>
|
|
49
|
+
node scripts/system-one-cycle.js all --until publish --data-dir "<private-cycle-dir>" --since <YYYY-MM-DD> --version <version-id> --history "<absolute-private-history.jsonl>"
|
|
49
50
|
```
|
|
50
51
|
|
|
51
|
-
`all` runs each step in order and stops at `--until
|
|
52
|
+
`all` runs each step in order and stops at `--until`; it passes `--history` through to evaluation. Completed collection, label, and judge steps with their outputs are skipped. If a label or judge batch fails, `all` stops at that step without marking it complete; rerun the same command to resume. `build` can be rerun. Training resumes between completed stages; evaluation reuses complete curve artifacts; packaging can be repeated. Publish only after packaging, then use the private data directory as the install source described in the [System One routing guide](system-one-routing.md).
|
|
53
|
+
|
|
54
|
+
## Cross-cycle history and floor baseline
|
|
55
|
+
|
|
56
|
+
- History is append-only. Reusing a version id is allowed only when its saved curve content matches; duplicate or conflicting version rows fail without overwriting existing history.
|
|
57
|
+
- Cached resume is accepted only when the selected history reproduces its saved baseline, ordered predecessor comparisons, and verdict; incompatible history is rejected without changing history or saved artifacts.
|
|
58
|
+
- Each stage keeps the first compatible historical holdout row as its floor baseline. Later rows record the baseline version and compare against that same row, including after partial recovery.
|
|
59
|
+
- A supplied history path must resolve outside the repository and name a file. Malformed history fails visibly. On POSIX, newly created history directories and files use `0700` and `0600`; existing shared parent permissions are left alone. Windows ACLs remain the operator's responsibility.
|
|
60
|
+
- The two-consecutive-cycle detector uses the latest three evaluation rows as its active-trend proxy. It does not identify the version currently installed; active-version rollback semantics remain with #443.
|
|
52
61
|
|
|
53
62
|
For a synthetic integration check that does not read local session data or invoke model engines, prepare the earlier stage artifacts and completion entries under `.s1-work/`, then run:
|
|
54
63
|
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Status: **accepted**, 2026-09-27. Owner decisions are recorded below.
|
|
4
4
|
Implementation: `hooks/scripts/observation-hook.js`,
|
|
5
|
-
`hooks/scripts/lib/observations.js`, `scripts/system-one-observations-export.js`, `scripts/system-one-observations-import-codex-sessions.js
|
|
5
|
+
`hooks/scripts/lib/observations.js`, `scripts/system-one-observations-export.js`, `scripts/system-one-observations-import-codex-sessions.js`,
|
|
6
|
+
`scripts/system-one-observations-import-store.js` and
|
|
6
7
|
`scripts/system-one-observations-review.js`; tests in
|
|
7
|
-
`ci/mechanism-34-observations.test.js`. Issue
|
|
8
|
+
`ci/mechanism-34-observations.test.js` and `ci/mechanism-397-cycle-import.test.js`. Issue
|
|
8
9
|
[#233](https://github.com/dyphn1/Harness-everything/issues/233).
|
|
9
10
|
|
|
10
11
|
## Why
|
|
@@ -29,7 +30,7 @@ validity, intent, tier, workflow and skills.
|
|
|
29
30
|
- Collection is **on by default**, with no environment variable needed to
|
|
30
31
|
enable it. `HARNESS_OBSERVATIONS=off` turns it off; this opt-out exists
|
|
31
32
|
because the plugin ships to other users.
|
|
32
|
-
- Hosts: **Claude Code** and **
|
|
33
|
+
- Hosts: **Claude Code**, **Codex** and **OpenCode**.
|
|
33
34
|
- This document is the specification; implementation follows
|
|
34
35
|
docs → RED → GREEN.
|
|
35
36
|
|
|
@@ -173,6 +174,8 @@ warning sign. The review page samples the turns where they differ.
|
|
|
173
174
|
cannot read Codex trust state.
|
|
174
175
|
- The final message comes from the rollout's `task_complete` event.
|
|
175
176
|
- Fresh live-host verification on Windows (Codex CLI 0.162.1, 2026-10-13) exercised the user-hook compatibility fallback: only the `UserPromptSubmit` and `Stop` observation hooks were individually reviewed/trusted. Two consecutive real turns produced `host: "codex"` records with distinct current `turn_id` values and their respective valid self-reports. The sanitized record excerpt and scope limits are preserved in [Codex live-host evidence](../benchmarks/results/live-host/codex-2026-10-13/README.md). This does not verify native plugin-bundled hooks, other lifecycle events, or tool behavior capture.
|
|
177
|
+
- **OpenCode 2.x:** the plugin's documented `prompt` hook captures the original user text and runs the canonical kernel router; its `context` hook adds that router output, including the exact label instruction, to primary model requests. OpenCode tool events and `session.idle` feed the shared observation library, which reads the current turn's final assistant text through the session context API. `HARNESS_OBSERVATIONS=off` disables capture while routing injection remains active. Deterministic mechanism tests cover injection, turn recording, malformed labels, and opt-out; there is no retained live-host artifact for these hooks yet.
|
|
178
|
+
- The OpenCode exporter reports malformed `label-invalid` and `label-unparseable` records by host in `malformedLabelsByHost`; missing labels remain a separate reason and count.
|
|
176
179
|
- The final message must belong to the current turn. A transcript scan
|
|
177
180
|
stops at the start of the current turn (Codex `task_started` or a user
|
|
178
181
|
message; a Claude user prompt) and a Codex `task_complete` must carry the
|
|
@@ -195,15 +198,43 @@ The importer scans local Codex rollout files and pairs each completed turn with
|
|
|
195
198
|
|
|
196
199
|
The importer accepts only valid label lines, applies the same email/home-path redaction, and appends idempotently to the private observations store. Backfill and live hook records deduplicate by `(host, writer.sessionId, writer.turnId)`. For older live records without a turn ID, an exact turn-and-text match is skipped; a partial match is counted as ambiguous and skipped to avoid silently duplicating training data. Duplicate and ambiguous legacy live matches are checked atomically under the store lock. A bounded lock timeout is reported as a persistence failure, not as a duplicate, and gives the importer a nonzero exit status; migration lock timeouts are reported the same way. Existing backfill behavior placeholders are migrated to `null`. Reports contain counts and generic error descriptions without printing session text. The cutoff defaults to the date the label contract was accepted. The importer never uploads or writes session content into the repository.
|
|
197
200
|
|
|
201
|
+
## Cycle import boundary
|
|
202
|
+
|
|
203
|
+
The `collect` step writes only to its private cycle directory. It runs Codex
|
|
204
|
+
session backfill, then imports every in-window record from the live store at
|
|
205
|
+
`observations.storeRoot()` (overridable with `HARNESS_OBSERVATIONS_DIR`). The
|
|
206
|
+
store importer preserves unlabeled and malformed-label metadata, including
|
|
207
|
+
its reason code, and deduplicates through `appendRecordDetailed` by host,
|
|
208
|
+
session and turn. It copies text only while the source record's original
|
|
209
|
+
retention deadline permits it; missing or expired text stays unavailable.
|
|
210
|
+
|
|
211
|
+
```mermaid
|
|
212
|
+
flowchart LR
|
|
213
|
+
OC[OpenCode and other live capture] --> LS[Private live observation store]
|
|
214
|
+
CS[Codex session backfill] --> CY[Private cycle observation store]
|
|
215
|
+
LS --> IM[Cycle store importer]
|
|
216
|
+
IM --> CY
|
|
217
|
+
CY --> EX[Prompt and label exports]
|
|
218
|
+
IM --> IR[Text-free import-report.json]
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
`import-report.json` records each source's status and per-host persisted,
|
|
222
|
+
duplicate, ambiguous and failed import counts. It contains a stable label for
|
|
223
|
+
the live store rather than its path. Final label rows retain their `host` so
|
|
224
|
+
OpenCode and Codex examples remain attributable after collection.
|
|
225
|
+
|
|
198
226
|
## Export
|
|
199
227
|
|
|
200
228
|
`scripts/system-one-observations-export.js` writes to the private data
|
|
201
229
|
repository:
|
|
202
230
|
|
|
203
231
|
- `prompts-observed.jsonl`: `{id, family, source: "observation", split, text}`
|
|
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.
|
|
232
|
+
- `labels-observed.jsonl`: `{id, validity, tier, tierSource, intents, workflow, skills, behaviorEvidence, contradictions, host, systemOne}`. `systemOne` is `{version, sha256, mode, decision}` or `null`; score maps stay in the private observation store.
|
|
205
233
|
- `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.
|
|
206
234
|
|
|
235
|
+
The text-free `export-report.json` includes `malformedLabelsByHost` for invalid
|
|
236
|
+
or unparseable self-reports, including those omitted by `--self-report-only`.
|
|
237
|
+
|
|
207
238
|
`family` groups near-duplicate prompts. The split is by time: the newest 15%
|
|
208
239
|
is validation. The existing holdouts stay frozen and separate. Observed data
|
|
209
240
|
may later seed a new holdout, but only after owner review.
|
|
@@ -345,7 +345,7 @@ function transcriptMessage(file, turnId) {
|
|
|
345
345
|
|
|
346
346
|
function detectHost(payload, hints) {
|
|
347
347
|
const direct = String(payload.host || payload.runtime || '').toLowerCase();
|
|
348
|
-
if (['claude', 'codex'].includes(direct)) return direct;
|
|
348
|
+
if (['claude', 'codex', 'opencode'].includes(direct)) return direct;
|
|
349
349
|
if (hints.codex || payload.turn_id || payload.last_agent_message) return 'codex';
|
|
350
350
|
if (process.env.CLAUDE_PLUGIN_ROOT || process.env.CLAUDECODE || process.env.CLAUDE_CODE_ENTRYPOINT || process.env.CLAUDE) return 'claude';
|
|
351
351
|
if (process.env.CODEX_HOME || process.env.CODEX_THREAD_ID) return 'codex';
|
|
@@ -587,6 +587,8 @@ function collectEvents(root, sessionId, turn) {
|
|
|
587
587
|
function startTurn(payload, root) {
|
|
588
588
|
const file = sessionFile(root, payload.session_id);
|
|
589
589
|
const session = readJson(file, null) || { turn: 0, lastFinal: '', pending: null };
|
|
590
|
+
const turnId = String(payload.turn_id || payload.turnId || '');
|
|
591
|
+
if (session.pending && turnId && session.pending.turnId === turnId) return;
|
|
590
592
|
if (session.pending) finishPending(session, payload, root, { text: null, reason: 'stop-missing' });
|
|
591
593
|
if (!session.lastFinalAt || Date.now() - Date.parse(session.lastFinalAt) > RETENTION_MS) session.lastFinal = '';
|
|
592
594
|
// Events left from an earlier turn arrived after its Stop; they belong to no record.
|
|
@@ -594,7 +596,7 @@ function startTurn(payload, root) {
|
|
|
594
596
|
session.turn++;
|
|
595
597
|
session.pending = {
|
|
596
598
|
turn: session.turn,
|
|
597
|
-
turnId
|
|
599
|
+
turnId,
|
|
598
600
|
startedAt: new Date().toISOString(),
|
|
599
601
|
prompt: redact(typeof payload.prompt === 'string' ? payload.prompt : ''),
|
|
600
602
|
previous: session.lastFinal || '',
|
|
@@ -654,7 +656,7 @@ function finishPending(session, payload, root, final) {
|
|
|
654
656
|
selfReport: label,
|
|
655
657
|
selfReportReason: reason,
|
|
656
658
|
};
|
|
657
|
-
|
|
659
|
+
appendRecordDetailed(root, record, textExpired ? null : text, { dedupeById: true, dedupeByTurn: true });
|
|
658
660
|
fs.rmSync(eventsDir(root, payload.session_id, pending.turn), { recursive: true, force: true });
|
|
659
661
|
session.lastFinal = final.text ? redact(tailBytes(stripLabels(final.text), PREVIOUS_BYTES)) : '';
|
|
660
662
|
session.lastFinalAt = observedAt;
|
|
@@ -15,9 +15,9 @@ only SUGGEST rules (soft guidance). This means:
|
|
|
15
15
|
|
|
16
16
|
## The plugin
|
|
17
17
|
|
|
18
|
-
**File:** `index.mjs` -
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
**File:** `index.mjs` - the ESM plugin entrypoint. The OpenCode 2 adapter uses
|
|
19
|
+
the documented prompt and context hooks; the V1 factory remains available for
|
|
20
|
+
existing OpenCode 1 installations. There is no manifest-to-script
|
|
21
21
|
mechanism; an earlier version of this plugin assumed one (a `plugin.json`
|
|
22
22
|
mapping event names to standalone scripts) and opencode never invoked it -
|
|
23
23
|
see issue #37 for how that was found and fixed. **Naming caveat (issue
|
|
@@ -26,7 +26,7 @@ must be copied to a `.js` name when installed - see Installation below.
|
|
|
26
26
|
|
|
27
27
|
It implements three lifecycle mechanisms across opencode's real hooks:
|
|
28
28
|
|
|
29
|
-
The
|
|
29
|
+
The V1 factory follows opencode's plugin contract directly: the named
|
|
30
30
|
`HarnessEnforcement` export is an async factory receiving the opencode context
|
|
31
31
|
(`client`, `directory`, `project`, `worktree`, and `$`) and returning the hook
|
|
32
32
|
map. Copying this one file into `.opencode/plugins/` under a `.js` name is
|
|
@@ -35,6 +35,9 @@ repository
|
|
|
35
35
|
inventory and is not an opencode runtime manifest. The hook callbacks use the
|
|
36
36
|
V1 `(input, output)` shape, including
|
|
37
37
|
`output.args` when the host supplies tool arguments only in the result object.
|
|
38
|
+
OpenCode 2's prompt injection and observation path resolves the canonical
|
|
39
|
+
`harness-everything/scripts/kernel-router.js` and
|
|
40
|
+
`hooks/scripts/lib/observations.js` from an ancestor Harness checkout/runtime.
|
|
38
41
|
|
|
39
42
|
### 1. Edit tracking (`tool.execute.after`)
|
|
40
43
|
|
|
@@ -102,8 +105,9 @@ new breaker failure. A reflection artifact itself does not count as a code edit.
|
|
|
102
105
|
|
|
103
106
|
## Installation
|
|
104
107
|
|
|
105
|
-
**OpenCode 2.x
|
|
106
|
-
`{ id: "harness.enforcement", setup(ctx) }` and registers
|
|
108
|
+
**OpenCode 2.x:** the module default-exports
|
|
109
|
+
`{ id: "harness.enforcement", setup(ctx) }` and registers
|
|
110
|
+
`ctx.session.hook("prompt|context")`, `ctx.tool.hook("execute.before|after")`,
|
|
107
111
|
plus `ctx.event.subscribe()` through the OpenCode 2 plugin context. OpenCode 2
|
|
108
112
|
never loads a named-export-only plugin: it fails with `Plugin must export a
|
|
109
113
|
default definition with an id and an effect or setup function`
|
|
@@ -114,11 +118,17 @@ available for OpenCode 1.x hosts: it receives the V1 context
|
|
|
114
118
|
adapter wraps that factory and maps the V2 hook events onto it, so the
|
|
115
119
|
enforcement logic is shared, not duplicated.
|
|
116
120
|
|
|
121
|
+
The prompt/context routing and System One observation hooks are V2-only. The
|
|
122
|
+
V1 factory keeps its existing enforcement hooks; it does not capture turns.
|
|
123
|
+
|
|
117
124
|
Direction:
|
|
118
125
|
named factory (V1 hosts/tests) → default-export setup adapter → V2 domains.
|
|
119
126
|
|
|
120
|
-
Copy `index.mjs` into opencode's plugin directory **under a `.js` filename
|
|
121
|
-
|
|
127
|
+
Copy `index.mjs` into opencode's plugin directory **under a `.js` filename**.
|
|
128
|
+
The router and observation hooks resolve from a Harness checkout above the
|
|
129
|
+
plugin, or from sibling `harness-everything/`, `hooks/scripts/`, and
|
|
130
|
+
`scripts/lib/` runtime directories. A project install inside the Harness
|
|
131
|
+
checkout already has those files.
|
|
122
132
|
|
|
123
133
|
```bash
|
|
124
134
|
mkdir -p .opencode/plugins
|
|
@@ -126,6 +136,10 @@ cp opencode-plugin/index.mjs .opencode/plugins/harness-enforcement.js # projec
|
|
|
126
136
|
# or
|
|
127
137
|
mkdir -p ~/.config/opencode/plugins
|
|
128
138
|
cp opencode-plugin/index.mjs ~/.config/opencode/plugins/harness-enforcement.js # global
|
|
139
|
+
mkdir -p ~/.config/opencode/hooks ~/.config/opencode/scripts
|
|
140
|
+
cp -R harness-everything ~/.config/opencode/
|
|
141
|
+
cp -R hooks/scripts ~/.config/opencode/hooks/
|
|
142
|
+
cp -R scripts/lib ~/.config/opencode/scripts/
|
|
129
143
|
```
|
|
130
144
|
|
|
131
145
|
Restart OpenCode after copying so the plugin is discovered at startup.
|