harness-everything 0.56.0 → 0.57.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 +23 -0
- package/benchmarks/results/live-host/claude-2026-11-21-ledger-lesson/README.md +33 -0
- package/benchmarks/results/live-host/claude-2026-11-21-ledger-lesson/trace.jsonl +13 -0
- package/ci/fixtures/394-claude-ledger-lesson/post-tool-use-failure.json +13 -0
- package/ci/fixtures/394-claude-ledger-lesson/pre-tool-use.json +10 -0
- package/ci/fixtures/394-codex-ledger-lesson/post-tool-use-failure.json +17 -0
- package/ci/fixtures/394-codex-ledger-lesson/post-tool-use-success.json +17 -0
- package/ci/fixtures/394-codex-ledger-lesson/post-tool-use-unknown.json +15 -0
- package/ci/fixtures/394-codex-ledger-lesson/pre-tool-use.json +12 -0
- package/ci/fixtures/394-ledger-match/commitlint-empty-subject.txt +5 -0
- package/ci/fixtures/394-ledger-match/commitlint-subject-case.txt +5 -0
- package/ci/fixtures/394-ledger-match/provisional-candidates.json +20 -0
- package/ci/fixtures/394-ledger-match/quoted-match-record.md +25 -0
- package/ci/fixtures/468-dispatch/runner.js +30 -4
- package/ci/mechanism-394-claude-ledger-lesson.test.js +176 -0
- package/ci/mechanism-394-codex-ledger-lesson.test.js +203 -0
- package/ci/mechanism-394-ledger-match.test.js +507 -0
- package/ci/mechanism-394-opencode-ledger-lesson.test.js +232 -0
- package/ci/mechanism-468-dispatch-cli.test.js +143 -5
- package/ci/mechanism-errors-sync-root.test.js +86 -4
- package/ci/mechanism-report-writer.test.js +13 -1
- package/docs/adr/ROUTE-001-error-lesson-delivery.md +52 -49
- package/docs/error-handling/details/c8-dispatch-cli.md +8 -4
- package/docs/governed-index.md +1 -1
- package/docs/platform-capabilities.md +4 -0
- package/hooks/hooks.json +22 -0
- package/hooks/scripts/codex-ledger-lesson.js +82 -0
- package/hooks/scripts/ledger-lesson.js +94 -0
- package/hooks/scripts/lib/ledger-match.js +452 -0
- package/opencode-plugin/index.mjs +113 -4
- 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/hooks.json +24 -0
- package/plugins/harness-everything/hooks/scripts/codex-ledger-lesson.js +82 -0
- package/plugins/harness-everything/hooks/scripts/ledger-lesson.js +94 -0
- package/plugins/harness-everything/hooks/scripts/lib/ledger-match.js +452 -0
- package/plugins/harness-everything/plugin.json +1 -1
- package/sbom.cdx.json +7 -7
- package/scripts/dispatch.js +31 -7
- package/scripts/errors-sync.js +63 -2
- package/scripts/report-writer.js +4 -2
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: ROUTE-001
|
|
3
|
-
status:
|
|
3
|
+
status: superseded
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# ROUTE-001 — Error lesson delivery into active-step context
|
|
7
7
|
|
|
8
|
-
**
|
|
9
|
-
|
|
8
|
+
> **Superseded (2026-11-21).** The E-0002 delivery design below is no longer the governing design. Owner decision [#394 comment 7062351415](https://github.com/dyphn1/Harness-everything/issues/394#issuecomment-7062351415) supersedes it; E-0002 is now owned by the C4 report writer shipped in [#462](https://github.com/dyphn1/Harness-everything/pull/462), and the Rule-of-3 breaker it carved out around was retired in [#494](https://github.com/dyphn1/Harness-everything/pull/494). Obsolete design is struck through; the enduring policy and historical evidence remain unstruck.
|
|
9
|
+
|
|
10
|
+
~~**This is a design ADR for a mechanism that is not shipped.** Nothing in this repository is modified
|
|
11
|
+
by this document; the follow-up implementation it defines does not exist yet.~~ This ADR does **not** claim:
|
|
10
12
|
|
|
11
13
|
- that error handling improved, or that any behavior changed (no paired evidence exists);
|
|
12
14
|
- that the chosen error class is closed or its recurrence prevented;
|
|
@@ -19,7 +21,7 @@ by this document; the follow-up implementation it defines does not exist yet. Th
|
|
|
19
21
|
|
|
20
22
|
## Decision
|
|
21
23
|
|
|
22
|
-
-
|
|
24
|
+
- ~~**Chosen error class: `E-0002` (`report-protocol` — reports ending without a plain column-zero
|
|
23
25
|
terminal `STATUS` line).** The generated ledger index has no rank field; E-0002 is not the most
|
|
24
26
|
frequent class (E-0009 has 7 episodes, E-0002 and E-0003 have 5 each — counts freshly verified by
|
|
25
27
|
`node scripts/errors-sync.js --check` at this SHA). E-0002 is chosen because it fits #402's stated
|
|
@@ -28,7 +30,7 @@ by this document; the follow-up implementation it defines does not exist yet. Th
|
|
|
28
30
|
`425-review2-label-after-status` (2026-11-11) occurred *after* the lesson existed, in packets that did
|
|
29
31
|
not state the terminal-line condition. Sources:
|
|
30
32
|
[#402 comment 6785928296](https://github.com/dyphn1/Harness-everything/issues/402#issuecomment-6785928296);
|
|
31
|
-
`.agents/harness-everything/errors/E-0002-report-missing-terminal-status.md
|
|
33
|
+
`.agents/harness-everything/errors/E-0002-report-missing-terminal-status.md`.~~
|
|
32
34
|
- **The existing ledger lesson (carried verbatim, not restated):** every report ends with one plain
|
|
33
35
|
column-zero `STATUS: DONE` or `STATUS: BLOCKED: <reason>` line; when a host rule also requires a
|
|
34
36
|
trailing line, the packet must state which line is terminal. The E-0002 record file is the content
|
|
@@ -44,14 +46,16 @@ by this document; the follow-up implementation it defines does not exist yet. Th
|
|
|
44
46
|
| `SONE` | System One domain; this decision does not change System One provider or routing internals |
|
|
45
47
|
| `DIST` | Distribution domain; this decision changes no packaging or distribution behavior |
|
|
46
48
|
|
|
47
|
-
-
|
|
49
|
+
- ~~**Delivery channel: prompt context at `UserPromptSubmit`, through the existing `additionalContext`
|
|
48
50
|
seam (owner ruling A7.1).** No new hook file, no second router. On Claude Code the router already runs
|
|
49
51
|
at `UserPromptSubmit` (`hooks/hooks.json`, id `harness:pre:kernel-router`); on Codex,
|
|
50
52
|
`hooks/scripts/codex-user-prompt.js` pipes the whole hook payload to the router and wraps its stdout as
|
|
51
53
|
JSON `hookSpecificOutput.additionalContext` (`plugins/harness-everything/hooks/hooks.json`), because
|
|
52
54
|
Codex adds prompt-time context to the model only from that JSON field
|
|
53
55
|
([system-one-observations.md](../system-one-observations.md#hosts)). The lesson rides in the context the
|
|
54
|
-
seam already sends
|
|
56
|
+
seam already sends;~~ the hook stays a **context carrier, not a decision maker** (A2).
|
|
57
|
+
|
|
58
|
+
### Mermaid flow (superseded, historical)
|
|
55
59
|
|
|
56
60
|
```mermaid
|
|
57
61
|
flowchart LR
|
|
@@ -64,7 +68,7 @@ flowchart LR
|
|
|
64
68
|
W --> O["Observation: the report file's raw<br/>final line is column-zero STATUS —<br/>or it is not"]
|
|
65
69
|
```
|
|
66
70
|
|
|
67
|
-
-
|
|
71
|
+
- ~~**Relevance: an explicit report-required signal selects the E-0002 record only (owner ruling A7.2).**
|
|
68
72
|
The signal is defined concretely:
|
|
69
73
|
- *Source:* the prompt text of the `UserPromptSubmit` payload — `payload.prompt`, which the router
|
|
70
74
|
already reads (`harness-everything/scripts/kernel-router.js`: `const prompt = promptArg ||
|
|
@@ -84,19 +88,18 @@ flowchart LR
|
|
|
84
88
|
(`activeExecutionFor` → `activeStepSnapshot`) — defined only when a retained workflow with a loaded
|
|
85
89
|
obligation set exists, so it covers a subset of report work through a second selection surface; and
|
|
86
90
|
agent-side grep of the index at task start — no code change but depends on agent discipline, the
|
|
87
|
-
failure mode the ledger README already records
|
|
88
|
-
|
|
91
|
+
failure mode the ledger README already records.~~
|
|
89
92
|
- **Label vs STATUS (owner ruling A7.4), stated as decided:**
|
|
90
93
|
- A report **file** ends with its raw column-zero `STATUS:` line and carries no harness-label; the
|
|
91
94
|
**turn's** final message summarises or links the report and ends with the hidden harness-label line
|
|
92
95
|
(`docs/routing.md` § Turn label line).
|
|
93
|
-
- When the report *is* the turn's final message, the rule is a **report-turn exception to
|
|
96
|
+
- ~~When the report *is* the turn's final message, the rule is a **report-turn exception to
|
|
94
97
|
label-last**. That exception is owned by `AGENTS.md` (applicability) and `docs/routing.md` (label
|
|
95
|
-
contract); making it is a follow-up change, **not made here** — those files are not edited by this ADR
|
|
98
|
+
contract); making it is a follow-up change, **not made here** — those files are not edited by this ADR.~~
|
|
96
99
|
- E-0002's recorded episodes (including the label-after-status ones) stay as history; a
|
|
97
100
|
provenance-carrying correction of the lesson text is **#359's** follow-up. This ADR does not rewrite
|
|
98
101
|
the ledger record.
|
|
99
|
-
- **Success / failure observation, in three layers that are never merged into one PASS:**
|
|
102
|
+
- **Success / failure observation, in three layers that are never merged into one PASS:** *(historical E-0002 example)*
|
|
100
103
|
|
|
101
104
|
| Layer | What is recorded | What is not claimed |
|
|
102
105
|
| --- | --- | --- |
|
|
@@ -108,25 +111,25 @@ flowchart LR
|
|
|
108
111
|
nonconformant. Neither is recorded as a single PASS.
|
|
109
112
|
- Any later behavior-improvement claim requires paired baseline/treatment evidence; this ADR's
|
|
110
113
|
observation contract does not provide it.
|
|
111
|
-
-
|
|
114
|
+
- ~~**Smallest follow-up implementation acceptance (design only; nothing is implemented here):** one seam
|
|
112
115
|
(the `UserPromptSubmit` context assembly above), one minimal change (signal match ⇒ read
|
|
113
116
|
`.agents/harness-everything/errors/E-0002-report-missing-terminal-status.md` § Lesson and append it
|
|
114
|
-
verbatim to the existing context), with these controls
|
|
117
|
+
verbatim to the existing context), with these controls:~~
|
|
115
118
|
|
|
116
|
-
| Control | Expected result | Evidence layer the check gives |
|
|
119
|
+
| ~~Control~~ | ~~Expected result~~ | ~~Evidence layer the check gives~~ |
|
|
117
120
|
| --- | --- | --- |
|
|
118
|
-
| No marker in the prompt | No injection; context identical to today | Deterministic mechanism test |
|
|
119
|
-
| Marker present, record readable | The exact E-0002 lesson text delivered in context | Deterministic mechanism test, then one real-host task for receipt |
|
|
120
|
-
| Marker present, record unreadable or source stale | Delivery unavailable; tools stay usable; no fallback to the whole ledger | Deterministic mechanism test |
|
|
121
|
-
| Report produced | Final line conformant or not, recorded per the observation table | One real-host task (one-run outcome) |
|
|
121
|
+
| ~~No marker in the prompt~~ | ~~No injection; context identical to today~~ | ~~Deterministic mechanism test~~ |
|
|
122
|
+
| ~~Marker present, record readable~~ | ~~The exact E-0002 lesson text delivered in context~~ | ~~Deterministic mechanism test, then one real-host task for receipt~~ |
|
|
123
|
+
| ~~Marker present, record unreadable or source stale~~ | ~~Delivery unavailable; tools stay usable; no fallback to the whole ledger~~ | ~~Deterministic mechanism test~~ |
|
|
124
|
+
| ~~Report produced~~ | ~~Final line conformant or not, recorded per the observation table~~ | ~~One real-host task (one-run outcome)~~ |
|
|
122
125
|
|
|
123
126
|
- Explicitly forbidden: no fallback to the whole ledger, no fabricated receipt, no automatic rewrite of
|
|
124
127
|
the report, no error counter, no fixed recurrence threshold, no reflection tokens, no forced report,
|
|
125
128
|
no mutation lock, no automatic escalation or reset ritual (A2).
|
|
126
|
-
- Host evidence boundary: only the host seam chosen here (`UserPromptSubmit` context on Claude Code and
|
|
129
|
+
- ~~Host evidence boundary: only the host seam chosen here (`UserPromptSubmit` context on Claude Code and
|
|
127
130
|
Codex) is covered by future checks. Other hosts and other lifecycle events are unverified; a file
|
|
128
|
-
existing in a package proves no host loaded it ([platform-capabilities.md](../platform-capabilities.md))
|
|
129
|
-
-
|
|
131
|
+
existing in a package proves no host loaded it ([platform-capabilities.md](../platform-capabilities.md)).~~
|
|
132
|
+
- ~~**Rule-of-3 boundary (owner ruling A7.5), stated exactly:** this cycle's lesson delivery adds, extends,
|
|
130
133
|
calls or depends on **no counter, lock or forced reflection**; the existing Rule-of-3 breaker
|
|
131
134
|
(`hooks/scripts/rule-of-3.js` `isTripped`/`blockForReflection`, `hooks/scripts/rule-of-3-tracker.js`,
|
|
132
135
|
`hooks/scripts/reset-circuit-breaker.js`, [docs/enforcement-locks.md](../enforcement-locks.md)) is not
|
|
@@ -138,7 +141,7 @@ flowchart LR
|
|
|
138
141
|
own separate Rule-of-3 breaker (`opencode-plugin/index.mjs` — an independent counter, required
|
|
139
142
|
reflection, block on the covered edit tools), which this delivery neither uses nor modifies and which
|
|
140
143
|
this ADR does not claim conforms to A2. The OpenCode sources are reading-list evidence only: they do not
|
|
141
|
-
mean OpenCode was run and do not extend the hosts the lesson injection supports
|
|
144
|
+
mean OpenCode was run and do not extend the hosts the lesson injection supports.~~
|
|
142
145
|
- **Non-goals (from A2 and the ownership boundary):** the hook stays a context carrier, not a decision
|
|
143
146
|
maker; this ADR does not duplicate #359 (Error Ledger), #394 (ledger context injection and
|
|
144
147
|
agent-initiated zoom-out) or #141 (candidate creation/evaluation); candidate creation/evaluation
|
|
@@ -150,7 +153,7 @@ flowchart LR
|
|
|
150
153
|
|
|
151
154
|
- **The problem:** agent mistakes recur even when a lesson is already recorded in the ledger — the
|
|
152
155
|
recording-to-application gap [#402 comment 6785928296](https://github.com/dyphn1/Harness-everything/issues/402#issuecomment-6785928296).
|
|
153
|
-
- **What exists today (each verified in this repository):**
|
|
156
|
+
- **What exists ~~today~~ (each verified in this repository):**
|
|
154
157
|
- the ledger and generated index (`.agents/harness-everything/errors/README.md`, `index.jsonl`,
|
|
155
158
|
`E-*.md`) with a lookup convention (grep by write-set or signature); a convention, not a gate;
|
|
156
159
|
- hook context seams that carry *policy and routing* context but do not retrieve ledger records:
|
|
@@ -164,22 +167,22 @@ flowchart LR
|
|
|
164
167
|
`self-evolve/scripts/lesson-candidate.js`);
|
|
165
168
|
- zoom-out and self-evolve skills as agent-initiated reflection/evaluation paths (`zoom-out/SKILL.md`,
|
|
166
169
|
`self-evolve/SKILL.md`).
|
|
167
|
-
- No ledger-aware delivery seam exists today
|
|
168
|
-
-
|
|
170
|
+
- ~~No ledger-aware delivery seam exists today.~~
|
|
171
|
+
- ~~**What zoom-out carries today (correction):** when an agent enters a repair-loop reflection, the
|
|
169
172
|
carried material is the acceptance anchor, links to the previous comparable report, prior finding IDs
|
|
170
173
|
and dispositions, the fix made since, and round counts per class in the error ledger
|
|
171
174
|
(`zoom-out/references/circuit-breaker.md`). It does **not** carry the static ledger lesson text; no
|
|
172
|
-
current seam delivers the E-0002 record
|
|
175
|
+
current seam delivers the E-0002 record.~~
|
|
173
176
|
- **Ownership boundary:** #359 owns the Error Ledger; #394 owns ledger context injection and
|
|
174
177
|
agent-initiated zoom-out; #141 owns candidate creation/evaluation
|
|
175
178
|
([#402 comment 6785928296](https://github.com/dyphn1/Harness-everything/issues/402#issuecomment-6785928296)).
|
|
176
|
-
|
|
179
|
+
~~**Unverified:** current tracker state of #394 (no #394-specific implementation found on local `main`).~~
|
|
177
180
|
|
|
178
181
|
## Evidence
|
|
179
182
|
|
|
180
183
|
- **E-0002 episode table** (counts freshly verified by `node scripts/errors-sync.js --check`, exit 0, at
|
|
181
184
|
this SHA) drawn from `.agents/harness-everything/errors/E-0002-report-missing-terminal-status.md` and
|
|
182
|
-
its index row:
|
|
185
|
+
its index row: *(historical)*
|
|
183
186
|
|
|
184
187
|
| Episode | Date | Rounds | Closed |
|
|
185
188
|
| --- | --- | --- | --- |
|
|
@@ -201,20 +204,20 @@ flowchart LR
|
|
|
201
204
|
- **The rule conflict witness:** episode `412-review13-label-after-status` (a column-zero
|
|
202
205
|
`STATUS: DONE` followed by a hidden harness-label line) as the concrete observation that motivates the
|
|
203
206
|
label/STATUS decision above.
|
|
204
|
-
-
|
|
205
|
-
(`.husky/commit-msg`). E-0002 has `mechanism_ref: null
|
|
207
|
+
- ~~**Candidate-class context:** the index has 14 records; only E-0003 carries a non-null `mechanism_ref`
|
|
208
|
+
(`.husky/commit-msg`). E-0002 has `mechanism_ref: null`.~~
|
|
206
209
|
|
|
207
210
|
## Open gates
|
|
208
211
|
|
|
209
|
-
-
|
|
210
|
-
verification (deterministic mechanism tests, then one real-host task) are not started
|
|
211
|
-
-
|
|
212
|
-
is a follow-up owned by those files; not made here
|
|
213
|
-
-
|
|
214
|
-
-
|
|
215
|
-
this ADR, unresolved for its owner (A7.5)
|
|
216
|
-
-
|
|
217
|
-
local `main
|
|
212
|
+
- ~~**Owner acceptance of this ADR** (`status: proposed`); the follow-up implementation and its
|
|
213
|
+
verification (deterministic mechanism tests, then one real-host task) are not started.~~
|
|
214
|
+
- ~~**`AGENTS.md` / `docs/routing.md` wording change** for the report-turn exception to label-last (A7.4)
|
|
215
|
+
is a follow-up owned by those files; not made here.~~
|
|
216
|
+
- ~~**A provenance-carrying correction of the E-0002 lesson text** is a #359 follow-up.~~
|
|
217
|
+
- ~~**Whether A2 requires a separate change to the existing Rule-of-3 breaker** — separate item outside
|
|
218
|
+
this ADR, unresolved for its owner (A7.5).~~
|
|
219
|
+
- ~~**#394 tracker state** is unverified against the tracker; no #394-specific implementation exists on
|
|
220
|
+
local `main`.~~
|
|
218
221
|
|
|
219
222
|
## Reading list
|
|
220
223
|
|
|
@@ -285,21 +288,21 @@ Decision rests on. One line each.
|
|
|
285
288
|
- **`AGENTS.md` rule 14 / `docs/routing.md` vs the E-0002 terminal rule:** the repository requires a
|
|
286
289
|
trailing hidden harness-label line on every final message; the ledger lesson requires `STATUS:` to be
|
|
287
290
|
the last line at column zero. Episode `412-review13-label-after-status` records the conflict. This ADR
|
|
288
|
-
states the A7.4 decision and its report-turn exception, but the wording change in `AGENTS.md` and
|
|
289
|
-
`docs/routing.md` is a follow-up; until it lands, the conflict stands as written
|
|
290
|
-
-
|
|
291
|
+
states the A7.4 decision and its report-turn exception, ~~but the wording change in `AGENTS.md` and
|
|
292
|
+
`docs/routing.md` is a follow-up; until it lands, the conflict stands as written.~~
|
|
293
|
+
- ~~**Existing generic Rule-of-3 lock vs A2:** `hooks/scripts/rule-of-3.js` and
|
|
291
294
|
[docs/enforcement-locks.md](../enforcement-locks.md) describe a generic three-failure mutation lock with
|
|
292
295
|
a required reflection report; #402 prohibits exactly such mechanisms for ledger lesson handling. This
|
|
293
296
|
ADR adds, extends, calls or depends on none of them and does not modify the breaker; whether A2 requires
|
|
294
297
|
a separate change to the existing breaker stays unresolved for its owner. The OpenCode plugin's separate
|
|
295
298
|
breaker (`opencode-plugin/index.mjs`, [opencode-plugin/README.md](../../opencode-plugin/README.md)) is
|
|
296
|
-
likewise neither used nor modified by this delivery, and this ADR does not claim it conforms to A2
|
|
299
|
+
likewise neither used nor modified by this delivery, and this ADR does not claim it conforms to A2.~~
|
|
297
300
|
- **Ledger README lookup rule vs the owner's full-read standard:** the README says grep `index.jsonl` for
|
|
298
301
|
the packet's write-set; the owner standard requires reading every record. Injecting one record does not
|
|
299
302
|
change that operational standard for packets.
|
|
300
|
-
-
|
|
301
|
-
in #394, but no #394-specific implementation exists on local `main` (**unverified** against the tracker)
|
|
302
|
-
- **Index freshness:**
|
|
303
|
-
the index can be stale
|
|
303
|
+
- ~~**#394 point-of-action proposals vs shipped code:** E-0002 and E-0003 propose point-of-action injection
|
|
304
|
+
in #394, but no #394-specific implementation exists on local `main` (**unverified** against the tracker).~~
|
|
305
|
+
- **Index freshness:** ~~`scripts/errors-sync.js` is not wired into CI or hooks (its own source comment), so
|
|
306
|
+
the index can be stale;~~ this design never injects index content — the E-0002 record file is the content
|
|
304
307
|
authority and the index is a locator. Counts cited in this ADR were verified by
|
|
305
308
|
`node scripts/errors-sync.js --check` at this SHA.
|
|
@@ -7,7 +7,7 @@ This detail implements the C8 action map for one coordinator-selected runner att
|
|
|
7
7
|
```sh
|
|
8
8
|
npm run --silent dispatch -- --runner <codex|opencode> --model <id> \
|
|
9
9
|
--packet <path> --worktree <git-root> --scratch <absolute-external-path> \
|
|
10
|
-
--report <path> [--dry-run] [--json]
|
|
10
|
+
--report <path> [--effort <low|medium|high|xhigh>] [--dry-run] [--json]
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
`node scripts/dispatch.js` accepts the same options. `--help` prints this short synopsis. The coordinator supplies every value; packet and report paths may be relative to the worktree or absolute. The worktree must be an existing Git root. Scratch must be absolute and outside every Git repository/worktree. A pre-existing report path is rejected as invalid input.
|
|
@@ -20,11 +20,12 @@ npm run --silent dispatch -- --runner <codex|opencode> --model <id> \
|
|
|
20
20
|
| `--worktree` | Required existing Git repository or worktree root; child cwd. |
|
|
21
21
|
| `--scratch` | Required absolute path outside all Git repository/worktree roots; child `TMPDIR`. |
|
|
22
22
|
| `--report` | Required fresh report path, resolved from the worktree when relative. |
|
|
23
|
+
| `--effort` | Optional Codex reasoning effort: `low`, `medium`, `high`, or `xhigh`. It passes a Codex `-c model_reasoning_effort="…"` override; omission leaves Codex configuration unchanged. Rejected for OpenCode. |
|
|
23
24
|
| `--dry-run` | Validate inputs and return planned argv/cwd; no child or filesystem writes. |
|
|
24
25
|
| `--json` | Return one JSON object on stdout, including refusals. |
|
|
25
26
|
| `--help` | Return the short usage synopsis with exit 0. |
|
|
26
27
|
|
|
27
|
-
In JSON mode the common shape is `{ok, code, phase, message}` with resolved `runner`, `model`, and existing `evidence` paths when available. Dry run also returns `argv` and `cwd`; Codex's generated raw-output argument uses a `<run-id>` placeholder. Human-mode refusals go to stderr. Child logs and raw output stay in evidence files, not in the JSON result.
|
|
28
|
+
In JSON mode the common shape is `{ok, code, phase, message}` with resolved `runner`, `model`, and existing `evidence` paths when available. A validated requested Codex `--effort` is also returned as `effort`; it records the request and does not claim the provider applied it. Dry run also returns `argv` and `cwd`; Codex's generated raw-output argument uses a `<run-id>` placeholder. Human-mode refusals go to stderr. Child logs and raw output stay in evidence files, not in the JSON result.
|
|
28
29
|
|
|
29
30
|
## Exit and JSON codes
|
|
30
31
|
|
|
@@ -32,7 +33,7 @@ In JSON mode the common shape is `{ok, code, phase, message}` with resolved `run
|
|
|
32
33
|
| --- | --- | --- |
|
|
33
34
|
| `0` | `HELP`, `DRY_RUN_OK`, `DONE` | Help, validated dry run, or a fresh validated DONE report. |
|
|
34
35
|
| `1` | `INTERNAL_ERROR` | Unexpected application failure outside a named phase result. |
|
|
35
|
-
| `10` | `INVALID_INPUT` | Bad/missing option, runner/model, packet/worktree, or a report path that already exists. |
|
|
36
|
+
| `10` | `INVALID_INPUT` | Bad/missing/duplicate option, unsupported or runner-incompatible effort, runner/model, packet/worktree, or a report path that already exists. |
|
|
36
37
|
| `11` | `UNSAFE_SCRATCH` | Scratch is relative, an existing scratch path is not a directory, or it is inside a Git repository/worktree. |
|
|
37
38
|
| `12` | `NOT_READY` | Selected executable is missing or readiness failed, timed out, or omitted `READY`. No run starts. |
|
|
38
39
|
| `13` | `RUNNER_RATE_LIMITED` | The selected runner's failed readiness stderr has a recognized provider throttling diagnostic. No run starts. |
|
|
@@ -49,6 +50,8 @@ In JSON mode the common shape is `{ok, code, phase, message}` with resolved `run
|
|
|
49
50
|
|
|
50
51
|
## Readiness classification and evidence
|
|
51
52
|
|
|
53
|
+
The readiness prompt is `Reply with the single word READY`. One terminal Harness host label line (`<!-- harness-label {…} -->`, valid JSON object; its fields are not validated) is dropped first, because Harness hosts append it to every final message. After trimming outer whitespace, only `READY` and `READY.` are accepted. Any other reply returns `12 NOT_READY`. A nonzero, signaled, or timed-out child is refused even if it produced an accepted reply.
|
|
54
|
+
|
|
52
55
|
Classification requires a full runner-specific diagnostic line on the failed readiness child's stderr after ANSI stripping. Only a normal nonzero exit is eligible; zero exits, signals, timeouts, stdout, quoted text, a different envelope, and partial or bare `429` text do not receive provider credit. Everything else, including local/cache errors, invalid `--quota`, header timeout, or a missing/ambiguous diagnostic, returns `12 NOT_READY`. The JSON `code` distinguishes throttling from usage/quota exhaustion.
|
|
53
56
|
|
|
54
57
|
| Runner / outcome | Recognized stderr line | Evidence |
|
|
@@ -60,7 +63,7 @@ Classification requires a full runner-specific diagnostic line on the failed rea
|
|
|
60
63
|
|
|
61
64
|
Each invocation uses one selected runner and one readiness attempt. A `12` or `13` refusal starts no execution, report writer, fallback, or retry; available child evidence remains available to the coordinator.
|
|
62
65
|
|
|
63
|
-
Codex writes raw output with `codex exec -o`; it must contain an explicit terminal DONE or BLOCKED status. `report-writer --from-codex-output` strips an optional valid terminal host label, writes the final report, and `report-writer check` validates it. OpenCode is asked to write the report path directly; the path must remain absent through readiness and the resulting file must pass `report-writer check`. A valid BLOCKED report returns 17. Failed execution returns 15 and preserves its logs/raw output; it may have changed the worktree.
|
|
66
|
+
Codex writes raw output with `codex exec -o`; it must contain an explicit terminal DONE or BLOCKED status. `report-writer --from-codex-output` strips an optional valid terminal host label (blank lines between STATUS and the label are allowed; live codex output has one), writes the final report, and `report-writer check` validates it. OpenCode is asked to write the report path directly; the path must remain absent through readiness and the resulting file must pass `report-writer check`. A valid BLOCKED report returns 17. Failed execution returns 15 and preserves its logs/raw output; it may have changed the worktree.
|
|
64
67
|
|
|
65
68
|
## Evidence boundary
|
|
66
69
|
|
|
@@ -68,6 +71,7 @@ Codex writes raw output with `codex exec -o`; it must contain an explicit termin
|
|
|
68
71
|
| --- | --- | --- |
|
|
69
72
|
| Fixture | The real Node entry with stubbed child runners exercises argv, cwd, closed stdin, readiness, quota, timeout, fresh delivery, report writing/checking, and exit/JSON outcomes. | No real provider behavior or live host behavior. |
|
|
70
73
|
| Checkout/package entry | The npm script invokes the checked-in entry, and documented options work through that entry; named repository gates validate local consistency and portability. | No installed npm tarball or distributed plugin integration. |
|
|
74
|
+
| Live dispatch (2026-11-21, #497) | One full `npm run --silent dispatch` per runner on this Mac: OpenCode `opencode/hy4-flash-free` and Codex `gpt-6-luna --effort medium`, a two-line probe packet, both `0 DONE` with a validated report. The readiness replies carried a trailing host label; the Codex raw output had a blank line before it. | Effort is recorded as requested; provider-side application of the effort is not observed. One run each, not a reliability claim. |
|
|
71
75
|
| Live (channel probe only) | `opencode run --auto -m <model>`, the exact C8 OpenCode readiness argv, against failing nvidia models on OpenCode 2.1.4 (2026-11-21): provider errors reach stderr as one ANSI `Error: <message>` line, exit 1, empty stdout. | Not a C8 dispatch: no live 429 or quota reproduction (the 429 and quota bodies come from the retained OpenCode log), no Codex provider call, no host dispatch or live report delivery. |
|
|
72
76
|
|
|
73
77
|
## #466 boundary
|
package/docs/governed-index.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
- `DOCS-007` — `docs/adr/DOCS-007-shared-doc-craft-derived-views.md` (role: adr; status: accepted)
|
|
14
14
|
- `DOCS-008` — `docs/adr/DOCS-008-obligation-abstraction-bounded-consumer.md` (role: adr; status: accepted)
|
|
15
15
|
- `EVID-001` — `docs/adr/EVID-001.md` (role: adr; status: proposed)
|
|
16
|
-
- `ROUTE-001` — `docs/adr/ROUTE-001-error-lesson-delivery.md` (role: adr; status:
|
|
16
|
+
- `ROUTE-001` — `docs/adr/ROUTE-001-error-lesson-delivery.md` (role: adr; status: superseded)
|
|
17
17
|
|
|
18
18
|
## PRD revision chains
|
|
19
19
|
|
|
@@ -64,6 +64,10 @@ The registered `doc-check check --conflict-assessment` mode runs document lifecy
|
|
|
64
64
|
|
|
65
65
|
Source and packaged plugin self-evolve entrypoints use installation-relative canonical workspace helpers and the same workspace/session state path. Missing helpers, unresolved identities, and unusable state paths fail explicitly; only absent candidate directories yield an empty list. The [resolver contract](../self-evolve/references/memory-resolution.md#workspace-helper-and-diagnostics) and source/package subprocess regressions establish deterministic mechanism coverage, not a live-host upgrade. Existing memory authorization remains required.
|
|
66
66
|
|
|
67
|
+
### Error-ledger lesson injection (mechanism only, #394)
|
|
68
|
+
|
|
69
|
+
A shared matcher (`hooks/scripts/lib/ledger-match.js`) selects workspace ledger lessons whose `match` rules fit a direct `git commit` action (optionally after `-C`, `-c`, `--git-dir=`, `--work-tree=`, `--no-pager` or `-P`; compound and wrapped commands stay silent, #502) or its commitlint failure; rules are read from the generated index row and checked against the record's frontmatter binding, and the host carriers add the record's Cue and Lesson as model context: Claude Code `PreToolUse` and `PostToolUseFailure` (`hooks/scripts/ledger-lesson.js`), Codex `PreToolUse` and `PostToolUse` with outcome classification (`hooks/scripts/codex-ledger-lesson.js`, packaged and user-hook compatibility paths), and OpenCode V2 tool `execute.before/after` selection delivered through the next `context` hook, i.e. after the action. The OpenCode V1 adapter does not register `experimental.chat.system.transform` (`output.system`). V1 lesson delivery is `UNCHECKED`. Delivery is bounded, deduplicated per session and phase, fail-open, and never changes a tool result or permission. Deterministic mechanism tests cover all three carriers. [Claude Code live evidence](../benchmarks/results/live-host/claude-2026-11-21-ledger-lesson/README.md) (2.1.330, one run) shows both contexts in the model request that follows the commit, so the action lesson arrives after the first attempt. Codex and OpenCode live receipt remain `UNCHECKED`.
|
|
70
|
+
|
|
67
71
|
## Current capability summary
|
|
68
72
|
|
|
69
73
|
| Platform surface | Standalone skills | Plugin support | Hooks/lifecycle | Project scope | Global scope | Current evidence boundary |
|
package/hooks/hooks.json
CHANGED
|
@@ -123,6 +123,17 @@
|
|
|
123
123
|
],
|
|
124
124
|
"description": "Record privacy-safe Harness skill load start telemetry",
|
|
125
125
|
"id": "harness:pre:skill-telemetry"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"matcher": "Bash",
|
|
129
|
+
"hooks": [
|
|
130
|
+
{
|
|
131
|
+
"type": "command",
|
|
132
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/scripts/ledger-lesson.js\""
|
|
133
|
+
}
|
|
134
|
+
],
|
|
135
|
+
"description": "Inject a matched workspace ledger lesson as fail-open Bash context",
|
|
136
|
+
"id": "harness:pre:ledger-lesson"
|
|
126
137
|
}
|
|
127
138
|
],
|
|
128
139
|
"Stop": [
|
|
@@ -309,6 +320,17 @@
|
|
|
309
320
|
],
|
|
310
321
|
"description": "Record a local, content-private System One turn observation (docs/system-one-observations.md); fail-open and silent",
|
|
311
322
|
"id": "harness:obs:observation-posttoolusefailure"
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
"matcher": "Bash",
|
|
326
|
+
"hooks": [
|
|
327
|
+
{
|
|
328
|
+
"type": "command",
|
|
329
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/scripts/ledger-lesson.js\""
|
|
330
|
+
}
|
|
331
|
+
],
|
|
332
|
+
"description": "Inject a matched workspace ledger lesson after a failed Bash tool",
|
|
333
|
+
"id": "harness:post-failure:ledger-lesson"
|
|
312
334
|
}
|
|
313
335
|
],
|
|
314
336
|
"SubagentStart": [
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
const { getWorkspaceRoot, getSessionDir, getSessionId, resolveWorkspaceIdentity } = require('./lib/harness-state');
|
|
6
|
+
const { readCodexToolOutcome } = require('./lib/codex-tool-outcome');
|
|
7
|
+
const { matchLedgerLessons, releaseLedgerMatch } = require('./lib/ledger-match');
|
|
8
|
+
|
|
9
|
+
const MAX_INPUT_BYTES = 128 * 1024;
|
|
10
|
+
|
|
11
|
+
function eventFor(payload) {
|
|
12
|
+
if (payload?.tool_name !== 'Bash' || typeof payload?.tool_input?.command !== 'string') return null;
|
|
13
|
+
const command = payload.tool_input.command;
|
|
14
|
+
if (payload.hook_event_name === 'PreToolUse') {
|
|
15
|
+
return { phase: 'action', tool: 'shell', command, outcome: { failed: 'unknown' } };
|
|
16
|
+
}
|
|
17
|
+
if (payload.hook_event_name !== 'PostToolUse') return null;
|
|
18
|
+
|
|
19
|
+
const result = readCodexToolOutcome(payload);
|
|
20
|
+
const failed = result.outcome === 'failure' ? true : result.outcome === 'success' ? false : 'unknown';
|
|
21
|
+
const outcome = { failed };
|
|
22
|
+
if (failed === true) outcome.output = [result.stderr, result.stdout].filter(Boolean).join('\n');
|
|
23
|
+
return { phase: 'failure', tool: 'shell', command, outcome };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function deliver(payload) {
|
|
27
|
+
if (typeof payload?.cwd !== 'string' || !payload.cwd.trim()) return;
|
|
28
|
+
const event = eventFor(payload);
|
|
29
|
+
const sessionIdentity = getSessionId(payload);
|
|
30
|
+
if (!event || !sessionIdentity) return;
|
|
31
|
+
|
|
32
|
+
const workspaceRoot = getWorkspaceRoot(payload);
|
|
33
|
+
const identity = resolveWorkspaceIdentity(payload);
|
|
34
|
+
if (!workspaceRoot || !identity?.workspaceKey) return;
|
|
35
|
+
const stateDir = path.join(getSessionDir(workspaceRoot, sessionIdentity, payload), 'ledger-lessons');
|
|
36
|
+
const result = matchLedgerLessons({
|
|
37
|
+
workspaceRoot,
|
|
38
|
+
workspaceIdentity: identity.workspaceKey,
|
|
39
|
+
sessionIdentity,
|
|
40
|
+
stateDir,
|
|
41
|
+
event,
|
|
42
|
+
});
|
|
43
|
+
if (!result) return;
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
const output = JSON.stringify({
|
|
47
|
+
hookSpecificOutput: {
|
|
48
|
+
hookEventName: payload.hook_event_name,
|
|
49
|
+
additionalContext: result.text,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
process.stdout.write(output, error => {
|
|
53
|
+
if (error) releaseLedgerMatch(result);
|
|
54
|
+
});
|
|
55
|
+
} catch (_) {
|
|
56
|
+
releaseLedgerMatch(result);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function run() {
|
|
61
|
+
let input = '';
|
|
62
|
+
let bytes = 0;
|
|
63
|
+
let oversized = false;
|
|
64
|
+
process.stdin.setEncoding('utf8');
|
|
65
|
+
process.stdin.on('data', chunk => {
|
|
66
|
+
if (oversized) return;
|
|
67
|
+
bytes += Buffer.byteLength(chunk, 'utf8');
|
|
68
|
+
if (bytes > MAX_INPUT_BYTES) {
|
|
69
|
+
input = '';
|
|
70
|
+
oversized = true;
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
input += chunk;
|
|
74
|
+
});
|
|
75
|
+
process.stdin.on('end', () => {
|
|
76
|
+
if (oversized) return;
|
|
77
|
+
try { deliver(JSON.parse(input || '{}')); } catch (_) { /* Fail open without changing tool flow. */ }
|
|
78
|
+
});
|
|
79
|
+
process.stdin.on('error', () => {});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (require.main === module) run();
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
|
|
6
|
+
const MAX_INPUT_BYTES = 64 * 1024;
|
|
7
|
+
let state;
|
|
8
|
+
let matcher;
|
|
9
|
+
try {
|
|
10
|
+
state = require('./lib/harness-state');
|
|
11
|
+
matcher = require('./lib/ledger-match');
|
|
12
|
+
} catch (_) {
|
|
13
|
+
// Missing runtime pieces leave the host hook fail-open and silent.
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let pending = null;
|
|
17
|
+
function releasePending() {
|
|
18
|
+
if (!pending) return;
|
|
19
|
+
try { matcher?.releaseLedgerMatch(pending); } catch (_) { /* fail open */ }
|
|
20
|
+
pending = null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
process.stdout.on('error', releasePending);
|
|
24
|
+
|
|
25
|
+
function handle(payload) {
|
|
26
|
+
try {
|
|
27
|
+
if (!payload || typeof payload !== 'object' || Array.isArray(payload) || !state || !matcher) return;
|
|
28
|
+
const hookEventName = payload.hook_event_name;
|
|
29
|
+
const phase = hookEventName === 'PreToolUse' ? 'action'
|
|
30
|
+
: hookEventName === 'PostToolUseFailure' ? 'failure' : null;
|
|
31
|
+
if (!phase || payload.tool_name !== 'Bash') return;
|
|
32
|
+
if (typeof payload.cwd !== 'string' || !path.isAbsolute(payload.cwd)) return;
|
|
33
|
+
|
|
34
|
+
const sessionIdentity = state.getSessionId(payload);
|
|
35
|
+
const command = typeof payload.tool_input_command === 'string' ? payload.tool_input_command
|
|
36
|
+
: typeof payload.tool_input?.command === 'string' ? payload.tool_input.command : null;
|
|
37
|
+
if (!sessionIdentity || !command) return;
|
|
38
|
+
|
|
39
|
+
const workspace = state.resolveWorkspaceIdentity(payload);
|
|
40
|
+
if (!workspace.workspaceRoot || !workspace.workspaceKey) return;
|
|
41
|
+
const sessionDir = state.getSessionDir(workspace.workspaceRoot, sessionIdentity, payload);
|
|
42
|
+
const result = matcher.matchLedgerLessons({
|
|
43
|
+
workspaceRoot: workspace.workspaceRoot,
|
|
44
|
+
workspaceIdentity: workspace.workspaceKey,
|
|
45
|
+
sessionIdentity,
|
|
46
|
+
stateDir: path.join(sessionDir, 'ledger-lessons'),
|
|
47
|
+
event: {
|
|
48
|
+
phase,
|
|
49
|
+
tool: 'shell',
|
|
50
|
+
command,
|
|
51
|
+
outcome: phase === 'failure'
|
|
52
|
+
? { failed: true, ...(typeof payload.error === 'string' ? { output: payload.error } : {}) }
|
|
53
|
+
: { failed: 'unknown' }
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
if (!result) return;
|
|
57
|
+
|
|
58
|
+
pending = result;
|
|
59
|
+
process.stdout.write(`${JSON.stringify({
|
|
60
|
+
hookSpecificOutput: { hookEventName, additionalContext: result.text }
|
|
61
|
+
})}\n`, error => {
|
|
62
|
+
if (error) releasePending();
|
|
63
|
+
else pending = null;
|
|
64
|
+
});
|
|
65
|
+
} catch (_) {
|
|
66
|
+
releasePending();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let input = '';
|
|
71
|
+
let inputBytes = 0;
|
|
72
|
+
let oversized = false;
|
|
73
|
+
let finished = false;
|
|
74
|
+
|
|
75
|
+
function finish() {
|
|
76
|
+
if (finished) return;
|
|
77
|
+
finished = true;
|
|
78
|
+
if (oversized) return;
|
|
79
|
+
try { handle(JSON.parse(input)); } catch (_) { /* malformed payloads are silent */ }
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
process.stdin.setEncoding('utf8');
|
|
83
|
+
process.stdin.on('data', chunk => {
|
|
84
|
+
if (oversized) return;
|
|
85
|
+
inputBytes += Buffer.byteLength(chunk, 'utf8');
|
|
86
|
+
if (inputBytes > MAX_INPUT_BYTES) {
|
|
87
|
+
oversized = true;
|
|
88
|
+
input = '';
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
input += chunk;
|
|
92
|
+
});
|
|
93
|
+
process.stdin.on('end', finish);
|
|
94
|
+
process.stdin.on('error', finish);
|