harness-everything 1.2.2 → 1.3.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/ci/fixtures/468-dispatch/agy-quota-PROVENANCE.md +19 -0
- package/ci/fixtures/468-dispatch/agy-quota-direct-individual.stderr +2 -0
- package/ci/fixtures/468-dispatch/agy-quota-direct-third-party.stderr +2 -0
- package/ci/fixtures/468-dispatch/agy-quota-exec-individual.log +3 -0
- package/ci/mechanism-468-dispatch-cli.test.js +1496 -4
- package/ci/mechanism-548-bigint-identity.test.js +531 -0
- package/ci/mechanism-error-ledger-oracle.test.js +786 -3
- package/ci/mechanism-error-ledger-scan.test.js +981 -0
- package/ci/mechanism-report-writer.test.js +45 -0
- package/docs/error-handling/details/c8-dispatch-cli.md +109 -13
- package/error-ledger-bootstrap/SKILL.md +1 -1
- package/error-ledger-bootstrap/references/workflow.md +42 -7
- package/error-ledger-bootstrap/scripts/promote.js +8 -6
- package/error-ledger-bootstrap/scripts/scan.js +525 -12
- package/opencode-plugin/plugin.json +1 -1
- package/package.json +1 -1
- package/plugins/harness-everything/.antigravity-plugin/plugin.json +1 -1
- package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
- package/plugins/harness-everything/plugin.json +1 -1
- package/plugins/harness-everything/skills/error-ledger-bootstrap/SKILL.md +1 -1
- package/plugins/harness-everything/skills/error-ledger-bootstrap/references/workflow.md +42 -7
- package/plugins/harness-everything/skills/error-ledger-bootstrap/scripts/promote.js +8 -6
- package/plugins/harness-everything/skills/error-ledger-bootstrap/scripts/scan.js +525 -12
- package/sbom.cdx.json +7 -7
- package/scripts/dispatch.js +499 -87
- package/scripts/error-ledger-oracle.js +521 -27
- package/scripts/errors-sync.js +4 -3
- package/scripts/report-writer.js +4 -3
|
@@ -182,6 +182,40 @@ test('497 accepts the live codex -o shape: STATUS, one blank line, then the EOF
|
|
|
182
182
|
assertOk(run(['check', '--file', output]));
|
|
183
183
|
});
|
|
184
184
|
|
|
185
|
+
test('441-A accepts trailing ASCII spaces or tabs on raw Codex STATUS and writes canonical report bytes', t => {
|
|
186
|
+
const dir = tempDir(t);
|
|
187
|
+
const raw = path.join(dir, 'raw.txt');
|
|
188
|
+
const output = path.join(dir, 'report.md');
|
|
189
|
+
|
|
190
|
+
// P498-F shape: raw STATUS: BLOCKED: <reason> followed by two trailing ASCII spaces.
|
|
191
|
+
const blockedRaw = Buffer.from('Summary\nSTATUS: BLOCKED: verification unavailable \n');
|
|
192
|
+
fs.writeFileSync(raw, blockedRaw);
|
|
193
|
+
const blockedResult = run(writeArgs(output, 'BLOCKED', ['--from-codex-output', raw], '--reason', 'verification unavailable'));
|
|
194
|
+
assertOk(blockedResult);
|
|
195
|
+
assert.deepEqual(fs.readFileSync(raw), blockedRaw);
|
|
196
|
+
assert.deepEqual(fs.readFileSync(output), Buffer.from('Summary\nSTATUS: BLOCKED: verification unavailable\n'));
|
|
197
|
+
assertOk(run(['check', '--file', output]));
|
|
198
|
+
|
|
199
|
+
// Padded STATUS: DONE with a trailing ASCII tab.
|
|
200
|
+
const doneTabRaw = Buffer.from('Summary\nSTATUS: DONE\t\n');
|
|
201
|
+
fs.writeFileSync(raw, doneTabRaw);
|
|
202
|
+
const doneTabResult = run(writeArgs(output, 'DONE', ['--from-codex-output', raw]));
|
|
203
|
+
assertOk(doneTabResult);
|
|
204
|
+
assert.deepEqual(fs.readFileSync(raw), doneTabRaw);
|
|
205
|
+
assert.deepEqual(fs.readFileSync(output), Buffer.from('Summary\nSTATUS: DONE\n'));
|
|
206
|
+
assertOk(run(['check', '--file', output]));
|
|
207
|
+
|
|
208
|
+
// Padded STATUS: BLOCKED followed by a blank line and an EOF host label.
|
|
209
|
+
const labeledRaw = Buffer.from(`Summary\nSTATUS: BLOCKED: verification unavailable \t\n\n${VALID_LABEL}\n`);
|
|
210
|
+
fs.writeFileSync(raw, labeledRaw);
|
|
211
|
+
const labeledResult = run(writeArgs(output, 'BLOCKED', ['--from-codex-output', raw], '--reason', 'verification unavailable'));
|
|
212
|
+
assertOk(labeledResult);
|
|
213
|
+
assert.match(labeledResult.stderr, /stripped.*host label/i);
|
|
214
|
+
assert.deepEqual(fs.readFileSync(raw), labeledRaw);
|
|
215
|
+
assert.deepEqual(fs.readFileSync(output), Buffer.from('Summary\nSTATUS: BLOCKED: verification unavailable\n'));
|
|
216
|
+
assertOk(run(['check', '--file', output]));
|
|
217
|
+
});
|
|
218
|
+
|
|
185
219
|
test('rejects embedded STATUS in body without changing an existing target', t => {
|
|
186
220
|
const dir = tempDir(t);
|
|
187
221
|
const output = path.join(dir, 'report.md');
|
|
@@ -266,11 +300,20 @@ test('rejects mismatched, malformed, duplicate, or trailing Codex controls and p
|
|
|
266
300
|
const invalidRaw = [
|
|
267
301
|
['Summary\nSTATUS: BLOCKED: wrong reason\n', 'DONE'],
|
|
268
302
|
['Summary\nSTATUS: BLOCKED: wrong reason\n', 'BLOCKED', '--reason', 'expected reason'],
|
|
303
|
+
['Summary\nSTATUS: BLOCKED: wrong reason \n', 'BLOCKED', '--reason', 'expected reason'],
|
|
304
|
+
['Summary\nSTATUS: BLOCKED: expected reason \n', 'BLOCKED', '--reason', 'expected reason'],
|
|
305
|
+
['Summary\nSTATUS: DONE\u00a0\n', 'DONE'],
|
|
306
|
+
['Summary\nSTATUS: BLOCKED: expected reason\u00a0\n', 'BLOCKED', '--reason', 'expected reason'],
|
|
307
|
+
['Summary\nSTATUS: DONE \n', 'DONE'],
|
|
269
308
|
['Summary\nSTATUS: FINISHED\n', 'DONE'],
|
|
270
309
|
['Summary\nSTATUS: malformed\nSTATUS: DONE\n', 'DONE'],
|
|
310
|
+
['Summary\nSTATUS: DONE \nSTATUS: DONE\n', 'DONE'],
|
|
271
311
|
['Summary\nSTATUS: DONE\nSTATUS: DONE\n', 'DONE'],
|
|
312
|
+
['Summary\nSTATUS: DONE \n\n', 'DONE'],
|
|
272
313
|
['Summary\nSTATUS: DONE\n\n', 'DONE'],
|
|
314
|
+
['Summary\nSTATUS: DONE \ntext after status\n', 'DONE'],
|
|
273
315
|
['Summary\nSTATUS: DONE\ntext after status\n', 'DONE'],
|
|
316
|
+
[`Summary\nSTATUS: DONE ${VALID_LABEL}`, 'DONE'],
|
|
274
317
|
[`Summary\nSTATUS: DONE\ntext\n${VALID_LABEL}`, 'DONE'],
|
|
275
318
|
[`Summary\nSTATUS: DONE\n${VALID_LABEL}\n${VALID_LABEL}\n`, 'DONE'],
|
|
276
319
|
[`Summary\nSTATUS: DONE\n${VALID_LABEL}\ntrailing text`, 'DONE'],
|
|
@@ -327,6 +370,8 @@ test('check accepts one terminal status with LF or CRLF and rejects other contro
|
|
|
327
370
|
}
|
|
328
371
|
for (const invalid of [
|
|
329
372
|
'Summary',
|
|
373
|
+
'Summary\nSTATUS: DONE ',
|
|
374
|
+
'Summary\n STATUS: DONE',
|
|
330
375
|
'Summary\nSTATUS: DONE\n\n',
|
|
331
376
|
'Summary\nSTATUS: DONE\ntrailing',
|
|
332
377
|
'Summary\nSTATUS: DONE\nSTATUS: DONE',
|
|
@@ -5,27 +5,30 @@ This detail implements the C8 action map for one coordinator-selected runner att
|
|
|
5
5
|
## Invocation
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
|
-
npm run --silent dispatch -- --runner <codex|opencode> --model <id> \
|
|
8
|
+
npm run --silent dispatch -- --runner <codex|opencode|agy> --model <id> \
|
|
9
9
|
--packet <path> --worktree <git-root> --scratch <absolute-external-path> \
|
|
10
|
-
--report <path> [--effort <low|medium|high|xhigh>] [--
|
|
10
|
+
--report <path> [--effort <low|medium|high|xhigh>] [--assignment <path>] \
|
|
11
|
+
[--admission-policy <path>] [--dry-run] [--json]
|
|
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.
|
|
14
|
+
`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 (for `agy`, both must resolve inside `--worktree` so the prompt passes cwd-relative worker paths only). 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.
|
|
14
15
|
|
|
15
16
|
| Option | Meaning |
|
|
16
17
|
| --- | --- |
|
|
17
|
-
| `--runner` | Required explicit selection: `codex` or `
|
|
18
|
+
| `--runner` | Required explicit selection: `codex`, `opencode`, or `agy`. |
|
|
18
19
|
| `--model` | Required model id for that runner. |
|
|
19
|
-
| `--packet` | Required existing packet file, resolved from the worktree when relative. |
|
|
20
|
+
| `--packet` | Required existing packet file, resolved from the worktree when relative (must resolve inside `--worktree` for `agy`). |
|
|
20
21
|
| `--worktree` | Required existing Git repository or worktree root; child cwd. |
|
|
21
|
-
| `--scratch` | Required absolute path outside all Git repository/worktree roots; child `TMPDIR
|
|
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
|
|
22
|
+
| `--scratch` | Required absolute path outside all Git repository/worktree roots; child `TMPDIR` (in managed mode: the external root of per-attempt directories, see [Managed scratch](#managed-scratch-and-lifecycle-466-d-scratch)). |
|
|
23
|
+
| `--report` | Required fresh report path, resolved from the worktree when relative (must resolve inside `--worktree` for `agy`). |
|
|
24
|
+
| `--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 and `agy`. |
|
|
25
|
+
| `--assignment` | Optional managed-mode gate assignment sidecar JSON; see [Managed mode](#managed-mode-and-gate-assignment-466-d-gate). |
|
|
26
|
+
| `--admission-policy` | Required in managed mode (`--assignment`); host-level per-pool reservation policy JSON, see [Managed admission](#managed-per-pool-admission-466-d-admission). Rejected in unmanaged mode (`10 INVALID_INPUT`). |
|
|
24
27
|
| `--dry-run` | Validate inputs and return planned argv/cwd; no child or filesystem writes. |
|
|
25
28
|
| `--json` | Return one JSON object on stdout, including refusals. |
|
|
26
29
|
| `--help` | Return the short usage synopsis with exit 0. |
|
|
27
30
|
|
|
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.
|
|
31
|
+
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. For `agy`, JSON also returns `sandbox: "requested"`; it records the requested `--sandbox` flag only and does not claim proven isolation (scope any isolation claim to separately executed evidence). 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.
|
|
29
32
|
|
|
30
33
|
## Exit and JSON codes
|
|
31
34
|
|
|
@@ -34,7 +37,7 @@ In JSON mode the common shape is `{ok, code, phase, message}` with resolved `run
|
|
|
34
37
|
| `0` | `HELP`, `DRY_RUN_OK`, `DONE` | Help, validated dry run, or a fresh validated DONE report. |
|
|
35
38
|
| `1` | `INTERNAL_ERROR` | Unexpected application failure outside a named phase result. |
|
|
36
39
|
| `10` | `INVALID_INPUT` | Bad/missing/duplicate option, unsupported or runner-incompatible effort, runner/model, packet/worktree, or a report path that already exists. |
|
|
37
|
-
| `11` | `UNSAFE_SCRATCH` | Scratch is relative, an existing scratch path is not a directory, or it
|
|
40
|
+
| `11` | `UNSAFE_SCRATCH` | Scratch is relative, an existing scratch path is not a directory, it crosses a dangling symlink or unresolved symlink chain, or it resolves inside a Git repository/worktree. |
|
|
38
41
|
| `12` | `NOT_READY` | Selected executable is missing or readiness failed, timed out, or omitted `READY`. No run starts. |
|
|
39
42
|
| `13` | `RUNNER_RATE_LIMITED` | The selected runner's failed readiness stderr has a recognized provider throttling diagnostic. No run starts. |
|
|
40
43
|
| `13` | `RUNNER_QUOTA` | The selected runner's failed readiness stderr has an explicit usage/quota exhaustion diagnostic. No run starts. |
|
|
@@ -60,20 +63,113 @@ Classification requires a full runner-specific diagnostic line on the failed rea
|
|
|
60
63
|
| OpenCode usage/quota exhaustion | `Error: Free usage limit reached. Free models work in OpenCode (https://opencode.ai); subscribe to OpenCode Go to keep going: https://opencode.ai/go` | The stderr envelope is live-traced; the cause is from the retained OpenCode log. |
|
|
61
64
|
| Codex provider rate limit | `ERROR: Provider request failed with HTTP 429: {"status":429,"title":"Too Many Requests"}` | Fixture-only; no retained live Codex 429 trace. |
|
|
62
65
|
| Codex usage/quota exhaustion | `ERROR: Free usage limit reached. Free models work in OpenCode (https://opencode.ai); subscribe to OpenCode Go to keep going: https://opencode.ai/go` | Fixture-only; no retained live Codex usage-limit trace. |
|
|
66
|
+
| `agy` usage/quota exhaustion | One normal exit `3` (no signal, no spawn error, no timeout, no report) whose ANSI-stripped stderr has exactly one full line `error: <Third-party\|Individual> quota reached. … Resets in <duration>.` **and** exactly one `AGY_ERROR: <json>` line whose parsed object has `status: "RESOURCE_EXHAUSTED"` and numeric `error_code: 429` and whose `short_error` names the same pool. Advice text, reset value and redacted identifier are not pinned. | Live-backed stderr shape from the sanitized captures in `ci/fixtures/468-dispatch/agy-quota-*` (see `agy-quota-PROVENANCE.md`); the managed wrappers and the execution exit status are fixtures. One recognizer serves readiness and execution. Duplicate, contradictory, partial, malformed, generic/quoted, wrong/split-stream, stdout-only or retired-single-line diagnostics, unsupported pools, other exit shapes, and runs that wrote a report are not classified as quota. |
|
|
63
67
|
|
|
64
68
|
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.
|
|
65
69
|
|
|
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
|
|
70
|
+
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 and `agy` follow the direct-delivery contract: the worker writes the report path directly, the path must remain absent through readiness (pre-existing returns `10 INVALID_INPUT`, populated during readiness returns `16 REPORT_INVALID`), exit 0 without a fresh regular report file fails delivery (`16 REPORT_INVALID`) with logs retained, 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 (for `agy`, an execution exit `3` with no report and the validated diagnostic pair above returns `13 RUNNER_QUOTA` with `phase: "execution"` and logs retained); a failed execution may have changed the worktree. The execution-pair fixture is derived from a live Individual stderr shape plus a fixture exit status: the captured managed result was `15 RUN_FAILED` and did not preserve its original exit status, so the `13 RUNNER_QUOTA` execution row is a fixture outcome, not a live reclassification (see `ci/fixtures/468-dispatch/agy-quota-PROVENANCE.md`).
|
|
71
|
+
|
|
72
|
+
## `agy` headless runner adapter (#466 D-agy)
|
|
73
|
+
|
|
74
|
+
`agy` is invoked with the pinned headless argv, `cwd` set to `--worktree`, closed stdin (`stdio: ['ignore', 'pipe', 'pipe']`), and child execution bounded by C8 (`120s` readiness, `2700s` execution) in addition to `--print-timeout`:
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
agy -p "<prompt>" --model <id> --mode accept-edits --sandbox \
|
|
78
|
+
--settings '{"permissions":{"allow":["command(*)","read_file(*)"]}}' --print-timeout <N>s
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
- **Cwd-relative worker paths:** `--packet` and `--report` must resolve inside `--worktree` (otherwise `10 INVALID_INPUT`), and the execution prompt points only at cwd-relative paths (`<packet-rel>`, `<report-rel>`).
|
|
82
|
+
- **Readiness:** runs the same pinned argv with `Reply with the single word READY` and `--print-timeout 120s`; accepts `READY` or `READY.` after dropping an optional trailing Harness host label. A failed readiness check starts no execution.
|
|
83
|
+
- **Sandbox configuration:** `--sandbox` is recorded as requested configuration (`sandbox: "requested"` in JSON). No isolation is claimed; scope any isolation claim to separately executed evidence.
|
|
84
|
+
- **Gate profile:** `runnerProfile('agy')` returns `{ sandboxed: true }` conservatively because `agy` requests `--sandbox` and is not treated as an unsandboxed loopback-capable profile. Assigning `verify:all` or `verify:all --fast` to the worker returns `18 GATE_REFUSED` ("assign it to the coordinator").
|
|
85
|
+
- **Evidence:** fixture rows A1–A10 in `ci/mechanism-468-dispatch-cli.test.js` (real Node entry, stubbed `agy` fixture). Live `agy` runs remain out of scope here until admission is in place.
|
|
67
86
|
|
|
68
87
|
## Evidence boundary
|
|
69
88
|
|
|
70
89
|
| Layer | What it establishes | What it does not establish |
|
|
71
90
|
| --- | --- | --- |
|
|
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. |
|
|
91
|
+
| 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. Captured `agy` quota-pair rows replay sanitized live stderr through that entry. | No real provider behavior or live host behavior. The managed exit status is a fixture; only the direct calls establish a live normal exit 3. |
|
|
73
92
|
| 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
93
|
| 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. |
|
|
75
94
|
| 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. |
|
|
76
95
|
|
|
96
|
+
## Managed mode and gate assignment (#466 D-gate)
|
|
97
|
+
|
|
98
|
+
Managed mode is entered only by `--assignment <path>` (resolved from the worktree when relative): a sidecar JSON file next to the packet. Without the option, behavior, output, and JSON shape are unchanged. A sidecar was chosen over packet frontmatter so the C6 packet format stays untouched and C8 reads one strict, machine-checkable file; packet metadata owns which actor runs each gate, C8 owns admission.
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
{ "schemaVersion": 1, "gates": [ { "id": "verify:all", "actor": "coordinator" }, { "id": "npm run test:consistency", "actor": "worker" } ] }
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Validation is strict: the root has exactly `schemaVersion` (`1`) and `gates`; each gate has exactly `id` and `actor` (`worker` or `coordinator`); ids are unique and must be in the registry. Any unknown key, value, shape, unreadable file, or unknown id returns `19 GATE_ASSIGNMENT_INVALID`.
|
|
105
|
+
|
|
106
|
+
| Gate id | Requirement for a worker |
|
|
107
|
+
| --- | --- |
|
|
108
|
+
| `verify:all`, `verify:all --fast` | Unsandboxed, loopback-capable profile |
|
|
109
|
+
| `npm run test:consistency`, `npm run test:references`, `npm run test:portability`, `node --test <repo-relative .js file>` | Any profile (focused) |
|
|
110
|
+
|
|
111
|
+
One decision function maps the selected runner to a profile: `codex` runs `-s workspace-write` and `agy` requests `--sandbox` (not treated as an unsandboxed loopback-capable profile), so both are conservatively `sandboxed: true`; `opencode` is not. A sandboxed profile with a worker assignment of either full or fast `verify:all` returns `18 GATE_REFUSED` ("assign it to the coordinator"). Both refusals happen after input validation and before readiness or any file creation, so no child starts and no scratch, report, or evidence exists; `--dry-run` applies the same refusals. An accepted managed run returns `gates: {worker: [...], coordinator: [...]}` in JSON (also on dry run). C8 never runs a gate itself: coordinator gates are only recorded, and the attempt is the same single readiness plus execution.
|
|
112
|
+
|
|
113
|
+
| Exit | JSON `code` | Meaning |
|
|
114
|
+
| --- | --- | --- |
|
|
115
|
+
| `18` | `GATE_REFUSED` | Managed worker gate needs a profile the selected runner does not provide. |
|
|
116
|
+
| `19` | `GATE_ASSIGNMENT_INVALID` | Managed assignment is missing, malformed, or names an unknown gate. |
|
|
117
|
+
|
|
118
|
+
Evidence: fixture rows G1–G7 in `ci/mechanism-468-dispatch-cli.test.js` (real entry, stubbed runners). The registry is a v1 list of gates C8 can assess; gates outside it are refused rather than assumed.
|
|
119
|
+
|
|
120
|
+
## Managed scratch and lifecycle (#466 D-scratch)
|
|
121
|
+
|
|
122
|
+
This is #466 policy within C8, entered only with `--assignment`. In managed mode `--scratch` names the canonical external **root**, not the child `TMPDIR`. Unmanaged invocations (no `--assignment`) are unchanged: `--scratch` is used directly and nothing is removed.
|
|
123
|
+
|
|
124
|
+
| Step | Behavior |
|
|
125
|
+
| --- | --- |
|
|
126
|
+
| Root check | Same `UNSAFE_SCRATCH` (`11`) validation as before, on the canonical path: a root inside any repository or linked worktree, including through a symlink or a symlinked ancestor, or crossing a dangling symlink or unresolved symlink chain at the root or any ancestor, is refused before any slot, directory, report, or child exists. |
|
|
127
|
+
| Attempt dir | After validation and admission, C8 creates `<root>/attempt-<random>` with `mkdtemp` (distinct for concurrent attempts, even on one root). It is re-resolved after creation; one that lands inside a repository is removed and refused. It is the child `TMPDIR` and holds readiness/run/report-writer logs and Codex raw output. |
|
|
128
|
+
| Checked DONE | Report validated and not BLOCKED: the logs and raw output are copied to `<root>/retained/<attempt>/` (outside the run dir), each copy is size-verified, and only then this attempt's own directory is removed. The JSON `evidence` paths point at the retained copies. Other attempt dirs are never touched. The report stays at `--report`. |
|
|
129
|
+
| BLOCKED (`17`), failure (`12`/`13`/`15`/`16`) | The attempt dir and all available evidence are kept. |
|
|
130
|
+
| Retention failure | Returns `20 EVIDENCE_RETENTION_FAILED` (phase `retention`) although the report was valid; the attempt dir and evidence are kept, and `evidence` points at them. |
|
|
131
|
+
| `--dry-run` | Creates no root, attempt dir, or child. |
|
|
132
|
+
|
|
133
|
+
| Exit | JSON `code` | Meaning |
|
|
134
|
+
| --- | --- | --- |
|
|
135
|
+
| `20` | `EVIDENCE_RETENTION_FAILED` | Managed DONE could not copy and verify its evidence outside the run dir; nothing was deleted. |
|
|
136
|
+
|
|
137
|
+
Scratch and evidence have different lifetimes: scratch is disposable only after a checked DONE has usable retained evidence. Evidence: fixture rows S1–S8 in `ci/mechanism-468-dispatch-cli.test.js`.
|
|
138
|
+
|
|
139
|
+
## Managed per-pool admission (#466 D-admission)
|
|
140
|
+
|
|
141
|
+
In managed mode (`--assignment`), C8 requires `--admission-policy <path>` (resolved from the worktree when relative) and atomically reserves one slot for the selected credential or shared quota pool before readiness. Without `--assignment`, unmanaged invocations are unchanged and take no reservation (`--admission-policy` without `--assignment` returns `10 INVALID_INPUT`).
|
|
142
|
+
|
|
143
|
+
```json
|
|
144
|
+
{
|
|
145
|
+
"schemaVersion": 1,
|
|
146
|
+
"dir": "/abs/external/admission-dir",
|
|
147
|
+
"pools": {
|
|
148
|
+
"opencode-pilot-key": { "cap": 2 },
|
|
149
|
+
"agy-shared-pool": { "cap": 1 }
|
|
150
|
+
},
|
|
151
|
+
"routes": [
|
|
152
|
+
{ "runner": "opencode", "model": "fixture/opencode-model", "pool": "opencode-pilot-key" },
|
|
153
|
+
{ "runner": "opencode", "model": "fixture/opencode-alias", "pool": "opencode-pilot-key" },
|
|
154
|
+
{ "runner": "agy", "model": "gemini-4-neon-medium", "pool": "agy-shared-pool" }
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
- **Strict validation (`21 ADMISSION_POLICY_INVALID`, phase `admission`):** exact root keys (`schemaVersion: 1`, `dir`, `pools`, `routes`); `dir` must be an absolute directory outside every Git repository/worktree (reusing the canonical path check from D-scratch) and disjoint from `--scratch`; `pools` maps opaque pool ids (`^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$`) to `{ "cap": <integer >= 1> }`; `routes` maps unique `(runner, model)` pairs to defined pools; the selected `(runner, model)` must have a route. Missing, malformed, or unknown policies refuse before spawn.
|
|
160
|
+
- **Opaque identity, no credentials:** pool ids are operator-supplied opaque names. C8 never derives identity from environment secrets and never emits credential values in JSON, slot files, or evidence. Aliases sharing a pool consume the same cap even across different scratch roots.
|
|
161
|
+
- **Atomic bounded slots:** `<dir>/<pool>/slot-<0..cap-1>.json` created with `O_EXCL` (`wx`). Each slot records `{ schemaVersion: 1, pool, slot, holderPid, childPid, startedAt }`, updating `childPid` when a child spawns and clearing it after the child exits.
|
|
162
|
+
- **Over-cap refusal (`22 ADMISSION_CAP_REACHED`, phase `admission`):** no queueing. If all `cap` slots are occupied (including live, abandoned, corrupt, or indeterminate slot files), the excess attempt refuses before spawn and creates no scratch attempt dir; independent pools remain eligible.
|
|
163
|
+
- **Release and coordinator manual slot recovery:** DONE, BLOCKED, readiness failure, runner failure, timeout, and report/retention errors release the owned slot in `finally` after the child has ended (verifying ownership before unlink). Automatic stale-slot reclamation is disabled for the pilot: any existing slot file — including an abandoned, corrupt, or indeterminate reservation — is treated as occupied and is never displaced by contenders. To recover an abandoned slot, the coordinator must first quiesce admission for that pool, confirm that the recorded `holderPid` and any `childPid` (and any spawned child process) have ended and are absent, and only then remove the stale `slot-<k>.json` file before resuming admission.
|
|
164
|
+
- **`--dry-run`:** validates the policy and route and returns `admission: { pool, cap }` without creating `dir` or taking any reservation.
|
|
165
|
+
|
|
166
|
+
| Exit | JSON `code` | Meaning |
|
|
167
|
+
| --- | --- | --- |
|
|
168
|
+
| `21` | `ADMISSION_POLICY_INVALID` | Managed admission policy is missing, malformed, unsafe, or has no route for the selected runner/model. |
|
|
169
|
+
| `22` | `ADMISSION_CAP_REACHED` | Selected admission pool is at cap; excess attempt refused before spawn (no queueing). |
|
|
170
|
+
|
|
171
|
+
Admission bounds concurrency; a provider can still return quota exhaustion at concurrency one. Evidence: fixture rows R1–R10 in `ci/mechanism-468-dispatch-cli.test.js`.
|
|
172
|
+
|
|
77
173
|
## #466 boundary
|
|
78
174
|
|
|
79
|
-
#466 owns
|
|
175
|
+
#466 still owns enforcement across launch paths, refusing packets that declare worker `gh`/network needs (no network capability is assessed here), and any live `agy` pilot. Managed gate assignment, managed scratch, the `agy` headless runner adapter, and managed per-pool admission above are the #466 policy implemented in C8. This CLI otherwise accepts coordinator-supplied inputs for one attempt and cannot certify launcher guarantees outside C8. It also does not add a distributed plugin command or run a live provider.
|
|
@@ -14,13 +14,26 @@ Bug/regression/flake labels or `fix`/`bug` title prefixes qualify; reports keep
|
|
|
14
14
|
- `--hide-ledger` excludes existing error-ledger files from the scan.
|
|
15
15
|
- `--home <dir>` changes the local home used to resolve automatic memory.
|
|
16
16
|
|
|
17
|
+
- **Redaction scope:** the opaque-ref/no-excerpt rules below apply only to fields derived from local-store rows. Git, doc and tracker fields in the same report keep their own sanitization (repo-existing sites, issue reference only); local-store redaction does not rewrite them. The whole combined report still follows the privacy rules below and stays local.
|
|
18
|
+
|
|
17
19
|
## Optional local error store
|
|
18
20
|
|
|
19
|
-
Local observations are opt-in: `--source local-store --destination harness
|
|
21
|
+
Local observations are opt-in: `--source local-store --destination <harness-or-project>`. With no `--source` option, the scanner keeps the legacy report bytes and source set. `--destination` is required with this source and accepts exactly one of `harness` or `project` (the `harness|project` notation is not a literal value); it is the operator's declaration for the canonical Git `--root`, not a router to another repository.
|
|
22
|
+
|
|
23
|
+
The scanner derives the workspace key from that root, calls the supported reader as `listRecords({ workspaceRoot, workspaceKey })`, and accepts only returned rows carrying that key. A bound host workspace that disagrees fails closed. The report binds the resolved destination to an opaque `workspaceRef`; each record ref is `p-local-<sha256>` over the workspace key and validated stored provisional ID. Raw provisional IDs are never reported.
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
| Reader condition | Source status / reason | Recovery |
|
|
26
|
+
| --- | --- | --- |
|
|
27
|
+
| Reader module missing (the packaged Skills-only copy has no `hooks/scripts/lib/local-errors.js`) | `unavailable` / `reader-unavailable` | Re-scan from a trusted full Harness checkout with the command below. |
|
|
28
|
+
| Reader module present but its contract/API is incomplete (for example a missing `DESTINATIONS` export) | `unavailable` / `reader-contract-incomplete` | Repair that checkout's reader, then re-scan. |
|
|
22
29
|
|
|
23
|
-
|
|
30
|
+
Both conditions yield zero local leads, keep the other sources, and fail closed; neither implies routing to another repository. Full-checkout recovery command (choose one destination value, not the literal `harness|project`):
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
node "<Harness checkout>/error-ledger-bootstrap/scripts/scan.js" --root "<target>" --no-memory --source local-store --destination harness --out "<private dir outside target>" --json
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The `local-store` source status is `used`, `missing`, `unverified`, or `unavailable`. Missing local-store indexes use `index-missing`; unreadable or corrupt input uses a sanitized reason such as `store-unreadable`, `store-corrupt`, or `store-unsupported`. A missing destination ledger directory or `index.jsonl` reports `ledgerStatus: unverified` / `ledgerReason: ledger-missing`; unreadable or corrupt ledger uses `ledger-unreadable` / `ledger-corrupt`. An empty reader result is `unverified` (`empty-reader-result`) because the reader returns an empty array for both an empty workspace and several read failures. Invalid rows are skipped and counted as `malformed`; they are never quoted. The report separately counts valid rows assigned to another destination and rows whose destination is `unknown`.
|
|
24
37
|
|
|
25
38
|
Each valid destination-matched provisional lesson yields one neutral local lead. Occurrences are grouped by exact signature and suppressed when a selected lesson covers that signature. JSON and Markdown contain only opaque refs, validated destination/kind/command-class metadata, signatures, counts, and dedupe/evidence results. They never include excerpts, cues, lesson text, issue URLs, paths, session IDs, or tool-use IDs. Keep the reports local; the local store and destination ledger are read-only during scan.
|
|
26
39
|
|
|
@@ -38,9 +51,9 @@ Obtain explicit owner approval for each candidate. Bind the approval to the exac
|
|
|
38
51
|
|
|
39
52
|
The top-level approval JSON has `schemaVersion: 1`, a 20-character hexadecimal `candidateId`, a 64-character hexadecimal `reportSha256` of the exact report bytes, an absolute canonical `targetRoot` matching `--target`, a non-empty `approvedBy`, and a parseable `approvedAt` timestamp. Its `record` object has a kebab-case `signature`; non-empty `class`, `title`, `violates`, and `sourcesNote`; `scope` of `in`, `out`, or `unresolved`; `status` of `open`, `lesson`, or `mechanism`; and `sites`, an array of existing target-repository files named by relative paths without absolute paths or `.` or `..` components. Do not put absolute paths in `approvedBy`, `approvedAt`, or the record text fields. The approved candidate must occur exactly once in the report, and the selected and approved site files must exist in the target.
|
|
40
53
|
|
|
41
|
-
For a candidate with a `local-store` source, also include top-level `destination: harness` or `destination: project` in the approval
|
|
54
|
+
For a candidate with a `local-store` source, also include exactly one top-level `destination: harness` or `destination: project` in the approval, matching the report's `--destination`. Promotion requires one `used` workspace binding whose opaque ref resolves to canonical `--target` through the trusted Harness checkout's local-store reader; every candidate ref must still resolve to a row for that workspace and destination. The report's exact-dedupe result must be eligible, and the candidate must carry a verified Git or documentation commit source that exists in the target repository on that same candidate. Promotion rechecks exact signature and whole-rule dedupe against the current destination ledger while holding the promotion lock. Missing, unknown, mismatched, stale, or unreadable local bindings fail closed before ledger changes. Legacy reports without a local-store source keep their existing approval shape. A stored issue URL is only a local lead and never satisfies the durable-source requirement.
|
|
42
55
|
|
|
43
|
-
Use this
|
|
56
|
+
Use this example as the approval structure, replacing the sample candidate ID and digest with the exact report values, `targetRoot` with the target's absolute canonical path, and the approver, timestamp, and reviewed record content with the owner's approval. A local-store approval includes the top-level `destination` shown here; a legacy approval omits that field.
|
|
44
57
|
|
|
45
58
|
```json
|
|
46
59
|
{
|
|
@@ -48,6 +61,7 @@ Use this complete example as the approval file structure, replacing the sample c
|
|
|
48
61
|
"candidateId": "0123456789abcdef0123",
|
|
49
62
|
"reportSha256": "0000000000000000000000000000000000000000000000000000000000000000",
|
|
50
63
|
"targetRoot": "/absolute/path/to/target",
|
|
64
|
+
"destination": "harness",
|
|
51
65
|
"approvedBy": "Owner Name",
|
|
52
66
|
"approvedAt": "2026-11-20T00:00:00.000Z",
|
|
53
67
|
"record": {
|
|
@@ -65,13 +79,34 @@ Use this complete example as the approval file structure, replacing the sample c
|
|
|
65
79
|
|
|
66
80
|
Do not promote an unapproved, changed, or stale candidate. Keep full candidate reports and private inputs out of E-records, PRs, shared logs, and uploads.
|
|
67
81
|
|
|
68
|
-
Promotion requires the target to already contain `.agents/harness-everything/errors
|
|
82
|
+
Promotion requires the target to already contain `.agents/harness-everything/errors/`; it refuses when the directory is absent. Create that directory once:
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
mkdir -p "<target repo>/.agents/harness-everything/errors"
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
| Candidate source | Index precondition before scan and approval |
|
|
89
|
+
| --- | --- |
|
|
90
|
+
| Legacy (no `local-store` source) | No index file needed beforehand; the first promotion creates it through the sync command below. |
|
|
91
|
+
| `local-store` | `index.jsonl` must already exist and be current in the target. Create/refresh it from the trusted checkout with `node "<Harness checkout>/scripts/errors-sync.js" --root "<target repo>"`. A missing index leaves scan dedupe `unverified` (`ledger-missing`). Scan does not detect a stale index; promotion rechecks it under lock and fails closed (`destination ledger index is stale or unavailable`). Never bypass either; refresh, rescan and reapprove. |
|
|
92
|
+
|
|
93
|
+
Copyable first-promotion sequence for a `local-store` lead:
|
|
69
94
|
|
|
70
95
|
```sh
|
|
96
|
+
# 1. Target ledger directory and index (an empty ledger is fine)
|
|
71
97
|
mkdir -p "<target repo>/.agents/harness-everything/errors"
|
|
98
|
+
node "<Harness checkout>/scripts/errors-sync.js" --root "<target repo>"
|
|
99
|
+
|
|
100
|
+
# 2. Scan from the trusted full checkout, not the packaged Skills-only copy
|
|
101
|
+
node "<Harness checkout>/error-ledger-bootstrap/scripts/scan.js" \
|
|
102
|
+
--root "<target repo>" --no-memory --source local-store --destination harness \
|
|
103
|
+
--out "<private dir outside target>" --json
|
|
104
|
+
|
|
105
|
+
# 3. Classify locally; obtain fresh per-item approval bound to the exact report bytes
|
|
106
|
+
# 4. Promote with the packaged script below
|
|
72
107
|
```
|
|
73
108
|
|
|
74
|
-
|
|
109
|
+
If the index was missing or stale, re-run step 1 **before** step 2, then rescan and reapprove the new `reportSha256`; an approval bound to earlier report bytes is stale.
|
|
75
110
|
|
|
76
111
|
Before promotion, resolve a trusted local Harness checkout containing `scripts/errors-sync.js` and verify its Node dependencies are installed. Local-store candidates also require `hooks/scripts/lib/local-errors.js` in that checkout. The current sync script requires `js-yaml`; a read-only preflight is:
|
|
77
112
|
|
|
@@ -515,10 +515,11 @@ function savedIndex(index) {
|
|
|
515
515
|
function indexState(index) {
|
|
516
516
|
let fd;
|
|
517
517
|
try {
|
|
518
|
-
|
|
518
|
+
// Keep 64-bit device/file IDs exact (Windows IDs can exceed Number's safe integer range).
|
|
519
|
+
const current = fs.lstatSync(index, { bigint: true });
|
|
519
520
|
if (current.isSymbolicLink() || !current.isFile()) throw new Error('index was replaced with a non-regular file');
|
|
520
521
|
fd = fs.openSync(index, fs.constants.O_RDONLY | (fs.constants.O_NOFOLLOW || 0));
|
|
521
|
-
const opened = fs.fstatSync(fd);
|
|
522
|
+
const opened = fs.fstatSync(fd, { bigint: true });
|
|
522
523
|
if (!opened.isFile() || opened.dev !== current.dev || opened.ino !== current.ino) {
|
|
523
524
|
throw new Error('index changed while it was being read');
|
|
524
525
|
}
|
|
@@ -544,13 +545,14 @@ function writePreviousIndex(index, saved, current, expected) {
|
|
|
544
545
|
}
|
|
545
546
|
|
|
546
547
|
const dir = path.dirname(index);
|
|
548
|
+
const mode = Number(saved.stat.mode) & 0o777;
|
|
547
549
|
let temporary;
|
|
548
550
|
let fd;
|
|
549
551
|
try {
|
|
550
552
|
for (let attempt = 0; attempt < 5; attempt++) {
|
|
551
553
|
temporary = path.join(dir, `.${INDEX}.${process.pid}.${crypto.randomBytes(8).toString('hex')}.tmp`);
|
|
552
554
|
try {
|
|
553
|
-
fd = fs.openSync(temporary, 'wx',
|
|
555
|
+
fd = fs.openSync(temporary, 'wx', mode);
|
|
554
556
|
break;
|
|
555
557
|
} catch (error) {
|
|
556
558
|
temporary = undefined;
|
|
@@ -558,7 +560,7 @@ function writePreviousIndex(index, saved, current, expected) {
|
|
|
558
560
|
}
|
|
559
561
|
}
|
|
560
562
|
if (fd === undefined) throw new Error('could not allocate a temporary rollback index');
|
|
561
|
-
fs.fchmodSync(fd,
|
|
563
|
+
fs.fchmodSync(fd, mode);
|
|
562
564
|
fs.writeFileSync(fd, saved.bytes);
|
|
563
565
|
const openFd = fd;
|
|
564
566
|
fd = undefined;
|
|
@@ -615,7 +617,7 @@ function rollback(context, saved, destination, identity, beforeNames) {
|
|
|
615
617
|
}
|
|
616
618
|
if (identity) {
|
|
617
619
|
try {
|
|
618
|
-
const current = fs.lstatSync(destination);
|
|
620
|
+
const current = fs.lstatSync(destination, { bigint: true });
|
|
619
621
|
if (current.dev !== identity.dev || current.ino !== identity.ino || current.isSymbolicLink()) {
|
|
620
622
|
problems.push('new record was replaced by another writer');
|
|
621
623
|
} else fs.unlinkSync(destination);
|
|
@@ -662,7 +664,7 @@ function promote(context) {
|
|
|
662
664
|
let recordFd;
|
|
663
665
|
try {
|
|
664
666
|
recordFd = fs.openSync(destination.destination, 'wx', 0o644);
|
|
665
|
-
identity = fs.fstatSync(recordFd);
|
|
667
|
+
identity = fs.fstatSync(recordFd, { bigint: true });
|
|
666
668
|
fs.writeFileSync(recordFd, text, 'utf8');
|
|
667
669
|
fs.closeSync(recordFd);
|
|
668
670
|
recordFd = undefined;
|