From 830a48c72d6baf71c0f6e2207bfa68aae3eda05d Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 14:54:01 +0900 Subject: [PATCH 01/38] rdm(api): plan the M6 gaps campaign before M7 Closing M6.5 and M6d left three gaps on main, and M7's jobs and show ops would read what one of them decides. This roadmap fixes all three in one small campaign first. - opencode_stop_guard (O1): the ignored OpenCode stop-script guard takes the first collect spec, which is the file spec since 8d88cb50, and no CI job runs it. The leaf finds the export spec by variant, moves the guard into candler-core's container e2e module on an image it builds, and names it in container-e2e's expected list. - job_refusal_record (O11): a job-start refusal's code reaches only supervisor.log. Every job kind now leaves refusal.json through one end_job shared by both runtimes. JobOutcome gains a field, so the fix is marked breaking and the core goes to 0.20.0. - needs_batches (notice 04): requests split by the needs of each dependency component, so a kind's digest and refusal no longer depend on the kinds sent beside it. Two adversarial reviews, each on validity and on how the change was developed, what it leaves and how it is consumed, gate the two engine leaves before they merge. A close-out runs the whole-suite and container gates and writes the knowledge-transfer report. Co-Authored-By: Claude Opus 5.5 --- __roadmap__/m6_gaps/README.md | 82 +++++++++++++++++++ __roadmap__/m6_gaps/job_refusal_record.md | 69 ++++++++++++++++ __roadmap__/m6_gaps/needs_batches.md | 58 +++++++++++++ __roadmap__/m6_gaps/opencode_stop_guard.md | 57 +++++++++++++ __roadmap__/m6_gaps/review/README.md | 49 +++++++++++ __roadmap__/m6_gaps/review/close/README.md | 38 +++++++++ __roadmap__/m6_gaps/review/close/close_out.md | 27 ++++++ .../m6_gaps/review/review_job_refusal.md | 21 +++++ .../m6_gaps/review/review_needs_batches.md | 21 +++++ 9 files changed, 422 insertions(+) create mode 100644 __roadmap__/m6_gaps/README.md create mode 100644 __roadmap__/m6_gaps/job_refusal_record.md create mode 100644 __roadmap__/m6_gaps/needs_batches.md create mode 100644 __roadmap__/m6_gaps/opencode_stop_guard.md create mode 100644 __roadmap__/m6_gaps/review/README.md create mode 100644 __roadmap__/m6_gaps/review/close/README.md create mode 100644 __roadmap__/m6_gaps/review/close/close_out.md create mode 100644 __roadmap__/m6_gaps/review/review_job_refusal.md create mode 100644 __roadmap__/m6_gaps/review/review_needs_batches.md diff --git a/__roadmap__/m6_gaps/README.md b/__roadmap__/m6_gaps/README.md new file mode 100644 index 00000000..29df5bc8 --- /dev/null +++ b/__roadmap__/m6_gaps/README.md @@ -0,0 +1,82 @@ +# M6 gaps before M7 + +## Context +Closing M6.5 and M6d left three gaps on `main` (v0.19.0, `ad74ff94`). Each is judged against the README's purpose paragraph, quoted verbatim: "A domain-agnostic core for evaluating LLM-based agents. Candler has two equal halves behind one operation API: **Execution:** run agents under controlled conditions (experiment matrix, runners, isolation, per-run tool census, provenance). **Evaluation:** grade traces and artifacts, fresh or already on disk, through pluggable evaluators that emit one outcome record format. A library, a lean CLI and an MCP server are thin surfaces over that API. Domain science (for example the HTN-creator evaluation) plugs in as evaluators, suite specs and fixtures. The core names no domain." +- **O1** ([observation round 05 §O1](../../__reports__/agent_config/05-observation_level2_out_of_scope_v0.md)): the ignored guard `opencode_real_binary_is_interrupted_by_the_stop_script` has failed with `no collect` since `8d88cb50`, and no CI job runs it. It serves "run agents under controlled conditions": stopping a real OpenCode run is proven only on the real binary. +- **O11** ([observation round 06 §O11](../../__reports__/agent_config/06-observation_level3_out_of_scope_v0.md)): a job-start refusal ends as `job.ended {"reason":"failed"}` plus a line in `supervisor.log`, so its code reaches no consumer. It serves "one operation API … thin surfaces over that API": the code must sit in the job's own state, which the library, the CLI and later the MCP server read alike. +- **Batched needs** ([notice 04](../../__reports__/run-context/04-notice_batching_needs_v0.md)): one request per evaluator and stage carries the union of its entries' needs, so a kind's `I4Key` digest changes when another kind joins the suite, and a part missing for one kind refuses all of them. It serves "grade traces and artifacts, fresh or already on disk … one outcome record format". The approved choice is Idea A, narrowed: split by the needs of each dependency component, not of each entry. +- None of the three adds a domain name to the core. They are fixed here, before M7 ([`m7_mcp_server.md`](../candler-v1/contracts/parity/alignment/surfaces/isolation/m5b/stats/surface/integrity/mcp/m7_mcp_server.md), blocked by A14), because M7's `jobs` and `show` ops read what O11 decides. +- **Order and ownership.** Depth gives the order. Level 1 holds the three build leaves in parallel, and they share no file: + - `opencode_stop_guard.md`: `crates/candler-harness-opencode/tests/it/guard_opencode_driver.rs` (the guard leaves it), `crates/candler-core/tests/it/guard_container_e2e.rs` and `guard_container_e2e/opencode_stop_e2e.rs`, and `.github/workflows/container-e2e.yml`, which only this leaf edits (it also adds `guard_harness_check_refuses`, which passes on the base); + - `job_refusal_record.md`: `crates/candler-core/src/jobs/**`, `crates/candler-core/tests/it/guard_config_check.rs`, `crates/candler/tests/it/guard_cli_e2e/agent_config_e2e.rs`, and `__design__/architecture.md` (the sentence near line 400 on `refusal.json`); + - `needs_batches.md`: `crates/candler-core/src/evaluation/**`, `crates/candler-core/tests/it/guard_engine.rs` and `guard_run_context.rs`, the engine fixtures under `crates/candler-core/tests/fixtures/engine/`, and `docs/contract/evaluator-protocol.md`. +- `review/` (level 2) holds one adversarial review each of `job_refusal_record` and `needs_batches`, read on their leaf branches before they merge. `opencode_stop_guard` is test and CI only, so it has no review leaf and merges at level 1 once the lead has read its Docker logs. `review/close/` (level 3) holds the close-out, which alone writes under `__reports__/m6_gaps/` outside `leaves/` and `reviews/`, and updates the three source reports. +- **Branches and builds.** The integration branch is `fix/m6-gaps`, cut from `origin/main` at `ad74ff94`. The leaf branches are `test/opencode-stop-guard`, `fix/job-refusal-record` and `fix/needs-batches`, each in its own worktree made by `python3 scripts/worktree.py add ` from the `fix/m6-gaps` tip and removed at its merge. Every build sets `CARGO_TARGET_DIR=/Users/hacker/Documents/tmp/claude-worktrees/Candler/m6-gaps-target/` and `RUSTC_WRAPPER=sccache` in its own environment, one dir per leaf, because a dir shared between worktrees reuses another checkout's test binaries. Never export `TMPDIR` around a sccache cargo command. At most three builds run at once, each leaf's dir is removed at its merge, and `df -h /System/Volumes/Data` is checked before each level. Docker is used by `opencode_stop_guard`, by `job_refusal_record`'s G6 run and by the close-out; each removes what it built by id, with scratch roots under `$HOME`. Nothing is pruned and Docker is never stopped. +- **Conventions.** Each leaf loads the `designing-tests` skill before it writes a test. Guards come first and are seen red, on the base or under their named bite, before they pass; each carries a `Guards: / Oracle: / Bite:` doc comment. Test names that start with `confirm_` are build-step checks, deleted before their leaf merges or rewritten to guard standard. Leaf reports go to `__reports__/m6_gaps/leaves/_v0.md`, review reports to `__reports__/m6_gaps/reviews/_v0.md`, and the knowledge-transfer report to `__reports__/m6_gaps/`. +- **Execution model.** The lead coordinates and does not implement. Every subagent runs on Claude Sonnet 5, with `model: "sonnet"` passed explicitly on each Agent call. A brief names the leaf's worktree, its own scratch subdirectory, its target dir, colgrep-only code reading, the whole-workspace gate, the Docker rules, cleanup on finish, and a full scope boundary instead of a call cap. Verification follows risk: the lead reads `opencode_stop_guard`'s Docker logs; `job_refusal_record` and `needs_batches` each get one cold adversarial review, one pass. The lead talks with a running leaf at its joints (after the fails-on-the-base run, and before the docs step). Each leaf branch is rebased onto `fix/m6-gaps`, then merged with `git merge --no-ff`; long commit and merge messages are written to a file and passed with `-F`. The lead runs the whole suite after each merge. The integration pull request follows CONTRIBUTING.md §Branches and integration. +- **Version effect.** `JobOutcome` (`crates/candler-core/src/jobs/model.rs`) is a public struct without `non_exhaustive`, so adding its `refusal` field breaks construction outside the crate: the commit is `fix(jobs)!` and its body gives the migration (`refusal: None`). At `0.y` the core goes from 0.19.0 to 0.20.0 once; `needs_batches`' `fix(evaluation)` lands in the same release. `schemas@` and `candler-evaluator@` do not change. `docs/contract/codes.toml` does not change either (its rows hold no reason text), and there is no jobs contract page. + +## Reference Documents +- [R01 Observation round 05](../../__reports__/agent_config/05-observation_level2_out_of_scope_v0.md) — §O1, the broken stop-script guard, and §Process lessons on shared build dirs +- [R02 Observation round 06](../../__reports__/agent_config/06-observation_level3_out_of_scope_v0.md) — §O11, the job-start refusal code that reaches no consumer +- [R03 Notice 04](../../__reports__/run-context/04-notice_batching_needs_v0.md) — the reuse-miss and over-refusal effects, and Ideas A and B +- [R04 M7 MCP server](../candler-v1/contracts/parity/alignment/surfaces/isolation/m5b/stats/surface/integrity/mcp/m7_mcp_server.md) — the `jobs` and `show` ops that will read the refusal record +- [R05 Architecture](../../__design__/architecture.md) — the sentence near line 400 on `report.json` and `refusal.json` +- [R06 Evaluator protocol](../../docs/contract/evaluator-protocol.md) — the Notes bullet on request kinds sharing context and digest + +## Goal +Every job kind that ends on a refusal leaves that refusal's code in `jobs//refusal.json`; a kind's stored outcome and its refusal depend only on the needs of its own request; and the OpenCode stop-script guard runs in CI and passes on the real binary. + +## Pre-conditions +- [x] `[nl]` The maintainer approved the plan "close three M6 gaps before M7" (2026-12-01), with narrowed Idea A for batching +- [ ] `[nl]` The maintainer approved the campaign's spend cap below before the first dispatch +- [ ] `[cmd]` `git merge-base --is-ancestor ad74ff94 fix/m6-gaps` succeeds +- [ ] `[cmd]` Before dispatching a leaf, the lead runs, in its worktree and with its environment, `cargo metadata --format-version 1 --no-deps | jq -r '.workspace_root, .target_directory'`, and it prints that worktree and that leaf's target dir +- [ ] `[cmd]` `docker info` succeeds, and `df -h /System/Volumes/Data` shows at least 20 GiB free + +## Success Gates +- ⬜ Every leaf is `done`, and each build leaf's report records every guard it owns seen red (on the base or under its named bite) and then green, with the failing message +- ⬜ `git grep -n confirm_ -- crates python` prints nothing on the `fix/m6-gaps` tip +- ⬜ `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo nextest run --workspace` and `RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps` pass on the tip +- ⬜ `container-e2e` on the integration pull request lists `opencode_real_binary_is_interrupted_by_the_stop_script` and `guard_harness_check_refuses` as PASS +- ⬜ A run job refused at job start leaves `jobs//refusal.json`, a `refusal/1` record that names its code, side and pointer, for each of `experiment.harness_rejected_input`, `jobs.config_check_failed` and `jobs.server_check_failed` +- ⬜ For a plug-in with an artifacts- or manifest-only kind A and a trace kind B, on a run with no trace A is graded and B carries `evaluation.run_part_missing`; on a run with a trace, A's context digest is the same for suite {A} and suite {A, B} +- ⬜ Each review report answers both of its lenses with evidence, and each finding is fixed on the leaf branch or recorded as an observation with its reason before that leaf merges +- ⬜ The pull request `merge(api): close three M6 gaps before M7` is opened only after the maintainer's go; after it merges, the CI release cuts 0.20.0 +- ⬜ Spend is measured from transcripts per leaf, and no leaf passed its cap without stopping. Leaf estimates add to $10.6 and caps to $21.2; with the lead's $4–7, the campaign stays within the cap the maintainer approves + +## Gotchas +- The two reviewed leaves stay on their branches until their review is answered; a finding is fixed on the leaf branch by the same builder, then the leaf merges. +- `needs_batches` changes the context digest of outcomes stored from mixed batches, so those miss reuse once. The commit body says so; it is not a regression. +- `cargo nextest run --workspace` does not run ignored guards. Docker guards run with `--run-ignored only`. +- A timing guard from observation rounds 05 (O10) and 06 (O15) that fails in a full run under load is rerun alone before it is called a regression, and the leaf report records both runs. + +## Status +```mermaid +graph TD + opencode_stop_guard[OpenCode stop guard]:::planned + job_refusal_record[Job refusal record]:::planned + needs_batches[Needs batches]:::planned + review[Review]:::planned + classDef done fill:#166534,color:#bbf7d0 + classDef inprogress fill:#854d0e,color:#fef08a + classDef planned fill:#374151,color:#e5e7eb + classDef amendment fill:#1e3a5f,color:#bfdbfe + classDef blocked fill:#7f1d1d,color:#fecaca +``` + +## Nodes +| Node | Type | Status | +|:-----|:-----|:-------| +| `opencode_stop_guard.md` | 📄 Leaf Task | ⬜ Planned | +| `job_refusal_record.md` | 📄 Leaf Task | ⬜ Planned | +| `needs_batches.md` | 📄 Leaf Task | ⬜ Planned | +| `review/` | 📁 Directory | ⬜ Planned | + +## Amendment Log +| ID | Date | Source | Nodes Added | Rationale | +|:---|:-----|:-------|:------------|:----------| + +## Progress +| Node | Branch | Commits | Notes | +|:-----|:-------|:--------|:------| diff --git a/__roadmap__/m6_gaps/job_refusal_record.md b/__roadmap__/m6_gaps/job_refusal_record.md new file mode 100644 index 00000000..2c8b48db --- /dev/null +++ b/__roadmap__/m6_gaps/job_refusal_record.md @@ -0,0 +1,69 @@ +# Job refusal record + +**Goal**: A job of any kind that ends on a refusal leaves `jobs//refusal.json`, the `refusal/1` record of its typed error, written before `job.ended` by one function both runtimes call, so a job-start refusal's code is read from the job's state and not from `supervisor.log` (O11) +**Estimate**: Sonnet, $3, cap $6. At the cap, stop, commit what is green, and list what is left in the leaf report. Builds use the target dir the campaign README names; the leaf removes it at its merge. +**Pre-conditions**: +- [ ] `[cmd]` `git -C merge-base --is-ancestor fix/m6-gaps HEAD` succeeds +- [ ] `[cmd]` `docker info` succeeds (G6 runs on Docker) +**Success Gates**: +- ⬜ G6 `guard_harness_check_refuses` reads `jobs//refusal.json` and asserts its code `experiment.harness_rejected_input`, its side and its pointer; on the base it is red because the file is absent, and the leaf report records the message; on the tip it passes with `--run-ignored only` +- ⬜ The job-start refusal guard in `guard_config_check.rs` is one parameterized guard with a row each for `experiment.harness_rejected_input` (its message quotes `REJECT: unknown key hooks.Foo`), `jobs.config_check_failed` and `jobs.server_check_failed`, read from the record the job body returns; under the bite "`refused` is handed a string error" every row goes red +- ⬜ `git grep -nE 'CANDLER_CONFIG_CHECK_CHILD|fn refusal_of' -- crates` prints nothing: the child-process helper that read stderr is gone +- ⬜ `crates/candler-core/src/jobs/runtime/refusal.rs` holds the one record builder (`record_of`), `write_refusal`, `REFUSAL_FILE` and `end_job`; `session::run` and evaluate's `run` both end through `end_job`; `evaluate.rs` defines no record builder of its own +- ⬜ `guard_cli_evaluate::r2_a_refusal_raised_in_the_job_keeps_its_code_through_the_verb` passes unchanged, so the order "record, then `job.ended`" holds through the shared path +- ⬜ The `JobOutcome` commit is `fix(jobs)!` with a `BREAKING CHANGE:` footer that gives the migration (`refusal: None`) +- ⬜ `__design__/architecture.md` says every job kind leaves `refusal.json` when an error ended it, in the one sentence that said it of evaluate jobs +- ⬜ `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo nextest run --workspace` and `RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps` pass +**References**: [R02 §O11](../../__reports__/agent_config/06-observation_level3_out_of_scope_v0.md) — the gap and its working theory, one refusal record for every job kind. Code: +- `crates/candler-core/src/jobs/orchestrate/mod.rs`: `refused` (prints the error and returns `failed()`, so the typed error is lost), `run_job` and its refusal paths (`experiment_of`, `plan_runs`, `cells_of`, `gate_controls`, `JobSession::open`, `check_servers`, `check_config`); +- `crates/candler-core/src/jobs/model.rs`: `JobOutcome { end, runs }`, `JobBody`; +- `crates/candler-core/src/jobs/runtime/session.rs`: `run` (emits `job.ended` and nothing else); `crates/candler-core/src/jobs/runtime/evaluate.rs`: `run`, `write_refusal`, `REFUSAL_FILE`; +- `crates/candler-core/src/refusal.rs` (`find`) and `crates/candler-core/src/jobs/refusal.rs` (the jobs codes); +- `crates/candler-core/tests/it/guard_config_check.rs`: `harness_finding_refuses_the_job_before_any_run`, `finding_on_stderr_with_a_failing_exit_refuses_as_a_finding`, `a_check_that_did_not_run_or_printed_nothing_is_refused`, `refusal_of`; `crates/candler/tests/it/guard_cli_e2e/agent_config_e2e.rs`: `guard_harness_check_refuses`; `crates/candler/tests/it/guard_cli_evaluate.rs`: `r2_a_refusal_raised_in_the_job_keeps_its_code_through_the_verb`; +- `__design__/architecture.md` near line 400. + +Scope boundary: no new field on `job.ended` and no `schemas@` change; the CLI prints nothing new; the `supervisor.log` line stays for humans. + +## Step 1: G6 on the base +**Goal**: G6 states what a consumer reads, and is seen red on the base. +**Implementation Logic**: +Change `guard_harness_check_refuses` to read `jobs//refusal.json` and assert its code, side and pointer (written by hand from the contract, not read from the code), instead of searching `supervisor.log` for `"rejects it: "`. Update its `Guards: / Oracle: / Bite:` doc comment. Run it with `--run-ignored only` on the base and record the failing message (the file is absent). The guard is ignored, so the workspace gate stays green between commits. +**Deliverables**: `crates/candler/tests/it/guard_cli_e2e/agent_config_e2e.rs` (`guard_harness_check_refuses`) +**Consistency Checks**: `cargo nextest run -p candler --test it -E 'test(/guard_harness_check_refuses$/)' --run-ignored only` on the base (expected: FAIL) +**Commit**: `test(cli): read a job-start refusal from the job's refusal record` + +## Step 2: One refusal path for every job kind +**Goal**: The record builder and the "record, then `job.ended`" order have one home, and evaluate jobs behave as before. +**Implementation Logic**: +Move the record builder out of `evaluate.rs` into `crates/candler-core/src/jobs/runtime/refusal.rs` with `REFUSAL_FILE`: `record_of(&(dyn Error + 'static)) -> RefusalRecord` (code, side and path from `refusal::find`, the fallback `candler.internal`, the chain of causes, as now) and `write_refusal(dir, &RefusalRecord)` through `write_atomic`. Add `end_job(sink, dir, end, refusal)`, which writes the record when there is one and then emits `job.ended`. Evaluate's `run` calls it. No behaviour changes. +**Deliverables**: `crates/candler-core/src/jobs/runtime/refusal.rs` (`REFUSAL_FILE`, `record_of`, `write_refusal`, `end_job`); `crates/candler-core/src/jobs/runtime/evaluate.rs`; `crates/candler-core/src/jobs/runtime/mod.rs` +**Consistency Checks**: `cargo nextest run --workspace`, with `r2_a_refusal_raised_in_the_job_keeps_its_code_through_the_verb` green (expected: PASS) +**Commit**: `refactor(jobs): share the refusal record between job kinds` + +## Step 3: Run jobs keep their refusal +**Goal**: A refusal in `run_job` reaches `refusal.json` with its code, and each refusal class is guarded. +**Implementation Logic**: +`JobOutcome` gains `refusal: Option`. `refused` takes `&(dyn Error + 'static)`, builds the record with `record_of` and keeps its stderr line. Every refusal path of `run_job` passes its typed error. `session::run` ends through `end_job`, handing it the outcome's record. Fix every constructor of `JobOutcome` in the workspace with `refusal: None`. + +Rewrite the job-start refusal tests of `guard_config_check.rs` as one parameterized guard over the three classes named in the success gates, each row reading `JobOutcome.refusal`; this retires `refusal_of` and its child process. The `jobs.server_check_failed` row joins an existing test that reaches `check_servers` if one exists; only if none does is it written new. G6 sees only the first class, so this guard exists for a wrong mapping of the other two (for example every refusal falling back to `candler.internal`). + +The commit body names the rewritten guard and gives the `BREAKING CHANGE:` footer with the migration. +**Deliverables**: `crates/candler-core/src/jobs/model.rs` (`JobOutcome.refusal`); `crates/candler-core/src/jobs/orchestrate/mod.rs` (`refused`, `run_job`); `crates/candler-core/src/jobs/runtime/session.rs` (`run`); `crates/candler-core/tests/it/guard_config_check.rs` (the parameterized guard) +**Consistency Checks**: G6 with `--run-ignored only`, and `cargo nextest run --workspace` (expected: PASS) +**Commit**: `fix(jobs)!: keep a run job's refusal in its refusal record` + +## Step 4: The design says every job kind +**Goal**: The architecture states the record for every job kind, once. +**Implementation Logic**: +Rewrite the sentence of `__design__/architecture.md` near line 400 ("A finished evaluate job leaves `report.json`, or, when an error ended it, `refusal.json` …") so that every job kind leaves `refusal.json` when an error ended it, written before `job.ended`, and an evaluate job also leaves `report.json` when it finished. Change no other page: `docs/contract/codes.toml` holds no reason text, and there is no jobs contract page. +**Deliverables**: `__design__/architecture.md` +**Consistency Checks**: `grep -n 'refusal.json' __design__/architecture.md` shows the sentence naming every job kind (expected: PASS) +**Commit**: `docs(jobs): say every job kind leaves its refusal record` + +## Step 5: Bite and verify +**Goal**: Each guard goes red under its bite, and nothing is left behind. +**Implementation Logic**: +On a scratch branch, hand `refused` a string error (so every record falls back to `candler.internal`) and see each row of the parameterized guard go red; then drop the `end_job` call from `session::run` and see G6 go red. Record each message. Check that a successful job and a killed job leave no `refusal.json` (read from an existing guard's job directory, or a `confirm_` test deleted afterwards). Remove what Docker built by id. Delete every `confirm_` test. Write the leaf report. +**Deliverables**: `__reports__/m6_gaps/leaves/job_refusal_record_v0.md` +**Consistency Checks**: `git grep -n confirm_ -- crates python` prints nothing (expected: PASS) +**Commit**: `reports(jobs): close the job refusal record` diff --git a/__roadmap__/m6_gaps/needs_batches.md b/__roadmap__/m6_gaps/needs_batches.md new file mode 100644 index 00000000..571d40f2 --- /dev/null +++ b/__roadmap__/m6_gaps/needs_batches.md @@ -0,0 +1,58 @@ +# Needs batches + +**Goal**: The engine sends one request per stage, evaluator and canonical needs set of a dependency component, so a kind's context digest and its refusal depend only on the needs of its own request, and entries that depend on each other within one evaluator still share a request (notice 04, Idea A narrowed) +**Estimate**: Sonnet, $2.5, cap $5. At the cap, stop, commit what is green, and list what is left in the leaf report. Builds use the target dir the campaign README names; the leaf removes it at its merge. +**Pre-conditions**: +- [ ] `[cmd]` `git -C merge-base --is-ancestor fix/m6-gaps HEAD` succeeds +**Success Gates**: +- ⬜ The probe's answer is recorded: whether `run_batch`, the stage loop or the `Interleaved` check assumes one batch per evaluator and stage; if it does, the leaf stopped and reported before step 2 +- ⬜ A new guard, "a kind's result does not depend on the kinds sent beside it", holds two cases through the engine with the test plug-in fixture: on a run sealed with no trace, kind A (artifacts or manifest only) is graded and kind B (trace) carries `evaluation.run_part_missing`; on a run with a trace, A's stamped `context_digest` is equal for suite {A} and suite {A, B}. Both cases are red on the base, with the messages in the leaf report +- ⬜ `guard_engine::dependencies_and_applies_to_decide_what_is_sent` is extended so its dependent entries declare different needs; it passes on the base and the tip, and goes red under the bite "split every entry by its own needs" +- ⬜ Every existing test that asserted one request per evaluator and stage is changed on purpose and named in the fix commit's body, which also says that outcomes stored from mixed batches miss reuse once +- ⬜ No unit test of `plan()`'s grouping remains, and no per-entry digest or refusal machinery (Idea B) was added +- ⬜ The Notes bullet of `docs/contract/evaluator-protocol.md` that says a request's kinds share context and digest is rewritten at its source with a new stamp, the page's Notes stay within 120 words, and the page is regenerated; the doc comment of `evaluation/context/assemble.rs` that states the union rule, and the "what a plug-in is served" wording found by colgrep, say the same +- ⬜ `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo nextest run --workspace` and `RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps` pass +**References**: [R03](../../__reports__/run-context/04-notice_batching_needs_v0.md) — the two effects and Ideas A and B; the narrowing (by component, not by entry) is the campaign's. Code: +- `crates/candler-core/src/evaluation/engine/plan.rs`: `plan` (groups components by `(stage, evaluator)` in a `BTreeMap<(usize, &Name), Vec>`), `stages` (works per component), `Batch`; +- `crates/candler-core/src/evaluation/engine/run.rs`: `send` (one context from `union_needs` of the batch, its digest stamped on every record; an `assemble` error faults the whole batch), `attempt`, `run_batch`, the stage loop and the `Interleaved` refusal; +- `crates/candler-core/src/evaluation/selection/select.rs`: the `I4Key`; `crates/candler-core/src/evaluation/context/assemble.rs`; +- `crates/candler-core/tests/it/guard_engine.rs`: `dependencies_and_applies_to_decide_what_is_sent` (with `dependency_verdicts`, fixtures `suite_dependencies.toml`/`.json`, `plugin.toml`/`plugin_bare.toml`), `the_persisted_context_digest_is_the_digest_of_what_the_plugin_received`, `rig_of`; `crates/candler-core/tests/it/guard_run_context.rs`: `needs_parts_refused_when_the_run_cannot_serve_them` (`mini_store`, `seal_with_inputs`, `needs_declaring`); kinds in `crates/candler-core/tests/fixtures/engine/kinds/engine_fixture.py`; +- [R06](../../docs/contract/evaluator-protocol.md) — the Notes bullet; CONTRIBUTING.md §Contract pages for the stamp and the regeneration command. + +Scope boundary: stages, `send` and `attempt` do not change; no wire or schema change. + +## Step 1: Probe and guards on the base +**Goal**: Know whether the engine assumes one batch per evaluator and stage, and see the new guard red on the base. +**Implementation Logic**: +Probe. Question: does `run_batch`, the stage loop or the `Interleaved` check assume one batch per `(evaluator, stage)`, for example by keying prior outcomes or a refusal on that pair? Read them with colgrep. Decision: if not, go on. If so, stop and tell the lead what assumes it: the leaf would grow past its estimate. + +Write the new guard next to `the_persisted_context_digest_is_the_digest_of_what_the_plugin_received` in `guard_engine.rs`, or next to `needs_parts_refused_when_the_run_cannot_serve_them` in `guard_run_context.rs`, whichever file's helpers can seal a run without a trace and read a stored record's digest; add a kind to `engine_fixture.py` only if no existing kind has the needs the cases call for. Its expected values are written by hand: the code A should carry, and A's digest from suite {A} as the oracle for suite {A, B}. Extend `dependencies_and_applies_to_decide_what_is_sent` so its dependent entries declare different needs. Run both on the base; record the new guard's two failing messages and the extended guard passing. +**Deliverables**: the new guard in `guard_engine.rs` or `guard_run_context.rs`; the extended `dependencies_and_applies_to_decide_what_is_sent` and its fixtures; `__reports__/m6_gaps/leaves/needs_batches_v0.md` (probe answer, base messages) +**Consistency Checks**: the new guard on the base (expected: FAIL) +**Commit**: `test(evaluation): state that a kind's result ignores the kinds beside it` + +## Step 2: Group by needs +**Goal**: Both guards pass on the tip, with the change confined to `plan()`'s grouping key. +**Implementation Logic**: +In `plan()`, key a batch by `(stage, evaluator, needs)`, where `needs` is `union_needs` over the component's members in a canonical order, computed once per component, so components with equal needs share a request. Entries that depend on each other in one evaluator are one component, so they stay in one request with their union, which is what serves the dependent its prior. Stages stay as they are: components of one evaluator do not depend on each other, so splitting a stage by needs orders nothing new. `send` and `attempt` do not change. Update every existing test that asserted one request per evaluator and stage. Any `plan()` unit test written while building is a `confirm_` and is deleted before step 4 ends. + +The commit body names each changed test, and says that outcomes stored from today's mixed batches miss reuse once because their digest changes; every record valid before stays valid. +**Deliverables**: `crates/candler-core/src/evaluation/engine/plan.rs` (`plan`, the batch key); the changed tests +**Consistency Checks**: both guards of step 1, then `cargo nextest run --workspace` (expected: PASS) +**Commit**: `fix(evaluation): split an evaluator's stage by its kinds' needs` + +## Step 3: Say what a request serves +**Goal**: The contract and the docs say a kind is served the needs of its own request. +**Implementation Logic**: +Rewrite the Notes bullet of `docs/contract/evaluator-protocol.md` ("Context and digest cover the request's kinds together; a part the run lacks refuses the request.") so that a request holds the kinds of one evaluator and stage that need the same parts, with entries that depend on each other kept together; context and digest cover that request, and a missing part refuses only its kinds. Keep the page's Notes within 120 words, give the bullet a new stamp, and regenerate the page with `CANDLER_BLESS_CONTRACT=1 cargo nextest run -p candler -E 'test(/^contract_pages::/)'`. Bring the doc comment of `evaluation/context/assemble.rs` and the "what a plug-in is served" wording into line, each at its one source. +**Deliverables**: `docs/contract/evaluator-protocol.md`; `crates/candler-core/src/evaluation/context/assemble.rs` (doc comment); the served-parts wording at its source +**Consistency Checks**: `cargo nextest run -p candler -E 'test(/^contract_pages::/)'` without the bless variable (expected: PASS) +**Commit**: `docs(evaluator-protocol): serve each kind the needs of its own request` + +## Step 4: Bite and verify +**Goal**: Each guard goes red under its bite, and nothing is left behind. +**Implementation Logic**: +On a scratch branch, restore the `(stage, evaluator)` key and see both cases of the new guard go red; then key every entry by its own needs and see the extended dependency guard go red. Record each message. Delete every `confirm_` test. Write the leaf report: probe answer, base messages, bite messages, the tests changed on purpose. +**Deliverables**: `__reports__/m6_gaps/leaves/needs_batches_v0.md` (complete) +**Consistency Checks**: `git grep -n confirm_ -- crates python` prints nothing (expected: PASS) +**Commit**: `reports(evaluation): close the needs batches` diff --git a/__roadmap__/m6_gaps/opencode_stop_guard.md b/__roadmap__/m6_gaps/opencode_stop_guard.md new file mode 100644 index 00000000..d71dc159 --- /dev/null +++ b/__roadmap__/m6_gaps/opencode_stop_guard.md @@ -0,0 +1,57 @@ +# OpenCode stop guard + +**Goal**: The OpenCode stop-script guard finds the export spec by its variant, builds its own base image, lives in candler-core's container e2e module and is named in CI's expected-guard list, so CI runs it on the real binary and fails if it is skipped (O1) +**Estimate**: Sonnet, $1.5, cap $3. At the cap, stop, commit what is green, and list what is left in the leaf report. Builds use the target dir the campaign README names; the leaf removes it at its merge. +**Pre-conditions**: +- [ ] `[cmd]` `git -C merge-base --is-ancestor fix/m6-gaps HEAD` succeeds +- [ ] `[cmd]` `docker info` succeeds +**Success Gates**: +- ⬜ The leaf report records the guard on the base: `no collect` with `CANDLER_OPENCODE_IMAGE` set to an image the leaf built, and `NotPresent` without it +- ⬜ The probe's answer is recorded: with only the export spec found by variant, the guard passes on the base, or the leaf stopped and reported the other failure to the lead +- ⬜ `cargo nextest run -p candler-core --test it -E 'test(/^guard_container_e2e::opencode_stop_e2e::/)' --run-ignored only` passes with no Candler environment variable set +- ⬜ Under the bite "the stop script exits 0 without signalling the agent", the guard goes red; the leaf report records the message +- ⬜ An image the guard built under a tag that did not exist before the run is removed by id; `docker images -q` lists no new id after the run +- ⬜ `.github/workflows/container-e2e.yml`'s expected list names `opencode_real_binary_is_interrupted_by_the_stop_script` and `guard_harness_check_refuses` +- ⬜ `git diff fix/m6-gaps -- crates/candler-harness-opencode/src` prints nothing: what `collect` returns is unchanged (the report's scope boundary) +- ⬜ `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo nextest run --workspace` and `RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps` pass; the leaf report gives the guard's wall time, cold and with Docker's layer cache warm +**References**: [R01 §O1](../../__reports__/agent_config/05-observation_level2_out_of_scope_v0.md) — the failure, the hand-off question and the scope boundary. Code: +- `crates/candler-harness-opencode/tests/it/guard_opencode_driver.rs`: `opencode_real_binary_is_interrupted_by_the_stop_script` (lines 1085–1225 at `ad74ff94`) and its helpers; +- `crates/candler-harness-opencode/src/driver.rs`: `OpenCodeDriver::collect` (lines 436–463), which returns the `**/*` file spec, then the exclusions, then the `CollectSpec::Exec` export spec; +- `crates/candler-core/tests/it/guard_container_e2e/version_probe_e2e.rs`: how a guard builds `assets/docker/base-opencode` from `driver.base_image().build_args` under its own tag; `crates/candler-core/tests/it/guard_container_e2e.rs`: the module list; +- `.github/workflows/container-e2e.yml`: the `test(/^guard_container_e2e::/)` filter and the expected-guard list. + +## Step 1: Probe and the guard on the base +**Goal**: Know whether the spec selection is the only thing broken, and see the guard fail on the base. +**Implementation Logic**: +Build `assets/docker/base-opencode` the way `version_probe_e2e.rs` does, under a scratch tag, and note whether the tag existed before. Run the guard where it is, `cargo nextest run -p candler-harness-opencode --test it -E 'test(=guard_opencode_driver::opencode_real_binary_is_interrupted_by_the_stop_script)' --run-ignored only`, once with `CANDLER_OPENCODE_IMAGE` set to that tag and once without; record both messages. + +Probe. Question: with only the export spec found by variant (`collect(..).iter().find_map(|s| match s { CollectSpec::Exec { spec, .. } => Some(spec.argv().to_vec()), _ => None })`), does the guard pass, or has the decoy `serve`, the export argv or the stop script drifted too since `8d88cb50`? Apply only that change on a scratch commit and run the guard again. Decision: if it passes, go on to step 2. If it fails for another reason, stop and send the lead the failing message: changing the driver is outside this leaf. + +Write the leaf report's first section (the base messages and the probe's answer). +**Deliverables**: `__reports__/m6_gaps/leaves/opencode_stop_guard_v0.md` (base messages, probe answer) +**Consistency Checks**: the guard on the base fails with `no collect` when the image is set (expected: FAIL) +**Commit**: `reports(adapter-opencode): record the stop-script guard on the base` + +## Step 2: Move and repair the guard +**Goal**: The guard runs in candler-core's container e2e module on an image it builds, with no environment variable. +**Implementation Logic**: +Move the guard to `crates/candler-core/tests/it/guard_container_e2e/opencode_stop_e2e.rs` under the same name, with `#[ignore = "needs Docker; run with --run-ignored only"]` as its siblings have, and declare the module in `guard_container_e2e.rs`. Select the export spec by variant as in the probe. Build the base image as `version_probe_e2e.rs` does: if its builder is private to that file, lift it into a helper both guards call rather than copying it. Remove the image by id at the end only if its tag did not exist before the run, so a cached image another guard uses survives. Drop `CANDLER_OPENCODE_IMAGE`, and remove the guard and any helper that only it used from `guard_opencode_driver.rs`. Its doc comment carries `Guards: / Oracle: / Bite:`; the bite is the one step 4 runs. Do not change `OpenCodeDriver::collect`. +**Deliverables**: `crates/candler-core/tests/it/guard_container_e2e/opencode_stop_e2e.rs` (`opencode_real_binary_is_interrupted_by_the_stop_script`); `crates/candler-core/tests/it/guard_container_e2e.rs` (`mod opencode_stop_e2e`); the shared image builder if lifted; `crates/candler-harness-opencode/tests/it/guard_opencode_driver.rs` (guard removed) +**Consistency Checks**: `cargo nextest run -p candler-core --test it -E 'test(/^guard_container_e2e::opencode_stop_e2e::/)' --run-ignored only` with no Candler variable set, and `git grep -n CANDLER_OPENCODE_IMAGE` prints nothing (expected: PASS) +**Commit**: `test(adapter-opencode): run the stop-script guard on an image it builds` + +## Step 3: Expect the guards in CI +**Goal**: CI's container-e2e job fails if the stop-script guard or G6 is skipped or renamed. +**Implementation Logic**: +Add `opencode_real_binary_is_interrupted_by_the_stop_script` and `guard_harness_check_refuses` to the expected list in `.github/workflows/container-e2e.yml`. Both are already selected by the job's `test(/^guard_container_e2e::/) | test(/^guard_cli_e2e::/)` filter; the list makes their absence an error. `guard_harness_check_refuses` passes on the base (it asserts on the message today), and `job_refusal_record` changes what it asserts, not its name. No other workflow line changes; a missing name for another guard goes in the leaf report as an observation. +**Deliverables**: `.github/workflows/container-e2e.yml` (two names in the expected list) +**Consistency Checks**: `grep -cE 'opencode_real_binary_is_interrupted_by_the_stop_script|guard_harness_check_refuses' .github/workflows/container-e2e.yml` prints `2` (expected: PASS) +**Commit**: `ci(repo): expect the OpenCode stop and harness-check guards` + +## Step 4: Bite and verify +**Goal**: The guard goes red under its bite, and the leaf leaves nothing behind. +**Implementation Logic**: +On a scratch branch, make the driver's stop script exit 0 without signalling the agent, run the guard and record the failing message; discard the branch. Run the guard twice on the tip, cold and with the layer cache warm, and record both wall times. Check that `docker images -q` lists no id the leaf made, and remove by id any it did. Run the whole-workspace gates. Delete every `confirm_` test. Finish the leaf report: base messages, probe answer, bite message, wall times, and any observation. +**Deliverables**: `__reports__/m6_gaps/leaves/opencode_stop_guard_v0.md` (complete) +**Consistency Checks**: `git grep -n confirm_ -- crates python` prints nothing (expected: PASS) +**Commit**: `reports(adapter-opencode): close the OpenCode stop-script guard` diff --git a/__roadmap__/m6_gaps/review/README.md b/__roadmap__/m6_gaps/review/README.md new file mode 100644 index 00000000..d76aab3f --- /dev/null +++ b/__roadmap__/m6_gaps/review/README.md @@ -0,0 +1,49 @@ +# Review + +## Context +Level 2 of the M6 gaps campaign. It runs after the three build leaves are `done`: `opencode_stop_guard` is already merged into `fix/m6-gaps`, and `fix/job-refusal-record` and `fix/needs-batches` wait on their branches for the review below. +- Each review is one cold pass by a fresh Sonnet agent (`model: "sonnet"`), read-only on code. It gets the leaf file, the leaf branch's diff against `fix/m6-gaps` and the code, not the builder's report or conclusions, and reads code with colgrep only. +- Each reviewer judges two lenses. **Mechanistic validity:** is the change correct? **Sustainability, scalability and efficiency** at the three levels the work touches: how it was developed, what it leaves in the code, how it is consumed. Each answer cites a `file:line`, a command and its output, or a transcript measure. +- Findings go back to the leaf branch, where the leaf's own builder fixes them (the lead continues that agent with `SendMessage`); a finding not fixed is recorded as an observation with its reason. Then the leaf is rebased onto `fix/m6-gaps` and merged with `git merge --no-ff`, and the lead runs the whole suite. No second review round follows. +- `opencode_stop_guard` has no review leaf. The lead checked, in its place: the Docker logs of the base failure, the bite and the pass; that the image is built through `version_probe_e2e`'s builder, so the layer cache keeps a second build cheap; that the image is removed by id; and the time the guard adds to `container-e2e`. +- `close/` (level 3) runs after both reviewed leaves have merged. + +## Goal +Each risky change is judged on validity and on develop, leave and consume before it merges, in one pass. + +## Pre-conditions +- [ ] `[cmd]` `git merge-base --is-ancestor test/opencode-stop-guard fix/m6-gaps` succeeds +- [ ] `[nl]` `job_refusal_record` and `needs_batches` are `done` on their branches, each with its leaf report + +## Success Gates +- ⬜ `__reports__/m6_gaps/reviews/job_refusal_record_v0.md` and `__reports__/m6_gaps/reviews/needs_batches_v0.md` answer every question of their leaf with evidence +- ⬜ Every finding is fixed on its leaf branch or recorded as an observation with its reason +- ⬜ `git merge-base --is-ancestor fix/job-refusal-record fix/m6-gaps` and `git merge-base --is-ancestor fix/needs-batches fix/m6-gaps` succeed, each merged with `--no-ff`, and `cargo nextest run --workspace` passed after each merge + +## Status +```mermaid +graph TD + review_job_refusal[Review: job refusal]:::planned + review_needs_batches[Review: needs batches]:::planned + close[Close]:::planned + classDef done fill:#166534,color:#bbf7d0 + classDef inprogress fill:#854d0e,color:#fef08a + classDef planned fill:#374151,color:#e5e7eb + classDef amendment fill:#1e3a5f,color:#bfdbfe + classDef blocked fill:#7f1d1d,color:#fecaca +``` + +## Nodes +| Node | Type | Status | +|:-----|:-----|:-------| +| `review_job_refusal.md` | 📄 Leaf Task | ⬜ Planned | +| `review_needs_batches.md` | 📄 Leaf Task | ⬜ Planned | +| `close/` | 📁 Directory | ⬜ Planned | + +## Amendment Log +| ID | Date | Source | Nodes Added | Rationale | +|:---|:-----|:-------|:------------|:----------| + +## Progress +| Node | Branch | Commits | Notes | +|:-----|:-------|:--------|:------| diff --git a/__roadmap__/m6_gaps/review/close/README.md b/__roadmap__/m6_gaps/review/close/README.md new file mode 100644 index 00000000..6cc995a8 --- /dev/null +++ b/__roadmap__/m6_gaps/review/close/README.md @@ -0,0 +1,38 @@ +# Close + +## Context +Level 3 of the M6 gaps campaign, after every leaf has merged into `fix/m6-gaps`. It holds one leaf, `close_out.md`: the lead runs the whole-workspace and container gates on the tip, one Sonnet agent writes the knowledge-transfer report, and the integration pull request's text is drafted. The pull request is opened only after the maintainer's go, under CONTRIBUTING.md §Branches and integration. + +## Goal +The `fix/m6-gaps` tip passes every gate, and one report closes the three gaps and says what the campaign cost. + +## Pre-conditions +- [ ] `[cmd]` `git merge-base --is-ancestor fix/job-refusal-record fix/m6-gaps` and `git merge-base --is-ancestor fix/needs-batches fix/m6-gaps` succeed + +## Success Gates +- ⬜ `close_out.md` is `done` +- ⬜ The pull request text exists and is not opened before the maintainer's go + +## Status +```mermaid +graph TD + close_out[Close out]:::planned + classDef done fill:#166534,color:#bbf7d0 + classDef inprogress fill:#854d0e,color:#fef08a + classDef planned fill:#374151,color:#e5e7eb + classDef amendment fill:#1e3a5f,color:#bfdbfe + classDef blocked fill:#7f1d1d,color:#fecaca +``` + +## Nodes +| Node | Type | Status | +|:-----|:-----|:-------| +| `close_out.md` | 📄 Leaf Task | ⬜ Planned | + +## Amendment Log +| ID | Date | Source | Nodes Added | Rationale | +|:---|:-----|:-------|:------------|:----------| + +## Progress +| Node | Branch | Commits | Notes | +|:-----|:-------|:--------|:------| diff --git a/__roadmap__/m6_gaps/review/close/close_out.md b/__roadmap__/m6_gaps/review/close/close_out.md new file mode 100644 index 00000000..6bf508bb --- /dev/null +++ b/__roadmap__/m6_gaps/review/close/close_out.md @@ -0,0 +1,27 @@ +# Close out + +**Goal**: The `fix/m6-gaps` tip passes the whole-workspace and container gates, one knowledge-transfer report closes O1, O11 and notice 04 and gives the measured spend, and the integration pull request's text is ready +**Estimate**: Sonnet, $2, cap $4 (the lead runs the gates; one Sonnet agent writes the report). At the cap, stop, commit what is written, and list what is left. Builds use `/Users/hacker/Documents/tmp/claude-worktrees/Candler/m6-gaps-target/close_out`, removed at the end. +**Pre-conditions**: +- [ ] `[cmd]` `git merge-base --is-ancestor fix/job-refusal-record fix/m6-gaps` and `git merge-base --is-ancestor fix/needs-batches fix/m6-gaps` succeed +- [ ] `[cmd]` `docker info` succeeds +**Success Gates**: +- ⬜ On the tip, `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo nextest run --workspace` and `RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps` pass, and `git grep -n confirm_ -- crates python` prints nothing +- ⬜ `cargo nextest run -p candler-core -p candler --test it -E 'test(/^guard_container_e2e::/) | test(/^guard_cli_e2e::/)' --run-ignored only --no-fail-fast` passes locally, `opencode_real_binary_is_interrupted_by_the_stop_script` and `guard_harness_check_refuses` included; what it built is removed by id +- ⬜ `__reports__/m6_gaps/00-knowledge_transfer_v0.md` says what each gap was and what closed it (commits, guards, the bites that turned them red), the probes' answers, the review findings and what became of each, the version effect (core 0.20.0, no `schemas@` or `candler-evaluator@` release), the spend per leaf measured from transcripts against each estimate, and the observations found on the way +- ⬜ Notice 04's front matter says `status: accepted`, with Idea A narrowed and a link to the report; observation rounds 05 and 06 each get one line under O1 and O11 pointing at the report +- ⬜ The pull request text `merge(api): close three M6 gaps before M7` is written to the report's last section: its body says why, what changes, the hard parts, what is not covered and the observations, speaks from outside the project (no person's name, no one awaited), ends with the `Co-Authored-By:` trailer CONTRIBUTING.md §Branches and integration asks of an agent-authored body, and the pull request is not opened +- ⬜ Every leaf worktree and target dir the campaign made is removed, and no Docker image, container or network it made is left +**References**: [the campaign README](../../README.md) — the success gates this leaf checks; the leaf and review reports under `__reports__/m6_gaps/`; CONTRIBUTING.md §Branches and integration for the pull request's title and body. + +## Step 1: Gates, report and pull request text +**Goal**: Everything the campaign promised is checked on the tip and written down once. +**Implementation Logic**: +The lead checks `df -h /System/Volumes/Data`, then runs the whole-workspace gates and the container selection on the tip, and keeps their output for the report. A timing guard from observation rounds 05 and 06 that fails under load is rerun alone and both runs are recorded. The lead measures each leaf's and review's spend from its transcript. + +One Sonnet agent then writes the knowledge-transfer report from the leaf and review reports, the gate output and the spend, with the `writing-reports` skill, and updates notice 04 and the two observation rounds as the success gates say. The report's last section is the pull request text. + +The lead removes every leaf worktree with `python3 scripts/worktree.py`, every target dir under `m6-gaps-target/`, and by id any Docker object the campaign made. +**Deliverables**: `__reports__/m6_gaps/00-knowledge_transfer_v0.md`; `__reports__/run-context/04-notice_batching_needs_v0.md` (status); `__reports__/agent_config/05-observation_level2_out_of_scope_v0.md` and `06-observation_level3_out_of_scope_v0.md` (one line each) +**Consistency Checks**: `git grep -n confirm_ -- crates python` prints nothing, and `grep -n '^status: accepted' __reports__/run-context/04-notice_batching_needs_v0.md` prints one line (expected: PASS) +**Commit**: `reports(api): close the M6 gaps campaign` diff --git a/__roadmap__/m6_gaps/review/review_job_refusal.md b/__roadmap__/m6_gaps/review/review_job_refusal.md new file mode 100644 index 00000000..aea169ae --- /dev/null +++ b/__roadmap__/m6_gaps/review/review_job_refusal.md @@ -0,0 +1,21 @@ +# Review: job refusal + +**Goal**: An adversarial, read-only review of `fix/job-refusal-record` on validity and on develop, leave and consume, before it merges +**Estimate**: Sonnet, $0.8, cap $1.6. At the cap, stop and hand back what is answered, with the open questions listed. The reviewer builds in its own target dir, `/Users/hacker/Documents/tmp/claude-worktrees/Candler/m6-gaps-target/review_job_refusal`, and removes it when done. +**Pre-conditions**: +- [ ] `[nl]` `job_refusal_record` is `done` on `fix/job-refusal-record`, with its leaf report +**Success Gates**: +- ⬜ Validity: the report says, with a `file:line` or a command's output for each, whether `refusal.json` is written before `job.ended` on every refusal path of `run_job`; whether it is absent after a successful job and after a kill; whether each of the three codes keeps its side and pointer; and whether each changed guard goes red under the bite the leaf names (the reviewer reruns at least one bite) +- ⬜ Develop: whether the leaf stayed inside its scope boundary (no `job.ended` field, no `schemas@` change, nothing new printed by the CLI), and its spend against its $3 estimate, measured from its transcript +- ⬜ Leave: whether there is one record builder and one `end_job` that both runtimes call; whether any state is stored twice (the file and an event, or two writers of the file); whether `refusal_of` and its child process are gone and the test count held or fell; whether every remaining test catches a bug another test on the same behaviour misses; whether each doc change is made once, at its source +- ⬜ Consume: whether a reader (the CLI, later M7's `jobs` and `show`, an agent) gets the code of any job kind's refusal from one file without parsing a log; whether the success path pays any extra I/O +- ⬜ Each finding names its severity and the smallest fix, and the report says which findings block the merge +**References**: [the leaf](../job_refusal_record.md) — goal, scope boundary, guards and bites; [R02 §O11](../../../__reports__/agent_config/06-observation_level3_out_of_scope_v0.md) — the gap. Read the diff with `git diff fix/m6-gaps...fix/job-refusal-record` and the code with colgrep; do not read the leaf report until every question has an answer. + +## Step 1: Review +**Goal**: Every question of the success gates has an answer with its evidence. +**Implementation Logic**: +Read the leaf file and the diff cold. Answer validity first, then develop, leave and consume, in that order. Rerun what is cheap to rerun: the parameterized guard and one of its bites, and `cargo nextest run --workspace`. G6 needs Docker; rerun it only if a finding depends on it, and remove by id what it built. Write findings as: what is wrong, where, what it costs a consumer or a later milestone, the smallest fix, blocking or not. Change no code. +**Deliverables**: `__reports__/m6_gaps/reviews/job_refusal_record_v0.md` +**Consistency Checks**: `git diff --stat fix/job-refusal-record` on the reviewer's worktree shows only the review report (expected: PASS) +**Commit**: `reports(jobs): review the job refusal record` diff --git a/__roadmap__/m6_gaps/review/review_needs_batches.md b/__roadmap__/m6_gaps/review/review_needs_batches.md new file mode 100644 index 00000000..7a46c844 --- /dev/null +++ b/__roadmap__/m6_gaps/review/review_needs_batches.md @@ -0,0 +1,21 @@ +# Review: needs batches + +**Goal**: An adversarial, read-only review of `fix/needs-batches` on validity and on develop, leave and consume, with the request and process count it costs and how that count scales, before it merges +**Estimate**: Sonnet, $0.8, cap $1.6. At the cap, stop and hand back what is answered, with the open questions listed. The reviewer builds in its own target dir, `/Users/hacker/Documents/tmp/claude-worktrees/Candler/m6-gaps-target/review_needs_batches`, and removes it when done. +**Pre-conditions**: +- [ ] `[nl]` `needs_batches` is `done` on `fix/needs-batches`, with its leaf report +**Success Gates**: +- ⬜ Validity: the report says, with evidence, whether a kind's digest is the same whatever other kinds share its evaluator and stage; whether entries that depend on each other in one evaluator are still sent in one request with their prior; whether prior outcomes are still served across stages; and whether both cases of the new guard go red under the old `(stage, evaluator)` key (the reviewer reruns that bite) +- ⬜ Develop: whether the leaf stayed inside its scope boundary (stages, `send` and `attempt` unchanged, no wire change), and its spend against its $2.5 estimate, measured from its transcript +- ⬜ Leave: whether the change is confined to `plan()`'s grouping key, with no per-entry digest or refusal machinery (Idea B); whether the canonical needs key is cheap and computed once per component; whether the `confirm_` tests were culled; whether each doc change is made once, at its source +- ⬜ Consume and scale: the number of requests and plug-in processes before and after on the largest suite fixture under `crates/candler-core/tests/fixtures/engine/`, measured on both branches; a static count of the distinct needs sets per evaluator and stage of the golden suite (htn-creator-eval 0.4.2) if a checkout of it is on this machine, or a statement that none is; how the count grows with the number of distinct needs sets, whose worst case is one process per kind; and whether the commit body states the one-off reuse miss for outcomes stored from mixed batches +- ⬜ Each finding names its severity and the smallest fix, and the report says which findings block the merge +**References**: [the leaf](../needs_batches.md) — goal, scope boundary, guards and bites; [R03](../../../__reports__/run-context/04-notice_batching_needs_v0.md) — the two effects and both ideas. Read the diff with `git diff fix/m6-gaps...fix/needs-batches` and the code with colgrep; do not read the leaf report until every question has an answer. + +## Step 1: Review +**Goal**: Every question of the success gates has an answer with its evidence. +**Implementation Logic**: +Read the leaf file and the diff cold. Answer validity first, then develop, leave, and consume and scale. Count requests and processes by running the fixture suite through the engine on each branch, with a `confirm_` counter in a scratch worktree that is never committed, or from a log the fixture plug-in already writes. Rerun the old-key bite and `cargo nextest run --workspace`. Write findings as: what is wrong, where, what it costs a consumer or a later milestone, the smallest fix, blocking or not. Change no code on the leaf branch. +**Deliverables**: `__reports__/m6_gaps/reviews/needs_batches_v0.md` +**Consistency Checks**: `git diff --stat fix/needs-batches` on the reviewer's worktree shows only the review report (expected: PASS) +**Commit**: `reports(evaluation): review the needs batches` From fcb2f692a8421d3db2ad77e9301ab8560d92d171 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 15:05:15 +0900 Subject: [PATCH 02/38] rdm(api): start the three M6 gap leaves The pre-conditions hold on fix/m6-gaps (cut from 830a48c7, which contains ad74ff94): each leaf worktree resolves to its own target dir, Docker answers and 194 GiB are free. Co-Authored-By: Claude Opus 5.5 --- __roadmap__/m6_gaps/README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/__roadmap__/m6_gaps/README.md b/__roadmap__/m6_gaps/README.md index 29df5bc8..5a9be07e 100644 --- a/__roadmap__/m6_gaps/README.md +++ b/__roadmap__/m6_gaps/README.md @@ -29,10 +29,10 @@ Every job kind that ends on a refusal leaves that refusal's code in `jobs//r ## Pre-conditions - [x] `[nl]` The maintainer approved the plan "close three M6 gaps before M7" (2026-12-01), with narrowed Idea A for batching -- [ ] `[nl]` The maintainer approved the campaign's spend cap below before the first dispatch -- [ ] `[cmd]` `git merge-base --is-ancestor ad74ff94 fix/m6-gaps` succeeds -- [ ] `[cmd]` Before dispatching a leaf, the lead runs, in its worktree and with its environment, `cargo metadata --format-version 1 --no-deps | jq -r '.workspace_root, .target_directory'`, and it prints that worktree and that leaf's target dir -- [ ] `[cmd]` `docker info` succeeds, and `df -h /System/Volumes/Data` shows at least 20 GiB free +- [x] `[nl]` The maintainer approved the campaign's spend cap below before the first dispatch (go to lead the roadmap as written, 2026-12-01) +- [x] `[cmd]` `git merge-base --is-ancestor ad74ff94 fix/m6-gaps` succeeds +- [x] `[cmd]` Before dispatching a leaf, the lead runs, in its worktree and with its environment, `cargo metadata --format-version 1 --no-deps | jq -r '.workspace_root, .target_directory'`, and it prints that worktree and that leaf's target dir +- [x] `[cmd]` `docker info` succeeds, and `df -h /System/Volumes/Data` shows at least 20 GiB free ## Success Gates - ⬜ Every leaf is `done`, and each build leaf's report records every guard it owns seen red (on the base or under its named bite) and then green, with the failing message @@ -54,9 +54,9 @@ Every job kind that ends on a refusal leaves that refusal's code in `jobs//r ## Status ```mermaid graph TD - opencode_stop_guard[OpenCode stop guard]:::planned - job_refusal_record[Job refusal record]:::planned - needs_batches[Needs batches]:::planned + opencode_stop_guard[OpenCode stop guard]:::inprogress + job_refusal_record[Job refusal record]:::inprogress + needs_batches[Needs batches]:::inprogress review[Review]:::planned classDef done fill:#166534,color:#bbf7d0 classDef inprogress fill:#854d0e,color:#fef08a @@ -68,9 +68,9 @@ graph TD ## Nodes | Node | Type | Status | |:-----|:-----|:-------| -| `opencode_stop_guard.md` | 📄 Leaf Task | ⬜ Planned | -| `job_refusal_record.md` | 📄 Leaf Task | ⬜ Planned | -| `needs_batches.md` | 📄 Leaf Task | ⬜ Planned | +| `opencode_stop_guard.md` | 📄 Leaf Task | 🔄 In Progress | +| `job_refusal_record.md` | 📄 Leaf Task | 🔄 In Progress | +| `needs_batches.md` | 📄 Leaf Task | 🔄 In Progress | | `review/` | 📁 Directory | ⬜ Planned | ## Amendment Log From 1beaf676cb5f0009eb51f4e2bb9bd02695b95511 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 15:06:37 +0900 Subject: [PATCH 03/38] reports(adapter-opencode): record the stop-script guard on the base Co-Authored-By: Claude Sonnet 5.5 --- .../m6_gaps/leaves/opencode_stop_guard_v0.md | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 __reports__/m6_gaps/leaves/opencode_stop_guard_v0.md diff --git a/__reports__/m6_gaps/leaves/opencode_stop_guard_v0.md b/__reports__/m6_gaps/leaves/opencode_stop_guard_v0.md new file mode 100644 index 00000000..fdab2c67 --- /dev/null +++ b/__reports__/m6_gaps/leaves/opencode_stop_guard_v0.md @@ -0,0 +1,32 @@ +# OpenCode stop-script guard: the base, the probe, the move (v0) + +Leaf `opencode_stop_guard` of the campaign `__roadmap__/m6_gaps/`. Closes O1 of +`__reports__/agent_config/05-observation_level2_out_of_scope_v0.md`. + +## 1. The guard on the base + +The guard `guard_opencode_driver::opencode_real_binary_is_interrupted_by_the_stop_script` was run +where it lives, on `fix/m6-gaps`, against an image built from `assets/docker/base-opencode` with +`--build-arg OC_VERSION=2.2.7` (the driver's `base_image` arguments) under the scratch tag +`candler-test-stop-guard:opencode`. The tag did not exist before; the build took 2.5 s because +Docker's layer cache held every layer. + +| Run | Result | Message | +|---|---|---| +| `CANDLER_OPENCODE_IMAGE` set to the scratch tag | FAIL in 0.05 s | `Error: "no collect"` | +| `CANDLER_OPENCODE_IMAGE` unset | FAIL in 0.02 s | `Error: NotPresent` | + +Cause: the guard takes `collect(..).first()`, but `OpenCodeDriver::collect` now returns the `**/*` +file spec first and the `CollectSpec::Exec` export spec later. The guard never reaches Docker. + +## 2. The probe + +Question: with only the export spec found by variant, does the guard pass, or have the decoy +`serve`, the export argv or the stop script drifted too since `8d88cb50`? + +Change applied (and discarded after the run, step 2 carries it): `first()` plus the match became +`.iter().find_map(|s| match s { CollectSpec::Exec { spec, .. } => Some(spec.argv().to_vec()), _ => None }).ok_or("no collect")?`. + +Answer: the guard PASSES (7.5 s, `1 passed`) on the real `opencode` 2.2.7 image. Only the spec +selection drifted; the decoy, the export argv and the stop script still agree with the driver. The +driver is not wrong, so the leaf goes on to the move. From e4a895a5a354687f707145fb05f09d1377bfb515 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 15:10:07 +0900 Subject: [PATCH 04/38] test(adapter-opencode): run the stop-script guard on an image it builds Co-Authored-By: Claude Sonnet 5.5 --- .../tests/it/guard_container_e2e.rs | 6 +- .../guard_container_e2e/opencode_stop_e2e.rs | 213 ++++++++++++++++++ .../guard_container_e2e/version_probe_e2e.rs | 68 ++++-- .../tests/it/guard_opencode_driver.rs | 142 ------------ 4 files changed, 263 insertions(+), 166 deletions(-) create mode 100644 crates/candler-core/tests/it/guard_container_e2e/opencode_stop_e2e.rs diff --git a/crates/candler-core/tests/it/guard_container_e2e.rs b/crates/candler-core/tests/it/guard_container_e2e.rs index 054d4851..d3a1ada3 100644 --- a/crates/candler-core/tests/it/guard_container_e2e.rs +++ b/crates/candler-core/tests/it/guard_container_e2e.rs @@ -1,7 +1,7 @@ //! The real-Docker guards of the container runner, ignored by default and run in the //! `container-e2e` nextest group (`--run-ignored only`). //! -//! `container_run_e2e`, `container_stop_e2e`, `env_image_e2e`, `controls_e2e` and `version_probe_e2e` hold their guards. `gateway_e2e` +//! `container_run_e2e`, `container_stop_e2e`, `env_image_e2e`, `controls_e2e`, `version_probe_e2e` and `opencode_stop_e2e` hold their guards. `gateway_e2e` //! and `supervision_gates_e2e` each hold one ignored placeholder that panics, so the container //! gate cannot pass before they hold their own guards. #![cfg(unix)] @@ -24,6 +24,8 @@ mod egress_proxy_e2e; mod env_image_e2e; #[path = "guard_container_e2e/gateway_e2e.rs"] mod gateway_e2e; +#[path = "guard_container_e2e/opencode_stop_e2e.rs"] +mod opencode_stop_e2e; #[path = "guard_container_e2e/plugin_env_e2e.rs"] mod plugin_env_e2e; #[path = "guard_container_e2e/preflight_e2e.rs"] @@ -32,4 +34,4 @@ mod preflight_e2e; mod supervision_gates_e2e; #[cfg(test)] #[path = "guard_container_e2e/version_probe_e2e.rs"] -mod version_probe_e2e; +pub(crate) mod version_probe_e2e; diff --git a/crates/candler-core/tests/it/guard_container_e2e/opencode_stop_e2e.rs b/crates/candler-core/tests/it/guard_container_e2e/opencode_stop_e2e.rs new file mode 100644 index 00000000..975353ec --- /dev/null +++ b/crates/candler-core/tests/it/guard_container_e2e/opencode_stop_e2e.rs @@ -0,0 +1,213 @@ +//! The real-Docker guard of the `OpenCode` stop script: the real `opencode` binary in the base +//! image is interrupted by the driver's stop script, and the export collected afterwards says so. +//! +//! The test builds the base image under the tag the version-probe guard uses and removes that image +//! by exact id when the build created it; it names its one container and docker removes it on exit. +#![cfg(test)] + +use std::error::Error; +use std::path::Path; +use std::process::{Command, Stdio}; +use std::str::FromStr as _; + +use candler_harness::driver::HarnessDriver; +use candler_harness::reader::FrameIn; +use candler_harness::spec::{ + Action, Cell, CollectSpec, Observed, ObservedEnd, ProcessEnd, ProcessExit, Workspace, +}; +use candler_harness_opencode::driver::OpenCodeDriver; +use candler_schemas::primitives::FieldPath; +use candler_schemas::process::ExitStatus; +use candler_schemas::raw::{FrameData, RawFrame, RawRef, StreamName}; +use candler_schemas::trace::{EndedBy, SessionId}; +use candler_schemas::values::{JsonValue, ResolvedValue}; +use serde_json::{Value, json}; + +use super::version_probe_e2e::build_base_image; + +// TRAIT_OBJECT: a test returns any error its steps raise; the error is only printed +type Res = Result>; + +/// The cell values of a run: the model, the permission mode and the prompt. +fn values() -> Res> { + [ + ("model.id", json!("claude-x")), + ("model.endpoint", json!("https://api.example.test")), + ("permission_mode", json!("bypassPermissions")), + ("prompt.template", json!("Do {thing}")), + ("prompt.values", json!({"thing": "it"})), + ] + .into_iter() + .map(|(path, value)| { + Ok(ResolvedValue::recorded( + FieldPath::from_str(path)?, + JsonValue::new(value)?, + )) + }) + .collect() +} + +/// Guards: I22 — the stop interrupts a real run: the script finds the `serve` child by its whole +/// argument vector (a decoy process whose arguments hold the same words is not it), reads its port +/// and password, interrupts through the API, the run ends with exit 1 and an `aborted` error, and +/// the export collected afterwards says `interrupted`. The image is built by the guard, offline +/// from the layer cache or online, and needs no environment variable. +/// Oracle: the real `opencode` v2.2.7 binary and its export, read by the driver's readers; the +/// expectations are the recorded `interrupt_api` facts (exit 1, `aborted`, outcome `interrupted`). +/// Bite: a stop script that exits 0 without signalling the agent leaves the run alive, so the +/// harness's wait for the run ends with `subprocess.TimeoutExpired ... timed out after 30 seconds` +/// and the container exits non-zero. +#[test] +#[ignore = "needs Docker; run with --run-ignored only"] +fn opencode_real_binary_is_interrupted_by_the_stop_script() -> Res<()> { + let driver = OpenCodeDriver::new(); + let built = build_base_image( + &driver, + "base-opencode", + "candler-test-version-probe:opencode", + ); + check(&driver, &run_in_container(&driver, &built.id)?) +} + +/// Runs the harness script in a container of the image `image` and returns the JSON line it prints. +fn run_in_container(driver: &OpenCodeDriver, image: &str) -> Res { + let values = values()?; + let cell = Cell::new(&values); + let workspace = Workspace::new(Path::new(".")); + let plan = driver.plan(&cell, &workspace)?; + let run = plan.command; + let prepared = plan.prepared; + let config = String::from_utf8(prepared.files.first().ok_or("no config")?.contents.clone())?; + let Some(Action::Exec(stop)) = driver.stop().pre_stop else { + return Err("no pre-stop".into()); + }; + let observed_id: SessionId = "ses_placeholder".parse()?; + let collect = driver + .collect(&workspace, &Observed::new(vec![observed_id])) + .iter() + .find_map(|spec| { + if let CollectSpec::Exec { spec, .. } = spec { + Some(spec.argv().to_vec()) + } else { + None + } + }) + .ok_or("no collect")?; + // The harness inside the container: the run in the background, a decoy, the stop, the export. + let harness = r#" +import json, os, subprocess, sys, time +env = os.environ +home = env["HOME"] +for name, sub in [("XDG_DATA_HOME", ".xdg/data"), ("XDG_CONFIG_HOME", ".xdg/config"), + ("XDG_CACHE_HOME", ".xdg/cache"), ("XDG_STATE_HOME", ".xdg/state")]: + os.makedirs(home + "/" + sub, exist_ok=True) + env[name] = home + "/" + sub +env["OPENCODE_DB"] = home + "/.xdg/data/oc.db" +os.makedirs(home + "/.xdg/config/opencode", exist_ok=True) +open(home + "/.xdg/config/opencode/opencode.json", "w").write(env["CFG"]) +env["CANDLER_GATEWAY_URL"] = "http://dead.invalid" +env["CANDLER_GATEWAY_TOKEN"] = "placeholder" +os.chdir("/tmp") +out = open("/tmp/out.jsonl", "w") +run = subprocess.Popen(json.loads(env["RUN"]), stdout=out) +time.sleep(6) +sid = json.loads(open("/tmp/out.jsonl").readline())["sessionID"] +decoy = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(300)", "serve", "--stdio", "--port", "0"]) +fill = lambda argv: [a.replace("{session_id}", sid) for a in argv] +stop_rc = subprocess.run(fill(json.loads(env["STOP"]))).returncode +run_rc = run.wait(timeout=30) +decoy.kill() +export = subprocess.run(fill(json.loads(env["COLLECT"]))[:-1] + [sid], capture_output=True, text=True) +print(json.dumps({"stop_rc": stop_rc, "run_rc": run_rc, "stdout": open("/tmp/out.jsonl").read(), + "export": export.stdout, "export_rc": export.returncode})) +"#; + let name = format!("candler-opencode-driver-test-{}", std::process::id()); + let output = Command::new("docker") + .args([ + "run", + "--rm", + "--name", + &name, + "--network", + "none", + "--read-only", + ]) + .args(["--cap-drop", "ALL", "--security-opt", "no-new-privileges"]) + .args([ + "--pids-limit", + "512", + "--memory", + "4g", + "--user", + "10001:10001", + ]) + .args(["--tmpfs", "/tmp:rw,noexec,nosuid"]) + .args(["--tmpfs", "/home/agent:rw,uid=10001,gid=10001,mode=700"]) + .args(["-e", &format!("CFG={config}")]) + .args(["-e", &format!("RUN={}", serde_json::to_string(run.argv())?)]) + .args([ + "-e", + &format!("STOP={}", serde_json::to_string(stop.argv())?), + ]) + .args([ + "-e", + &format!("COLLECT={}", serde_json::to_string(&collect)?), + ]) + .args(["--entrypoint", "python3", image, "-I", "-c", harness]) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output()?; + assert!( + output.status.success(), + "{}", + String::from_utf8_lossy(&output.stderr) + ); + // The stop script prints the API's answer first; the harness's own line is the last. + let printed = String::from_utf8(output.stdout)?; + Ok(serde_json::from_str( + printed.lines().last().ok_or("no output")?, + )?) +} + +/// Asserts what the harness script printed: the stop, the run's exit, the export, the live stream. +fn check(driver: &OpenCodeDriver, result: &Value) -> Res<()> { + assert_eq!( + result["stop_rc"], 0, + "the stop script found the server child" + ); + assert_eq!(result["run_rc"], 1, "an interrupt ends the run with exit 1"); + assert_eq!(result["export_rc"], 0); + let export = result["export"].as_str().ok_or("no export")?; + let document: Value = serde_json::from_str(export)?; + assert_eq!(document["info"]["outcome"], "interrupted"); + let stdout = result["stdout"].as_str().ok_or("no stdout")?; + let mut live = driver.live_reader().ok_or("no live reader")?; + let stream: StreamName = "stdout".parse()?; + for (index, line) in stdout.split_inclusive('\n').enumerate() { + let frame = RawFrame::new(None, FrameData::from_bytes(line.as_bytes())); + live.feed(FrameIn::new( + RawRef::new(stream.clone(), u64::try_from(index)?), + None, + &frame, + ))?; // BORROW: .clone() copies the name + } + let observed = live.observed(); + assert_eq!(observed.end, Some(ObservedEnd::Aborted)); + let export_stream: StreamName = "export".parse()?; + let mut reader = driver + .offline_reader(&export_stream, &[]) + .ok_or("no export reader")?; + let frame = RawFrame::new(None, FrameData::from_bytes(export.as_bytes())); + reader.feed(FrameIn::new(RawRef::new(export_stream, 0), None, &frame))?; + let sessions = reader.finish()?; + assert_eq!( + sessions.first().map(|s| s.id().clone()), + observed.session_ids.first().cloned() + ); // BORROW: .clone() copies the id + let exit = ProcessExit::new(ExitStatus::Code { code: 1 }, ProcessEnd::Exited, Vec::new()); + assert_eq!( + driver.classify_end(&exit, &sessions, &observed), + EndedBy::Unknown + ); + Ok(()) +} diff --git a/crates/candler-core/tests/it/guard_container_e2e/version_probe_e2e.rs b/crates/candler-core/tests/it/guard_container_e2e/version_probe_e2e.rs index 56486096..6d47904e 100644 --- a/crates/candler-core/tests/it/guard_container_e2e/version_probe_e2e.rs +++ b/crates/candler-core/tests/it/guard_container_e2e/version_probe_e2e.rs @@ -38,7 +38,7 @@ struct Row { } /// The stdout of `docker `, trimmed; empty when docker fails. -fn docker(args: &[&str]) -> String { +pub(crate) fn docker(args: &[&str]) -> String { let out = Command::new("docker") .args(args) .output() @@ -46,6 +46,49 @@ fn docker(args: &[&str]) -> String { String::from_utf8_lossy(&out.stdout).trim().to_owned() } +/// A base image the guard built under its own tag. +pub(crate) struct BuiltImage { + /// The image id the build printed. + pub(crate) id: String, + /// Whether the tag named an image before the build, so that image is not the guard's to remove. + existed: bool, +} + +impl Drop for BuiltImage { + /// Removes the image by its id when the tag did not exist before the build, so a failed + /// assertion leaves no image behind either. + fn drop(&mut self) { + if !self.existed { + docker(&["rmi", &self.id]); + } + } +} + +/// Builds the base image `dir` under `assets/docker` as `tag`, with the build arguments `driver` +/// pins, and panics unless the build printed an image id. +pub(crate) fn build_base_image(driver: &dyn HarnessDriver, dir: &str, tag: &str) -> BuiltImage { + let context = Path::new(env!("CARGO_MANIFEST_DIR")) + .join("../../assets/docker") + .join(dir); + let context = context.to_str().expect("a UTF-8 path"); + let existed = !docker(&["image", "inspect", "--format", "{{.Id}}", tag]).is_empty(); + let build_args: Vec = driver + .base_image() + .build_args + .iter() + .flat_map(|(name, value)| ["--build-arg".to_owned(), format!("{name}={value}")]) + .collect(); + let mut build = vec!["build", "--quiet", "-t", tag]; + build.extend(build_args.iter().map(String::as_str)); + build.push(context); + let id = docker(&build); + assert!( + id.starts_with("sha256:"), + "{dir}: the build printed an id: {id}" + ); + BuiltImage { id, existed } +} + /// Guards: R01 §Harness drivers — preflight reads the version of each real base image: the probe /// runs in the read-only control container with the home and the state a run gives the harness, /// so `opencode --version` creates its directories and prints, Claude Code's version is the one @@ -57,7 +100,6 @@ fn docker(args: &[&str]) -> String { #[tokio::test(flavor = "multi_thread")] #[ignore = "needs Docker"] async fn opencode_probe_reads_each_real_base_image_version() { - let assets = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../assets/docker"); let rows = vec![ Row { dir: "base-opencode", @@ -83,23 +125,8 @@ async fn opencode_probe_reads_each_real_base_image_version() { want, } in rows { - let context = assets.join(dir); - let context = context.to_str().expect("a UTF-8 path"); - let existing = docker(&["image", "inspect", "--format", "{{.Id}}", tag]); - let build_args: Vec = driver - .base_image() - .build_args - .iter() - .flat_map(|(name, value)| ["--build-arg".to_owned(), format!("{name}={value}")]) - .collect(); - let mut build = vec!["build", "--quiet", "-t", tag]; - build.extend(build_args.iter().map(String::as_str)); - build.push(context); - let id = docker(&build); - assert!( - id.starts_with("sha256:"), - "{dir}: the build printed an id: {id}" - ); + let built = build_base_image(driver.as_ref(), dir, tag); + let id = built.id.clone(); // BORROW: .clone() keeps the id the service image holds let writable_root = docker(&["run", "--rm", "--entrypoint", binary, &id, "--version"]); let label = docker(&[ "image", @@ -133,9 +160,6 @@ async fn opencode_probe_reads_each_real_base_image_version() { }; let read = service.harness_version(&image).await; - if existing.is_empty() { - docker(&["rmi", &id]); - } assert!( writable_root.contains(want), "{dir}: the oracle read {writable_root}" diff --git a/crates/candler-harness-opencode/tests/it/guard_opencode_driver.rs b/crates/candler-harness-opencode/tests/it/guard_opencode_driver.rs index db1acf65..95351ee0 100644 --- a/crates/candler-harness-opencode/tests/it/guard_opencode_driver.rs +++ b/crates/candler-harness-opencode/tests/it/guard_opencode_driver.rs @@ -1082,148 +1082,6 @@ fn opencode_skills_land_in_the_project_skill_directory() -> Res<()> { Ok(()) } -/// Guards: I22 — the stop interrupts a real run: the script finds the `serve` child by its whole -/// argument vector (a decoy process whose arguments hold the same words is not it), reads its port -/// and password, interrupts through the API, the run ends with exit 1 and an `aborted` error, and -/// the export collected afterwards says `interrupted`. Run once against the base image, offline: -/// `CANDLER_OPENCODE_IMAGE= cargo nextest run -p candler-harness-opencode --run-ignored -/// only -E 'test(opencode_real_binary_)'`. -/// Oracle: the real `opencode` v2.2.7 binary and its export, read by the driver's readers; the -/// expectations are the recorded `interrupt_api` facts (exit 1, `aborted`, outcome `interrupted`). -#[test] -#[ignore = "needs Docker and CANDLER_OPENCODE_IMAGE, the id of the base-opencode image"] -fn opencode_real_binary_is_interrupted_by_the_stop_script() -> Res<()> { - use std::process::Stdio; - let image = std::env::var("CANDLER_OPENCODE_IMAGE")?; - let driver = OpenCodeDriver::new(); - let values = values(&[])?; - let cell = Cell::new(&values); - let workspace = Workspace::new(Path::new(".")); - let plan = driver.plan(&cell, &workspace)?; - let run = plan.command; - let prepared = plan.prepared; - let config = String::from_utf8(prepared.files.first().ok_or("no config")?.contents.clone())?; - let Some(Action::Exec(stop)) = driver.stop().pre_stop else { - return Err("no pre-stop".into()); - }; - let observed_id: SessionId = "ses_placeholder".parse()?; - let collect = match driver - .collect(&workspace, &Observed::new(vec![observed_id])) - .first() - { - Some(CollectSpec::Exec { spec, .. }) => spec.argv().to_vec(), - _ => return Err("no collect".into()), - }; - // The harness inside the container: the run in the background, a decoy, the stop, the export. - let harness = r#" -import json, os, subprocess, sys, time -env = os.environ -home = env["HOME"] -for name, sub in [("XDG_DATA_HOME", ".xdg/data"), ("XDG_CONFIG_HOME", ".xdg/config"), - ("XDG_CACHE_HOME", ".xdg/cache"), ("XDG_STATE_HOME", ".xdg/state")]: - os.makedirs(home + "/" + sub, exist_ok=True) - env[name] = home + "/" + sub -env["OPENCODE_DB"] = home + "/.xdg/data/oc.db" -os.makedirs(home + "/.xdg/config/opencode", exist_ok=True) -open(home + "/.xdg/config/opencode/opencode.json", "w").write(env["CFG"]) -env["CANDLER_GATEWAY_URL"] = "http://dead.invalid" -env["CANDLER_GATEWAY_TOKEN"] = "placeholder" -os.chdir("/tmp") -out = open("/tmp/out.jsonl", "w") -run = subprocess.Popen(json.loads(env["RUN"]), stdout=out) -time.sleep(6) -sid = json.loads(open("/tmp/out.jsonl").readline())["sessionID"] -decoy = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(300)", "serve", "--stdio", "--port", "0"]) -fill = lambda argv: [a.replace("{session_id}", sid) for a in argv] -stop_rc = subprocess.run(fill(json.loads(env["STOP"]))).returncode -run_rc = run.wait(timeout=30) -decoy.kill() -export = subprocess.run(fill(json.loads(env["COLLECT"]))[:-1] + [sid], capture_output=True, text=True) -print(json.dumps({"stop_rc": stop_rc, "run_rc": run_rc, "stdout": open("/tmp/out.jsonl").read(), - "export": export.stdout, "export_rc": export.returncode})) -"#; - let name = format!("candler-opencode-driver-test-{}", std::process::id()); - let output = Command::new("docker") - .args([ - "run", - "--rm", - "--name", - &name, - "--network", - "none", - "--read-only", - ]) - .args(["--cap-drop", "ALL", "--security-opt", "no-new-privileges"]) - .args([ - "--pids-limit", - "512", - "--memory", - "4g", - "--user", - "10001:10001", - ]) - .args(["--tmpfs", "/tmp:rw,noexec,nosuid"]) - .args(["--tmpfs", "/home/agent:rw,uid=10001,gid=10001,mode=700"]) - .args(["-e", &format!("CFG={config}")]) - .args(["-e", &format!("RUN={}", serde_json::to_string(run.argv())?)]) - .args([ - "-e", - &format!("STOP={}", serde_json::to_string(stop.argv())?), - ]) - .args([ - "-e", - &format!("COLLECT={}", serde_json::to_string(&collect)?), - ]) - .args(["--entrypoint", "python3", &image, "-I", "-c", harness]) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .output()?; - assert!( - output.status.success(), - "{}", - String::from_utf8_lossy(&output.stderr) - ); - // The stop script prints the API's answer first; the harness's own line is the last. - let printed = String::from_utf8(output.stdout)?; - let result: Value = serde_json::from_str(printed.lines().last().ok_or("no output")?)?; - assert_eq!( - result["stop_rc"], 0, - "the stop script found the server child" - ); - assert_eq!(result["run_rc"], 1, "an interrupt ends the run with exit 1"); - assert_eq!(result["export_rc"], 0); - let export = result["export"].as_str().ok_or("no export")?; - let document: Value = serde_json::from_str(export)?; - assert_eq!(document["info"]["outcome"], "interrupted"); - let stdout = result["stdout"].as_str().ok_or("no stdout")?; - let mut live = driver.live_reader().ok_or("no live reader")?; - let stream: StreamName = "stdout".parse()?; - for (index, line) in stdout.split_inclusive('\n').enumerate() { - let frame = RawFrame::new(None, FrameData::from_bytes(line.as_bytes())); - live.feed(FrameIn::new( - RawRef::new(stream.clone(), u64::try_from(index)?), - None, - &frame, - ))?; // BORROW: .clone() copies the name - } - let observed = live.observed(); - assert_eq!( - observed.end, - Some(candler_harness::spec::ObservedEnd::Aborted) - ); - let (_, sessions) = read_export(export.as_bytes())?; - assert_eq!( - sessions.first().map(|s| s.id().clone()), - observed.session_ids.first().cloned() - ); // BORROW: .clone() copies the id - let exit = ProcessExit::new(ExitStatus::Code { code: 1 }, ProcessEnd::Exited, Vec::new()); - assert_eq!( - driver.classify_end(&exit, &sessions, &observed), - EndedBy::Unknown - ); - Ok(()) -} - /// The sessions the live reader finishes with for a recorded stream, and the export reader's for a /// recorded export, with the live reader's last word. fn live_and_export( From f78e2723402a405e90bbe4ebde76f21f589f26b7 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 15:10:15 +0900 Subject: [PATCH 05/38] ci(repo): expect the OpenCode stop and harness-check guards Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/container-e2e.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/container-e2e.yml b/.github/workflows/container-e2e.yml index 06423176..babc2f9d 100644 --- a/.github/workflows/container-e2e.yml +++ b/.github/workflows/container-e2e.yml @@ -79,6 +79,8 @@ jobs: graded_run_sees_trace \ control_each_kind_runs_on_the_real_base \ opencode_probe_reads_each_real_base_image_version \ + opencode_real_binary_is_interrupted_by_the_stop_script \ + guard_harness_check_refuses \ plugin_environment_serves_live_mcp_tools \ x1_env_image_prunes_the_named_file_and_reads_the_pin \ x1_env_image_without_requirements_has_only_seed_packages; do From c6a5a2332e6a7f5f1c5ed397290d068516c88ca8 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 15:20:42 +0900 Subject: [PATCH 06/38] reports(adapter-opencode): close the OpenCode stop-script guard Co-Authored-By: Claude Sonnet 5.5 --- .../m6_gaps/leaves/opencode_stop_guard_v0.md | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/__reports__/m6_gaps/leaves/opencode_stop_guard_v0.md b/__reports__/m6_gaps/leaves/opencode_stop_guard_v0.md index fdab2c67..a960cba9 100644 --- a/__reports__/m6_gaps/leaves/opencode_stop_guard_v0.md +++ b/__reports__/m6_gaps/leaves/opencode_stop_guard_v0.md @@ -30,3 +30,74 @@ Change applied (and discarded after the run, step 2 carries it): `first()` plus Answer: the guard PASSES (7.5 s, `1 passed`) on the real `opencode` 2.2.7 image. Only the spec selection drifted; the decoy, the export argv and the stop script still agree with the driver. The driver is not wrong, so the leaf goes on to the move. + +## 3. The move + +The guard now lives in `crates/candler-core/tests/it/guard_container_e2e/opencode_stop_e2e.rs` +under the same name, ignored as its siblings are, and is declared in `guard_container_e2e.rs`. It +selects the export spec by variant. The image builder of `version_probe_e2e.rs` was lifted into +`build_base_image` / `BuiltImage` (pub(crate)) and both guards call it; the guard builds under the +tag `candler-test-version-probe:opencode`, so Docker's layer cache serves CI's second build of +`base-opencode`. `BuiltImage` removes the image by id in `Drop` only when the tag did not exist +before the build. Drop, not an explicit call, because the first bite run (below) failed an +assertion before the explicit removal and left an image behind; that image +(`sha256:1b61db53c906...`) was removed by id and the cleanup moved into `Drop`. The nextest +group `container-e2e` runs the guards one at a time, so the two guards never share the tag at once. +`CANDLER_OPENCODE_IMAGE` is gone (`git grep` finds it only in reports and the roadmap), and the +guard and its helper were removed from `guard_opencode_driver.rs`. + +CI's expected list names `opencode_real_binary_is_interrupted_by_the_stop_script` and +`guard_harness_check_refuses` (the latter lives in +`crates/candler/tests/it/guard_cli_e2e/agent_config_e2e.rs`; the job's regex covers `guard_cli_e2e`). + +## 4. The bite + +Bite: `crates/candler-harness-opencode/src/stop.py` made to start with `import sys; sys.exit(0)` +on a scratch branch (discarded; the `src` diff against `fix/m6-gaps` is empty). The guard goes red +after 37 s, verbatim: + +``` +Traceback (most recent call last): + File "", line 22, in + File "/usr/local/lib/python3.12/subprocess.py", line 1264, in wait + return self._wait(timeout=timeout) +subprocess.TimeoutExpired: Command '['opencode', 'run', '--standalone', '--format', 'json', '--auto', '-m', 'candler/claude-x', '--', 'Do it']' timed out after 30 seconds +``` +(panicked at `opencode_stop_e2e.rs`, the assertion on the container's exit status). Run twice; after +the `Drop` fix the second bite run left no new image. + +## 5. Wall times + +A true cold time needs a prune of Docker's layer cache, which is forbidden here, so every figure +below is with the cache as it stood (all `base-opencode` layers cached from earlier builds on this +machine). + +| Run | Guard time | +|---|---| +| first run on the tip (image tag absent, layers cached) | 8.3 s (49 s wall including the compile) | +| second and later runs | 7.1 to 7.4 s | + +Estimate for CI: `version_probe_e2e` already builds `base-opencode` in the same job; this guard's +build is then a cache hit (about 2.5 s measured) plus its run (about 5 s of container time), so it +adds roughly 10 s. If the guard ran first on an empty runner it would pay the image download and +install instead, which the probe guard pays today. + +## 6. Gates + +`cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, +`RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps`: clean. `cargo nextest run --workspace`: +772 passed, 35 skipped (6 slow, among them `kt_simpson_blocked_holds`; no timing failure, so no +rerun was needed). The container selection `test(/opencode_real_binary_is_interrupted_by_the_stop_script$/) +--run-ignored only`: passed. `git diff fix/m6-gaps -- crates/candler-harness-opencode/src` is empty; +`git grep -n confirm_ -- crates python` is empty. + +## 7. Deviations and observations + +- The builder lifting touched `version_probe_e2e.rs` (allowed: shared helper) and made its module + `pub(crate)`. +- The step-2 commit was amended once (via a rebase) to carry the `Drop` fix; one commit per step holds. +- Observation: `guard_harness_check_refuses` is in `crates/candler`, not `candler-core`; the + expected-list regex is the one that covers both. Other guards named in the list were not audited. +- Observation: an image built by a guard that panics before its cleanup leaks; any sibling guard + that removes an image by an explicit call after assertions (`version_probe_e2e` did) shares that + risk; it is now covered through `Drop`. From c77c1e01005fb48cf62f01a6a198a4b4197788f9 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 15:25:19 +0900 Subject: [PATCH 07/38] rdm(api): name the server refusal code that is really raised The server-exit test that reaches check_servers raises jobs.server_exited_at_start, not jobs.server_check_failed; no test reaches the latter, which goes through the same ServerCheckError path and the same record builder, so a row for it would catch no bug the server-exit row misses. The campaign gate and the leaf's gate now name the raised code, and the leaf owns guard_server_check.rs (approved at its first joint) and the refusal: None migrations its fix(jobs)! forces. Co-Authored-By: Claude Opus 5.5 --- __roadmap__/m6_gaps/README.md | 4 ++-- __roadmap__/m6_gaps/job_refusal_record.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/__roadmap__/m6_gaps/README.md b/__roadmap__/m6_gaps/README.md index 5a9be07e..2c219fb4 100644 --- a/__roadmap__/m6_gaps/README.md +++ b/__roadmap__/m6_gaps/README.md @@ -8,7 +8,7 @@ Closing M6.5 and M6d left three gaps on `main` (v0.19.0, `ad74ff94`). Each is ju - None of the three adds a domain name to the core. They are fixed here, before M7 ([`m7_mcp_server.md`](../candler-v1/contracts/parity/alignment/surfaces/isolation/m5b/stats/surface/integrity/mcp/m7_mcp_server.md), blocked by A14), because M7's `jobs` and `show` ops read what O11 decides. - **Order and ownership.** Depth gives the order. Level 1 holds the three build leaves in parallel, and they share no file: - `opencode_stop_guard.md`: `crates/candler-harness-opencode/tests/it/guard_opencode_driver.rs` (the guard leaves it), `crates/candler-core/tests/it/guard_container_e2e.rs` and `guard_container_e2e/opencode_stop_e2e.rs`, and `.github/workflows/container-e2e.yml`, which only this leaf edits (it also adds `guard_harness_check_refuses`, which passes on the base); - - `job_refusal_record.md`: `crates/candler-core/src/jobs/**`, `crates/candler-core/tests/it/guard_config_check.rs`, `crates/candler/tests/it/guard_cli_e2e/agent_config_e2e.rs`, and `__design__/architecture.md` (the sentence near line 400 on `refusal.json`); + - `job_refusal_record.md`: `crates/candler-core/src/jobs/**`, `crates/candler-core/tests/it/guard_config_check.rs`, `crates/candler-core/tests/it/guard_server_check.rs` (added at joint 1), `crates/candler/tests/it/guard_cli_e2e/agent_config_e2e.rs`, the `refusal: None` migrations its `fix(jobs)!` forces in test support and in the CLI, and `__design__/architecture.md` (the sentence near line 400 on `refusal.json`); - `needs_batches.md`: `crates/candler-core/src/evaluation/**`, `crates/candler-core/tests/it/guard_engine.rs` and `guard_run_context.rs`, the engine fixtures under `crates/candler-core/tests/fixtures/engine/`, and `docs/contract/evaluator-protocol.md`. - `review/` (level 2) holds one adversarial review each of `job_refusal_record` and `needs_batches`, read on their leaf branches before they merge. `opencode_stop_guard` is test and CI only, so it has no review leaf and merges at level 1 once the lead has read its Docker logs. `review/close/` (level 3) holds the close-out, which alone writes under `__reports__/m6_gaps/` outside `leaves/` and `reviews/`, and updates the three source reports. - **Branches and builds.** The integration branch is `fix/m6-gaps`, cut from `origin/main` at `ad74ff94`. The leaf branches are `test/opencode-stop-guard`, `fix/job-refusal-record` and `fix/needs-batches`, each in its own worktree made by `python3 scripts/worktree.py add ` from the `fix/m6-gaps` tip and removed at its merge. Every build sets `CARGO_TARGET_DIR=/Users/hacker/Documents/tmp/claude-worktrees/Candler/m6-gaps-target/` and `RUSTC_WRAPPER=sccache` in its own environment, one dir per leaf, because a dir shared between worktrees reuses another checkout's test binaries. Never export `TMPDIR` around a sccache cargo command. At most three builds run at once, each leaf's dir is removed at its merge, and `df -h /System/Volumes/Data` is checked before each level. Docker is used by `opencode_stop_guard`, by `job_refusal_record`'s G6 run and by the close-out; each removes what it built by id, with scratch roots under `$HOME`. Nothing is pruned and Docker is never stopped. @@ -39,7 +39,7 @@ Every job kind that ends on a refusal leaves that refusal's code in `jobs//r - ⬜ `git grep -n confirm_ -- crates python` prints nothing on the `fix/m6-gaps` tip - ⬜ `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo nextest run --workspace` and `RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps` pass on the tip - ⬜ `container-e2e` on the integration pull request lists `opencode_real_binary_is_interrupted_by_the_stop_script` and `guard_harness_check_refuses` as PASS -- ⬜ A run job refused at job start leaves `jobs//refusal.json`, a `refusal/1` record that names its code, side and pointer, for each of `experiment.harness_rejected_input`, `jobs.config_check_failed` and `jobs.server_check_failed` +- ⬜ A run job refused at job start leaves `jobs//refusal.json`, a `refusal/1` record that names its code, side and pointer, for each of `experiment.harness_rejected_input`, `jobs.config_check_failed` and `jobs.server_exited_at_start` (the code a server that exits at start raises; `jobs.server_check_failed` goes through the same `ServerCheckError` path and needs no row of its own) - ⬜ For a plug-in with an artifacts- or manifest-only kind A and a trace kind B, on a run with no trace A is graded and B carries `evaluation.run_part_missing`; on a run with a trace, A's context digest is the same for suite {A} and suite {A, B} - ⬜ Each review report answers both of its lenses with evidence, and each finding is fixed on the leaf branch or recorded as an observation with its reason before that leaf merges - ⬜ The pull request `merge(api): close three M6 gaps before M7` is opened only after the maintainer's go; after it merges, the CI release cuts 0.20.0 diff --git a/__roadmap__/m6_gaps/job_refusal_record.md b/__roadmap__/m6_gaps/job_refusal_record.md index 2c8b48db..fd7be56f 100644 --- a/__roadmap__/m6_gaps/job_refusal_record.md +++ b/__roadmap__/m6_gaps/job_refusal_record.md @@ -7,7 +7,7 @@ - [ ] `[cmd]` `docker info` succeeds (G6 runs on Docker) **Success Gates**: - ⬜ G6 `guard_harness_check_refuses` reads `jobs//refusal.json` and asserts its code `experiment.harness_rejected_input`, its side and its pointer; on the base it is red because the file is absent, and the leaf report records the message; on the tip it passes with `--run-ignored only` -- ⬜ The job-start refusal guard in `guard_config_check.rs` is one parameterized guard with a row each for `experiment.harness_rejected_input` (its message quotes `REJECT: unknown key hooks.Foo`), `jobs.config_check_failed` and `jobs.server_check_failed`, read from the record the job body returns; under the bite "`refused` is handed a string error" every row goes red +- ⬜ The job-start refusal guards read the record the job body returns, one test per refusal class: in `guard_config_check.rs`, a parameterized guard over `experiment.harness_rejected_input` (its message quotes `REJECT: unknown key hooks.Foo`) and `jobs.config_check_failed`; in `guard_server_check.rs`, the server-exit test, which asserts `jobs.server_exited_at_start`; under the bite "`refused` is handed a string error" every row goes red - ⬜ `git grep -nE 'CANDLER_CONFIG_CHECK_CHILD|fn refusal_of' -- crates` prints nothing: the child-process helper that read stderr is gone - ⬜ `crates/candler-core/src/jobs/runtime/refusal.rs` holds the one record builder (`record_of`), `write_refusal`, `REFUSAL_FILE` and `end_job`; `session::run` and evaluate's `run` both end through `end_job`; `evaluate.rs` defines no record builder of its own - ⬜ `guard_cli_evaluate::r2_a_refusal_raised_in_the_job_keeps_its_code_through_the_verb` passes unchanged, so the order "record, then `job.ended`" holds through the shared path @@ -45,7 +45,7 @@ Move the record builder out of `evaluate.rs` into `crates/candler-core/src/jobs/ **Implementation Logic**: `JobOutcome` gains `refusal: Option`. `refused` takes `&(dyn Error + 'static)`, builds the record with `record_of` and keeps its stderr line. Every refusal path of `run_job` passes its typed error. `session::run` ends through `end_job`, handing it the outcome's record. Fix every constructor of `JobOutcome` in the workspace with `refusal: None`. -Rewrite the job-start refusal tests of `guard_config_check.rs` as one parameterized guard over the three classes named in the success gates, each row reading `JobOutcome.refusal`; this retires `refusal_of` and its child process. The `jobs.server_check_failed` row joins an existing test that reaches `check_servers` if one exists; only if none does is it written new. G6 sees only the first class, so this guard exists for a wrong mapping of the other two (for example every refusal falling back to `candler.internal`). +Rewrite the job-start refusal tests of `guard_config_check.rs` as one parameterized guard over the three classes named in the success gates, each row reading `JobOutcome.refusal`; this retires `refusal_of` and its child process. The server row is the existing `guard_server_check.rs` test that reaches `check_servers`, reading `JobOutcome.refusal`; its child process retires too. It asserts `jobs.server_exited_at_start`, the code that path raises. G6 sees only the first class, so this guard exists for a wrong mapping of the other two (for example every refusal falling back to `candler.internal`). The commit body names the rewritten guard and gives the `BREAKING CHANGE:` footer with the migration. **Deliverables**: `crates/candler-core/src/jobs/model.rs` (`JobOutcome.refusal`); `crates/candler-core/src/jobs/orchestrate/mod.rs` (`refused`, `run_job`); `crates/candler-core/src/jobs/runtime/session.rs` (`run`); `crates/candler-core/tests/it/guard_config_check.rs` (the parameterized guard) From 4d4e0a939daf1dfea8480990e83e65ae67f22428 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 15:27:19 +0900 Subject: [PATCH 08/38] rdm(api): close the OpenCode stop guard leaf Merged as e1a5769f. The whole-suite gates pass on the integration tip after the merge: fmt, clippy, doc, and nextest 772 of 772 (35 skipped). Co-Authored-By: Claude Opus 5.5 --- __roadmap__/m6_gaps/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/__roadmap__/m6_gaps/README.md b/__roadmap__/m6_gaps/README.md index 2c219fb4..f9a75c17 100644 --- a/__roadmap__/m6_gaps/README.md +++ b/__roadmap__/m6_gaps/README.md @@ -54,7 +54,7 @@ Every job kind that ends on a refusal leaves that refusal's code in `jobs//r ## Status ```mermaid graph TD - opencode_stop_guard[OpenCode stop guard]:::inprogress + opencode_stop_guard[OpenCode stop guard]:::done job_refusal_record[Job refusal record]:::inprogress needs_batches[Needs batches]:::inprogress review[Review]:::planned @@ -68,7 +68,7 @@ graph TD ## Nodes | Node | Type | Status | |:-----|:-----|:-------| -| `opencode_stop_guard.md` | 📄 Leaf Task | 🔄 In Progress | +| `opencode_stop_guard.md` | 📄 Leaf Task | ✅ Done | | `job_refusal_record.md` | 📄 Leaf Task | 🔄 In Progress | | `needs_batches.md` | 📄 Leaf Task | 🔄 In Progress | | `review/` | 📁 Directory | ⬜ Planned | From 7e28a1000c97f7f9fe4e87145a305b2eeb6483ef Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 15:32:20 +0900 Subject: [PATCH 09/38] rdm(api): send the job refusal record to its review The leaf is done on fix/job-refusal-record (five commits, whole suite 772 of 772, G6 green), at $2.19 measured from its transcript against a $3 estimate. Its one-pass review starts; the leaf merges after it. Co-Authored-By: Claude Opus 5.5 --- __roadmap__/m6_gaps/README.md | 8 ++++---- __roadmap__/m6_gaps/review/README.md | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/__roadmap__/m6_gaps/README.md b/__roadmap__/m6_gaps/README.md index f9a75c17..01df8a3d 100644 --- a/__roadmap__/m6_gaps/README.md +++ b/__roadmap__/m6_gaps/README.md @@ -55,9 +55,9 @@ Every job kind that ends on a refusal leaves that refusal's code in `jobs//r ```mermaid graph TD opencode_stop_guard[OpenCode stop guard]:::done - job_refusal_record[Job refusal record]:::inprogress + job_refusal_record[Job refusal record]:::done needs_batches[Needs batches]:::inprogress - review[Review]:::planned + review[Review]:::inprogress classDef done fill:#166534,color:#bbf7d0 classDef inprogress fill:#854d0e,color:#fef08a classDef planned fill:#374151,color:#e5e7eb @@ -69,9 +69,9 @@ graph TD | Node | Type | Status | |:-----|:-----|:-------| | `opencode_stop_guard.md` | 📄 Leaf Task | ✅ Done | -| `job_refusal_record.md` | 📄 Leaf Task | 🔄 In Progress | +| `job_refusal_record.md` | 📄 Leaf Task | ✅ Done | | `needs_batches.md` | 📄 Leaf Task | 🔄 In Progress | -| `review/` | 📁 Directory | ⬜ Planned | +| `review/` | 📁 Directory | 🔄 In Progress | ## Amendment Log | ID | Date | Source | Nodes Added | Rationale | diff --git a/__roadmap__/m6_gaps/review/README.md b/__roadmap__/m6_gaps/review/README.md index d76aab3f..a014c74a 100644 --- a/__roadmap__/m6_gaps/review/README.md +++ b/__roadmap__/m6_gaps/review/README.md @@ -23,7 +23,7 @@ Each risky change is judged on validity and on develop, leave and consume before ## Status ```mermaid graph TD - review_job_refusal[Review: job refusal]:::planned + review_job_refusal[Review: job refusal]:::inprogress review_needs_batches[Review: needs batches]:::planned close[Close]:::planned classDef done fill:#166534,color:#bbf7d0 @@ -36,7 +36,7 @@ graph TD ## Nodes | Node | Type | Status | |:-----|:-----|:-------| -| `review_job_refusal.md` | 📄 Leaf Task | ⬜ Planned | +| `review_job_refusal.md` | 📄 Leaf Task | 🔄 In Progress | | `review_needs_batches.md` | 📄 Leaf Task | ⬜ Planned | | `close/` | 📁 Directory | ⬜ Planned | From e5e63253f91f7e1237a3316fc98928c444e18a18 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 15:07:57 +0900 Subject: [PATCH 10/38] test(cli): read a job-start refusal from the job's refusal record guard_harness_check_refuses now reads jobs//refusal.json, the record a consumer of the job's state reads, and asserts its schema, code, side and pointer, and that the harness's own output is quoted, instead of searching supervisor.log. It is red on the base because no run job writes the file. Co-Authored-By: Claude Sonnet 5.5 --- .../it/guard_cli_e2e/agent_config_e2e.rs | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/crates/candler/tests/it/guard_cli_e2e/agent_config_e2e.rs b/crates/candler/tests/it/guard_cli_e2e/agent_config_e2e.rs index ada3d623..87e26807 100644 --- a/crates/candler/tests/it/guard_cli_e2e/agent_config_e2e.rs +++ b/crates/candler/tests/it/guard_cli_e2e/agent_config_e2e.rs @@ -440,15 +440,18 @@ const PAYLOADS: [Payload; 2] = [ /// Guards: README (the harness's own check refuses what it cannot read before a run starts) -- /// a job of the real `candler run` on real images, with an invalid payload (a Claude Code hooks /// entry on an unknown event; an `OpenCode` plugin with no default export) is refused before its -/// first run, the refusal quotes the harness's own output and no run is sealed; the same job with -/// a valid payload is not refused and seals its run (G6). +/// first run, its `jobs//refusal.json` is the `refusal/1` record that names the code +/// `experiment.harness_rejected_input`, the side `experiment` and the pointer `/fixed/hooks`, the +/// record's message quotes the harness's own output, and no run is sealed; the same job with a +/// valid payload is not refused, leaves no `refusal.json` and seals its run (G6). /// -/// Oracle: the harness outputs recorded for both cases (`fixtures/doctor` and `fixtures/check` -/// of the two harness crates); the refusal line is the one the supervisor logs for -/// `experiment.harness_rejected_input` (`Candler installed .. at ..; rejects it: ..`). +/// Oracle: the contract's row for `experiment.harness_rejected_input` (side `experiment`, the +/// setting the file comes from, `/fixed/hooks`) and the harness outputs recorded for both cases +/// (`fixtures/doctor` and `fixtures/check` of the two harness crates), all written by hand. /// -/// Bite: a job that starts its first run whatever the check says (a sealed run, no refusal line), -/// or a check that refuses a payload the harness accepts. +/// Bite: a job that starts its first run whatever the check says (a sealed run, no record), a job +/// that keeps its refusal only in `supervisor.log` (no `refusal.json`), a record that falls back +/// to `candler.internal`, or a check that refuses a payload the harness accepts. #[test] #[ignore = "needs Docker; run with --run-ignored only"] fn guard_harness_check_refuses() { @@ -465,27 +468,34 @@ fn guard_harness_check_refuses() { let ran = run_job(&experiment, &model.endpoint, &model.ca, &mut made, |_| {}); let job = made.jobs.last().cloned().unwrap_or_default(); // BORROW: the job id names its log jobs.push(job.clone()); // BORROW: the leftover check names every job - let supervisor = - fs::read_to_string(ran.store.join("jobs").join(&job).join("supervisor.log")) - .unwrap_or_default(); + let record = fs::read(ran.store.join("jobs").join(&job).join("refusal.json")) + .ok() + .and_then(|bytes| serde_json::from_slice::(&bytes).ok()); + let log = fs::read_to_string(ran.store.join("jobs").join(&job).join("supervisor.log")) + .unwrap_or_default(); let sealed = fs::read_dir(ran.store.join("runs")) .into_iter() .flatten() .flatten() .filter(|entry| entry.path().join("run.done").is_file()) .count(); - let rejects = format!("{} rejects it: ", payload.harness); - let refused = supervisor.contains(&rejects); + let held = |key: &str| record.as_ref().map(|record| shown(&record[key])); + let message = held("message").unwrap_or_default(); if label == "invalid" { - if !refused || !supervisor.contains(payload.quoted) || sealed != 0 { + let fits = held("schema").as_deref() == Some("refusal/1") + && held("code").as_deref() == Some("experiment.harness_rejected_input") + && held("side").as_deref() == Some("experiment") + && held("path").as_deref() == Some("/fixed/hooks") + && message.contains(payload.quoted); + if !fits || sealed != 0 { failures.push(format!( - "{}: invalid payload: refused {refused}, sealed {sealed}\n{supervisor}", + "{}: invalid payload: refusal record {record:?}, sealed {sealed}\n{log}", payload.harness )); } - } else if refused || sealed == 0 { + } else if record.is_some() || sealed == 0 { failures.push(format!( - "{}: valid payload: refused {refused}, sealed {sealed}\n{supervisor}", + "{}: valid payload: refusal record {record:?}, sealed {sealed}\n{log}", payload.harness )); } From 9559a28fdcade79db50ae30c32a4a74aaeadb5bc Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 15:13:29 +0900 Subject: [PATCH 11/38] refactor(jobs): share the refusal record between job kinds The record builder (record_of), write_refusal, REFUSAL_FILE and the new end_job move out of the evaluate job's body into jobs/runtime/refusal.rs. end_job writes the record when there is one and then emits job.ended, so the order "record, then job.ended" has one home. Evaluate's supervisor ends through it. No behaviour changes. REFUSAL_FILE moves from jobs::runtime::evaluate to jobs::runtime::refusal; candler's evaluate command imports it from there. Co-Authored-By: Claude Sonnet 5.5 --- .../candler-core/src/jobs/runtime/evaluate.rs | 53 ++----------- crates/candler-core/src/jobs/runtime/mod.rs | 1 + .../candler-core/src/jobs/runtime/refusal.rs | 74 +++++++++++++++++++ crates/candler/src/commands/evaluate.rs | 3 +- 4 files changed, 83 insertions(+), 48 deletions(-) create mode 100644 crates/candler-core/src/jobs/runtime/refusal.rs diff --git a/crates/candler-core/src/jobs/runtime/evaluate.rs b/crates/candler-core/src/jobs/runtime/evaluate.rs index fe6e88da..a4845926 100644 --- a/crates/candler-core/src/jobs/runtime/evaluate.rs +++ b/crates/candler-core/src/jobs/runtime/evaluate.rs @@ -12,13 +12,13 @@ use std::time::Duration; use candler_schemas::execution::{EventPayload, JobEnd, JobState}; use candler_schemas::primitives::JobId; -use candler_schemas::refusal::{RefusalCode, RefusalRecord, Side}; use futures::FutureExt as _; use futures::future::BoxFuture; use tokio::sync::watch; use tokio::task::JoinHandle; use super::RuntimeError; +use super::refusal::{end_job, record_of, write_refusal}; use super::session::SPEC_FILE; use super::session::{ZombieTick, become_subreaper, detach_session, digest_of, note}; use super::signals::SignalWatch; @@ -40,11 +40,6 @@ use crate::supervise::{EventSink, Supervisor}; /// `EvaluateReport::to_document` makes. It is written before `job.ended`. pub const REPORT_FILE: &str = "report.json"; -/// The file of the job directory that holds the `refusal/1` record of the error a failed job ended -/// with, as the binary would print it. It is written, atomically, before `job.ended`, so that a -/// command that waits for the job can answer with the same code, side and path. -pub const REFUSAL_FILE: &str = "refusal.json"; - /// Everything the supervisor of one evaluate job starts from. The spec's digest was checked against /// `job.json` before this is built. pub struct EvaluateEntry { @@ -65,42 +60,6 @@ pub struct EvaluateJobOutcome { pub report: EvaluateReport, } -/// Writes the record of `error` to [`REFUSAL_FILE`]: the code, side and path the walk of causes -/// finds in it, or the fallback code when it finds none. A write that fails is noted and the job -/// goes on: the command that waits then falls back to the text of the log. -fn write_refusal(dir: &JobDir, error: &(dyn std::error::Error + 'static)) { - let message = error.to_string(); - let record = match crate::refusal::find(error) { - Some(found) => { - let record = RefusalRecord::new(found.code(), found.side(), message); - match found.path() { - Some(pointer) => record.clone().at_path(pointer).unwrap_or(record), - None => record, - } - } - None => RefusalRecord::new( - RefusalCode::from_checked("candler.internal"), - Side::Candler, - message, - ), - }; - let mut causes = Vec::new(); - let mut source = error.source(); - while let Some(cause) = source { - causes.push(cause.to_string()); - source = cause.source(); - } - let record = record.with_causes(causes); - let written = serde_json::to_vec(&record) - .map_err(|e| e.to_string()) - .and_then(|bytes| { - write_atomic(&dir.path().join(REFUSAL_FILE), &bytes).map_err(|e| e.to_string()) - }); - if let Err(reason) = written { - note(&format!("the refusal cannot be written: {reason}")); - } -} - fn session_error(detail: &impl ToString) -> RuntimeError { RuntimeError::Session { detail: detail.to_string(), @@ -215,10 +174,10 @@ async fn run(entry: EvaluateEntry) -> Result { } // The cause the handler set decides how a stopped job ends, whatever the body returns. let told_to_die = matches!(*seen.cancel.borrow(), Some(JobCause::Killed)); - if let Err(error) = &result { + let refusal = result.as_ref().err().map(|error| { note(&error.to_string()); - write_refusal(&dir, error); - } + record_of(error) + }); let result = result.map(|outcome| { if told_to_die { EvaluateJobOutcome { @@ -234,7 +193,7 @@ async fn run(entry: EvaluateEntry) -> Result { Ok(outcome) => outcome.end, Err(_) => JobEnd::Failed, }; - sink.emit(None, EventPayload::job_ended(end)); + end_job(sink.as_ref(), &dir, end, refusal.as_ref()); let sealed = dir.set_state(JobState::Ended).map_err(|e| job_error(&e)); drop(lock); match (result, sealed) { @@ -328,7 +287,7 @@ async fn serve( } Err(error) => { note(&format!("the evaluation failed: {error}")); - write_refusal(dir, &error); + write_refusal(dir, &record_of(&error)); Ok(EvaluateJobOutcome { end: JobEnd::Failed, report: EvaluateReport::default(), diff --git a/crates/candler-core/src/jobs/runtime/mod.rs b/crates/candler-core/src/jobs/runtime/mod.rs index ff05f060..25d45178 100644 --- a/crates/candler-core/src/jobs/runtime/mod.rs +++ b/crates/candler-core/src/jobs/runtime/mod.rs @@ -5,6 +5,7 @@ pub mod detach; pub mod evaluate; pub mod launch; pub mod reap; +pub mod refusal; pub mod session; pub mod signals; pub mod sweep; diff --git a/crates/candler-core/src/jobs/runtime/refusal.rs b/crates/candler-core/src/jobs/runtime/refusal.rs new file mode 100644 index 00000000..20d4200c --- /dev/null +++ b/crates/candler-core/src/jobs/runtime/refusal.rs @@ -0,0 +1,74 @@ +//! The refusal record of a job: the one place both job kinds build it, write it and end the job +//! after it. +//! +//! A job that an error ended leaves `jobs//refusal.json`, the `refusal/1` record of that +//! error, written before `job.ended`, so that whoever waits for the job reads its code, side and +//! pointer from the job's own state and not from a log. + +use candler_schemas::execution::{EventPayload, JobEnd}; +use candler_schemas::refusal::{RefusalCode, RefusalRecord, Side}; + +use super::session::note; +use crate::jobs::dir::{JobDir, write_atomic}; +use crate::supervise::EventSink; + +/// The file of the job directory that holds the `refusal/1` record of the error a failed job ended +/// with, as the binary would print it. It is written, atomically, before `job.ended`, so that a +/// command that waits for the job can answer with the same code, side and path. +pub const REFUSAL_FILE: &str = "refusal.json"; + +/// The record of `error`: the code, side and path the walk of causes finds in it, or the fallback +/// code `candler.internal` when it finds none, its message and the messages of its causes. +#[must_use] +pub fn record_of(error: &(dyn std::error::Error + 'static)) -> RefusalRecord { + let message = error.to_string(); + let record = match crate::refusal::find(error) { + Some(found) => { + let record = RefusalRecord::new(found.code(), found.side(), message); + match found.path() { + Some(pointer) => record.clone().at_path(pointer).unwrap_or(record), + None => record, + } + } + None => RefusalRecord::new( + RefusalCode::from_checked("candler.internal"), + Side::Candler, + message, + ), + }; + let mut causes = Vec::new(); + let mut source = error.source(); + while let Some(cause) = source { + causes.push(cause.to_string()); + source = cause.source(); + } + record.with_causes(causes) +} + +/// Writes `record` to [`REFUSAL_FILE`] of `dir`. A write that fails is noted and the job goes on: +/// the command that waits then falls back to the text of the log. +pub fn write_refusal(dir: &JobDir, record: &RefusalRecord) { + let written = serde_json::to_vec(record) + .map_err(|e| e.to_string()) + .and_then(|bytes| { + write_atomic(&dir.path().join(REFUSAL_FILE), &bytes).map_err(|e| e.to_string()) + }); + if let Err(reason) = written { + note(&format!("the refusal cannot be written: {reason}")); + } +} + +/// Ends the job: writes `refusal` when there is one, then emits `job.ended` with `end`. The +/// record is on disk before the event, whichever kind of job this is. +pub fn end_job( + // TRAIT_OBJECT: the sink is the job's event log + sink: &dyn EventSink, + dir: &JobDir, + end: JobEnd, + refusal: Option<&RefusalRecord>, +) { + if let Some(record) = refusal { + write_refusal(dir, record); + } + sink.emit(None, EventPayload::job_ended(end)); +} diff --git a/crates/candler/src/commands/evaluate.rs b/crates/candler/src/commands/evaluate.rs index 3bb5e99a..6c393834 100644 --- a/crates/candler/src/commands/evaluate.rs +++ b/crates/candler/src/commands/evaluate.rs @@ -21,9 +21,10 @@ use candler_core::jobs::lost::{self, JobLiveness}; use candler_core::jobs::model::{EvaluateSpec, JobSpecFile}; use candler_core::jobs::runtime::TEARDOWN_BOUND; use candler_core::jobs::runtime::detach::{DetachArgs, detach}; -use candler_core::jobs::runtime::evaluate::{REFUSAL_FILE, REPORT_FILE}; +use candler_core::jobs::runtime::evaluate::REPORT_FILE; use candler_core::jobs::runtime::launch::{mint_job_id, own_identity, spec_digest}; use candler_core::jobs::runtime::reap::reap_one; +use candler_core::jobs::runtime::refusal::REFUSAL_FILE; use candler_core::jobs::runtime::session::recover_job_dir; use candler_core::store::Store; use candler_core::store::layout::StoreLayout; From b94889efea62f64f941b20b8dc2a048d6843bbc0 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 15:24:36 +0900 Subject: [PATCH 12/38] fix(jobs)!: keep a run job's refusal in its refusal record A run job refused at start ended as job.ended {"reason":"failed"} plus a line in supervisor.log, so its code reached no consumer. JobOutcome gains `refusal`, `refused` takes the typed error and builds the record with record_of (keeping its stderr line), every refusal path of run_job passes its error, and session::run ends through end_job, which writes refusal.json before job.ended, as evaluate jobs already did. Guards: the job-start refusal tests of guard_config_check.rs and guard_server_check.rs now read the record the job body returns (code, side, pointer, message) instead of a child process's stderr; refusal_of, CANDLER_CONFIG_CHECK_CHILD and CANDLER_SERVER_CHECK_CHILD are retired. One test per refusal class: harness_rejected_input (harness finding), config_check_failed (five rows: a check that did not run) and the server that exits at start (jobs.server_exited_at_start). The server row stays in guard_server_check.rs, whose setup (a job that declares mcp servers) differs from the stand-in harness of guard_config_check.rs; it reads outcome.refusal there. BREAKING CHANGE: JobOutcome has a new public field `refusal: Option`. Where JobOutcome is built, add `refusal: None`. Co-Authored-By: Claude Sonnet 5.5 --- crates/candler-core/src/jobs/model.rs | 4 + .../candler-core/src/jobs/orchestrate/mod.rs | 22 +-- .../candler-core/src/jobs/runtime/session.rs | 7 +- .../tests/it/guard_config_check.rs | 180 +++++++++--------- .../tests/it/guard_server_check.rs | 57 +++--- .../tests/it/support/job_runtime.rs | 1 + .../tests/it/support/supervision_gates.rs | 1 + .../candler/tests/it/guard_cli_kill_live.rs | 1 + 8 files changed, 145 insertions(+), 128 deletions(-) diff --git a/crates/candler-core/src/jobs/model.rs b/crates/candler-core/src/jobs/model.rs index 1482e39a..49522257 100644 --- a/crates/candler-core/src/jobs/model.rs +++ b/crates/candler-core/src/jobs/model.rs @@ -5,6 +5,7 @@ use std::sync::Arc; use candler_schemas::execution::{Budget, DigestRef, ExperimentFile, JobEnd}; use candler_schemas::primitives::Digest; +use candler_schemas::refusal::RefusalRecord; use futures::future::BoxFuture; use tokio::sync::watch; @@ -114,6 +115,9 @@ pub struct JobOutcome { pub end: JobEnd, /// The outcome of every run the job started. pub runs: Vec, + /// The record of the error that refused the job at start, when one did; the supervisor writes + /// it to the job's `refusal.json` before `job.ended`. + pub refusal: Option, } /// Why a job is being stopped from outside. diff --git a/crates/candler-core/src/jobs/orchestrate/mod.rs b/crates/candler-core/src/jobs/orchestrate/mod.rs index 47eee895..ec97bf0d 100644 --- a/crates/candler-core/src/jobs/orchestrate/mod.rs +++ b/crates/candler-core/src/jobs/orchestrate/mod.rs @@ -27,6 +27,7 @@ use self::session::{ }; use crate::isolation::model::{ImageId, ImageRef, SweepScope}; use crate::jobs::model::{JobControl, JobOutcome, JobSpec}; +use crate::jobs::runtime::refusal::record_of; use crate::runner::plan::{Force, PlanCtx, PlanMode, experiment_of, plan_runs}; use crate::runner::{JobMeter, Runtime}; @@ -46,22 +47,20 @@ pub fn orchestrate_with( Box::pin(run_job(rt, spec, ctl, host)) } -/// The outcome of a job that never started a run. -const fn failed() -> JobOutcome { - JobOutcome { - end: JobEnd::Failed, - runs: Vec::new(), - } -} - -/// Writes one line to the supervisor's stderr that names why a job could not start. Errors name +/// The outcome of a job that never started a run: it ended `failed` and carries the record of +/// `error`, which the supervisor writes to the job's `refusal.json` before `job.ended`. One line +/// on the supervisor's stderr, its log, names why the job could not start for a human. Errors name /// a secret, never its value. -fn refused(what: &str, error: &impl std::fmt::Display) -> JobOutcome { +fn refused(what: &str, error: &(dyn std::error::Error + 'static)) -> JobOutcome { #[expect(clippy::print_stderr, reason = "the supervisor's stderr is its log")] { eprintln!("orchestrate: {what}: {error}"); } - failed() + JobOutcome { + end: JobEnd::Failed, + runs: Vec::new(), + refusal: Some(record_of(error)), + } } /// Runs the session controls once when a cell of the job is a session, and gives each session @@ -204,5 +203,6 @@ async fn run_job( JobOutcome { end: schedule.end, runs: schedule.runs, + refusal: None, } } diff --git a/crates/candler-core/src/jobs/runtime/session.rs b/crates/candler-core/src/jobs/runtime/session.rs index b9e17ad2..715fc101 100644 --- a/crates/candler-core/src/jobs/runtime/session.rs +++ b/crates/candler-core/src/jobs/runtime/session.rs @@ -15,6 +15,7 @@ use rustix::process::{getpid, setsid}; use tokio::sync::watch; use tokio::task::JoinHandle; +use super::refusal::end_job; use super::signals::SignalWatch; use super::sweep::{ProcMarkerSweeper, reap_confirmed, sweep_orphans}; use super::{JobEntry, RuntimeError}; @@ -454,7 +455,11 @@ pub(crate) async fn run(entry: JobEntry, body: JobBody) -> Result outcome.end, Err(_) => JobEnd::Failed, }; - sink.emit(None, EventPayload::job_ended(end)); + let refusal = match &result { + Ok(outcome) => outcome.refusal.as_ref(), + Err(_) => None, + }; + end_job(sink.as_ref(), &dir, end, refusal); let sealed = dir.set_state(JobState::Ended).map_err(|e| job_error(&e)); drop(lock); match (result, sealed) { diff --git a/crates/candler-core/tests/it/guard_config_check.rs b/crates/candler-core/tests/it/guard_config_check.rs index 08a5750f..3502584d 100644 --- a/crates/candler-core/tests/it/guard_config_check.rs +++ b/crates/candler-core/tests/it/guard_config_check.rs @@ -28,6 +28,7 @@ use candler_harness::spec::{ use candler_schemas::primitives::RelPath; use candler_schemas::process::ExitStatus; use candler_schemas::raw::StreamName; +use candler_schemas::refusal::{RefusalRecord, Side}; use candler_schemas::trace::{EndedBy, Session}; use serde_json::{Value, json}; use support::job_orchestrate::{Probed, QuietDriver, Rig, run_to_end, spec}; @@ -306,22 +307,13 @@ fn run_ending(job: JobSpec, driver: Checking, output: ExecOutput) -> Ran { }) } -/// The supervisor's stderr of the job `child` runs when this test runs again as a child of the -/// test binary, or `None` in the child itself, where `child` runs. The job's refusal is a line -/// of that stderr. -fn refusal_of(test: &str, child: impl FnOnce()) -> Option { - if std::env::var_os("CANDLER_CONFIG_CHECK_CHILD").is_some() { - child(); - return None; - } - let out = std::process::Command::new(std::env::current_exe().expect("the test binary")) - .args([test, "--exact", "--nocapture", "--test-threads=1"]) - .env("CANDLER_CONFIG_CHECK_CHILD", "1") - .output() - .expect("the child ran"); - let stderr = String::from_utf8_lossy(&out.stderr).into_owned(); - assert!(out.status.success(), "the child's guards held: {stderr}"); - Some(stderr) +/// The refusal record a job that was refused at start carries, which the supervisor writes to +/// the job's `refusal.json`; it fails the guard when the job carries none. +fn recorded(outcome: &JobOutcome) -> &RefusalRecord { + outcome + .refusal + .as_ref() + .unwrap_or_else(|| panic!("the refused job carries no refusal record: {outcome:?}")) } /// The file `name` of the first run's directory, read as JSON. @@ -355,109 +347,123 @@ fn mount_at<'m>(mounts: &'m [MountSpec], target: &str) -> Option<&'m MountSpec> } /// Guards: a harness check that reports a finding refuses the job before its first run, and the -/// refusal line names what was installed, where, the harness and the harness's output. -/// Oracle: the literal `REJECT: unknown key hooks.Foo` the scripted check prints, and the file -/// names the stand-in driver lists. The job runs in a child of this test binary, so its stderr -/// line can be read. -/// Bite: the refusal drops the harness's output, the check runs after the runs are scheduled, or the -/// check plans its cell twice. +/// job's refusal record carries the code `experiment.harness_rejected_input`, the side +/// `experiment` and the pointer `/fixed`, with a message that names what was installed, where, the +/// harness and the harness's output; the refusal is the record, not a line of a log. +/// Oracle: the literal `REJECT: unknown key hooks.Foo` the scripted check prints, the file names +/// the stand-in driver lists, and the contract's row for the code (side `experiment`, the +/// setting the file comes from; the stand-in sets no hooks or instructions, so `/fixed`). +/// Bite: the refusal drops the harness's output, is handed to `refused` as a string (the code +/// falls back to `candler.internal`), the check runs after the runs are scheduled, or the check +/// plans its cell twice. #[test] fn harness_finding_refuses_the_job_before_any_run() { - let line = refusal_of( - "guard_config_check::harness_finding_refuses_the_job_before_any_run", - || { - let driver = Checking::new(true); - let planned = Arc::clone(&driver.planned); - let ran = run(job(&["m1"]), driver, "REJECT: unknown key hooks.Foo"); - assert_eq!( - planned.load(Ordering::SeqCst), - 1, - "the check plans its cell once" - ); - let probing = ran.host.probing(); - assert_eq!(probing.executed().len(), 1, "the check ran once"); - assert_eq!(probing.runs(), 0, "no run starts"); - assert!(ran.outcome.runs.is_empty(), "no run is recorded"); - }, + let driver = Checking::new(true); + let planned = Arc::clone(&driver.planned); + let ran = run(job(&["m1"]), driver, "REJECT: unknown key hooks.Foo"); + assert_eq!( + planned.load(Ordering::SeqCst), + 1, + "the check plans its cell once" ); - let Some(stderr) = line else { return }; + let probing = ran.host.probing(); + assert_eq!(probing.executed().len(), 1, "the check ran once"); + assert_eq!(probing.runs(), 0, "no run starts"); + assert!(ran.outcome.runs.is_empty(), "no run is recorded"); + let record = recorded(&ran.outcome); + assert_eq!(record.code().as_str(), "experiment.harness_rejected_input"); + assert_eq!(record.side(), Side::Experiment); + assert_eq!(record.path(), Some("/fixed")); assert!( - stderr.contains( + record.message().contains( "Candler installed the files `settings.json`, `AGENTS.md` at the agent's home and the workspace; claude-code rejects it: REJECT: unknown key hooks.Foo" ), - "the refusal line: {stderr}" + "the refusal's message: {}", + record.message() ); } /// Guards: a harness check that exits non-zero with its finding on standard error refuses the -/// job as a finding, quoting that text, and not as a check that could not run; the exit status -/// does not decide the verdict. +/// job as a finding, quoting that text in the refusal record, and not as a check that could not +/// run; the exit status does not decide the verdict. /// Oracle: the literal `REJECT: unknown key hooks.Foo` the scripted check prints on standard /// error and the exit code `1`, which `OpenCode`'s check exits with for every report. /// Bite: read the verdict from standard output alone, or treat a non-zero exit as a check that /// could not run. #[test] fn finding_on_stderr_with_a_failing_exit_refuses_as_a_finding() { - let line = refusal_of( - "guard_config_check::finding_on_stderr_with_a_failing_exit_refuses_as_a_finding", - || { - let ran = run_ending( - job(&["m1"]), - Checking::new(true), - ExecOutput::exited(1, b"REJECT: unknown key hooks.Foo".to_vec()), - ); - assert_eq!(ran.host.probing().runs(), 0, "no run starts"); - assert!(ran.outcome.runs.is_empty(), "no run is recorded"); - }, + let ran = run_ending( + job(&["m1"]), + Checking::new(true), + ExecOutput::exited(1, b"REJECT: unknown key hooks.Foo".to_vec()), ); - let Some(stderr) = line else { return }; - assert!( - stderr.contains("claude-code rejects it: REJECT: unknown key hooks.Foo"), - "the refusal quotes the harness: {stderr}" + assert_eq!(ran.host.probing().runs(), 0, "no run starts"); + assert!(ran.outcome.runs.is_empty(), "no run is recorded"); + let record = recorded(&ran.outcome); + assert_eq!( + record.code().as_str(), + "experiment.harness_rejected_input", + "a finding is no failed check" ); assert!( - !stderr.contains("could not run"), - "a finding is no failed check: {stderr}" + record + .message() + .contains("claude-code rejects it: REJECT: unknown key hooks.Foo"), + "the refusal quotes the harness: {}", + record.message() ); } /// Guards: a check that did not run, printed nothing or printed more than the core keeps is /// refused as a check that could not run, whatever the stand-in's reader would say of the text: /// no output, a command that is missing (`127`), the in-container timeout (`124`), a signal and -/// output cut at the capture limit. -/// Oracle: the exit codes `127` and `124` that the shell and `timeout` give, signal 9, and the -/// wording of the refusal written by hand. -/// Bite: pass the empty or cut output to the driver, or read the exit code as a verdict. +/// output cut at the capture limit. Each row's refusal record carries the code +/// `jobs.config_check_failed`, the side `environment` and no pointer. +/// Oracle: the exit codes `127` and `124` that the shell and `timeout` give, signal 9, the +/// wording of the refusal written by hand, and the contract's row for the code. +/// Bite: pass the empty or cut output to the driver, read the exit code as a verdict, or hand +/// `refused` a string (the code falls back to `candler.internal`). #[test] fn a_check_that_did_not_run_or_printed_nothing_is_refused() { let mut killed = ExecOutput::printed(b"fine".to_vec()); killed.status = ExitStatus::Signal { signal: 9 }; let mut cut = ExecOutput::printed(b"fine".to_vec()); cut.truncated = true; - let line = refusal_of( - "guard_config_check::a_check_that_did_not_run_or_printed_nothing_is_refused", - || { - for (case, output) in [ - ("empty", ExecOutput::printed(Vec::new())), - ("missing", ExecOutput::exited(127, b"not found".to_vec())), - ("timeout", ExecOutput::exited(124, Vec::new())), - ("signal", killed), - ("cut", cut), - ] { - let ran = run_ending(job(&["m1"]), Checking::new(true), output); - assert_eq!(ran.host.probing().runs(), 0, "{case}: no run starts"); - } - }, - ); - let Some(stderr) = line else { return }; - for expected in [ - "the harness check could not run: the check printed nothing", - "the harness check could not run: the check command did not run: it exited 127: not found", - "it exited 124", - "the check was ended by signal 9", - "the check printed more than the core keeps", + for (case, output, expected) in [ + ( + "empty", + ExecOutput::printed(Vec::new()), + "the harness check could not run: the check printed nothing", + ), + ( + "missing", + ExecOutput::exited(127, b"not found".to_vec()), + "the harness check could not run: the check command did not run: it exited 127: not found", + ), + ( + "timeout", + ExecOutput::exited(124, Vec::new()), + "it exited 124", + ), + ("signal", killed, "the check was ended by signal 9"), + ("cut", cut, "the check printed more than the core keeps"), ] { - assert!(stderr.contains(expected), "{expected}: {stderr}"); + let ran = run_ending(job(&["m1"]), Checking::new(true), output); + assert_eq!(ran.host.probing().runs(), 0, "{case}: no run starts"); + let record = recorded(&ran.outcome); + assert_eq!( + record.code().as_str(), + "jobs.config_check_failed", + "{case}: {}", + record.message() + ); + assert_eq!(record.side(), Side::Environment, "{case}"); + assert_eq!(record.path(), None, "{case}"); + assert!( + record.message().contains(expected), + "{case}: {expected}: {}", + record.message() + ); } } diff --git a/crates/candler-core/tests/it/guard_server_check.rs b/crates/candler-core/tests/it/guard_server_check.rs index aede6119..a0db912e 100644 --- a/crates/candler-core/tests/it/guard_server_check.rs +++ b/crates/candler-core/tests/it/guard_server_check.rs @@ -14,6 +14,7 @@ use candler_core::isolation::StartProbe; use candler_core::jobs::model::{JobOutcome, JobSpec}; use candler_core::jobs::orchestrate::session::JobHost; use candler_schemas::execution::ExperimentFile; +use candler_schemas::refusal::Side; use serde_json::{Value, json}; use support::job_orchestrate::{Probed, Rig, run_to_end, spec}; use support::run_plan::Facts; @@ -63,38 +64,36 @@ fn run( (outcome, probing.probed(), probing.runs()) } -/// Guards: a declared server that exits at start refuses the job before any run, and the refusal -/// line names the server and carries what it printed. -/// Oracle: the literal `boom: no module named x` the scripted server prints. The job runs in a -/// child of this test binary, so its stderr line can be read. -/// Bite: the refusal drops the server's output. +/// Guards: a declared server that exits at start refuses the job before any run, and the job's +/// refusal record carries the code `jobs.server_exited_at_start`, the side `experiment` and no +/// pointer, with a message that names the server and carries what it printed. +/// Oracle: the literal `boom: no module named x` the scripted server prints, and the contract's +/// row for the code written by hand. +/// Bite: the refusal drops the server's output, or `refused` is handed a string (the code falls +/// back to `candler.internal`). #[test] fn server_that_exits_refuses_the_job_with_its_stderr() { - const NAME: &str = "guard_server_check::server_that_exits_refuses_the_job_with_its_stderr"; - if std::env::var_os("CANDLER_SERVER_CHECK_CHILD").is_some() { - let job = job_with(&[("alpha", json!({"command": "badserver", "args": ["--x"]}))]); - let answers = vec![( - String::from("badserver"), - StartProbe::Exited { - output: String::from("boom: no module named x"), - }, - )]; - let (outcome, probed, runs) = run(job, answers, Vec::new(), Vec::new()); - assert_eq!(probed, vec![vec!["badserver".to_owned(), "--x".to_owned()]]); - assert_eq!(runs, 0, "no run starts"); - assert!(outcome.runs.is_empty(), "no run is recorded"); - return; - } - let child = std::process::Command::new(std::env::current_exe().expect("the test binary")) - .args([NAME, "--exact", "--nocapture", "--test-threads=1"]) - .env("CANDLER_SERVER_CHECK_CHILD", "1") - .output() - .expect("the child ran"); - let stderr = String::from_utf8_lossy(&child.stderr); - assert!(child.status.success(), "the child's guards held: {stderr}"); + let job = job_with(&[("alpha", json!({"command": "badserver", "args": ["--x"]}))]); + let answers = vec![( + String::from("badserver"), + StartProbe::Exited { + output: String::from("boom: no module named x"), + }, + )]; + let (outcome, probed, runs) = run(job, answers, Vec::new(), Vec::new()); + assert_eq!(probed, vec![vec!["badserver".to_owned(), "--x".to_owned()]]); + assert_eq!(runs, 0, "no run starts"); + assert!(outcome.runs.is_empty(), "no run is recorded"); + let record = outcome.refusal.expect("the refused job carries a record"); + assert_eq!(record.code().as_str(), "jobs.server_exited_at_start"); + assert_eq!(record.side(), Side::Experiment); + assert_eq!(record.path(), None); assert!( - stderr.contains("the server `alpha` exited at start: boom: no module named x"), - "the refusal line: {stderr}" + record + .message() + .contains("the server `alpha` exited at start: boom: no module named x"), + "the refusal's message: {}", + record.message() ); } diff --git a/crates/candler-core/tests/it/support/job_runtime.rs b/crates/candler-core/tests/it/support/job_runtime.rs index c5ea1d22..1a65f1da 100644 --- a/crates/candler-core/tests/it/support/job_runtime.rs +++ b/crates/candler-core/tests/it/support/job_runtime.rs @@ -341,6 +341,7 @@ pub fn killed_body( JobOutcome { end: JobEnd::Completed, runs: Vec::new(), + refusal: None, } }) } diff --git a/crates/candler-core/tests/it/support/supervision_gates.rs b/crates/candler-core/tests/it/support/supervision_gates.rs index faf5d13a..31d9327b 100644 --- a/crates/candler-core/tests/it/support/supervision_gates.rs +++ b/crates/candler-core/tests/it/support/supervision_gates.rs @@ -266,6 +266,7 @@ pub fn gates_body( JobOutcome { end: JobEnd::Completed, runs: Vec::new(), + refusal: None, } }) } diff --git a/crates/candler/tests/it/guard_cli_kill_live.rs b/crates/candler/tests/it/guard_cli_kill_live.rs index 8e85db2b..e0094417 100644 --- a/crates/candler/tests/it/guard_cli_kill_live.rs +++ b/crates/candler/tests/it/guard_cli_kill_live.rs @@ -125,6 +125,7 @@ exit 1 JobOutcome { end: JobEnd::Completed, runs: Vec::new(), + refusal: None, } }) } From 4b01ba3da9e3f40fcf9a26008b6c39f8798a8d58 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 15:25:00 +0900 Subject: [PATCH 13/38] docs(jobs): say every job kind leaves its refusal record The architecture said only an evaluate job leaves refusal.json. Every job kind does when an error ended it, written before job.ended. Co-Authored-By: Claude Sonnet 5.5 --- __design__/architecture.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/__design__/architecture.md b/__design__/architecture.md index 584b24a3..a6d375f8 100644 --- a/__design__/architecture.md +++ b/__design__/architecture.md @@ -397,9 +397,10 @@ names. container. `candler evaluate` starts the job at once and waits for it; the job form is what lets `kill` and the recovery of a lost job reap evaluator processes after a crash, and lets one `events.jsonl` serve `watch`. - A finished evaluate job leaves `report.json`, or, when an error ended it, `refusal.json`: the - `refusal/1` record of that error, written before `job.ended`, which the command prints in place - of a report. The command stops the job on Ctrl-C only: SIGTERM or SIGHUP of the command leaves + Every job kind, run or evaluate, leaves `refusal.json` when an error ended it: the `refusal/1` + record of that error, written before `job.ended` by one function both supervisors call. A + finished evaluate job also leaves `report.json`, and the command prints the record in place of + a report. The command stops the job on Ctrl-C only: SIGTERM or SIGHUP of the command leaves the job running, as it does for any job. Two evaluations over the same runs at once may grade a run twice; the readers (`show`, `analyze`, `diff`, the pending selection) take the current record under each I4 key, so the run counts once. A claim per run is not in place. From 2894d1b8c2923715a06e49fc5462b89b23cab48a Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 15:31:17 +0900 Subject: [PATCH 14/38] reports(jobs): close the job refusal record Leaf report of job_refusal_record: G6 red on the base and under its bite, the string-error bite on every refusal-class guard, the checks that a successful job and a killed job leave no refusal.json, the gate results, the deviations and the observations. Co-Authored-By: Claude Sonnet 5.5 --- .../m6_gaps/leaves/job_refusal_record_v0.md | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 __reports__/m6_gaps/leaves/job_refusal_record_v0.md diff --git a/__reports__/m6_gaps/leaves/job_refusal_record_v0.md b/__reports__/m6_gaps/leaves/job_refusal_record_v0.md new file mode 100644 index 00000000..ce5f2804 --- /dev/null +++ b/__reports__/m6_gaps/leaves/job_refusal_record_v0.md @@ -0,0 +1,53 @@ +# Job refusal record: leaf report (v0) + +Date: 2026-12-01. Branch `fix/job-refusal-record`, cut from `fix/m6-gaps`. Closes O11 of [observation round 06](../../agent_config/06-observation_level3_out_of_scope_v0.md). + +## What was done + +| Step | Commit | Evidence | +|---|---|---| +| 1 | `1e95fd9a test(cli): read a job-start refusal from the job's refusal record` | G6 red on the base (below) | +| 2 | `6d6d1612 refactor(jobs): share the refusal record between job kinds` | whole workspace 772/772; `guard_cli_evaluate::r2_a_refusal_raised_in_the_job_keeps_its_code_through_the_verb` green unchanged | +| 3 | `68720657 fix(jobs)!: keep a run job's refusal in its refusal record` | whole workspace 772/772; G6 green with `--run-ignored only` | +| 4 | `072611a0 docs(jobs): say every job kind leaves its refusal record` | `__design__/architecture.md` near line 400 | +| 5 | this report | bites below; gate below | + +`jobs/runtime/refusal.rs` holds `REFUSAL_FILE`, `record_of`, `write_refusal` and `end_job`; `session::run` and evaluate's `run` both end through `end_job`. `JobOutcome` gains `refusal: Option`; `refused` takes the typed error. The `supervisor.log` line stays. + +## Guards, seen red and green + +| Guard | Red | Green | +|---|---|---| +| G6 `guard_harness_check_refuses` (reads `jobs//refusal.json`: schema `refusal/1`, code `experiment.harness_rejected_input`, side `experiment`, pointer `/fixed/hooks`, quoted harness output) | On the base: `claude-code: invalid payload: refusal record None, sealed 0` and `opencode: invalid payload: refusal record None, sealed 0` (each followed by the `supervisor.log` line). Under the bite "no record passed to `end_job` in `session::run`": the same two messages. | Step 3 tip, 41 s, and again at the gate | +| `harness_finding_refuses_the_job_before_any_run` | Bite "`refused` gets a string error": `assertion left == right failed; left: "candler.internal"; right: "experiment.harness_rejected_input"` | green | +| `finding_on_stderr_with_a_failing_exit_refuses_as_a_finding` | same bite: `a finding is no failed check; left: "candler.internal"; right: "experiment.harness_rejected_input"` | green | +| `a_check_that_did_not_run_or_printed_nothing_is_refused` (5 rows) | same bite, first row: `empty: the harness check could not run: the check printed nothing; left: "candler.internal"; right: "jobs.config_check_failed"` | green | +| `guard_server_check::server_that_exits_refuses_the_job_with_its_stderr` | same bite: `left: "candler.internal"; right: "jobs.server_exited_at_start"` | green | + +Four of the eight selected tests went red under the string-error bite and the other four (the remaining tests of those files) stayed green, as they do not read a refusal. + +## Checks on files left behind + +- A successful run job leaves no `refusal.json`: G6's valid-payload rows assert it on the real Docker run (`record.is_some()` fails the row) and pass. +- A killed job leaves none: a `confirm_` assertion added to `guard_cli_kill_live::kill_live::b41_kill_all_reaps_running_supervisors` (after the `JobEnd::Killed` check) passed, then was deleted. `git grep -n confirm_ -- crates python` prints nothing. + +## Gate + +`cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings` and `RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps` pass. `cargo nextest run --workspace`: the final run passed 772/772 (6 slow, 35 skipped); the runs after steps 2 and 3 passed 772/772 too, once after one flake. G6 alone passes. + +Timing flake (the O10/O15 family): in one full run `guard_supervise::a_pre_stop_command_leaves_nothing_in_its_group` failed once with `the command wrote a pid: ... No such file or directory`. Rerun alone it passed (0.9 s), and the full rerun with `--no-fail-fast` passed 772/772. + +## Deviations from the leaf file + +- The campaign gate names `jobs.server_check_failed` for the server row. The existing test reaches the path where a declared server exits at start, whose code is `jobs.server_exited_at_start` (side `experiment`, no pointer); the row asserts that code. A row for `jobs.server_check_failed` would go through the same `ServerCheckError`, `refused` and `record_of` path and differ only in a code that comes from the error type, so it would catch no bug the existing row misses. The lead agreed and rewords the gate. +- The job-start refusal guard is not one parameterized test in `guard_config_check.rs`: the harness-finding, check-did-not-run (five rows) and server-exit tests are one test per refusal class, each reading `JobOutcome.refusal`, and the server test stays in `guard_server_check.rs` (its setup declares MCP servers; the lead approved the file). `CANDLER_CONFIG_CHECK_CHILD`, `CANDLER_SERVER_CHECK_CHILD` and `refusal_of` in the tests are gone. +- Files edited outside the leaf's list, all forced: `crates/candler/src/commands/evaluate.rs` (import of `REFUSAL_FILE` moves to `jobs::runtime::refusal`), `refusal: None` in `crates/candler-core/tests/it/support/job_runtime.rs`, `.../support/supervision_gates.rs` and `crates/candler/tests/it/guard_cli_kill_live.rs`, and `crates/candler-core/tests/it/guard_server_check.rs`. + +## Docker + +G6 reused the cached images (none created today) and removes its own containers and networks (its leftover check passed). I built no image, container or network, so nothing was removed. Docker was not stopped and nothing was pruned. + +## Observations + +- `git grep -nE 'fn refusal_of' -- crates` still prints `crates/candler/src/commands/refusal.rs:416`, an unrelated `refusal_of(&CliError)`. The campaign gate's grep would list it; the gate text should name the test helper only. +- `session::run` writes no record for a supervisor-level `RuntimeError` (a setup failure before the body returns); only a body outcome's refusal is written. Evaluate jobs do write one in that case. Location: `crates/candler-core/src/jobs/runtime/session.rs`, the `Err(_)` arm before `end_job`. From 466b371a2b14fa286cbfee6e205e81a154fad6f7 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 15:41:42 +0900 Subject: [PATCH 15/38] reports(jobs): review the job refusal record Cold review of fix/job-refusal-record on validity, develop, leave and consume. No blocking findings. Co-Authored-By: Claude Sonnet 5.5 --- .../m6_gaps/reviews/job_refusal_record_v0.md | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 __reports__/m6_gaps/reviews/job_refusal_record_v0.md diff --git a/__reports__/m6_gaps/reviews/job_refusal_record_v0.md b/__reports__/m6_gaps/reviews/job_refusal_record_v0.md new file mode 100644 index 00000000..1fc122ca --- /dev/null +++ b/__reports__/m6_gaps/reviews/job_refusal_record_v0.md @@ -0,0 +1,46 @@ +# Review: job refusal record (v0) + +Reviewed `fix/job-refusal-record` (`git diff fix/m6-gaps...fix/job-refusal-record`, 15 files, +311/-195). One cold pass; no code changed. + +## Validity + +| Question | Answer and evidence | +|---|---| +| `refusal.json` written before `job.ended` on every refusal path of `run_job` | Yes. Every path in `orchestrate/mod.rs` (lines 119, 143, 174, 178, 183, 187, 191) returns `refused(what, &error)` (line 54), which builds `refusal: Some(record_of(error))`. `session::run` (`session.rs:458-462`) passes it to `end_job`, which writes the file then emits `job.ended` (`runtime/refusal.rs:64-73`). Their error types are catalogued (`jobs/refusal.rs`), so none falls back to `candler.internal` by accident. Only the three classes are guarded; the other four paths (plan, cells, gate_controls, session open) carry no guard. | +| Absent after a success and a kill | Success: `run_job` ends with `refusal: None` (mod.rs:206) and `end_job` writes nothing without a record; G6's valid-payload rows assert it on Docker per the builder (not rerun). Kill: `session.rs:458` passes the outcome's record even when `told_to_die`. A job refused and SIGTERMed in the same window would end `killed` with a `refusal.json`: unguarded corner, harmless (see F3). A kill of a running job has `refusal: None`. | +| Each code keeps side and pointer | Rerun `cargo nextest run -p candler-core --test it -E 'test(/guard_config_check/) \| test(/guard_server_check/)'`: 12/12 pass. They assert code, side and pointer: harness `/fixed` + `experiment`; config check `jobs.config_check_failed`, `environment`, no path (5 rows); server `jobs.server_exited_at_start`, `experiment`, none. | +| Bite: `refused` handed a string error | Reran by replacing `record_of(error)` with `record_of(&io::Error::other(error.to_string()))`: 4 of 4 red, `left: "candler.internal"` against each of the three codes. Reverted. | +| Bite: drop the record in `session::run` | Reran by passing `None` to `end_job`: all 4 unit guards stay green (`4 passed`). Only G6, ignored and Docker-only, catches it (F1). Reverted. | +| Workspace | `cargo nextest run --workspace`: first run failed `guard_protocol_client::a_deadline_beats_an_answer_that_is_already_waiting` (timing, code untouched by the diff); alone it passes. `cargo nextest run --workspace --no-fail-fast` then passed 772/772 (7 slow, 35 skipped, 213 s; `guard_wiring::wiring_stop_execs_in_the_container_with_the_observed_id` took 92 s while another leaf's build and tests shared the machine). The first-run failure is the O10/O15 timing family, not a finding. | + +## Develop + +- Scope held: no `JobEnd`/`job.ended` field change, no `schemas@` file in the diff, no CLI print change (the only `crates/candler/src` edit is an import path, `commands/evaluate.rs:24-27`). `supervisor.log` line kept (`refused` still `eprintln!`s). +- Spend: $2.19 over 69 API calls against the $3 estimate and $6 cap (the given figure, not remeasured). +- Deviations from the leaf, disclosed by the builder: not one parameterized guard but one test per class (config check keeps its five-row loop), the server row in `guard_server_check.rs`, and the server row asserts `jobs.server_exited_at_start`. I agree: a `server_check_failed` row passes through the same `refused`/`record_of` path and would catch nothing new. The README gate is already reworded. + +## Leave + +- One builder and one `end_job`: `record_of`, `write_refusal`, `REFUSAL_FILE`, `end_job` live in `runtime/refusal.rs`; `session::run` (session.rs:462) and evaluate `run` (evaluate.rs:196) both call `end_job`; `evaluate.rs` has no builder. The other `record_of` (`crates/candler/src/commands/refusal.rs:430`) builds from a `CliError`, a different input, not a duplicate. +- State stored twice: no. The record is a file only; `job.ended` gains no field. Two call sites write the file in evaluate (`serve` at evaluate.rs:290 and `run` via `end_job`) but they are exclusive: `serve` returns `Ok(Failed)`, so `run`'s refusal is `None`. Pre-existing shape. +- `refusal_of`/child process gone: the test helper and both `CANDLER_*_CHILD` env vars print nothing. `git grep 'fn refusal_of'` still hits `commands/refusal.rs:416` (unrelated; the leaf gate's grep text over-matches, as the builder observed). Test count: 12 in the two files before and after; none added or removed. +- Each remaining test catches a distinct bug: harness finding vs finding-on-stderr (verdict source) vs five did-not-run rows vs server exit. Yes; the first two overlap only in the code assertion, with different bites. +- Docs once, at source: `architecture.md:400-403` only. Guard doc comments updated in place. + +## Consume + +- A reader gets the code of any run-job refusal from `jobs//refusal.json` without parsing a log; `commands/evaluate.rs:105` already reads it. M7's `jobs`/`show` can read the same file. +- Success path I/O: none added (one `Option` match in `session.rs:458`). + +## Findings + +| # | Finding | Cost | Smallest fix | Severity | +|---|---|---|---|---| +| F1 | Dropping the record in `session::run` is caught only by G6 (ignored, Docker). The workspace gate stays green under that bite. | A regression in the one shared write path reaches M7 unseen until `container-e2e`. | One non-Docker test in `support/job_runtime.rs` running `session::run` with a body returning `refusal: Some(..)` and reading `refusal.json` plus event order. | Low, non-blocking (CI container-e2e lists G6) | +| F2 | `session::run` writes no record when `result` is `Err` (setup failure, `session.rs:458-461`), yet `architecture.md:400` says every job kind leaves `refusal.json` "when an error ended it". Evaluate does write one there. | M7 `show` finds no code for such a job; the sentence overstates. | Either call `record_of` on the `Err` arm (as evaluate does) or narrow the sentence to a refusal the body returns. | Low-medium, non-blocking; builder already lists it | +| F3 | A refused job that is killed concurrently ends `killed` yet leaves a record. | None practical. | None. | Info | +| F4 | Leaf gate text greps `fn refusal_of` over `crates`, matching an unrelated fn. | A false red gate for the close-out. | Reword the gate to name the test helper. | Info | + +## Blocking findings + +None. From a0ec58809a6965d48eed50cef45b9e131d5543ac Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 15:46:59 +0900 Subject: [PATCH 16/38] fix(jobs): keep the record of a run job whose setup failed When the supervisor's setup failed (no slot, an unreadable configuration, a docker client that cannot be built), session::run ended the job without a refusal.json, while an evaluate job writes one on the same kind of failure. The Err arm now builds the record with record_of and ends through end_job, so every job kind leaves its record when an error ended it, as architecture.md says. No existing test or its support reaches that arm, and a new fake was ruled out, so the arm is covered by the shared end_job path only. Co-Authored-By: Claude Sonnet 5.5 --- crates/candler-core/src/jobs/runtime/session.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/candler-core/src/jobs/runtime/session.rs b/crates/candler-core/src/jobs/runtime/session.rs index 715fc101..0e1558a8 100644 --- a/crates/candler-core/src/jobs/runtime/session.rs +++ b/crates/candler-core/src/jobs/runtime/session.rs @@ -15,7 +15,7 @@ use rustix::process::{getpid, setsid}; use tokio::sync::watch; use tokio::task::JoinHandle; -use super::refusal::end_job; +use super::refusal::{end_job, record_of}; use super::signals::SignalWatch; use super::sweep::{ProcMarkerSweeper, reap_confirmed, sweep_orphans}; use super::{JobEntry, RuntimeError}; @@ -455,11 +455,12 @@ pub(crate) async fn run(entry: JobEntry, body: JobBody) -> Result outcome.end, Err(_) => JobEnd::Failed, }; + // The record of the body's refusal, or of the error that ended the setup, as evaluate does. let refusal = match &result { - Ok(outcome) => outcome.refusal.as_ref(), - Err(_) => None, + Ok(outcome) => outcome.refusal.clone(), // BORROW: the outcome is returned to the caller + Err(error) => Some(record_of(error)), }; - end_job(sink.as_ref(), &dir, end, refusal); + end_job(sink.as_ref(), &dir, end, refusal.as_ref()); let sealed = dir.set_state(JobState::Ended).map_err(|e| job_error(&e)); drop(lock); match (result, sealed) { From edd02504a6556f0e999b466026435b0b24224f72 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 15:47:03 +0900 Subject: [PATCH 17/38] reports(jobs): record the review findings in the leaf report Co-Authored-By: Claude Sonnet 5.5 --- __reports__/m6_gaps/leaves/job_refusal_record_v0.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/__reports__/m6_gaps/leaves/job_refusal_record_v0.md b/__reports__/m6_gaps/leaves/job_refusal_record_v0.md index ce5f2804..ff7cc22c 100644 --- a/__reports__/m6_gaps/leaves/job_refusal_record_v0.md +++ b/__reports__/m6_gaps/leaves/job_refusal_record_v0.md @@ -50,4 +50,7 @@ G6 reused the cached images (none created today) and removes its own containers ## Observations - `git grep -nE 'fn refusal_of' -- crates` still prints `crates/candler/src/commands/refusal.rs:416`, an unrelated `refusal_of(&CliError)`. The campaign gate's grep would list it; the gate text should name the test helper only. -- `session::run` writes no record for a supervisor-level `RuntimeError` (a setup failure before the body returns); only a body outcome's refusal is written. Evaluate jobs do write one in that case. Location: `crates/candler-core/src/jobs/runtime/session.rs`, the `Err(_)` arm before `end_job`. +- Review finding F2 (fixed): `session::run` wrote no record when the setup failed (the `Err` arm); it now builds one with `record_of` and ends through `end_job`, as evaluate does. No existing test or support reaches that arm and a new fake was ruled out, so the arm is covered by the shared `end_job` path only. +- Review F1 (not fixed): dropping the record from `session::run` is caught only by G6. G6 runs in the CI container-e2e on every pull request that touches `crates/`; a non-Docker copy would catch the same bug a second time, only sooner. +- Review F3 (not fixed): a refused job that is then killed ends `killed` and keeps its record. That is accurate history, not a defect. +- Review F4 (not fixed): the leaf's `git grep` for `fn refusal_of` also matches the unrelated `refusal_of(&CliError)` in `crates/candler/src/commands/refusal.rs`. From ee1fa321a1653c7e637b4a384e95e2eec0a8f2d3 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 15:51:38 +0900 Subject: [PATCH 18/38] rdm(api): close the job refusal review The review found nothing blocking; F2 was fixed on the leaf branch and F1, F3 and F4 are observations in the leaf report. The leaf merged as 022db6fd, and the whole-suite gates pass after it: fmt, clippy, doc, and nextest 772 of 772 (35 skipped). Co-Authored-By: Claude Opus 5.5 --- __roadmap__/m6_gaps/review/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/__roadmap__/m6_gaps/review/README.md b/__roadmap__/m6_gaps/review/README.md index a014c74a..19f5d27f 100644 --- a/__roadmap__/m6_gaps/review/README.md +++ b/__roadmap__/m6_gaps/review/README.md @@ -23,7 +23,7 @@ Each risky change is judged on validity and on develop, leave and consume before ## Status ```mermaid graph TD - review_job_refusal[Review: job refusal]:::inprogress + review_job_refusal[Review: job refusal]:::done review_needs_batches[Review: needs batches]:::planned close[Close]:::planned classDef done fill:#166534,color:#bbf7d0 @@ -36,7 +36,7 @@ graph TD ## Nodes | Node | Type | Status | |:-----|:-----|:-------| -| `review_job_refusal.md` | 📄 Leaf Task | 🔄 In Progress | +| `review_job_refusal.md` | 📄 Leaf Task | ✅ Done | | `review_needs_batches.md` | 📄 Leaf Task | ⬜ Planned | | `close/` | 📁 Directory | ⬜ Planned | From 6c3f34f3031e35a45711a0903f165403eea6b2da Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 16:43:11 +0900 Subject: [PATCH 19/38] rdm(api): gate the needs refusal on the failed request it leaves The engine reports a request refused while its context is assembled as `EvaluateReport.failed_requests`, a request id and a text. The code `evaluation.run_part_missing` is lost where `send` turns the assemble error into a fault, so no consumer can read it. Carrying it would change the report document, which this campaign does not own. The gate now asks that only the kind that needs the missing part fails, and the lost code goes to the close-out as an observation. Co-Authored-By: Claude Opus 5.5 --- __roadmap__/m6_gaps/README.md | 2 +- __roadmap__/m6_gaps/needs_batches.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/__roadmap__/m6_gaps/README.md b/__roadmap__/m6_gaps/README.md index 01df8a3d..42139cff 100644 --- a/__roadmap__/m6_gaps/README.md +++ b/__roadmap__/m6_gaps/README.md @@ -40,7 +40,7 @@ Every job kind that ends on a refusal leaves that refusal's code in `jobs//r - ⬜ `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo nextest run --workspace` and `RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps` pass on the tip - ⬜ `container-e2e` on the integration pull request lists `opencode_real_binary_is_interrupted_by_the_stop_script` and `guard_harness_check_refuses` as PASS - ⬜ A run job refused at job start leaves `jobs//refusal.json`, a `refusal/1` record that names its code, side and pointer, for each of `experiment.harness_rejected_input`, `jobs.config_check_failed` and `jobs.server_exited_at_start` (the code a server that exits at start raises; `jobs.server_check_failed` goes through the same `ServerCheckError` path and needs no row of its own) -- ⬜ For a plug-in with an artifacts- or manifest-only kind A and a trace kind B, on a run with no trace A is graded and B carries `evaluation.run_part_missing`; on a run with a trace, A's context digest is the same for suite {A} and suite {A, B} +- ⬜ For a plug-in with an artifacts- or manifest-only kind A and a trace kind B, on a run with no trace A is graded and only B's request fails, with the missing-part refusal (`run stores no `trace``; the engine reports a failed request as text, so its code `evaluation.run_part_missing` is recorded as an observation, not carried); on a run with a trace, A's context digest is the same for suite {A} and suite {A, B} - ⬜ Each review report answers both of its lenses with evidence, and each finding is fixed on the leaf branch or recorded as an observation with its reason before that leaf merges - ⬜ The pull request `merge(api): close three M6 gaps before M7` is opened only after the maintainer's go; after it merges, the CI release cuts 0.20.0 - ⬜ Spend is measured from transcripts per leaf, and no leaf passed its cap without stopping. Leaf estimates add to $10.6 and caps to $21.2; with the lead's $4–7, the campaign stays within the cap the maintainer approves diff --git a/__roadmap__/m6_gaps/needs_batches.md b/__roadmap__/m6_gaps/needs_batches.md index 571d40f2..7401cf5e 100644 --- a/__roadmap__/m6_gaps/needs_batches.md +++ b/__roadmap__/m6_gaps/needs_batches.md @@ -6,7 +6,7 @@ - [ ] `[cmd]` `git -C merge-base --is-ancestor fix/m6-gaps HEAD` succeeds **Success Gates**: - ⬜ The probe's answer is recorded: whether `run_batch`, the stage loop or the `Interleaved` check assumes one batch per evaluator and stage; if it does, the leaf stopped and reported before step 2 -- ⬜ A new guard, "a kind's result does not depend on the kinds sent beside it", holds two cases through the engine with the test plug-in fixture: on a run sealed with no trace, kind A (artifacts or manifest only) is graded and kind B (trace) carries `evaluation.run_part_missing`; on a run with a trace, A's stamped `context_digest` is equal for suite {A} and suite {A, B}. Both cases are red on the base, with the messages in the leaf report +- ⬜ A new guard, "a kind's result does not depend on the kinds sent beside it", holds two cases through the engine with the test plug-in fixture: on a run sealed with no trace, kind A (artifacts or manifest only) is graded and only kind B's (trace) request fails, with the missing-part refusal text (`run stores no `trace``), since `EvaluateReport.failed_requests` holds text only; on a run with a trace, A's stamped `context_digest` is equal for suite {A} and suite {A, B}. Both cases are red on the base, with the messages in the leaf report - ⬜ `guard_engine::dependencies_and_applies_to_decide_what_is_sent` is extended so its dependent entries declare different needs; it passes on the base and the tip, and goes red under the bite "split every entry by its own needs" - ⬜ Every existing test that asserted one request per evaluator and stage is changed on purpose and named in the fix commit's body, which also says that outcomes stored from mixed batches miss reuse once - ⬜ No unit test of `plan()`'s grouping remains, and no per-entry digest or refusal machinery (Idea B) was added From dfca5d12a20de53d88ad37dee516ef0626f1cd6f Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 16:52:05 +0900 Subject: [PATCH 20/38] rdm(api): send the needs batches to their review Co-Authored-By: Claude Opus 5.5 --- __roadmap__/m6_gaps/README.md | 4 ++-- __roadmap__/m6_gaps/review/README.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/__roadmap__/m6_gaps/README.md b/__roadmap__/m6_gaps/README.md index 42139cff..18d41d51 100644 --- a/__roadmap__/m6_gaps/README.md +++ b/__roadmap__/m6_gaps/README.md @@ -56,7 +56,7 @@ Every job kind that ends on a refusal leaves that refusal's code in `jobs//r graph TD opencode_stop_guard[OpenCode stop guard]:::done job_refusal_record[Job refusal record]:::done - needs_batches[Needs batches]:::inprogress + needs_batches[Needs batches]:::done review[Review]:::inprogress classDef done fill:#166534,color:#bbf7d0 classDef inprogress fill:#854d0e,color:#fef08a @@ -70,7 +70,7 @@ graph TD |:-----|:-----|:-------| | `opencode_stop_guard.md` | 📄 Leaf Task | ✅ Done | | `job_refusal_record.md` | 📄 Leaf Task | ✅ Done | -| `needs_batches.md` | 📄 Leaf Task | 🔄 In Progress | +| `needs_batches.md` | 📄 Leaf Task | ✅ Done | | `review/` | 📁 Directory | 🔄 In Progress | ## Amendment Log diff --git a/__roadmap__/m6_gaps/review/README.md b/__roadmap__/m6_gaps/review/README.md index 19f5d27f..b4676e16 100644 --- a/__roadmap__/m6_gaps/review/README.md +++ b/__roadmap__/m6_gaps/review/README.md @@ -24,7 +24,7 @@ Each risky change is judged on validity and on develop, leave and consume before ```mermaid graph TD review_job_refusal[Review: job refusal]:::done - review_needs_batches[Review: needs batches]:::planned + review_needs_batches[Review: needs batches]:::inprogress close[Close]:::planned classDef done fill:#166534,color:#bbf7d0 classDef inprogress fill:#854d0e,color:#fef08a @@ -37,7 +37,7 @@ graph TD | Node | Type | Status | |:-----|:-----|:-------| | `review_job_refusal.md` | 📄 Leaf Task | ✅ Done | -| `review_needs_batches.md` | 📄 Leaf Task | ⬜ Planned | +| `review_needs_batches.md` | 📄 Leaf Task | 🔄 In Progress | | `close/` | 📁 Directory | ⬜ Planned | ## Amendment Log From 771760e894cfe2f2fe4d529568c5e8aff273cb21 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 15:08:04 +0900 Subject: [PATCH 21/38] test(evaluation): state that a kind's result ignores the kinds beside it Two guards at engine scope with the test plug-in: on a run sealed with no trace, a manifest-only kind is graded and a trace kind alone is refused; on a run with a trace, a kind's stamped context digest is the same whether the suite holds it alone or beside a trace kind. Both are red on the base: the engine sends one request per evaluator and stage with the union of the needs. Adds the kinds reads_manifest and reads_trace and two suites, and says in the dependency guard's doc comment that its dependents declare needs of their own. Co-Authored-By: Claude Sonnet 5.5 --- .../m6_gaps/leaves/needs_batches_v0.md | 22 ++++++ .../tests/fixtures/engine/README.md | 4 +- .../fixtures/engine/kinds/engine_fixture.py | 22 +++++- .../fixtures/engine/suite_needs_alone.toml | 13 ++++ .../fixtures/engine/suite_needs_beside.toml | 25 +++++++ crates/candler-core/tests/it/guard_engine.rs | 74 ++++++++++++++++++- .../tests/it/guard_run_context.rs | 2 +- 7 files changed, 157 insertions(+), 5 deletions(-) create mode 100644 __reports__/m6_gaps/leaves/needs_batches_v0.md create mode 100644 crates/candler-core/tests/fixtures/engine/suite_needs_alone.toml create mode 100644 crates/candler-core/tests/fixtures/engine/suite_needs_beside.toml diff --git a/__reports__/m6_gaps/leaves/needs_batches_v0.md b/__reports__/m6_gaps/leaves/needs_batches_v0.md new file mode 100644 index 00000000..8a71c869 --- /dev/null +++ b/__reports__/m6_gaps/leaves/needs_batches_v0.md @@ -0,0 +1,22 @@ +# Needs batches — Leaf report (v0) + +Leaf: `__roadmap__/m6_gaps/needs_batches.md`. Branch `fix/needs-batches`. Status: step 1 done. + +## Probe: does the engine assume one batch per (evaluator, stage)? + +No. `run_plan` walks `plan.batches` in stage order and groups consecutive batches of one stage; it never keys by evaluator. `run_batch` and `attempt` take one `Batch` and read `finished` (keyed by `ExpectationId`) and `na_ids`. The `Interleaved` refusal is raised by `stages()` per dependency component. The one pairing with the evaluator is `na_left`: a not-applicable entry is published by the first batch of its evaluator in the run, whichever batch that is, so several batches of one evaluator and stage are safe. Decision: go on. + +## Guard 1: a kind's result ignores the kinds beside it + +Two tests in `crates/candler-core/tests/it/guard_engine.rs`, with kinds `reads_manifest` (A1) and `reads_trace` (B1) added to `engine_fixture.py` and the suites `suite_needs_alone.toml` and `suite_needs_beside.toml`; the traceless run is sealed with `seal_with_inputs` (now `pub(crate)` in `guard_run_context.rs`). + +The engine reports a refused request as a failed request with the error text (`run stores no `trace``), not as a record carrying `evaluation.run_part_missing`: the code is lost between `assemble` and `Fault`. The refusal case therefore asserts on that text. + +Red on the base, verbatim: + +- `a_kinds_refusal_ignores_the_kinds_beside_it`: `assertion `left == right` failed: on a run with no trace A1 is graded and B1 is not; failed requests: [(RequestId { text: "01a23037-7680-7771-a494-e25be65edb6d" }, "run 8f82869f4eb3438f27acf835f43e91f2a3c35a303264305ba58de1732a64d38d-r6-a2 stores no `trace`")] left: [] right: ["A1"]` +- `a_kinds_reuse_key_ignores_the_kinds_beside_it`: `assertion `left == right` failed: A1's context digest under suite {A} and under suite {A, B} left: "sha256:5ac2394fac9c78d746ddf53336f8c43a14de1209d4dcc75bc6d4395f6d8c9ed8" right: "sha256:5b92ae6d3d70ba1a6724da88da03ae843d419b65c6790c73bc9c3b021cbee530"` + +## Guard 2: `dependencies_and_applies_to_decide_what_is_sent` + +On the base it passes (PASS, 5.8 s). Its dependents already declare other needs than their dependencies (`echo` reads artifacts and metadata; `ok` and `fail` read nothing), so no fixture change was needed; its doc comment now says so and names its bite. diff --git a/crates/candler-core/tests/fixtures/engine/README.md b/crates/candler-core/tests/fixtures/engine/README.md index d2c5c444..f98f7977 100644 --- a/crates/candler-core/tests/fixtures/engine/README.md +++ b/crates/candler-core/tests/fixtures/engine/README.md @@ -5,7 +5,7 @@ Read by `guard_engine`. The guard fills the `@...@` tokens at run time and runs | Path | Holds | |---|---| | `plugin.toml` | the manifest of the `engine` plug-in; it runs the helper from `python/candler-evaluator` under `uv run --frozen`, with `PYTHONPATH` set to the helper's example plug-ins and `kinds/`. `@EXAMPLES@` and `@KINDS@` are absolute paths | -| `kinds/engine_fixture.py` | the plug-in module: the helper's `ok` (synthetic) and `echo` kinds, the `fail` kind and the `counter` kind; `counter` keeps its count in the file its `file` param names. `echo` gets the needs of the parity suite so that it echoes the live context | +| `kinds/engine_fixture.py` | the plug-in module: the helper's `ok` (synthetic) and `echo` kinds, the `fail` kind, the `counter` kind, and `reads_manifest` and `reads_trace`, which each declare one part of a run; `counter` keeps its count in the file its `file` param names. `echo` gets the needs of the parity suite so that it echoes the live context | | `suite_dependencies.toml` | five entries: one with an `applies_to` miss, a `fail` with a dependent, a `pass` with a dependent | | `plugin_bare.toml` | the same manifest with a bare `python -m candler_evaluator ...` command: it runs only inside the activated environment, with no `uv run` | | `suite_dependencies.json` | `suite_dependencies.toml` written as JSON; the engine reads `.json` files as JSON | @@ -21,3 +21,5 @@ Read by `guard_engine`. The guard fills the `@...@` tokens at run time and runs | `suite_pool_ok.toml` | one `ok` entry of `pool` | | `suite_pool_interval.toml` | one `interval` entry of `pool`; `@FILE@` is the interval file and `@SLEEP@` the sleep in seconds | | `suite_pool_stray.toml` | one `stray` entry of `pool`; `@PIDFILE@` is the file that receives the stray's pid | +| `suite_needs_alone.toml` | A1, a `reads_manifest` entry of `engine`: it needs the manifest and nothing else | +| `suite_needs_beside.toml` | A1 and B1, a `reads_trace` entry of `engine`: two independent entries whose kinds need different parts of a run | diff --git a/crates/candler-core/tests/fixtures/engine/kinds/engine_fixture.py b/crates/candler-core/tests/fixtures/engine/kinds/engine_fixture.py index 647cf3f5..7a0532cb 100644 --- a/crates/candler-core/tests/fixtures/engine/kinds/engine_fixture.py +++ b/crates/candler-core/tests/fixtures/engine/kinds/engine_fixture.py @@ -1,4 +1,5 @@ -"""The kinds of the engine guards: the helper's `ok` and `echo` kinds, a `fail` and a `counter`. +"""The kinds of the engine guards: the helper's `ok` and `echo` kinds, a `fail`, a `counter`, and +`reads_manifest` and `reads_trace`, which declare one part of a run each. The echo kind is the helper's own, with the needs of the parity suite so that the context it echoes is the live one. `counter` keeps its count in the file named by its `file` param. @@ -19,6 +20,8 @@ "metadata": ["plan.prompt_domain_name"], } }, + "reads_manifest": {"needs": {"manifest": True}}, + "reads_trace": {"needs": {"trace": True}}, } @@ -33,4 +36,19 @@ def counter(params, context, prior): return {"status": "pass", "value": {"kind": "count", "count": count}} -KINDS = {"ok": ok, "echo": echo, "fail": fail, "counter": counter} +def reads_manifest(params, context, prior): + return {"status": "pass", "evidence": [{"note": "manifest only"}]} + + +def reads_trace(params, context, prior): + return {"status": "pass", "evidence": [{"note": "trace only"}]} + + +KINDS = { + "ok": ok, + "echo": echo, + "fail": fail, + "counter": counter, + "reads_manifest": reads_manifest, + "reads_trace": reads_trace, +} diff --git a/crates/candler-core/tests/fixtures/engine/suite_needs_alone.toml b/crates/candler-core/tests/fixtures/engine/suite_needs_alone.toml new file mode 100644 index 00000000..979d6b3d --- /dev/null +++ b/crates/candler-core/tests/fixtures/engine/suite_needs_alone.toml @@ -0,0 +1,13 @@ +schema = "suite/1" + +[[expectations]] +id = "A1" +role = "gate" +kind = "reads_manifest" +depends_on = [] + +[expectations.evaluator] +name = "engine" +range = "^0.1" + +[expectations.params] diff --git a/crates/candler-core/tests/fixtures/engine/suite_needs_beside.toml b/crates/candler-core/tests/fixtures/engine/suite_needs_beside.toml new file mode 100644 index 00000000..11aa26b4 --- /dev/null +++ b/crates/candler-core/tests/fixtures/engine/suite_needs_beside.toml @@ -0,0 +1,25 @@ +schema = "suite/1" + +[[expectations]] +id = "A1" +role = "gate" +kind = "reads_manifest" +depends_on = [] + +[expectations.evaluator] +name = "engine" +range = "^0.1" + +[expectations.params] + +[[expectations]] +id = "B1" +role = "gate" +kind = "reads_trace" +depends_on = [] + +[expectations.evaluator] +name = "engine" +range = "^0.1" + +[expectations.params] diff --git a/crates/candler-core/tests/it/guard_engine.rs b/crates/candler-core/tests/it/guard_engine.rs index fe6373d0..330b4bcf 100644 --- a/crates/candler-core/tests/it/guard_engine.rs +++ b/crates/candler-core/tests/it/guard_engine.rs @@ -325,8 +325,12 @@ fn reason_of(record: &OutcomeRecord) -> String { /// kind returns. A second suite lists D1 before its dependency P3: D1 is sent after P3 and sees it /// in `prior`; the dependent N2 of the `not_applicable` N1 is `blocked` and not sent. The same /// verdicts hold when the suite is written as JSON, and when the -/// manifest's command is a bare `python -m` that only the activated environment resolves. +/// manifest's command is a bare `python -m` that only the activated environment resolves. Each +/// dependent declares other needs than its dependency (`echo` reads artifacts and metadata, `ok` +/// and `fail` read nothing), and still shares its dependency's request. /// Oracle: the hand literals below. +/// Bite: splitting every entry by its own needs sends a dependent apart from its dependency, so +/// the request ids differ and the dependent's `prior` lacks it. #[tokio::test] async fn dependencies_and_applies_to_decide_what_is_sent() { for (manifest, suite) in [ @@ -603,6 +607,74 @@ async fn the_persisted_context_digest_is_the_digest_of_what_the_plugin_received( } } +/// Guards: a kind's result ignores the kinds sent beside it (refusal). On a run sealed with no +/// trace, the manifest-only kind A1 is graded and the trace kind B1 alone is refused, so the +/// report holds A1's record and exactly one failed request, whose reason names the missing +/// `trace`. Oracle: the hand literals below. +/// Bite: grouping a stage's entries by evaluator alone sends A1 and B1 in one request, which the +/// missing trace refuses whole. +#[tokio::test] +async fn a_kinds_refusal_ignores_the_kinds_beside_it() { + let sealed = rig().await; + let template = sealed.run_of(6); + let bare = { + let store = Store::open(&sealed.store).expect("the store opens"); + crate::guard_run_context::seal_with_inputs(&store, &template, 2, &[], &[]) + }; + let report = sealed + .grade("suite_needs_beside.toml", "*-r6-a2", Path::new("unused")) + .await; + let records = sealed.records(&bare); + let graded: Vec<&str> = records + .iter() + .map(|(_, record)| record.expectation_id().as_str()) + .collect(); + assert_eq!( + graded, + ["A1"], + "on a run with no trace A1 is graded and B1 is not; failed requests: {:?}", + report.failed_requests + ); + assert_eq!(record(&records, "A1").1.status(), Status::Pass, "A1"); + assert_eq!( + report.failed_requests.len(), + 1, + "B1 alone is refused: {:?}", + report.failed_requests + ); + let reason = &report.failed_requests[0].1; + assert!( + reason.contains("stores no `trace`") && reason.contains(&bare.to_string()), + "the refusal names the missing trace and the run: {reason}" + ); +} + +/// Guards: a kind's result ignores the kinds sent beside it (reuse key). On a run with a trace, +/// the stamped `context_digest` of the manifest-only kind A1 is the same when the suite is {A1} +/// and when it is {A1, B1}, because B1's need for the trace is no part of A1's request. +/// Oracle: the digest A1 is stamped with under suite {A1} is the expected value for {A1, B1}. +/// Bite: grouping a stage's entries by evaluator alone gives A1 a context that also serves the +/// trace, so its digest changes when B1 joins. +#[tokio::test] +async fn a_kinds_reuse_key_ignores_the_kinds_beside_it() { + let mut digests = Vec::new(); + for suite in ["suite_needs_alone.toml", "suite_needs_beside.toml"] { + let fresh = rig().await; + let report = fresh.grade(suite, "*-r6-a1", Path::new("unused")).await; + assert!( + report.failed_requests.is_empty(), + "{suite}: {:?}", + report.failed_requests + ); + let records = fresh.records(&fresh.run_of(6)); + digests.push(record(&records, "A1").1.context_digest().to_string()); + } + assert_eq!( + digests[0], digests[1], + "A1's context digest under suite {{A}} and under suite {{A, B}}" + ); +} + /// Guards: R5 — two regrades of one run with the counter kind each send a request, write their /// own outcome file, and the second file's value differs under the same I4 key, so selection flags /// it. Oracle: the hand literals: the counter reads 1, then 2. diff --git a/crates/candler-core/tests/it/guard_run_context.rs b/crates/candler-core/tests/it/guard_run_context.rs index 8a1a4f58..846fa9cb 100644 --- a/crates/candler-core/tests/it/guard_run_context.rs +++ b/crates/candler-core/tests/it/guard_run_context.rs @@ -673,7 +673,7 @@ fn store_inputs(store: &Store, vector: &toml::Value) -> Vec { /// Seals a run beside `template` whose manifest names `comparable` in `comparable.inputs` and /// `evaluation` in `evaluation_inputs`, as `(kind, digest)` pairs, and has no outputs. -fn seal_with_inputs( +pub(crate) fn seal_with_inputs( store: &Store, template: &RunKey, attempt: u32, From e44f4c31e2a2e29b223997eebfdc37468934568c Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 15:43:05 +0900 Subject: [PATCH 22/38] fix(evaluation): split an evaluator's stage by its kinds' needs plan() keyed a batch by (stage, evaluator), so every kind of an evaluator at one stage was sent in one request with the union of their needs. A kind's context digest, and so its reuse key, changed when another kind joined the suite, and a part the run lacked refused all the kinds of the request. A batch is now keyed by (stage, evaluator, needs), where needs is the union over the members of one dependency component, compared as sets. Entries that depend on each other in one evaluator are one component, so they still share a request and the dependent still receives its prior. Components with equal needs still share a request. Stages, send and attempt do not change, and nothing changes on the wire. Existing tests that asserted one request per evaluator and stage: none had to change, because their kinds have equal needs or one component (guard_engine independent_entries_of_one_evaluator_share_one_request and the deadline guard); the first guard's doc comment and message now say "as the needs are equal". Outcomes stored from today's mixed batches miss reuse once, because their context digest changes. Every record valid before stays valid. Co-Authored-By: Claude Sonnet 5.5 --- .../src/evaluation/engine/plan.rs | 48 ++++++++++++++----- crates/candler-core/tests/it/guard_engine.rs | 12 +++-- 2 files changed, 43 insertions(+), 17 deletions(-) diff --git a/crates/candler-core/src/evaluation/engine/plan.rs b/crates/candler-core/src/evaluation/engine/plan.rs index 9fe646ed..04094d56 100644 --- a/crates/candler-core/src/evaluation/engine/plan.rs +++ b/crates/candler-core/src/evaluation/engine/plan.rs @@ -7,14 +7,16 @@ use std::collections::{BTreeMap, BTreeSet}; -use candler_schemas::evaluation::SuiteEntry; +use candler_schemas::evaluation::{Needs, SuiteEntry}; use candler_schemas::execution::RunManifest; use candler_schemas::primitives::{ExpectationId, Name, RunKey}; +use crate::evaluation::context::union_needs; use crate::evaluation::registry::{CheckedEntry, CheckedSuite}; -/// The entries of one request: every applicable entry of one evaluator at one stage, in an order -/// in which every dependency comes before its dependents. +/// The entries of one request: the applicable entries of one evaluator at one stage whose +/// dependency components need the same parts of a run, in an order in which every dependency comes +/// before its dependents. #[derive(Debug, Clone, PartialEq)] #[non_exhaustive] pub struct Batch { @@ -35,7 +37,8 @@ pub struct RunPlan { pub run: RunKey, /// The entries that do not apply to the run, in suite order. They are never sent. pub not_applicable: Vec, - /// The batches, one per evaluator and stage, ordered by stage, then by evaluator name. + /// The batches, one per evaluator, stage and set of needs, ordered by stage, then by evaluator + /// name. pub batches: Vec, } @@ -103,9 +106,10 @@ pub fn applies(run: &RunManifest, entry: &SuiteEntry) -> bool { /// Plans `suite` for the run whose manifest is `run`. /// /// An entry that does not apply becomes a `not_applicable` entry of the plan. The entries that -/// apply are grouped into one batch per evaluator and stage; a dependency on another evaluator's -/// entry puts the dependent in a later stage, and a dependency on the same evaluator's entry keeps -/// both in one batch, dependency first. +/// apply are grouped into one batch per evaluator, stage and set of needs, where the needs of a +/// group of entries that depend on each other are the union of their kinds'; a dependency on +/// another evaluator's entry puts the dependent in a later stage, and a dependency on the same +/// evaluator's entry keeps both in one batch, dependency first. /// /// # Errors /// Returns [`PlanError::UnknownDependency`] for a dependency that names no entry, @@ -169,22 +173,29 @@ pub fn plan(run: &RunManifest, suite: &CheckedSuite) -> Result> = BTreeMap::new(); + // One request carries the components of one evaluator, at one stage, whose needs are the same: + // each kind is served, and its digest covers, what its own component asks for. Components of + // the same evaluator never depend on each other (such an edge would have joined them), so + // splitting a stage by needs orders nothing the dependencies did not already order. + let mut groups: BTreeMap<(usize, &Name, String), Vec> = BTreeMap::new(); for (head, members) in &components { let stage = stage_of.get(head).copied().unwrap_or_default(); if let Some(evaluator) = members.first().and_then(|at| evaluator_of(entries, *at)) { + let needs = union_needs( + members + .iter() + .filter_map(|at| entries.get(*at)) + .map(|checked| &checked.spec.needs), + ); groups - .entry((stage, evaluator)) + .entry((stage, evaluator, needs_key(&needs))) .or_default() .extend(members.iter().copied()); } } let mut batches: Vec<(usize, Batch)> = groups .iter() - .map(|((stage, evaluator), members)| { + .map(|((stage, evaluator, _), members)| { let ordered = order(members, &deps); let first = ordered.iter().copied().min().unwrap_or_default(); let checked = ordered @@ -213,6 +224,17 @@ pub fn plan(run: &RunManifest, suite: &CheckedSuite) -> Result String { + let mut value = serde_json::to_value(needs).unwrap_or_default(); + if let Some(fields) = value.as_object_mut() { + for list in fields.values_mut().filter_map(|field| field.as_array_mut()) { + list.sort_by_key(ToString::to_string); + } + } + value.to_string() +} + /// The evaluator name of the entry at `at`. fn evaluator_of<'a>(entries: &'a [CheckedEntry], at: usize) -> Option<&'a Name> { entries diff --git a/crates/candler-core/tests/it/guard_engine.rs b/crates/candler-core/tests/it/guard_engine.rs index 330b4bcf..5ebe54fe 100644 --- a/crates/candler-core/tests/it/guard_engine.rs +++ b/crates/candler-core/tests/it/guard_engine.rs @@ -452,9 +452,9 @@ async fn dependency_verdicts(manifest: &str, suite: &str) { ); } -/// Guards: R6 (A1) — one request carries every applicable entry of one evaluator at one stage: -/// two independent entries of one evaluator share a request id, and the entry of a second -/// evaluator has a request of its own. Oracle: the hand literals below, read from the outcome +/// Guards: R6 (A1) — one request carries the entries of one evaluator at one stage that need the +/// same parts of a run: two independent entries of one evaluator with equal needs share a request +/// id, and the entry of a second evaluator has a request of its own. Oracle: the hand literals below, read from the outcome /// files. #[tokio::test] async fn independent_entries_of_one_evaluator_share_one_request() { @@ -482,7 +482,11 @@ async fn independent_entries_of_one_evaluator_share_one_request() { "{:?}", report.failed_requests ); - assert_eq!(report.request_ids.len(), 2, "one request per evaluator"); + assert_eq!( + report.request_ids.len(), + 2, + "one request per evaluator, as the needs are equal" + ); let run = rig.run_of(6); let engine = rig.records_of(&run, "engine"); From b64b880ef3a964ca5d7204f96a7c365d50c80ec6 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 16:44:55 +0900 Subject: [PATCH 23/38] docs(evaluator-protocol): serve each kind the needs of its own request The Notes bullet said context and digest cover the request's kinds together and a missing part refuses the request. A request now holds the kinds with equal needs, so the bullet says that kinds with equal needs share request and digest and a missing part refuses only them, with a new stamp and the page's Notes still at 120 words. The doc comment of assemble and the architecture's evaluator-protocol paragraph, the one other place that states the union rule, say the same. Co-Authored-By: Claude Sonnet 5.5 --- __design__/architecture.md | 3 ++- crates/candler-core/src/evaluation/context/assemble.rs | 6 ++++-- docs/contract/evaluator-protocol.md | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/__design__/architecture.md b/__design__/architecture.md index a6d375f8..fb562019 100644 --- a/__design__/architecture.md +++ b/__design__/architecture.md @@ -1049,7 +1049,8 @@ snapshots[] (kinds), inputs[] (kinds), metadata[] (run-manifest field paths)}`; without a run; an `inputs` need for `build_inputs` is refused there, by name. A need a run cannot meet, such as a kind the run holds in neither list, is refused for that run, by name. The core builds one context per request, from the union of the needs of the kinds the request -sends; a part the run does not store refuses the whole request. +sends. A request holds the kinds of one evaluator and stage whose entries, with those they depend +on, have the same needs; a part the run does not store refuses only the requests that need it. **Run context:** `run` (key); `root` (a read-only, workspace-shaped view of the run: content- addressed blobs materialised under their workspace paths as private copies, so `domain.py` diff --git a/crates/candler-core/src/evaluation/context/assemble.rs b/crates/candler-core/src/evaluation/context/assemble.rs index 61ba0c55..991a9600 100644 --- a/crates/candler-core/src/evaluation/context/assemble.rs +++ b/crates/candler-core/src/evaluation/context/assemble.rs @@ -117,8 +117,10 @@ impl Assembled { /// Chooses the stored files and the metadata of the sealed run `run` that `needs` name. /// /// A context serves exactly what the needs name. The engine builds one context per request, from -/// the union of the needs of the kinds of the entries the request sends, so a part is served -/// when a kind of the request needs it. The artifacts are the files of the run's +/// the union of the needs of the entries the request sends. A request holds the entries of one +/// evaluator and stage whose dependency components have the same union, so a part is served when +/// a kind of its own component needs it, and a part the run lacks refuses only the requests that +/// need it. The artifacts are the files of the run's /// stored `outputs/` that the file rule keeps for the artifact globs, by path relative to /// `outputs/`. There is one metadata entry per metadata need, keyed by the dotted path, holding /// the JSON leaf of the manifest's `comparable.values`. There is one input per input need: the diff --git a/docs/contract/evaluator-protocol.md b/docs/contract/evaluator-protocol.md index 01cc8861..f1b63aaf 100644 --- a/docs/contract/evaluator-protocol.md +++ b/docs/contract/evaluator-protocol.md @@ -538,4 +538,4 @@ Wire line: `schemas@0.15.0`. - An `evaluate` request ends with the result `{"reported": n}`, after its `n` outcome notifications. [checked: candler-evaluator@0.1.0] - Candler does not compare protocol versions: any `describe` protocol is accepted. [checked: v@0.6.0] - Each output keeps its execute bit; its copy at `context.artifacts[].abs` is read-only, `0555` for an executable and `0444` otherwise. [checked: schemas@0.12.0] -- Context and digest cover the request's kinds together; a part the run lacks refuses the request. [checked: v@0.16.0] +- Kinds with equal needs share request and digest; a part the run lacks refuses only them. [checked: v@0.19.0] From 629400dc2452fd00fea21bfbdc9ee4bd6fcd7091 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 16:51:07 +0900 Subject: [PATCH 24/38] reports(evaluation): close the needs batches Leaf report: the probe's answer, the base and bite messages of both guards, the fix, the docs, the whole-workspace gate and the observations (the refusal code dropped at send, and the wiring timing guard under load). The dependency guard's doc comment now names the failure its bite produces. Co-Authored-By: Claude Sonnet 5.5 --- .../m6_gaps/leaves/needs_batches_v0.md | 27 ++++++++++++++++++- crates/candler-core/tests/it/guard_engine.rs | 2 +- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/__reports__/m6_gaps/leaves/needs_batches_v0.md b/__reports__/m6_gaps/leaves/needs_batches_v0.md index 8a71c869..ddd63eb8 100644 --- a/__reports__/m6_gaps/leaves/needs_batches_v0.md +++ b/__reports__/m6_gaps/leaves/needs_batches_v0.md @@ -1,6 +1,6 @@ # Needs batches — Leaf report (v0) -Leaf: `__roadmap__/m6_gaps/needs_batches.md`. Branch `fix/needs-batches`. Status: step 1 done. +Leaf: `__roadmap__/m6_gaps/needs_batches.md`. Branch `fix/needs-batches`. Status: steps 1 to 4 done. ## Probe: does the engine assume one batch per (evaluator, stage)? @@ -20,3 +20,28 @@ Red on the base, verbatim: ## Guard 2: `dependencies_and_applies_to_decide_what_is_sent` On the base it passes (PASS, 5.8 s). Its dependents already declare other needs than their dependencies (`echo` reads artifacts and metadata; `ok` and `fail` read nothing), so no fixture change was needed; its doc comment now says so and names its bite. + +## Fix (step 2) + +`plan()` keys a batch by `(stage, evaluator, needs_key)`, where `needs_key` is the set-equal text of `union_needs` over one dependency component, computed once per component. Nothing else changed. No existing test had to change (their kinds have equal needs or one component); the batching guard's doc comment and message now say the needs are equal. Outcomes stored from mixed batches miss reuse once. + +Green on the tip: `a_kinds_refusal_ignores_the_kinds_beside_it`, `a_kinds_reuse_key_ignores_the_kinds_beside_it`, `dependencies_and_applies_to_decide_what_is_sent`, `independent_entries_of_one_evaluator_share_one_request` (13 of 13 `guard_engine` tests pass). + +## Docs (step 3) + +The Notes bullet of `docs/contract/evaluator-protocol.md` is now "Kinds with equal needs share request and digest; a part the run lacks refuses only them." with stamp `v@0.19.0`; the Notes stay at 120 words (the old bullet was 16 words; a longer one that also named dependencies broke the limit, so the dependency rule is in the other two places). The doc comment of `assemble` and `__design__/architecture.md` (the paragraph under "Evaluator protocol", outside the leaf's file list, the one other statement of the union rule) say the same. The page regenerated with no other change; `contract_pages::` passes without the bless variable. + +## Bites (step 4), on a scratch branch since deleted + +- Restoring the `(stage, evaluator)` key: both new guards red with the same messages as on the base (A1 absent with `stores no `trace``; digests `sha256:5ac2394f…` against `sha256:5b92ae6d…`). The dependency guard and the batching guard stay green. +- Keying every entry by its own needs: `dependencies_and_applies_to_decide_what_is_sent` red with `[(RequestId {...}, "F2 depends on F1, which has no outcome because its request failed")]` at `guard_engine.rs:384`. The new guards stay green. + +## Observations + +- O1. `evaluation.run_part_missing` is dropped at `send`'s `Fault::new(error.to_string())` in `crates/candler-core/src/evaluation/engine/run.rs`, so `EvaluateReport.failed_requests` holds text only. Carrying the code would change the report document, which this campaign does not own. The refusal guard asserts the text. +- O2. A refused request leaves no file, so the not_applicable records that the batch would have published also go missing (existing behaviour: the first batch of an evaluator publishes them). With split batches, a refusal of that first batch now loses them where before it lost them together with everything; not changed. +- O3. Timing guard (O15 family): `guard_wiring::wiring_stop_execs_in_the_container_with_the_observed_id` failed in the first whole-workspace run (136.7 s, `children/container-000000000000.json did not appear`) and passed alone (91.9 s). + +## Gate on the final tree + +`cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings` and `RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps` pass. `cargo nextest run --workspace`: 774 passed, 0 failed (190.6 s; the wiring guard of O3 passed in this run). `git grep -n confirm_ -- crates python` prints nothing. diff --git a/crates/candler-core/tests/it/guard_engine.rs b/crates/candler-core/tests/it/guard_engine.rs index 5ebe54fe..e9cb3e63 100644 --- a/crates/candler-core/tests/it/guard_engine.rs +++ b/crates/candler-core/tests/it/guard_engine.rs @@ -330,7 +330,7 @@ fn reason_of(record: &OutcomeRecord) -> String { /// and `fail` read nothing), and still shares its dependency's request. /// Oracle: the hand literals below. /// Bite: splitting every entry by its own needs sends a dependent apart from its dependency, so -/// the request ids differ and the dependent's `prior` lacks it. +/// the dependent's request fails with "F2 depends on F1, which has no outcome". #[tokio::test] async fn dependencies_and_applies_to_decide_what_is_sent() { for (manifest, suite) in [ From 4811b113cf9ff44387c841ff588074a50b7a05d3 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 16:59:26 +0900 Subject: [PATCH 25/38] reports(evaluation): review the needs batches Cold review of fix/needs-batches: validity, scope, leave, and request counts on both branches, with both bites rerun. No blocking finding. Co-Authored-By: Claude Sonnet 5.5 --- .../m6_gaps/reviews/needs_batches_v0.md | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 __reports__/m6_gaps/reviews/needs_batches_v0.md diff --git a/__reports__/m6_gaps/reviews/needs_batches_v0.md b/__reports__/m6_gaps/reviews/needs_batches_v0.md new file mode 100644 index 00000000..0d268566 --- /dev/null +++ b/__reports__/m6_gaps/reviews/needs_batches_v0.md @@ -0,0 +1,66 @@ +# Review: needs batches (v0) + +Branch `fix/needs-batches` against `fix/m6-gaps`. Verdict: mergeable; no blocking finding. All runs are mine, in the builder's target dir; the branch holds no code change from me. + +## Validity + +| Question | Answer | Evidence | +|---|---|---| +| A kind's digest is the same whatever other kinds share its evaluator and stage | Yes, when the others have other needs. | `a_kinds_reuse_key_ignores_the_kinds_beside_it` passes on the tip; red on the base with `A1's context digest under suite {A} and under suite {A, B}` (guard_engine.rs:677). Kinds that have equal needs still share a digest by design. | +| Dependent entries of one evaluator still go in one request with their prior | Yes. | `plan.rs` keys per dependency component (`union_needs` over `members`); `dependencies_and_applies_to_decide_what_is_sent` passes on the tip and `suite_dependencies` sends 1 request on both branches. Its dependents (`echo`) declare other needs than `ok`/`fail`. | +| Prior outcomes served across stages | Unchanged, not newly guarded. | `stages()`, `send`, `attempt` are untouched in the diff; the split only subdivides a stage; 774/774 tests pass. No test is new for this and none needed. | +| Both new cases red under the old key | Yes. | Restored `plan.rs` from `fix/m6-gaps`: `a_kinds_refusal_ignores_the_kinds_beside_it` fails (`on a run with no trace A1 is graded and B1 is not; failed requests: [... stores no trace]`, guard_engine.rs:637) and `a_kinds_reuse_key_...` fails (:677); the other 11 `guard_engine` tests pass. | +| Extended dependency guard red under "every entry by its own needs" | Yes. | Temporary per-entry key: `dependencies_and_applies_to_decide_what_is_sent` red with `F2 depends on F1, which has no outcome because its request failed`. `e1_engine_emits_one_outcome_event_per_committed_record` also goes red, a second witness the leaf did not name. | + +## Develop + +- Scope boundary kept: `run.rs` (`send`, `attempt`, stages) is not in the diff; no schema, wire or contract-type change. Doc and fixture edits only beside `plan.rs`. +- Spend: given by the lead, $4.02 against $2.5 estimate and $5 cap, 1.6x the estimate, under the cap. The diff is 48 lines of `plan.rs`, a fixture kind pair and two tests; the overrun is more than the change explains, but I have no transcript to say why. Not a code finding. +- `suite_needs_alone`/`_beside` and two kinds are the only fixture growth; reasonable. + +## Leave + +- Confined to `plan()`'s grouping key plus a 10-line `needs_key`. No per-entry digest or refusal machinery (Idea B). PASS. +- Cost of the key: `union_needs` once per component, one `serde_json` value and sort per component; negligible next to a process spawn. +- `confirm_`: `git grep -n confirm_ -- crates python` prints nothing; no `plan()` unit test added. PASS. +- Docs at source: `evaluator-protocol.md` Notes bullet (stamp `v@0.19.0`), `assemble.rs` doc comment, `__design__/architecture.md` paragraph. The architecture edit is the one other statement of the union rule, so it is at its source. `git merge-tree --write-tree fix/m6-gaps fix/needs-batches` exits clean (tree 65ca726c); the job_refusal_record leaf edited another paragraph. PASS. +- Commit body of 837e3ba9 states that outcomes from today's mixed batches miss reuse once, and that no existing test needed changing. PASS. + +## Consume and scale + +Requests per run on the engine fixtures (temporary `eprintln` of `report.request_ids.len()` in `grade_within`, reverted; processes equal requests, one per request): + +| Suite (entries; kinds) | Base | Tip | +|---|---|---| +| suite_order (4; echo + 3 ok) | 1 | 2 | +| suite_needs_beside (2; reads_manifest, reads_trace) | 1 | 2 (traceless run: 1 graded, 1 refused) | +| suite_dependencies (5; echo, ok, fail, one component chain) | 1 | 1 | +| suite_batching (3; two evaluators) | 2 | 2 | +| suite_echo, deadlines, counter | 3, 1, 1 | 3, 1, 1 | + +The largest mixed fixture, `suite_order`, doubles from 1 to 2 requests/processes; every other fixture is unchanged. + +Golden suite (htn-creator-eval 0.4.2): the eval spec (13 evals, 43 expectations) carries no needs, they live in the plug-in's kinds. No Candler suite spec of it is on this machine (the Candler suite files are the engine fixtures, a registry fixture and `__reports__/diet/audit`). Inference: the m2a plan for the HTN plug-in (`__roadmap__/m2a-evaluation-parity/components/assembly/htn_plugin.md`) says all its kinds declare the same needs, `artifacts outputs/**` and `metadata plan.prompt_domain_name`. If that holds in 0.4.2, there is one needs set per evaluator and stage, so no extra request. This is an inference from a plan, not a count of the plug-in. + +Growth: requests per evaluator and stage = number of distinct needs sets among its components, between 1 and the number of components; worst case is one process per kind (all kinds with pairwise different needs). It costs nothing when kinds share needs, and each extra process buys a digest and a refusal that no other kind can change. + +## Findings + +| # | Sev | Finding | Smallest fix | Blocking | +|---|---|---|---|---| +| F1 | Low | `needs_key` uses `serde_json::to_value(needs).unwrap_or_default()`; a serialisation failure becomes `Null`, so every component keys equal and the old one-request grouping returns silently (plan.rs, `needs_key`). It cannot fail for this plain struct today. | Use `expect` as the codebase does for infallible serialisation, or key by a sorted tuple of the fields without JSON. | No | +| F2 | Low | The refusal reaches a consumer as text in `EvaluateReport.failed_requests`, not as `evaluation.run_part_missing` (agreed out of scope). A consumer that wants to tell a missing part from a plug-in crash must match the string `stores no trace`; the new guard pins that string. | A later leaf carries the code in `Fault` and the report; then the guard asserts the code. | No | +| F3 | Low | Digest stability across suites rests on `assemble` ordering artifacts and metadata canonically when two components with equal needs sets list them in another order (`needs_key` sorts, `union_needs` keeps insertion order). `assemble` collects into `BTreeMap`s, so it likely holds, but no test varies list order. | Add a case with the same needs in two orders to the reuse guard, or sort in `union_needs`. | No | +| F4 | Info | A refused first batch of an evaluator also loses the `not_applicable` records it would publish (leaf O2, existing behaviour, now narrower). | None now. | No | +| F5 | Info | Spend $4.02 vs $2.5 estimate. | Brief tighter for a leaf this size. | No | +| F6 | Info | A one-line wrap overrun in the `independent_entries_of_one_evaluator_share_one_request` doc comment (guard_engine.rs, longer than 100 columns); `cargo fmt --check` passes, so it is a comment only. | Rewrap. | No | + +## Runs + +- `cargo nextest run --workspace --no-fail-fast` on the tip: 774 passed, 35 skipped, 0 failed (186 s). No timing guard failed, so none was rerun. +- `guard_engine` binary on the tip: 13 of 13; on the base `plan.rs`: 11 of 13, the two new guards red; on the per-entry key: 2 red. + +## Open + +- Not read: the plug-in source of htn-creator-eval 0.4.2 (its needs), so the golden count is an inference. +- Not run: fmt, clippy, doc (the builder reports them green; the workspace test run is mine). From 22ed7d5c73ed2edff3ad7151b6a9deec3fd45a44 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 17:04:50 +0900 Subject: [PATCH 26/38] refactor(evaluation): key a stage's needs by a canonical set needs_key built a JSON text and fell back to Null if serialising failed, which would have restored the one-request grouping without a sign. The key is now a typed NeedsKey: the three flags and the sets of artifact globs, snapshot kinds, input kinds and metadata paths. It cannot fail and is equal for equal needs whatever the order of their lists. Behaviour is unchanged: the digest already sorts artifacts, snapshots and inputs and holds metadata in a map, so list order never reached it. The leaf report records the review's findings and their answers, and the doc comment of the batching guard is rewrapped. Co-Authored-By: Claude Sonnet 5.5 --- .../src/evaluation/engine/plan.rs | 29 +++++++++++++------ crates/candler-core/tests/it/guard_engine.rs | 4 +-- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/crates/candler-core/src/evaluation/engine/plan.rs b/crates/candler-core/src/evaluation/engine/plan.rs index 04094d56..eb3c4172 100644 --- a/crates/candler-core/src/evaluation/engine/plan.rs +++ b/crates/candler-core/src/evaluation/engine/plan.rs @@ -177,7 +177,7 @@ pub fn plan(run: &RunManifest, suite: &CheckedSuite) -> Result> = BTreeMap::new(); + let mut groups: BTreeMap<(usize, &Name, NeedsKey), Vec> = BTreeMap::new(); for (head, members) in &components { let stage = stage_of.get(head).copied().unwrap_or_default(); if let Some(evaluator) = members.first().and_then(|at| evaluator_of(entries, *at)) { @@ -224,15 +224,26 @@ pub fn plan(run: &RunManifest, suite: &CheckedSuite) -> Result String { - let mut value = serde_json::to_value(needs).unwrap_or_default(); - if let Some(fields) = value.as_object_mut() { - for list in fields.values_mut().filter_map(|field| field.as_array_mut()) { - list.sort_by_key(ToString::to_string); - } +/// What a request serves, as a key that is equal for equal needs whatever the order of their +/// lists: the flags and the sets of artifact globs, snapshot kinds, input kinds and metadata paths. +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] +struct NeedsKey { + flags: (bool, bool, bool), + artifacts: BTreeSet, + snapshots: BTreeSet, + inputs: BTreeSet, + metadata: BTreeSet, +} + +/// The key of `needs`. +fn needs_key(needs: &Needs) -> NeedsKey { + NeedsKey { + flags: (needs.trace, needs.raw, needs.manifest), + artifacts: needs.artifacts.iter().cloned().collect(), // BORROW: the key owns its members + snapshots: needs.snapshots.iter().map(ToString::to_string).collect(), + inputs: needs.inputs.iter().map(ToString::to_string).collect(), + metadata: needs.metadata.iter().map(ToString::to_string).collect(), } - value.to_string() } /// The evaluator name of the entry at `at`. diff --git a/crates/candler-core/tests/it/guard_engine.rs b/crates/candler-core/tests/it/guard_engine.rs index e9cb3e63..dec0c1b2 100644 --- a/crates/candler-core/tests/it/guard_engine.rs +++ b/crates/candler-core/tests/it/guard_engine.rs @@ -454,8 +454,8 @@ async fn dependency_verdicts(manifest: &str, suite: &str) { /// Guards: R6 (A1) — one request carries the entries of one evaluator at one stage that need the /// same parts of a run: two independent entries of one evaluator with equal needs share a request -/// id, and the entry of a second evaluator has a request of its own. Oracle: the hand literals below, read from the outcome -/// files. +/// id, and the entry of a second evaluator has a request of its own. Oracle: the hand literals +/// below, read from the outcome files. #[tokio::test] async fn independent_entries_of_one_evaluator_share_one_request() { let rig = rig().await; From 46516fd9fa25fe9b3da672e9d5911d40efcda269 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 17:09:25 +0900 Subject: [PATCH 27/38] rdm(api): close the needs batches review Co-Authored-By: Claude Opus 5.5 --- __roadmap__/m6_gaps/review/README.md | 4 ++-- __roadmap__/m6_gaps/review/close/README.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/__roadmap__/m6_gaps/review/README.md b/__roadmap__/m6_gaps/review/README.md index b4676e16..a3b3af46 100644 --- a/__roadmap__/m6_gaps/review/README.md +++ b/__roadmap__/m6_gaps/review/README.md @@ -24,7 +24,7 @@ Each risky change is judged on validity and on develop, leave and consume before ```mermaid graph TD review_job_refusal[Review: job refusal]:::done - review_needs_batches[Review: needs batches]:::inprogress + review_needs_batches[Review: needs batches]:::done close[Close]:::planned classDef done fill:#166534,color:#bbf7d0 classDef inprogress fill:#854d0e,color:#fef08a @@ -37,7 +37,7 @@ graph TD | Node | Type | Status | |:-----|:-----|:-------| | `review_job_refusal.md` | 📄 Leaf Task | ✅ Done | -| `review_needs_batches.md` | 📄 Leaf Task | 🔄 In Progress | +| `review_needs_batches.md` | 📄 Leaf Task | ✅ Done | | `close/` | 📁 Directory | ⬜ Planned | ## Amendment Log diff --git a/__roadmap__/m6_gaps/review/close/README.md b/__roadmap__/m6_gaps/review/close/README.md index 6cc995a8..5e317b62 100644 --- a/__roadmap__/m6_gaps/review/close/README.md +++ b/__roadmap__/m6_gaps/review/close/README.md @@ -16,7 +16,7 @@ The `fix/m6-gaps` tip passes every gate, and one report closes the three gaps an ## Status ```mermaid graph TD - close_out[Close out]:::planned + close_out[Close out]:::inprogress classDef done fill:#166534,color:#bbf7d0 classDef inprogress fill:#854d0e,color:#fef08a classDef planned fill:#374151,color:#e5e7eb @@ -27,7 +27,7 @@ graph TD ## Nodes | Node | Type | Status | |:-----|:-----|:-------| -| `close_out.md` | 📄 Leaf Task | ⬜ Planned | +| `close_out.md` | 📄 Leaf Task | 🔄 In Progress | ## Amendment Log | ID | Date | Source | Nodes Added | Rationale | From f2bf32484cca81264ceb6c410d8e72bef1436476 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 17:20:25 +0900 Subject: [PATCH 28/38] reports(api): close the M6 gaps campaign Write the knowledge-transfer report of the m6_gaps campaign: what each gap was and what closed it, the guards and their bites, the review findings, the version effect, the spend, the observations and the pull request text. Accept notice 04 with Idea A narrowed, and mark O1 and O11 of the observation rounds 05 and 06 closed. Co-Authored-By: Claude Sonnet 5.5 --- .../05-observation_level2_out_of_scope_v0.md | 2 + .../06-observation_level3_out_of_scope_v0.md | 2 + .../m6_gaps/00-knowledge_transfer_v0.md | 248 ++++++++++++++++++ .../04-notice_batching_needs_v0.md | 4 +- 4 files changed, 255 insertions(+), 1 deletion(-) create mode 100644 __reports__/m6_gaps/00-knowledge_transfer_v0.md diff --git a/__reports__/agent_config/05-observation_level2_out_of_scope_v0.md b/__reports__/agent_config/05-observation_level2_out_of_scope_v0.md index bce3644d..dd422f48 100644 --- a/__reports__/agent_config/05-observation_level2_out_of_scope_v0.md +++ b/__reports__/agent_config/05-observation_level2_out_of_scope_v0.md @@ -34,6 +34,8 @@ Two lessons from the level are process, not code, and are in the [last section]( ## O1. An ignored OpenCode guard has been broken on main since 8d88cb50 +**Closed** by the m6_gaps campaign, merge `e1a5769f` ([report](../m6_gaps/00-knowledge_transfer_v0.md)). + **What was noticed.** `opencode_real_binary_is_interrupted_by_the_stop_script` (`#[ignore]`, needs `CANDLER_OPENCODE_IMAGE`) takes `driver.collect(..).first()` as the export `Exec` spec. Since 8d88cb50 (`fix(adapter-opencode): collect the files an OpenCode run wrote`, on `origin/main`) the first spec is the `**/*` file spec, so the guard fails with `no collect` before Docker starts. Without the variable it fails with `NotPresent`. CI skips it because it is ignored, so nobody sees it fail. **Location map.** `crates/candler-harness-opencode/tests/it/guard_opencode_driver.rs` (the guard); `crates/candler-harness-opencode/src/driver.rs` (`collect`). diff --git a/__reports__/agent_config/06-observation_level3_out_of_scope_v0.md b/__reports__/agent_config/06-observation_level3_out_of_scope_v0.md index 98dabaa5..67d06de0 100644 --- a/__reports__/agent_config/06-observation_level3_out_of_scope_v0.md +++ b/__reports__/agent_config/06-observation_level3_out_of_scope_v0.md @@ -27,6 +27,8 @@ deferred-because: each lies outside the guard leaf's topic ## O11. A job-start refusal's code reaches no place a consumer reads +**Closed** by the m6_gaps campaign, merge `022db6fd` ([report](../m6_gaps/00-knowledge_transfer_v0.md)). + **What was noticed.** Since level 2 moved the harness check to job start (amendment A1), a rejected cell is refused inside the detached supervisor. The refusal is `DriverError::HarnessRejectedInput`, whose code is `experiment.harness_rejected_input`, but the job's `events.jsonl` ends with `job.ended {"reason": "failed"}` and `supervisor.log` carries the message only. `refusal.json` is documented for evaluate jobs only. A consumer, or the guard, can therefore not tell a rejected input from any other failure by its code. The same holds for `jobs.config_check_failed` and `jobs.server_check_failed`. G6 is met on the message; `guard_harness_check_refuses` asserts on it. **Location map.** `crates/candler-core/src/jobs/events.rs` (`job.ended`); `crates/candler-core/src/jobs/orchestrate/{config,servers}.rs`; `docs/contract/` error-model pages. diff --git a/__reports__/m6_gaps/00-knowledge_transfer_v0.md b/__reports__/m6_gaps/00-knowledge_transfer_v0.md new file mode 100644 index 00000000..cf078ade --- /dev/null +++ b/__reports__/m6_gaps/00-knowledge_transfer_v0.md @@ -0,0 +1,248 @@ +# M6 gaps before M7: knowledge transfer (v0) + +Date: 2026-12-01. Campaign `__roadmap__/m6_gaps/`, integration branch `fix/m6-gaps` (cut from `ad74ff94`, v0.19.0), tip `46516fd9`. + +## Executive summary + +Three gaps that M6.5 and M6d left on `main` are closed on `fix/m6-gaps`. Each is judged against the README purpose paragraph. + +```mermaid +graph LR + O1[O1: stop-script guard broken, run by nobody] --> L1[opencode_stop_guard] + O11[O11: job-start refusal code reaches no consumer] --> L2[job_refusal_record] + N04[Notice 04: a kind's digest and refusal depend on its batch] --> L3[needs_batches] + L1 --> M1[e1a5769f] + L2 --> M2[022db6fd] + L3 --> M3[e4ee9cc6] + M1 --> T[tip 46516fd9] + M2 --> T + M3 --> T +``` + +| Gap | Serves (README) | Closed by | Merge | +|---|---|---|---| +| O1, `opencode_real_binary_is_interrupted_by_the_stop_script` failed with `no collect` since `8d88cb50` and no CI job ran it | run agents under controlled conditions | the guard moved to the container selection and selects the export spec by variant | `e1a5769f` | +| O11, a run job's refusal ended as `job.ended {"reason":"failed"}` plus a `supervisor.log` line | one operation API, thin surfaces | every job kind writes `jobs//refusal.json` through one `end_job` | `022db6fd` | +| Notice 04, a kind's stored outcome and refusal depended on the kinds sent beside it | evaluation through pluggable evaluators | `plan()` keys a request by the needs of its own dependency component (Idea A, narrowed) | `e4ee9cc6` | + +Gates on the tip, run after the last merge: `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo nextest run --workspace` (774 run, 774 passed, 35 skipped, 183.7 s; 772/772 after each earlier merge) and `RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps` pass. `git grep -n confirm_ -- crates python` prints nothing. The container selection (below) passed 28 of 28. The `container-e2e` gate on the integration pull request is still open, because the pull request is not opened. + +## Gap 1: the OpenCode stop-script guard (O1) + +Leaf report: [opencode_stop_guard_v0](leaves/opencode_stop_guard_v0.md). + +| Commit | What | +|---|---| +| `1beaf676` | records the guard on the base | +| `e4a895a5` | runs the guard on an image it builds; the guard moves to `guard_container_e2e/opencode_stop_e2e.rs` | +| `f78e2723` | CI's expected list names the stop guard and `guard_harness_check_refuses` | + +- **Cause.** The guard took `collect(..).first()`. Since `8d88cb50` the first spec is the `**/*` file spec, so it failed before Docker started (`Error: "no collect"`; without the image variable, `NotPresent`). +- **Probe.** Question: with only the export spec found by variant, does the guard pass, or did the decoy `serve`, the export argv or the stop script drift too? Answer: it passes (7.5 s) on the real `opencode` 2.2.7 image. Only the spec selection had drifted, so the driver is not wrong and the leaf moved the guard. +- **Move.** The guard selects the `CollectSpec::Exec` variant. The image builder of `version_probe_e2e.rs` became a shared `build_base_image` / `BuiltImage`, so CI's second build of `base-opencode` is a cache hit. `BuiltImage` removes its image by id in `Drop`, and only when the tag did not exist before. `CANDLER_OPENCODE_IMAGE` is gone. +- **Bite.** `crates/candler-harness-opencode/src/stop.py` made to exit at once: the guard goes red after 37 s with `subprocess.TimeoutExpired ... timed out after 30 seconds`, then fails the container exit assertion. The first bite run leaked an image because the explicit removal sat after the assertion; that moved into `Drop`. +- **Cost in CI.** About 10 s on top of `version_probe_e2e` (2.5 s cache-hit build plus 5 s of container time). A cold runner pays the image install once, as the probe guard does today. +- **Container selection, run locally on the tip.** `cargo nextest run -p candler-core -p candler --test it -E 'test(/^guard_container_e2e::/) | test(/^guard_cli_e2e::/)' --run-ignored only --no-fail-fast`: 28 run, 28 passed, 442.4 s. It included `opencode_real_binary_is_interrupted_by_the_stop_script` (8.5 s) and `guard_harness_check_refuses` (20.5 s). The Docker images and containers were the same before and after. The one change was Docker's default `bridge` network, which the daemon recreated; the campaign did not make it. + +## Gap 2: the job refusal record (O11) + +Leaf report: [job_refusal_record_v0](leaves/job_refusal_record_v0.md). Review: [job_refusal_record_v0](reviews/job_refusal_record_v0.md). + +| Commit | What | +|---|---| +| `e5e63253` | test: G6 reads a job-start refusal from `jobs//refusal.json` | +| `9559a28f` | refactor: `record_of`, `write_refusal`, `REFUSAL_FILE`, `end_job` move to `jobs/runtime/refusal.rs`, shared by run and evaluate jobs | +| `b94889ef` | `fix(jobs)!`: `JobOutcome` gains `refusal: Option`; `refused` takes the typed error | +| `4b01ba3d` | docs: `architecture.md` says every job kind leaves its refusal record | +| `a0ec5880` | fix, from review F2: a run job whose setup failed now writes its record | + +`job.ended` gains no field, no `schemas@` file changed and the `supervisor.log` line stays. The record is a file only, so state is not stored twice. + +Guards, red then green: + +| Guard | Red | Bite or base | +|---|---|---| +| G6 `guard_harness_check_refuses` (Docker, ignored) | `refusal record None, sealed 0`, on `claude-code` and `opencode` | on the base, and again with no record passed to `end_job` | +| `harness_finding_refuses_the_job_before_any_run` | `left: "candler.internal"; right: "experiment.harness_rejected_input"` | `refused` handed a string error | +| `finding_on_stderr_with_a_failing_exit_refuses_as_a_finding` | same bite, same left value | same | +| `a_check_that_did_not_run_or_printed_nothing_is_refused` (5 rows) | `left: "candler.internal"; right: "jobs.config_check_failed"` | same | +| `guard_server_check::server_that_exits_refuses_the_job_with_its_stderr` | `left: "candler.internal"; right: "jobs.server_exited_at_start"` | same | + +The string-error bite turned 4 of the 8 selected tests red; the other four do not read a refusal. The review reran it and got the same 4 of 4. A successful run leaves no `refusal.json` (G6's valid-payload rows assert it) and a killed job leaves none (a temporary `confirm_` assertion passed and was deleted). + +**Probe-like deviation.** The campaign gate named `jobs.server_check_failed` for the server row. The existing test reaches the path where a declared server exits at start, which raises `jobs.server_exited_at_start`. `jobs.server_check_failed` goes through the same `ServerCheckError`, `refused` and `record_of` path and would catch no bug the existing row misses. The gate was amended (`c77c1e01`). + +**Review findings.** + +| # | Finding | What became of it | +|---|---|---| +| F1 | Dropping the record in `session::run` is caught only by G6 (ignored, Docker). | Not fixed. G6 runs in `container-e2e` on every pull request that touches `crates/`. Kept as an observation (row 7 below). | +| F2 | `session::run` wrote no record when setup failed, yet `architecture.md` said every job kind leaves one. | Fixed in `a0ec5880`. No test reaches that arm and a new fake was ruled out, so the shared `end_job` path covers it. | +| F3 | A refused job that is then killed ends `killed` and keeps its record. | Not changed. It is accurate history. | +| F4 | The leaf gate's grep for `fn refusal_of` also matches an unrelated function in `crates/candler/src/commands/refusal.rs`. | Not changed. The gate text over-matched. | + +## Gap 3: needs batches (notice 04) + +Leaf report: [needs_batches_v0](leaves/needs_batches_v0.md). Review: [needs_batches_v0](reviews/needs_batches_v0.md). + +| Commit | What | +|---|---| +| `771760e8` | test: a kind's refusal and reuse key ignore the kinds beside it | +| `e44f4c31` | `fix(evaluation)`: `plan()` splits an evaluator's stage by its kinds' needs | +| `b64b880e` | docs: `evaluator-protocol.md` Notes, `assemble` doc comment, `architecture.md` | +| `22ed7d5c` | refactor, from review F1, F3, F6: `NeedsKey` is a typed value | + +**Probe.** Question: does the engine assume one batch per (evaluator, stage)? Answer: no. `run_plan` groups consecutive batches by stage and never keys by evaluator; `run_batch` and `attempt` take one `Batch`; `Interleaved` is raised per dependency component. The only tie to the evaluator is `na_left`, which publishes a not-applicable entry from the first batch of its evaluator, whichever batch that is. The leaf went on. + +**Change.** Idea A, narrowed: a request is keyed by `(stage, evaluator, needs)`, where the needs are the union over one dependency component. Kinds with equal needs share a request and a digest. Dependent entries stay in one request with their prior. Nothing else in the engine changed, and no schema, wire or contract type moved. Outcomes stored from today's mixed batches miss reuse once; the commit body says so. + +Guards, red then green: + +| Guard | Red on the base | Bite | +|---|---|---| +| `a_kinds_refusal_ignores_the_kinds_beside_it` | `on a run with no trace A1 is graded and B1 is not; failed requests: [... stores no trace]`, left `[]`, right `["A1"]` | restoring the `(stage, evaluator)` key | +| `a_kinds_reuse_key_ignores_the_kinds_beside_it` | `A1's context digest under suite {A} and under suite {A, B}`: `sha256:5ac2394f...` against `sha256:5b92ae6d...` | same | +| `dependencies_and_applies_to_decide_what_is_sent` | passes on the base; red with `F2 depends on F1, which has no outcome because its request failed` | keying every entry by its own needs (the review also saw `e1_engine_emits_one_outcome_event_per_committed_record` go red) | + +The refusal guard asserts on the text `stores no trace`, because the engine reports a refused request as text only: `evaluation.run_part_missing` is lost at `send`'s `Fault::new(error.to_string())`. The campaign gate was amended for this (`6c3f34f3`); the code is an observation, not a fix, because carrying it changes the report document, which the campaign does not own. + +**Requests per run** (review measurement, engine fixtures): + +| Suite | Base | Tip | +|---|---|---| +| suite_order (echo + 3 ok) | 1 | 2 | +| suite_needs_beside (two kinds, other needs) | 1 | 2 (traceless run: 1 graded, 1 refused) | +| suite_dependencies, suite_batching, suite_echo, deadlines, counter | 1, 2, 3, 1, 1 | unchanged | + +Growth: requests per evaluator and stage equal the number of distinct needs sets among its components, from 1 up to the number of components. It costs nothing when kinds share needs. For the golden suite (htn-creator-eval 0.4.2) the review inferred one needs set per evaluator and stage from the m2a plan, so no extra request. That is an inference from a plan, not a count of the plug-in. + +**Review findings.** + +| # | Finding | What became of it | +|---|---|---| +| F1 | `needs_key` used `to_value(...).unwrap_or_default()`, so a serialisation failure would silently restore the old grouping. | Fixed in `22ed7d5c`: a typed `NeedsKey` that cannot fail. | +| F2 | The refusal reaches a consumer as text in `failed_requests`, not as `evaluation.run_part_missing`. | Observation (row 12 below). | +| F3 | Digest stability across suites relied on the order of needs lists. | Fixed in `22ed7d5c`: the key is equal for equal needs whatever the list order. No test varies the order; the digest already sorted artifacts, snapshots and inputs and held metadata in a map, so list order never reached it. | +| F4 | A refused first batch of an evaluator also loses the not-applicable records it would publish. | Observation (row 13 below). | +| F5 | Spend 1.6x the estimate. | A process lesson (below). | +| F6 | A comment line over 100 columns in `guard_engine.rs`. | Fixed in `22ed7d5c`. | + +## Version effect + +`JobOutcome` is a public struct without `non_exhaustive`, so the `refusal` field breaks construction outside the crate. That is why `b94889ef` is `fix(jobs)!`; its body gives the migration (`refusal: None`). At `0.y` the core goes from 0.19.0 to 0.20.0 once, and the `fix(evaluation)` change lands in the same release. There is no `schemas@` release and no `candler-evaluator@` release, and `docs/contract/codes.toml` is unchanged. The CI release cuts 0.20.0 only after the pull request merges. + +## Spend + +Measured from transcripts, counting each message id once. Sonnet rates are $2, $10, $4 and $0.1 per MTok for input, output, cache write and cache read; Opus rates are $4, $20, $8 and $0.2. + +| Agent | Calls | Spend | Estimate | Cap | +|---|---|---|---|---| +| opencode_stop_guard builder | 47 | $1.35 | $1.5 | $3 | +| job_refusal_record builder | 78 | $3.06 | $3 | $6 | +| review_job_refusal | 35 | $0.91 | $0.8 | $1.6 | +| needs_batches builder | 73 | $4.99 | $2.5 | $5 | +| review_needs_batches | 20 | $0.61 | $0.8 | $1.6 | +| close_out writer | measured by the lead at close | | $2 | $4 | +| Lead coordination (Opus), so far | 91 | $6.36 | $4 to $7 | | +| Lead planning and roadmap authoring (Opus), before the cap was set | 84 | $8.50 | not in the cap | | +| Total | | to be filled by the lead at close | | | + +The leaf and review reports quote earlier figures given to their authors ($2.19 for the job refusal builder, $4.02 for the needs builder). The table above replaces them. + +## Process lessons + +1. **A builder that stays in one long session gets expensive.** The needs_batches builder reached its cap without passing it, at $4.99 against $2.5 estimated. The change is 48 lines of `plan.rs`, a fixture kind pair and two tests, so the diff does not explain the overrun. Three causes: + - Its context, about 155k tokens per call, which every later call re-reads. + - Two joint reports that it wrote as text and never handed back. It sat idle about an hour each time while the lead waited. + - The fix round after review. + + What to change: a brief names the hand-back call for a joint report, and a leaf this size ends and restarts with a short brief rather than carrying its whole context into the fix round. +2. **Name the evidence the gate can produce.** Two gates were wrong about the code, and both were found by the builder while writing the guard: the server row named a code the path never raises (`c77c1e01`), and the needs refusal named a code that never reaches a consumer (`6c3f34f3`). A gate sentence should be checked against the call path before dispatch. +3. **Cleanup by `Drop`, not by a call after the assertions.** A guard that panics before an explicit removal leaks the image it built. The first bite run of the stop guard did exactly that. +4. **A guard only Docker can run is a weak net for the shared write path.** Review F1 of the job refusal leaf shows it: the workspace gate stays green when `session::run` drops the record. +5. **Timing guards fail under load and pass alone.** Three different ones failed once in a full run during this campaign (rows 9 to 11 below). Each was rerun alone before it was called a regression. + +## Observations + +Every observation the leaf and review reports name, with a place to start. "Urgency" is the author's call. + +| # | Observation | Where | Urgency | +|---|---|---|---| +| 1 | `guard_harness_check_refuses` lives in `crates/candler`, not `candler-core`; the other guards in CI's expected list were not audited. | `crates/candler/tests/it/guard_cli_e2e/agent_config_e2e.rs`; `.github/workflows/container-e2e.yml` | low | +| 2 | A guard that removes an image by an explicit call after its assertions leaks on a panic. The stop guard and `version_probe_e2e` now use `BuiltImage::drop`; other Docker guards were not audited. | `crates/candler-core/tests/it/guard_container_e2e/` | low | +| 3 | `run_job` has four refusal paths with no guard: plan, cells, gate_controls and session open. Only the three job-start classes are guarded. | `crates/candler-core/src/jobs/orchestrate/mod.rs` | low | +| 4 | The leaf gate's `git grep 'fn refusal_of'` also matches `refusal_of(&CliError)`, an unrelated function. | `crates/candler/src/commands/refusal.rs:416` | info | +| 5 | A refused job that is killed in the same window ends `killed` and keeps its record. | `crates/candler-core/src/jobs/runtime/session.rs` | info | +| 6 | The `Err` arm of `session::run` that `a0ec5880` fixed is reached by no test; it is covered by the shared `end_job` path only. | `crates/candler-core/src/jobs/runtime/session.rs` | low | +| 7 | Dropping the record in `session::run` is caught only by G6 (ignored, Docker). A non-Docker test in `support/job_runtime.rs` would catch it sooner. | `crates/candler-core/tests/it/support/job_runtime.rs` | low | +| 8 | A job's refusal is now in `refusal.json`; M7's `jobs` and `show` ops can read it as `commands/evaluate.rs:105` already does. | `crates/candler-core/src/jobs/runtime/refusal.rs` | feeds M7 | +| 9 | Timing guard `a_pre_stop_command_leaves_nothing_in_its_group` failed once in a full run (`the command wrote a pid: ... No such file or directory`), passed alone in 0.9 s. | `crates/candler-core/tests/it/guard_supervise.rs` | low | +| 10 | Timing guard `a_deadline_beats_an_answer_that_is_already_waiting` failed once in a full run, passed alone. | `crates/candler-core/tests/it/guard_protocol_client.rs` | low | +| 11 | Timing guard `wiring_stop_execs_in_the_container_with_the_observed_id` failed once (136.7 s, `children/container-000000000000.json did not appear`), passed alone in 91.9 s. It took 92 s in another full run while other builds shared the machine. | `crates/candler-core/tests/it/guard_wiring.rs` | low | +| 12 | `evaluation.run_part_missing` is dropped at `send`'s `Fault::new(error.to_string())`, so `EvaluateReport.failed_requests` holds text only. A consumer must match `stores no trace`, which the guard pins. A later leaf can carry the code in `Fault` and the report, then the guard asserts the code. | `crates/candler-core/src/evaluation/engine/run.rs` | medium (a document change) | +| 13 | A refused request leaves no file, so the not-applicable records its batch would publish are lost too. With split batches this now loses fewer records than before. | `crates/candler-core/src/evaluation/engine/` | low | +| 14 | The golden suite's request count is inferred from the m2a plan (one needs set per evaluator and stage), not counted on the htn-creator-eval 0.4.2 plug-in. | `__roadmap__/m2a-evaluation-parity/components/assembly/htn_plugin.md` | low | +| 15 | Docker's default `bridge` network was recreated by the daemon during the container run. The campaign did not make it. | Docker daemon | info | + +## Artifacts to preserve + +- [Leaf reports](leaves/) and [review reports](reviews/): the red messages and bites quoted above. +- [Notice 04](../run-context/04-notice_batching_needs_v0.md), now accepted; [observation round 05](../agent_config/05-observation_level2_out_of_scope_v0.md) and [round 06](../agent_config/06-observation_level3_out_of_scope_v0.md), whose O1 and O11 this campaign closes. +- The guards: `opencode_stop_e2e.rs`, `guard_config_check.rs`, `guard_server_check.rs`, `guard_engine.rs` and the engine fixtures `suite_needs_alone.toml` and `suite_needs_beside.toml`. + +## Open questions + +- When does the `container-e2e` gate on the integration pull request list the two named guards as PASS? It is open until the pull request is opened. +- Should the report document carry the refusal code of a failed request (row 12)? It decides whether M7 can tell a missing part from a plug-in crash without matching text. + +## Pull request text + +Title: + +```text +merge(api): close three M6 gaps before M7 +``` + +Body: + +```markdown +## Why + +Closing M6.5 and M6d left three gaps on `main`. Each one makes a promise of the README untrue on its own terms. + +- A guard that proves a real OpenCode run can be stopped had failed since `8d88cb50`, and no CI job ran it. +- A run job refused at its start ended as `job.ended {"reason":"failed"}` and a line in `supervisor.log`. The code of the refusal reached no place a library, CLI or MCP consumer reads. +- An evaluator's stage was sent as one request. A kind's stored outcome and its refusal therefore depended on the other kinds sent with it. + +## What changes + +- The OpenCode stop-script guard selects the export spec by variant, builds its own image and runs in the `container-e2e` job. The list of expected guards names it and `guard_harness_check_refuses`. +- Every job kind ends through one `end_job` and leaves its refusal in `jobs//refusal.json` (`refusal/1`: code, side, pointer). `job.ended` gains no field. `JobOutcome` gains `refusal: Option`, so code that builds one writes `refusal: None`. That is the `fix(jobs)!` commit, and the core goes from 0.19.0 to 0.20.0. A run job whose setup failed now also leaves its record. +- An evaluator's stage is split by the needs of its dependency components. Kinds with equal needs still share a request and a digest. A kind's context digest no longer changes when a kind with other needs joins the suite, and a run that lacks a trace refuses only the kinds that need one. The `fix(evaluation)` commit lands in the same release. There is no `schemas@` or `candler-evaluator@` release. + +## Hard parts + +- Two campaign gates named something the code does not do. The server refusal row names `jobs.server_exited_at_start`, the code a server that exits at start raises (`jobs.server_check_failed` takes the same path). The needs refusal is gated on the failed request it leaves, because the engine reports a refused request as text, so `evaluation.run_part_missing` does not reach a consumer. +- Outcomes stored from today's mixed batches miss reuse once. The commit body says so. +- A mixed suite sends more requests: the largest engine fixture goes from 1 to 2 per run. The count equals the number of distinct needs sets among an evaluator's components. The plug-in of the golden suite is expected to declare one set per evaluator and stage; that is inferred from a plan, not counted. +- Each guard was seen red before it passed, on the base or under a named bite. The review reruns of those bites gave the same results. + +## Not covered + +- The refusal code of a failed evaluation request still reaches a consumer as text only. +- Dropping the record in `session::run` is caught by the Docker guard only, which `container-e2e` runs on this pull request. +- Four refusal paths of `run_job` (plan, cells, gate_controls, session open) have no guard of their own. +- Per-entry digests and refusals in one request (Idea B of the notice) are not built. + +## Observations + +Fifteen observations, each with its location, are in `__reports__/m6_gaps/00-knowledge_transfer_v0.md`. The ones that matter next: + +- A document change would let a consumer tell a missing part from a plug-in crash by code. +- M7's `jobs` and `show` can read `refusal.json`. +- Three timing guards (`guard_supervise`, `guard_protocol_client`, `guard_wiring`) fail once under load and pass alone. + +Gates on the tip: `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo nextest run --workspace` (774 passed, 35 skipped) and `cargo doc` with warnings denied pass. The container selection passed 28 of 28 locally, including both named guards. Nobody is being waited on; the pull request can merge once CI is green. + +Co-Authored-By: Claude Sonnet 5.5 +``` diff --git a/__reports__/run-context/04-notice_batching_needs_v0.md b/__reports__/run-context/04-notice_batching_needs_v0.md index a9e87590..afc0222e 100644 --- a/__reports__/run-context/04-notice_batching_needs_v0.md +++ b/__reports__/run-context/04-notice_batching_needs_v0.md @@ -11,7 +11,9 @@ reversibility: engine-internal; no wire change in either idea evidence: verified spotted-during: the seam review after level 2 of the run context campaign (ruling 3 of `02-seam_review_v0.md`) date: 2026-11-25 -status: open +status: accepted +accepted: 2026-12-01 by the m6_gaps campaign; Idea A was narrowed (one request per evaluator, stage and dependency component's needs), merged as e4ee9cc6 +report: ../m6_gaps/00-knowledge_transfer_v0.md --- ## TL;DR From fb2ec64e8405bbb1950ac2fd30a6c8e0d298036e Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 17:21:07 +0900 Subject: [PATCH 29/38] reports(api): fill the campaign spend and the needs review round The close-out's spend table now carries the writer's and the lead's measured figures and the totals. The needs batches leaf report gains the review round it lacked: how F1, F3 and F6 were answered in the fix commit, the spend as an observation, and the second test the per-entry key turns red. Co-Authored-By: Claude Opus 5.5 --- __reports__/m6_gaps/00-knowledge_transfer_v0.md | 7 ++++--- __reports__/m6_gaps/leaves/needs_batches_v0.md | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/__reports__/m6_gaps/00-knowledge_transfer_v0.md b/__reports__/m6_gaps/00-knowledge_transfer_v0.md index cf078ade..091b1bbb 100644 --- a/__reports__/m6_gaps/00-knowledge_transfer_v0.md +++ b/__reports__/m6_gaps/00-knowledge_transfer_v0.md @@ -142,10 +142,11 @@ Measured from transcripts, counting each message id once. Sonnet rates are $2, $ | review_job_refusal | 35 | $0.91 | $0.8 | $1.6 | | needs_batches builder | 73 | $4.99 | $2.5 | $5 | | review_needs_batches | 20 | $0.61 | $0.8 | $1.6 | -| close_out writer | measured by the lead at close | | $2 | $4 | -| Lead coordination (Opus), so far | 91 | $6.36 | $4 to $7 | | +| close_out writer | 12 | $0.73 | $2 | $4 | +| Lead coordination (Opus), at close | 108 | $7.28 | $4 to $7 | | | Lead planning and roadmap authoring (Opus), before the cap was set | 84 | $8.50 | not in the cap | | -| Total | | to be filled by the lead at close | | | +| Total within the cap (leaves, reviews, close-out, lead coordination) | 373 | $18.93 | $14.6 to $17.6 | $25.2 to $28.2 | +| Total with planning | 457 | $27.43 | | | The leaf and review reports quote earlier figures given to their authors ($2.19 for the job refusal builder, $4.02 for the needs builder). The table above replaces them. diff --git a/__reports__/m6_gaps/leaves/needs_batches_v0.md b/__reports__/m6_gaps/leaves/needs_batches_v0.md index ddd63eb8..31b7b82e 100644 --- a/__reports__/m6_gaps/leaves/needs_batches_v0.md +++ b/__reports__/m6_gaps/leaves/needs_batches_v0.md @@ -42,6 +42,12 @@ The Notes bullet of `docs/contract/evaluator-protocol.md` is now "Kinds with equ - O2. A refused request leaves no file, so the not_applicable records that the batch would have published also go missing (existing behaviour: the first batch of an evaluator publishes them). With split batches, a refusal of that first batch now loses them where before it lost them together with everything; not changed. - O3. Timing guard (O15 family): `guard_wiring::wiring_stop_execs_in_the_container_with_the_observed_id` failed in the first whole-workspace run (136.7 s, `children/container-000000000000.json did not appear`) and passed alone (91.9 s). +- O4. Spend: $4.99 over 73 calls against a $2.5 estimate and a $5 cap, measured by the lead from the transcript. The overrun came from a context of about 155k tokens per call, kept alive through two joint reports that were written as text and not handed back, and from the fix round. + +## Review round + +The review (`__reports__/m6_gaps/reviews/needs_batches_v0.md`) found nothing blocking. F1 (`needs_key` fell back to `Null` on a serialisation error), F3 (needs listed in another order) and F6 (a doc comment past 100 columns) are answered in `22ed7d5c`. The key is now a typed `NeedsKey` of flags and `BTreeSet`s, with no fallback. List order reaches neither the key nor the stamped digest, because `context_digest` sorts its parts, so no test was added. F2 and F4 are O1 and O2 above, and F5 is O4. The review also found a second test that fails when every entry is keyed by its own needs: `e1_engine_emits_one_outcome_event_per_committed_record`. + ## Gate on the final tree `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings` and `RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps` pass. `cargo nextest run --workspace`: 774 passed, 0 failed (190.6 s; the wiring guard of O3 passed in this run). `git grep -n confirm_ -- crates python` prints nothing. From 923eb29dd4b0b4f27cee4d6bc96f194414004f51 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 17:21:21 +0900 Subject: [PATCH 30/38] rdm(api): close the M6 gaps campaign Every leaf and directory is done, and the campaign's success gates are ticked where they are met. The two that need the integration pull request, its container-e2e run and the 0.20.0 release after it merges, stay open until the pull request is opened and merged. Co-Authored-By: Claude Opus 5.5 --- __roadmap__/m6_gaps/README.md | 18 +++++++++--------- __roadmap__/m6_gaps/review/README.md | 4 ++-- __roadmap__/m6_gaps/review/close/README.md | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/__roadmap__/m6_gaps/README.md b/__roadmap__/m6_gaps/README.md index 18d41d51..07949ff0 100644 --- a/__roadmap__/m6_gaps/README.md +++ b/__roadmap__/m6_gaps/README.md @@ -35,15 +35,15 @@ Every job kind that ends on a refusal leaves that refusal's code in `jobs//r - [x] `[cmd]` `docker info` succeeds, and `df -h /System/Volumes/Data` shows at least 20 GiB free ## Success Gates -- ⬜ Every leaf is `done`, and each build leaf's report records every guard it owns seen red (on the base or under its named bite) and then green, with the failing message -- ⬜ `git grep -n confirm_ -- crates python` prints nothing on the `fix/m6-gaps` tip -- ⬜ `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo nextest run --workspace` and `RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps` pass on the tip +- ✅ Every leaf is `done`, and each build leaf's report records every guard it owns seen red (on the base or under its named bite) and then green, with the failing message +- ✅ `git grep -n confirm_ -- crates python` prints nothing on the `fix/m6-gaps` tip +- ✅ `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo nextest run --workspace` and `RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps` pass on the tip - ⬜ `container-e2e` on the integration pull request lists `opencode_real_binary_is_interrupted_by_the_stop_script` and `guard_harness_check_refuses` as PASS -- ⬜ A run job refused at job start leaves `jobs//refusal.json`, a `refusal/1` record that names its code, side and pointer, for each of `experiment.harness_rejected_input`, `jobs.config_check_failed` and `jobs.server_exited_at_start` (the code a server that exits at start raises; `jobs.server_check_failed` goes through the same `ServerCheckError` path and needs no row of its own) -- ⬜ For a plug-in with an artifacts- or manifest-only kind A and a trace kind B, on a run with no trace A is graded and only B's request fails, with the missing-part refusal (`run stores no `trace``; the engine reports a failed request as text, so its code `evaluation.run_part_missing` is recorded as an observation, not carried); on a run with a trace, A's context digest is the same for suite {A} and suite {A, B} -- ⬜ Each review report answers both of its lenses with evidence, and each finding is fixed on the leaf branch or recorded as an observation with its reason before that leaf merges +- ✅ A run job refused at job start leaves `jobs//refusal.json`, a `refusal/1` record that names its code, side and pointer, for each of `experiment.harness_rejected_input`, `jobs.config_check_failed` and `jobs.server_exited_at_start` (the code a server that exits at start raises; `jobs.server_check_failed` goes through the same `ServerCheckError` path and needs no row of its own) +- ✅ For a plug-in with an artifacts- or manifest-only kind A and a trace kind B, on a run with no trace A is graded and only B's request fails, with the missing-part refusal (`run stores no `trace``; the engine reports a failed request as text, so its code `evaluation.run_part_missing` is recorded as an observation, not carried); on a run with a trace, A's context digest is the same for suite {A} and suite {A, B} +- ✅ Each review report answers both of its lenses with evidence, and each finding is fixed on the leaf branch or recorded as an observation with its reason before that leaf merges - ⬜ The pull request `merge(api): close three M6 gaps before M7` is opened only after the maintainer's go; after it merges, the CI release cuts 0.20.0 -- ⬜ Spend is measured from transcripts per leaf, and no leaf passed its cap without stopping. Leaf estimates add to $10.6 and caps to $21.2; with the lead's $4–7, the campaign stays within the cap the maintainer approves +- ✅ Spend is measured from transcripts per leaf, and no leaf passed its cap without stopping. Leaf estimates add to $10.6 and caps to $21.2; with the lead's $4–7, the campaign stays within the cap the maintainer approves ## Gotchas - The two reviewed leaves stay on their branches until their review is answered; a finding is fixed on the leaf branch by the same builder, then the leaf merges. @@ -57,7 +57,7 @@ graph TD opencode_stop_guard[OpenCode stop guard]:::done job_refusal_record[Job refusal record]:::done needs_batches[Needs batches]:::done - review[Review]:::inprogress + review[Review]:::done classDef done fill:#166534,color:#bbf7d0 classDef inprogress fill:#854d0e,color:#fef08a classDef planned fill:#374151,color:#e5e7eb @@ -71,7 +71,7 @@ graph TD | `opencode_stop_guard.md` | 📄 Leaf Task | ✅ Done | | `job_refusal_record.md` | 📄 Leaf Task | ✅ Done | | `needs_batches.md` | 📄 Leaf Task | ✅ Done | -| `review/` | 📁 Directory | 🔄 In Progress | +| `review/` | 📁 Directory | ✅ Done | ## Amendment Log | ID | Date | Source | Nodes Added | Rationale | diff --git a/__roadmap__/m6_gaps/review/README.md b/__roadmap__/m6_gaps/review/README.md index a3b3af46..f3408e9b 100644 --- a/__roadmap__/m6_gaps/review/README.md +++ b/__roadmap__/m6_gaps/review/README.md @@ -25,7 +25,7 @@ Each risky change is judged on validity and on develop, leave and consume before graph TD review_job_refusal[Review: job refusal]:::done review_needs_batches[Review: needs batches]:::done - close[Close]:::planned + close[Close]:::done classDef done fill:#166534,color:#bbf7d0 classDef inprogress fill:#854d0e,color:#fef08a classDef planned fill:#374151,color:#e5e7eb @@ -38,7 +38,7 @@ graph TD |:-----|:-----|:-------| | `review_job_refusal.md` | 📄 Leaf Task | ✅ Done | | `review_needs_batches.md` | 📄 Leaf Task | ✅ Done | -| `close/` | 📁 Directory | ⬜ Planned | +| `close/` | 📁 Directory | ✅ Done | ## Amendment Log | ID | Date | Source | Nodes Added | Rationale | diff --git a/__roadmap__/m6_gaps/review/close/README.md b/__roadmap__/m6_gaps/review/close/README.md index 5e317b62..17a6fa41 100644 --- a/__roadmap__/m6_gaps/review/close/README.md +++ b/__roadmap__/m6_gaps/review/close/README.md @@ -16,7 +16,7 @@ The `fix/m6-gaps` tip passes every gate, and one report closes the three gaps an ## Status ```mermaid graph TD - close_out[Close out]:::inprogress + close_out[Close out]:::done classDef done fill:#166534,color:#bbf7d0 classDef inprogress fill:#854d0e,color:#fef08a classDef planned fill:#374151,color:#e5e7eb @@ -27,7 +27,7 @@ graph TD ## Nodes | Node | Type | Status | |:-----|:-----|:-------| -| `close_out.md` | 📄 Leaf Task | 🔄 In Progress | +| `close_out.md` | 📄 Leaf Task | ✅ Done | ## Amendment Log | ID | Date | Source | Nodes Added | Rationale | From e42fb4a2969a16eadd44a33fce97ca71087d031d Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 17:36:18 +0900 Subject: [PATCH 31/38] rdm(api): amend the campaign to carry the needs refusal code The batched-needs gate promised that kind B carries `evaluation.run_part_missing` on a run with no trace. The engine reports a failed request as text, and the gate was reworded at a joint to the text instead of the code. That narrowed an approved gate. Amendment A1 restores the gate and adds two nodes: the build leaf `needs_refusal_code`, which carries the refusal/1 record of a refused request into `EvaluateReport` and its document, and its cold review. The gap report gives the evidence and the root cause. The tip gates are reopened until A1 merges. The roadmap tool failed its own write when it added the nodes (the Nodes row landed after the table's blank line), so the Mermaid and Nodes lines were written in its format by hand and validated. Co-Authored-By: Claude Opus 5.5 --- __reports__/m6_gaps/01-gap_refusal_code_v0.md | 28 ++++++++++ __roadmap__/m6_gaps/README.md | 19 ++++--- __roadmap__/m6_gaps/needs_batches.md | 2 +- __roadmap__/m6_gaps/needs_refusal_code.md | 56 +++++++++++++++++++ __roadmap__/m6_gaps/review/README.md | 2 + .../review/review_needs_refusal_code.md | 21 +++++++ 6 files changed, 119 insertions(+), 9 deletions(-) create mode 100644 __reports__/m6_gaps/01-gap_refusal_code_v0.md create mode 100644 __roadmap__/m6_gaps/needs_refusal_code.md create mode 100644 __roadmap__/m6_gaps/review/review_needs_refusal_code.md diff --git a/__reports__/m6_gaps/01-gap_refusal_code_v0.md b/__reports__/m6_gaps/01-gap_refusal_code_v0.md new file mode 100644 index 00000000..7251f8d8 --- /dev/null +++ b/__reports__/m6_gaps/01-gap_refusal_code_v0.md @@ -0,0 +1,28 @@ +# Gap analysis: M6 gaps, a refused request's code reaches no consumer (v0) + +Date: 2026-12-01 + +## Problem statement +The campaign gate on batched needs reads: "on a run with no trace A is graded and B carries `evaluation.run_part_missing`". The `needs_batches` leaf met the behaviour half: A is graded, and only B's request fails. The code half was not met. The engine reports a refused request as `EvaluateReport.failed_requests: Vec<(RequestId, String)>`, and `to_document` writes each one as `{request, reason}`. So a consumer can tell why B failed only by matching the text `stores no trace`. That is the same defect O11 removed for job refusals. + +## Evidence +- `crates/candler-core/src/evaluation/engine/run.rs`: `send` turns the typed `assemble` error into `Fault::new(error.to_string())`, and `Fault` holds `{request, message}` only. +- `crates/candler-core/src/evaluation/engine/mod.rs`: `EvaluateReport.failed_requests` and `to_document` (`{request, reason}`). +- `guard_engine::a_kinds_refusal_ignores_the_kinds_beside_it` asserts the error text, as agreed at the leaf's second joint. + +## Root cause +At that joint the lead reworded both gates (6c3f34f3) instead of escalating, on the claim that the report document lay outside the campaign. It does not. Both files sit under `crates/candler-core/src/evaluation/**`, which `needs_batches` owned. The document is plain JSON with no schema, so no `schemas@` release is needed. + +## Impact +- **Consumers.** The library (`EvaluateReport`), the CLI's printed report, the evaluate job's `report.json`, and later M7's `show`. Each would otherwise parse an error message, which "one operation API … thin surfaces over that API" rules out. +- **Version.** `failed_requests` is a public field. Changing its element type breaks callers outside the crate. That change rides on the 0.20.0 release that `fix(jobs)!` already causes, so it becomes a second `!` commit with its migration. + +## Proposed solution +- A refused request carries the same `refusal/1` record that `jobs//refusal.json` holds. It is built by the one record builder O11 introduced (`record_of`, now in `jobs/runtime/refusal.rs`) from the typed error, where the fault is made. +- Each failure in the report document gains that record next to its `reason`. +- Placing the builder is the leaf's probe. If the engine would have to import from `jobs::runtime`, the builder moves to `crate::refusal`, beside `find`, so evaluation does not depend on jobs. +- The batched-needs gate in the campaign README is restored to its original wording. + +## Recommendations +1. Run it as amendment A1: one build leaf, `needs_refusal_code`, and one cold review, `review/review_needs_refusal_code`, before the integration pull request. +2. A gate changed at a joint goes to the maintainer when it narrows what was promised. The lead does not reword it alone. diff --git a/__roadmap__/m6_gaps/README.md b/__roadmap__/m6_gaps/README.md index 07949ff0..0a543a10 100644 --- a/__roadmap__/m6_gaps/README.md +++ b/__roadmap__/m6_gaps/README.md @@ -14,7 +14,7 @@ Closing M6.5 and M6d left three gaps on `main` (v0.19.0, `ad74ff94`). Each is ju - **Branches and builds.** The integration branch is `fix/m6-gaps`, cut from `origin/main` at `ad74ff94`. The leaf branches are `test/opencode-stop-guard`, `fix/job-refusal-record` and `fix/needs-batches`, each in its own worktree made by `python3 scripts/worktree.py add ` from the `fix/m6-gaps` tip and removed at its merge. Every build sets `CARGO_TARGET_DIR=/Users/hacker/Documents/tmp/claude-worktrees/Candler/m6-gaps-target/` and `RUSTC_WRAPPER=sccache` in its own environment, one dir per leaf, because a dir shared between worktrees reuses another checkout's test binaries. Never export `TMPDIR` around a sccache cargo command. At most three builds run at once, each leaf's dir is removed at its merge, and `df -h /System/Volumes/Data` is checked before each level. Docker is used by `opencode_stop_guard`, by `job_refusal_record`'s G6 run and by the close-out; each removes what it built by id, with scratch roots under `$HOME`. Nothing is pruned and Docker is never stopped. - **Conventions.** Each leaf loads the `designing-tests` skill before it writes a test. Guards come first and are seen red, on the base or under their named bite, before they pass; each carries a `Guards: / Oracle: / Bite:` doc comment. Test names that start with `confirm_` are build-step checks, deleted before their leaf merges or rewritten to guard standard. Leaf reports go to `__reports__/m6_gaps/leaves/_v0.md`, review reports to `__reports__/m6_gaps/reviews/_v0.md`, and the knowledge-transfer report to `__reports__/m6_gaps/`. - **Execution model.** The lead coordinates and does not implement. Every subagent runs on Claude Sonnet 5, with `model: "sonnet"` passed explicitly on each Agent call. A brief names the leaf's worktree, its own scratch subdirectory, its target dir, colgrep-only code reading, the whole-workspace gate, the Docker rules, cleanup on finish, and a full scope boundary instead of a call cap. Verification follows risk: the lead reads `opencode_stop_guard`'s Docker logs; `job_refusal_record` and `needs_batches` each get one cold adversarial review, one pass. The lead talks with a running leaf at its joints (after the fails-on-the-base run, and before the docs step). Each leaf branch is rebased onto `fix/m6-gaps`, then merged with `git merge --no-ff`; long commit and merge messages are written to a file and passed with `-F`. The lead runs the whole suite after each merge. The integration pull request follows CONTRIBUTING.md §Branches and integration. -- **Version effect.** `JobOutcome` (`crates/candler-core/src/jobs/model.rs`) is a public struct without `non_exhaustive`, so adding its `refusal` field breaks construction outside the crate: the commit is `fix(jobs)!` and its body gives the migration (`refusal: None`). At `0.y` the core goes from 0.19.0 to 0.20.0 once; `needs_batches`' `fix(evaluation)` lands in the same release. `schemas@` and `candler-evaluator@` do not change. `docs/contract/codes.toml` does not change either (its rows hold no reason text), and there is no jobs contract page. +- **Version effect.** `JobOutcome` (`crates/candler-core/src/jobs/model.rs`) is a public struct without `non_exhaustive`, so adding its `refusal` field breaks construction outside the crate: the commit is `fix(jobs)!` and its body gives the migration (`refusal: None`). At `0.y` the core goes from 0.19.0 to 0.20.0 once; `needs_batches`' `fix(evaluation)` lands in the same release. Amendment A1's `fix(evaluation)!` (`needs_refusal_code`) changes the public `EvaluateReport::failed_requests` and rides the same 0.20.0. `schemas@` and `candler-evaluator@` do not change. `docs/contract/codes.toml` does not change either (its rows hold no reason text), and there is no jobs contract page. ## Reference Documents - [R01 Observation round 05](../../__reports__/agent_config/05-observation_level2_out_of_scope_v0.md) — §O1, the broken stop-script guard, and §Process lessons on shared build dirs @@ -35,13 +35,13 @@ Every job kind that ends on a refusal leaves that refusal's code in `jobs//r - [x] `[cmd]` `docker info` succeeds, and `df -h /System/Volumes/Data` shows at least 20 GiB free ## Success Gates -- ✅ Every leaf is `done`, and each build leaf's report records every guard it owns seen red (on the base or under its named bite) and then green, with the failing message -- ✅ `git grep -n confirm_ -- crates python` prints nothing on the `fix/m6-gaps` tip -- ✅ `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo nextest run --workspace` and `RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps` pass on the tip +- ⬜ Every leaf is `done`, and each build leaf's report records every guard it owns seen red (on the base or under its named bite) and then green, with the failing message +- ⬜ `git grep -n confirm_ -- crates python` prints nothing on the `fix/m6-gaps` tip +- ⬜ `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo nextest run --workspace` and `RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps` pass on the tip - ⬜ `container-e2e` on the integration pull request lists `opencode_real_binary_is_interrupted_by_the_stop_script` and `guard_harness_check_refuses` as PASS - ✅ A run job refused at job start leaves `jobs//refusal.json`, a `refusal/1` record that names its code, side and pointer, for each of `experiment.harness_rejected_input`, `jobs.config_check_failed` and `jobs.server_exited_at_start` (the code a server that exits at start raises; `jobs.server_check_failed` goes through the same `ServerCheckError` path and needs no row of its own) -- ✅ For a plug-in with an artifacts- or manifest-only kind A and a trace kind B, on a run with no trace A is graded and only B's request fails, with the missing-part refusal (`run stores no `trace``; the engine reports a failed request as text, so its code `evaluation.run_part_missing` is recorded as an observation, not carried); on a run with a trace, A's context digest is the same for suite {A} and suite {A, B} -- ✅ Each review report answers both of its lenses with evidence, and each finding is fixed on the leaf branch or recorded as an observation with its reason before that leaf merges +- ⬜ For a plug-in with an artifacts- or manifest-only kind A and a trace kind B, on a run with no trace A is graded and B carries `evaluation.run_part_missing`; on a run with a trace, A's context digest is the same for suite {A} and suite {A, B} +- ⬜ Each review report answers both of its lenses with evidence, and each finding is fixed on the leaf branch or recorded as an observation with its reason before that leaf merges - ⬜ The pull request `merge(api): close three M6 gaps before M7` is opened only after the maintainer's go; after it merges, the CI release cuts 0.20.0 - ✅ Spend is measured from transcripts per leaf, and no leaf passed its cap without stopping. Leaf estimates add to $10.6 and caps to $21.2; with the lead's $4–7, the campaign stays within the cap the maintainer approves @@ -57,7 +57,8 @@ graph TD opencode_stop_guard[OpenCode stop guard]:::done job_refusal_record[Job refusal record]:::done needs_batches[Needs batches]:::done - review[Review]:::done + needs_refusal_code[Needs refusal code]:::amendment + review[Review]:::amendment classDef done fill:#166534,color:#bbf7d0 classDef inprogress fill:#854d0e,color:#fef08a classDef planned fill:#374151,color:#e5e7eb @@ -71,11 +72,13 @@ graph TD | `opencode_stop_guard.md` | 📄 Leaf Task | ✅ Done | | `job_refusal_record.md` | 📄 Leaf Task | ✅ Done | | `needs_batches.md` | 📄 Leaf Task | ✅ Done | -| `review/` | 📁 Directory | ✅ Done | +| `needs_refusal_code.md` | 📄 Leaf Task | 🔵 Amendment | +| `review/` | 📁 Directory | 🔵 Amendment | ## Amendment Log | ID | Date | Source | Nodes Added | Rationale | |:---|:-----|:-------|:------------|:----------| +| A1 | 2026-12-01 | [gap report](../../__reports__/m6_gaps/01-gap_refusal_code_v0.md) | [ "needs_refusal_code", "review_needs_refusal_code" ] | The approved gate's refusal code was narrowed away at a joint; carry it into the evaluate report | ## Progress | Node | Branch | Commits | Notes | diff --git a/__roadmap__/m6_gaps/needs_batches.md b/__roadmap__/m6_gaps/needs_batches.md index 7401cf5e..dea9bd01 100644 --- a/__roadmap__/m6_gaps/needs_batches.md +++ b/__roadmap__/m6_gaps/needs_batches.md @@ -6,7 +6,7 @@ - [ ] `[cmd]` `git -C merge-base --is-ancestor fix/m6-gaps HEAD` succeeds **Success Gates**: - ⬜ The probe's answer is recorded: whether `run_batch`, the stage loop or the `Interleaved` check assumes one batch per evaluator and stage; if it does, the leaf stopped and reported before step 2 -- ⬜ A new guard, "a kind's result does not depend on the kinds sent beside it", holds two cases through the engine with the test plug-in fixture: on a run sealed with no trace, kind A (artifacts or manifest only) is graded and only kind B's (trace) request fails, with the missing-part refusal text (`run stores no `trace``), since `EvaluateReport.failed_requests` holds text only; on a run with a trace, A's stamped `context_digest` is equal for suite {A} and suite {A, B}. Both cases are red on the base, with the messages in the leaf report +- ⬜ A new guard, "a kind's result does not depend on the kinds sent beside it", holds two cases through the engine with the test plug-in fixture: on a run sealed with no trace, kind A (artifacts or manifest only) is graded and only kind B's (trace) request fails, with the missing-part refusal text (`run stores no `trace``), since `EvaluateReport.failed_requests` holds text only (amendment A1, `needs_refusal_code`, carries the code); on a run with a trace, A's stamped `context_digest` is equal for suite {A} and suite {A, B}. Both cases are red on the base, with the messages in the leaf report - ⬜ `guard_engine::dependencies_and_applies_to_decide_what_is_sent` is extended so its dependent entries declare different needs; it passes on the base and the tip, and goes red under the bite "split every entry by its own needs" - ⬜ Every existing test that asserted one request per evaluator and stage is changed on purpose and named in the fix commit's body, which also says that outcomes stored from mixed batches miss reuse once - ⬜ No unit test of `plan()`'s grouping remains, and no per-entry digest or refusal machinery (Idea B) was added diff --git a/__roadmap__/m6_gaps/needs_refusal_code.md b/__roadmap__/m6_gaps/needs_refusal_code.md new file mode 100644 index 00000000..2bb93a57 --- /dev/null +++ b/__roadmap__/m6_gaps/needs_refusal_code.md @@ -0,0 +1,56 @@ +# Needs refusal code + +**Goal**: A request the engine refuses carries its `refusal/1` record, with its code, side and pointer, in `EvaluateReport` and in the report document, so that on a run with no trace kind B carries `evaluation.run_part_missing` and no consumer parses error text (amendment A1) +**Estimate**: Sonnet, $2, cap $4. At the cap, stop, commit what is green, and list what is left in the leaf report. Builds use `CARGO_TARGET_DIR=/Users/hacker/Documents/tmp/claude-worktrees/Candler/m6-gaps-target/needs_refusal_code`; the leaf removes it at its merge. +**Pre-conditions**: +- [ ] `[cmd]` `git -C merge-base --is-ancestor fix/m6-gaps HEAD` succeeds +**Success Gates**: +- ⬜ The probe's answer is recorded: where the one record builder lives so that the engine can call it without `evaluation` importing from `jobs`, and whether a refused request can reach `Fault` with its typed error intact on every path that fails a request +- ⬜ `guard_engine::a_kinds_refusal_ignores_the_kinds_beside_it` asserts that only B's request fails and that its failure carries a record with code `evaluation.run_part_missing`, in `EvaluateReport` and in `to_document()`; it is red on the base with the message in the leaf report, and green on the tip +- ⬜ Every failed request carries a record: one whose error holds no code carries the fallback `candler.internal` with its message, never no record; a guard that exists for a failure with no code is extended to say so, or the leaf report names why none is needed +- ⬜ `EvaluateReport` and `to_document()` hold one producer for the record: the builder `jobs//refusal.json` uses, moved if the probe says so, with no second builder; the reason text stays as a field of the failure +- ⬜ The fix commit is `fix(evaluation)!` and its body gives the migration of the public `failed_requests` field; every caller in the workspace is migrated, and `guard_cli_evaluate`'s `e1_`/`e4_` guards and `print_report` read the new shape +- ⬜ The doc comment of `EvaluateReport` and of `to_document`, `__design__/architecture.md` where it states the report's keys, and any contract page that lists them say the same, each at its one source +- ⬜ `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo nextest run --workspace` and `RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps` pass, and `git grep -n confirm_ -- crates python` prints nothing +**References**: [the gap report](../../__reports__/m6_gaps/01-gap_refusal_code_v0.md) — the problem, its evidence and the proposed solution. Code: +- `crates/candler-core/src/evaluation/engine/run.rs`: `Fault` (`request`, `message`), `Fault::new`, `send` (where `assemble`'s typed error becomes `Fault::new(error.to_string())`), every other place a `Fault` is made; +- `crates/candler-core/src/evaluation/engine/mod.rs`: `EvaluateReport::failed_requests`, `to_document`, `evaluate_reporting`; +- `crates/candler-core/src/jobs/runtime/refusal.rs`: `record_of`, `write_refusal`, `end_job`; `crates/candler-core/src/refusal.rs` (or its module): `find`; `crates/candler-schemas/src/refusal.rs`: `RefusalRecord`; +- `crates/candler/src/commands/evaluate.rs`: `print_report`; `crates/candler/tests/it/guard_cli_evaluate.rs`: `e1_evaluate_prints_the_job_id_on_stderr_and_the_report_on_stdout`, `e4_evaluate_with_no_plugin_option_grades_exactly_the_runs_just_run`; +- `crates/candler-core/tests/it/guard_engine.rs`: `a_kinds_refusal_ignores_the_kinds_beside_it`, `rig_of`; fixtures `suite_needs_alone.toml`, `suite_needs_beside.toml`. + +Scope boundary: no change to batching, stages, `send`'s context or the wire; no `schemas@` change (the record type exists and the report document has no schema). Owned: `crates/candler-core/src/evaluation/**`, `crates/candler-core/src/refusal*` and `crates/candler-core/src/jobs/runtime/refusal.rs` only if the builder moves, `crates/candler/src/commands/evaluate.rs`, the tests that build or read `failed_requests`, and the docs named in the gates. + +## Step 1: Probe and guard on the base +**Goal**: Know where the builder goes, and see the guard red on the base. +**Implementation Logic**: +Probe. Questions: can `evaluation::engine` call `jobs::runtime::refusal::record_of` without making evaluation depend on jobs, or does the builder belong beside `crate::refusal::find`? Does every path that fails a request (`send`'s assemble error, a client error, a cancel or a timeout, a bad reply) still hold its typed error where the `Fault` is made? Read them with colgrep. Decision: if the builder can sit beside `find` and every path holds its error, go on; if a path has already lost its type, it carries the fallback record and the report names it; if the move would touch more than the two refusal modules, stop and tell the lead. + +Strengthen `a_kinds_refusal_ignores_the_kinds_beside_it`: B's failure carries a record whose code is `evaluation.run_part_missing`, read from `EvaluateReport` and from `to_document()`. The expected code is written by hand. Run it on the base and record the failing message (the base cannot compile against a field that does not exist; write the assertion against `to_document()`'s JSON so the base build runs and fails on the missing key). +**Deliverables**: `crates/candler-core/tests/it/guard_engine.rs` (`a_kinds_refusal_ignores_the_kinds_beside_it`); `__reports__/m6_gaps/leaves/needs_refusal_code_v0.md` (probe answer, base message) +**Consistency Checks**: the guard on the base (expected: FAIL) +**Commit**: `test(evaluation): state that a refused request carries its code` + +## Step 2: Carry the record +**Goal**: The guard passes on the tip, with one record builder. +**Implementation Logic**: +Move the builder if the probe says so, with `jobs/runtime/refusal.rs` calling it from its new place. `Fault` keeps the record built from the typed error where the fault is made; a fault with no typed error gets the fallback record. `EvaluateReport::failed_requests` carries, for each failure, the request id, the reason text and the record; `to_document()` writes the record next to `reason`. Migrate every caller: `print_report`, the CLI guards, test support. The commit body names the migration of the public field. +**Deliverables**: `crates/candler-core/src/evaluation/engine/{run.rs,mod.rs}`; the builder's module; `crates/candler/src/commands/evaluate.rs`; the migrated tests +**Consistency Checks**: the guard of step 1, then `cargo nextest run --workspace` (expected: PASS) +**Commit**: `fix(evaluation)!: carry a refused request's code in the report` + +## Step 3: Say what a failure carries +**Goal**: The docs say a failed request carries its refusal record. +**Implementation Logic**: +Update the doc comments of `EvaluateReport` and `to_document`, the sentence of `__design__/architecture.md` that names the report's keys, and any contract page that lists them, each at its source; regenerate a contract page only if one changed, with the command in CONTRIBUTING.md §Contract pages. +**Deliverables**: the doc comments; `__design__/architecture.md`; any contract page found by colgrep +**Consistency Checks**: `cargo nextest run -p candler -E 'test(/^contract_pages::/)'` without the bless variable (expected: PASS) +**Commit**: `docs(evaluation): say a failed request carries its refusal` + +## Step 4: Bite and verify +**Goal**: The guard goes red under its bite, and nothing is left behind. +**Implementation Logic**: +On a scratch branch, build every fault's record as the fallback (drop the typed error) and see the guard go red; record the message. Delete every `confirm_` test. Write the leaf report: probe answer, base message, bite message, the callers migrated. +**Deliverables**: `__reports__/m6_gaps/leaves/needs_refusal_code_v0.md` (complete) +**Consistency Checks**: `git grep -n confirm_ -- crates python` prints nothing (expected: PASS) +**Commit**: `reports(evaluation): close the needs refusal code` diff --git a/__roadmap__/m6_gaps/review/README.md b/__roadmap__/m6_gaps/review/README.md index f3408e9b..653636e5 100644 --- a/__roadmap__/m6_gaps/review/README.md +++ b/__roadmap__/m6_gaps/review/README.md @@ -25,6 +25,7 @@ Each risky change is judged on validity and on develop, leave and consume before graph TD review_job_refusal[Review: job refusal]:::done review_needs_batches[Review: needs batches]:::done + review_needs_refusal_code[Review: needs refusal code]:::amendment close[Close]:::done classDef done fill:#166534,color:#bbf7d0 classDef inprogress fill:#854d0e,color:#fef08a @@ -38,6 +39,7 @@ graph TD |:-----|:-----|:-------| | `review_job_refusal.md` | 📄 Leaf Task | ✅ Done | | `review_needs_batches.md` | 📄 Leaf Task | ✅ Done | +| `review_needs_refusal_code.md` | 📄 Leaf Task | 🔵 Amendment | | `close/` | 📁 Directory | ✅ Done | ## Amendment Log diff --git a/__roadmap__/m6_gaps/review/review_needs_refusal_code.md b/__roadmap__/m6_gaps/review/review_needs_refusal_code.md new file mode 100644 index 00000000..99d2ff75 --- /dev/null +++ b/__roadmap__/m6_gaps/review/review_needs_refusal_code.md @@ -0,0 +1,21 @@ +# Review: needs refusal code + +**Goal**: An adversarial, read-only review of `fix/needs-refusal-code` on validity and on develop, leave and consume, before it merges +**Estimate**: Sonnet, $0.6, cap $1.2. At the cap, stop and hand back what is answered, with the open questions listed. The reviewer reuses the builder's target dir, `/Users/hacker/Documents/tmp/claude-worktrees/Candler/m6-gaps-target/needs_refusal_code`. +**Pre-conditions**: +- [ ] `[nl]` `needs_refusal_code` is `done` on `fix/needs-refusal-code`, with its leaf report +**Success Gates**: +- ⬜ Validity: the report says, with evidence, whether every path that fails a request carries a record, with the code the typed error holds or the fallback; whether the record in `EvaluateReport`, in `to_document()` and in a refused evaluate job's `refusal.json` come from the same builder and agree; and whether the guard goes red when the typed error is dropped (the reviewer reruns that bite) +- ⬜ Develop: whether the leaf stayed inside its scope boundary, and its spend against its $2 estimate, measured from its transcript +- ⬜ Leave: whether there is one record builder, with no copy left in `jobs`; whether evaluation depends on jobs; whether the reason text and the record's message duplicate state a consumer must reconcile; whether each doc change is made once, at its source +- ⬜ Consume: whether the library, the CLI's printed report and the evaluate job's `report.json` give the code without parsing text; whether the `!` commit's migration is enough for a caller outside the workspace +- ⬜ Each finding names its severity and the smallest fix, and the report says which findings block the merge +**References**: [the leaf](../needs_refusal_code.md) — goal, scope boundary, guard and bite; [the gap report](../../../__reports__/m6_gaps/01-gap_refusal_code_v0.md). Read the diff with `git diff fix/m6-gaps...fix/needs-refusal-code` and the code with colgrep; do not read the leaf report until every question has an answer. + +## Step 1: Review +**Goal**: Every question of the success gates has an answer with its evidence. +**Implementation Logic**: +Read the leaf file and the diff cold. Answer validity first, then develop, leave and consume. Rerun the bite on a scratch branch that is never committed, and `cargo nextest run --workspace`. Write findings as: what is wrong, where, what it costs a consumer or a later milestone, the smallest fix, blocking or not. Change no code on the leaf branch. +**Deliverables**: `__reports__/m6_gaps/reviews/needs_refusal_code_v0.md` +**Consistency Checks**: `git diff --stat fix/needs-refusal-code` on the reviewer's worktree shows only the review report (expected: PASS) +**Commit**: `reports(evaluation): review the needs refusal code` From b7198e5ed49a3bbb5d1dd7da1a67e8192449b7f4 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 17:39:25 +0900 Subject: [PATCH 32/38] rdm(api): store a failed request as its id and its record At the first joint of needs_refusal_code the record's message proved equal to the reason text on every path, so the failure keeps no second copy of it. Co-Authored-By: Claude Opus 5.5 --- __roadmap__/m6_gaps/needs_refusal_code.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/__roadmap__/m6_gaps/needs_refusal_code.md b/__roadmap__/m6_gaps/needs_refusal_code.md index 2bb93a57..f0749df1 100644 --- a/__roadmap__/m6_gaps/needs_refusal_code.md +++ b/__roadmap__/m6_gaps/needs_refusal_code.md @@ -8,7 +8,7 @@ - ⬜ The probe's answer is recorded: where the one record builder lives so that the engine can call it without `evaluation` importing from `jobs`, and whether a refused request can reach `Fault` with its typed error intact on every path that fails a request - ⬜ `guard_engine::a_kinds_refusal_ignores_the_kinds_beside_it` asserts that only B's request fails and that its failure carries a record with code `evaluation.run_part_missing`, in `EvaluateReport` and in `to_document()`; it is red on the base with the message in the leaf report, and green on the tip - ⬜ Every failed request carries a record: one whose error holds no code carries the fallback `candler.internal` with its message, never no record; a guard that exists for a failure with no code is extended to say so, or the leaf report names why none is needed -- ⬜ `EvaluateReport` and `to_document()` hold one producer for the record: the builder `jobs//refusal.json` uses, moved if the probe says so, with no second builder; the reason text stays as a field of the failure +- ⬜ `EvaluateReport` and `to_document()` hold one producer for the record: the builder `jobs//refusal.json` uses, moved if the probe says so, with no second builder; a failure holds its request id and its record only, its text being the record's `message`, so no reason text is stored beside it - ⬜ The fix commit is `fix(evaluation)!` and its body gives the migration of the public `failed_requests` field; every caller in the workspace is migrated, and `guard_cli_evaluate`'s `e1_`/`e4_` guards and `print_report` read the new shape - ⬜ The doc comment of `EvaluateReport` and of `to_document`, `__design__/architecture.md` where it states the report's keys, and any contract page that lists them say the same, each at its one source - ⬜ `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo nextest run --workspace` and `RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps` pass, and `git grep -n confirm_ -- crates python` prints nothing @@ -34,7 +34,7 @@ Strengthen `a_kinds_refusal_ignores_the_kinds_beside_it`: B's failure carries a ## Step 2: Carry the record **Goal**: The guard passes on the tip, with one record builder. **Implementation Logic**: -Move the builder if the probe says so, with `jobs/runtime/refusal.rs` calling it from its new place. `Fault` keeps the record built from the typed error where the fault is made; a fault with no typed error gets the fallback record. `EvaluateReport::failed_requests` carries, for each failure, the request id, the reason text and the record; `to_document()` writes the record next to `reason`. Migrate every caller: `print_report`, the CLI guards, test support. The commit body names the migration of the public field. +Move the builder if the probe says so, with `jobs/runtime/refusal.rs` calling it from its new place. `Fault` keeps the record built from the typed error where the fault is made; a fault with no typed error gets the fallback record. `EvaluateReport::failed_requests` carries, for each failure, a `#[non_exhaustive]` `FailedRequest` of the request id and the record; `to_document()` writes `{request, refusal}`, and the old `reason` text is the record's `message` (decided at joint 1: a second copy of the text would be state a consumer must reconcile). Migrate every caller: `print_report`, the CLI guards, test support. The commit body names the migration of the public field. **Deliverables**: `crates/candler-core/src/evaluation/engine/{run.rs,mod.rs}`; the builder's module; `crates/candler/src/commands/evaluate.rs`; the migrated tests **Consistency Checks**: the guard of step 1, then `cargo nextest run --workspace` (expected: PASS) **Commit**: `fix(evaluation)!: carry a refused request's code in the report` From 12135ec4405398b951914a506ed61c12d0005629 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 17:38:42 +0900 Subject: [PATCH 33/38] test(evaluation): state that a refused request carries its code a_kinds_refusal_ignores_the_kinds_beside_it reads the report document and expects B1's failure to carry the refusal/1 code evaluation.run_part_missing. It is red on the base: the document holds {request, reason} only. Co-Authored-By: Claude Sonnet 5 --- .../m6_gaps/leaves/needs_refusal_code_v0.md | 18 ++++++++++++++++++ crates/candler-core/tests/it/guard_engine.rs | 12 ++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 __reports__/m6_gaps/leaves/needs_refusal_code_v0.md diff --git a/__reports__/m6_gaps/leaves/needs_refusal_code_v0.md b/__reports__/m6_gaps/leaves/needs_refusal_code_v0.md new file mode 100644 index 00000000..5debc3ad --- /dev/null +++ b/__reports__/m6_gaps/leaves/needs_refusal_code_v0.md @@ -0,0 +1,18 @@ +# Needs refusal code — Leaf report (v0) + +Leaf: `__roadmap__/m6_gaps/needs_refusal_code.md`. Branch `fix/needs-refusal-code`. Status: step 1 done. + +## Probe: where does the one record builder go, and does every path hold its typed error? + +- `jobs` is `cfg(unix)`, `evaluation` is not, so `evaluation::engine` cannot import `jobs::runtime::refusal::record_of`. The builder moves beside `crate::refusal::find` and `jobs/runtime/refusal.rs` calls it from there. Only those two modules change. +- Paths that fail a request, by what the `Fault` is made from: + - typed at the fault: `Client::evaluate` (`ClientError`), `write::commit` (its error), `write::not_applicable`, `OutcomeError` (`fail` closure in `run_batch`); + - typed but stringified before the fault: `send`'s blocking closure turns `assemble` and `materialise` errors, and the two `create_dir_all` errors, into `String` inside the closure. This is the path of `evaluation.run_part_missing`. The closure returns the `Fault` instead, built there from the typed error; + - no typed error, only a message: the cancel paths, a bad marker, a missing evaluator description, a dependency whose request failed, a client answer for the wrong id, `empty_digest` (returns `String`), the blocking-task join error. These carry the fallback record `candler.internal` with their message. +- Decision: go on. + +## Guard red on the base + +`a_kinds_refusal_ignores_the_kinds_beside_it` now reads `to_document()["failed_requests"][0]["refusal"]["code"]` against the hand literal `evaluation.run_part_missing`. Red on the base, verbatim: + +`assertion `left == right` failed: B1's failure carries the code of its refusal: {"counts":{"pass":1},"failed_requests":[{"reason":"run 8f82869f4eb3438f27acf835f43e91f2a3c35a303264305ba58de1732a64d38d-r6-a2 stores no `trace`","request":"01a230c1-66ab-76cc-967c-865cdc8b5e88"}], ...} left: Null right: "evaluation.run_part_missing"` diff --git a/crates/candler-core/tests/it/guard_engine.rs b/crates/candler-core/tests/it/guard_engine.rs index dec0c1b2..a6253039 100644 --- a/crates/candler-core/tests/it/guard_engine.rs +++ b/crates/candler-core/tests/it/guard_engine.rs @@ -614,9 +614,11 @@ async fn the_persisted_context_digest_is_the_digest_of_what_the_plugin_received( /// Guards: a kind's result ignores the kinds sent beside it (refusal). On a run sealed with no /// trace, the manifest-only kind A1 is graded and the trace kind B1 alone is refused, so the /// report holds A1's record and exactly one failed request, whose reason names the missing -/// `trace`. Oracle: the hand literals below. +/// `trace` and whose `refusal/1` record, read from the report document, carries the code +/// `evaluation.run_part_missing`. Oracle: the hand literals below. /// Bite: grouping a stage's entries by evaluator alone sends A1 and B1 in one request, which the -/// missing trace refuses whole. +/// missing trace refuses whole; turning a request's typed error into text before its record is +/// built leaves the record with the fallback code `candler.internal`. #[tokio::test] async fn a_kinds_refusal_ignores_the_kinds_beside_it() { let sealed = rig().await; @@ -651,6 +653,12 @@ async fn a_kinds_refusal_ignores_the_kinds_beside_it() { reason.contains("stores no `trace`") && reason.contains(&bare.to_string()), "the refusal names the missing trace and the run: {reason}" ); + let document = report.to_document(); + assert_eq!( + document["failed_requests"][0]["refusal"]["code"], + "evaluation.run_part_missing", + "B1's failure carries the code of its refusal: {document}" + ); } /// Guards: a kind's result ignores the kinds sent beside it (reuse key). On a run with a trace, From 531b081174d0ec0103d15b06d7f73c457b01c9ff Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 17:45:17 +0900 Subject: [PATCH 34/38] fix(evaluation)!: carry a refused request's code in the report A request the engine refuses was reported as its error text. It now carries the refusal/1 record of its error, built by the one builder the job's refusal.json uses, so a consumer reads the code, side and pointer and no longer matches text. On a run with no trace, kind B's failure carries evaluation.run_part_missing. The builder `record_of` moves from jobs::runtime::refusal to crate::refusal, beside `find`, with `fallback` for a failure that holds no coded error (code candler.internal). The blocking closure of `send` returns the Fault built from the typed assemble and materialise errors instead of their text. BREAKING CHANGE: EvaluateReport::failed_requests is Vec and no longer Vec<(RequestId, String)>. FailedRequest is #[non_exhaustive] with `request: RequestId` and `refusal: RefusalRecord`. Migrate `.0` to `.request` and `.1` to `.refusal.message()`; the code is `.refusal.code()`. In the report document of `candler evaluate`, each failure is {request, refusal}: the `reason` key is gone, its text is `refusal.message`. jobs::runtime::refusal::record_of is now crate::refusal::record_of. Co-Authored-By: Claude Sonnet 5 --- .../candler-core/src/evaluation/engine/mod.rs | 27 +++++- .../candler-core/src/evaluation/engine/run.rs | 94 ++++++++++--------- .../candler-core/src/jobs/orchestrate/mod.rs | 2 +- .../candler-core/src/jobs/runtime/evaluate.rs | 3 +- .../candler-core/src/jobs/runtime/refusal.rs | 30 +----- .../candler-core/src/jobs/runtime/session.rs | 3 +- crates/candler-core/src/refusal.rs | 40 +++++++- crates/candler-core/tests/it/guard_engine.rs | 13 ++- 8 files changed, 127 insertions(+), 85 deletions(-) diff --git a/crates/candler-core/src/evaluation/engine/mod.rs b/crates/candler-core/src/evaluation/engine/mod.rs index 5225f2fe..ec1c2fa7 100644 --- a/crates/candler-core/src/evaluation/engine/mod.rs +++ b/crates/candler-core/src/evaluation/engine/mod.rs @@ -10,6 +10,7 @@ use std::time::Duration; use candler_schemas::evaluation::{EvaluationError, PluginEnvironment, SuiteFile}; use candler_schemas::execution::EventPayload; use candler_schemas::primitives::{Marker, Name, NameVersion, RequestId, RunKey}; +use candler_schemas::refusal::RefusalRecord; use futures::future::join_all; use globset::Glob; use tokio::sync::watch; @@ -93,13 +94,26 @@ pub struct EvaluateReport { pub counts: BTreeMap, /// The outcome files written. pub outcome_files: Vec, - /// The requests that failed, each with why. - pub failed_requests: Vec<(RequestId, String)>, + /// The requests that failed, each with the `refusal/1` record of why. + pub failed_requests: Vec, +} + +/// A request that failed and published no outcome file: its id and the `refusal/1` record of the +/// error that failed it. The record holds the stable code, the side at fault, the pointer and the +/// message; a failure that holds no coded error carries the code `candler.internal`. +#[derive(Debug, Clone, PartialEq, Eq)] +#[non_exhaustive] +pub struct FailedRequest { + /// The request that failed. + pub request: RequestId, + /// Why it failed, as the record of `jobs//refusal.json` states a refusal. + pub refusal: RefusalRecord, } impl EvaluateReport { /// The report as the document `candler evaluate` prints: `request_ids`, `counts`, - /// `outcome_files` and `failed_requests`, each failure as `{request, reason}`. + /// `outcome_files` and `failed_requests`, each failure as `{request, refusal}`, where `refusal` is + /// its `refusal/1` record. #[must_use] pub fn to_document(&self) -> serde_json::Value { serde_json::json!({ @@ -113,7 +127,12 @@ impl EvaluateReport { "failed_requests": self .failed_requests .iter() - .map(|(id, why)| serde_json::json!({"request": id.to_string(), "reason": why})) + .map(|failed| { + serde_json::json!({ + "request": failed.request.to_string(), + "refusal": failed.refusal, + }) + }) .collect::>(), }) } diff --git a/crates/candler-core/src/evaluation/engine/run.rs b/crates/candler-core/src/evaluation/engine/run.rs index 92f34a30..c338e8f6 100644 --- a/crates/candler-core/src/evaluation/engine/run.rs +++ b/crates/candler-core/src/evaluation/engine/run.rs @@ -15,6 +15,7 @@ use candler_schemas::outcome::{Instrument, OutcomeRecord, Status}; use candler_schemas::primitives::{ Digest, ExpectationId, Marker, Name, NameVersion, RequestId, RunKey, }; +use candler_schemas::refusal::RefusalRecord; use futures::future::join_all; use tokio::sync::watch; @@ -119,7 +120,7 @@ pub(crate) struct RunOutput { /// The records published, per status. pub(crate) counts: BTreeMap, /// The requests that failed, each with why. - pub(crate) failed: Vec<(RequestId, String)>, + pub(crate) failed: Vec, } /// What one batch came to. @@ -130,7 +131,7 @@ enum BatchResult { /// request was sent. Failed { request: RequestId, - message: String, + refusal: RefusalRecord, deadline: Option, }, /// The batch published `file`; `deadline` is the one given to the client, if the request was @@ -154,15 +155,32 @@ struct Ticket { /// Why a batch failed, with the request id when the client had given one. struct Fault { request: Option, - message: String, + // BORROW: boxed so that the error of a `Result` stays small + refusal: Box, } impl Fault { - /// A fault with no request id yet. + /// A fault with no request id yet and no coded error: it carries the fallback record. fn new(message: impl Into) -> Self { Self { request: None, - message: message.into(), + refusal: Box::new(crate::refusal::fallback(message.into())), + } + } + + /// A fault with no request id yet, whose record is built from `error`. + fn of(error: &(dyn std::error::Error + 'static)) -> Self { + Self { + request: None, + refusal: Box::new(crate::refusal::record_of(error)), + } + } + + /// The fault of the request `request`. + fn on(self, request: RequestId) -> Self { + Self { + request: Some(request), + ..self } } } @@ -301,7 +319,7 @@ fn absorb( BatchResult::NotStarted => {} BatchResult::Failed { request, - message, + refusal, deadline, } => { // BORROW: .clone() keeps the id in every list @@ -309,7 +327,7 @@ fn absorb( if let Some(deadline) = deadline { out.request_deadlines.push((request.clone(), deadline)); // BORROW: the list owns the id } - out.failed.push((request, message)); + out.failed.push(super::FailedRequest { request, refusal }); } BatchResult::Committed { request, @@ -356,8 +374,7 @@ async fn core_only( let mut records = Vec::with_capacity(entries.len()); for checked in entries { records.push( - write::not_applicable(&stamp, &checked.entry) - .map_err(|error| Fault::new(error.to_string()))?, + write::not_applicable(&stamp, &checked.entry).map_err(|error| Fault::of(&error))?, ); } publish(shared, stamp, records).await @@ -387,7 +404,7 @@ fn settle( Ok(result) => result, Err(fault) => BatchResult::Failed { request: fault.request.unwrap_or(request), - message: fault.message, + refusal: *fault.refusal, deadline: sent, }, } @@ -425,14 +442,8 @@ async fn publish( records, }) } - Ok(None) => Err(Fault { - request: Some(request), - message: "the request was cancelled".to_owned(), - }), - Err(error) => Err(Fault { - request: Some(request), - message: error.to_string(), - }), + Ok(None) => Err(Fault::new("the request was cancelled").on(request)), + Err(error) => Err(Fault::of(&error).on(request)), } } @@ -452,7 +463,9 @@ async fn run_batch( Err(error) => { return BatchResult::Failed { request: RequestId::new_v7(), - message: format!("no evaluator slot could be taken: {error}"), + refusal: crate::refusal::fallback(format!( + "no evaluator slot could be taken: {error}" + )), deadline: None, }; } @@ -538,10 +551,7 @@ async fn attempt( remove_tree(dir).await; let (outcome, digest) = sent?; if shared.cancelled() { - return Err(Fault { - request: Some(outcome.request_id), - message: "the request was cancelled".to_owned(), - }); + return Err(Fault::new("the request was cancelled").on(outcome.request_id)); } (outcome.request_id, digest, outcome.items) }; @@ -554,21 +564,18 @@ async fn attempt( context_digest, request, }; - let fail = |error: candler_schemas::outcome::OutcomeError| Fault { - request: Some(stamp.request.clone()), // BORROW: the fault owns the id - message: error.to_string(), + let fail = |error: candler_schemas::outcome::OutcomeError| { + Fault::of(&error).on(stamp.request.clone()) // BORROW: the fault owns the id }; let mut rows: BTreeMap<&ExpectationId, OutcomeRecord> = BTreeMap::new(); for (checked, item) in sendable.iter().zip(items) { if item.expectation_id() != checked.entry.id() { - return Err(Fault { - request: Some(stamp.request.clone()), // BORROW: the fault owns the id - message: format!( - "the client answered {} where {} was expected", - item.expectation_id(), - checked.entry.id() - ), - }); + return Err(Fault::new(format!( + "the client answered {} where {} was expected", + item.expectation_id(), + checked.entry.id() + )) + .on(stamp.request.clone())); // BORROW: the fault owns the id } // A dependency that ran earlier in this request may have ended without a pass. let record = match blocker(&checked.entry, &known, &BTreeSet::new()) { @@ -626,24 +633,23 @@ async fn send( let records_dir = shared.record_dir.clone(); // BORROW: the blocking task owns the path let context = blocking(move || { std::fs::create_dir_all(&scratch).map_err(|error| { - format!( + Fault::new(format!( "cannot create the scratch directory {}: {error}", scratch.display() - ) + )) })?; std::fs::create_dir_all(&records_dir).map_err(|error| { - format!( + Fault::new(format!( "cannot create the record directory {}: {error}", records_dir.display() - ) + )) })?; - let assembled = assemble(&store, &key, &needs).map_err(|error| error.to_string())?; - let context = materialise(&assembled, &workspace).map_err(|error| error.to_string())?; - Ok::<_, String>((context, scratch)) + let assembled = assemble(&store, &key, &needs).map_err(|error| Fault::of(&error))?; + let context = materialise(&assembled, &workspace).map_err(|error| Fault::of(&error))?; + Ok::<_, Fault>((context, scratch)) }) .await - .map_err(Fault::new)? - .map_err(Fault::new)?; + .map_err(Fault::new)??; let (context, scratch) = context; let digest = context.context_digest(); @@ -697,7 +703,7 @@ async fn send( if matches!(error, ClientError::Cancelled) { Fault::new("the request was cancelled") } else { - Fault::new(error.to_string()) + Fault::of(&error) } })?; Ok((outcome, digest)) diff --git a/crates/candler-core/src/jobs/orchestrate/mod.rs b/crates/candler-core/src/jobs/orchestrate/mod.rs index ec97bf0d..b8080417 100644 --- a/crates/candler-core/src/jobs/orchestrate/mod.rs +++ b/crates/candler-core/src/jobs/orchestrate/mod.rs @@ -27,7 +27,7 @@ use self::session::{ }; use crate::isolation::model::{ImageId, ImageRef, SweepScope}; use crate::jobs::model::{JobControl, JobOutcome, JobSpec}; -use crate::jobs::runtime::refusal::record_of; +use crate::refusal::record_of; use crate::runner::plan::{Force, PlanCtx, PlanMode, experiment_of, plan_runs}; use crate::runner::{JobMeter, Runtime}; diff --git a/crates/candler-core/src/jobs/runtime/evaluate.rs b/crates/candler-core/src/jobs/runtime/evaluate.rs index a4845926..48c48893 100644 --- a/crates/candler-core/src/jobs/runtime/evaluate.rs +++ b/crates/candler-core/src/jobs/runtime/evaluate.rs @@ -18,7 +18,7 @@ use tokio::sync::watch; use tokio::task::JoinHandle; use super::RuntimeError; -use super::refusal::{end_job, record_of, write_refusal}; +use super::refusal::{end_job, write_refusal}; use super::session::SPEC_FILE; use super::session::{ZombieTick, become_subreaper, detach_session, digest_of, note}; use super::signals::SignalWatch; @@ -32,6 +32,7 @@ use crate::jobs::events::JobEvents; use crate::jobs::lock::JobLock; use crate::jobs::model::{EvaluateSpec, JobCause, JobControl}; use crate::jobs::slots::{default_evaluator_slots, evaluator_slots_dir}; +use crate::refusal::record_of; use crate::resolve::config::{ConfigEnv, UserConfig}; use crate::store::Store; use crate::supervise::{EventSink, Supervisor}; diff --git a/crates/candler-core/src/jobs/runtime/refusal.rs b/crates/candler-core/src/jobs/runtime/refusal.rs index 20d4200c..749fd0fc 100644 --- a/crates/candler-core/src/jobs/runtime/refusal.rs +++ b/crates/candler-core/src/jobs/runtime/refusal.rs @@ -6,7 +6,7 @@ //! pointer from the job's own state and not from a log. use candler_schemas::execution::{EventPayload, JobEnd}; -use candler_schemas::refusal::{RefusalCode, RefusalRecord, Side}; +use candler_schemas::refusal::RefusalRecord; use super::session::note; use crate::jobs::dir::{JobDir, write_atomic}; @@ -17,34 +17,6 @@ use crate::supervise::EventSink; /// command that waits for the job can answer with the same code, side and path. pub const REFUSAL_FILE: &str = "refusal.json"; -/// The record of `error`: the code, side and path the walk of causes finds in it, or the fallback -/// code `candler.internal` when it finds none, its message and the messages of its causes. -#[must_use] -pub fn record_of(error: &(dyn std::error::Error + 'static)) -> RefusalRecord { - let message = error.to_string(); - let record = match crate::refusal::find(error) { - Some(found) => { - let record = RefusalRecord::new(found.code(), found.side(), message); - match found.path() { - Some(pointer) => record.clone().at_path(pointer).unwrap_or(record), - None => record, - } - } - None => RefusalRecord::new( - RefusalCode::from_checked("candler.internal"), - Side::Candler, - message, - ), - }; - let mut causes = Vec::new(); - let mut source = error.source(); - while let Some(cause) = source { - causes.push(cause.to_string()); - source = cause.source(); - } - record.with_causes(causes) -} - /// Writes `record` to [`REFUSAL_FILE`] of `dir`. A write that fails is noted and the job goes on: /// the command that waits then falls back to the text of the log. pub fn write_refusal(dir: &JobDir, record: &RefusalRecord) { diff --git a/crates/candler-core/src/jobs/runtime/session.rs b/crates/candler-core/src/jobs/runtime/session.rs index 0e1558a8..e1ef4cde 100644 --- a/crates/candler-core/src/jobs/runtime/session.rs +++ b/crates/candler-core/src/jobs/runtime/session.rs @@ -15,7 +15,7 @@ use rustix::process::{getpid, setsid}; use tokio::sync::watch; use tokio::task::JoinHandle; -use super::refusal::{end_job, record_of}; +use super::refusal::end_job; use super::signals::SignalWatch; use super::sweep::{ProcMarkerSweeper, reap_confirmed, sweep_orphans}; use super::{JobEntry, RuntimeError}; @@ -31,6 +31,7 @@ use crate::jobs::lost::{self, JobLiveness, RecoverReport}; use crate::jobs::model::{JobBody, JobCause, JobControl, JobOutcome, JobSpec, JobSpecFile}; use crate::jobs::slots::Slots; use crate::jobs::view::JobView; +use crate::refusal::record_of; use crate::resolve::config::{ConfigEnv, UserConfig}; use crate::runner::Runtime; use crate::supervise::{EventSink, Supervisor}; diff --git a/crates/candler-core/src/refusal.rs b/crates/candler-core/src/refusal.rs index af190b54..7b590db3 100644 --- a/crates/candler-core/src/refusal.rs +++ b/crates/candler-core/src/refusal.rs @@ -8,7 +8,7 @@ use std::error::Error; -use candler_schemas::refusal::{CatalogRow, Refusal, Side}; +use candler_schemas::refusal::{CatalogRow, Refusal, RefusalCode, RefusalRecord, Side}; /// The rows of every coded error, in the order of the modules: the schemas', then the core's by /// module, then the harness interface's. @@ -58,6 +58,44 @@ pub fn find<'e>(error: &'e (dyn Error + 'static)) -> Option<&'e dyn Refusal> { None } +/// The record of `error`: the code, side and path the walk of causes finds in it, or the fallback +/// code `candler.internal` when it finds none, its message and the messages of its causes. +/// +/// The one builder of the `refusal/1` record: the job that an error ended and the request that +/// the evaluation engine refused both write what it returns. +#[must_use] +pub fn record_of(error: &(dyn Error + 'static)) -> RefusalRecord { + let message = error.to_string(); + let record = match find(error) { + Some(found) => { + let record = RefusalRecord::new(found.code(), found.side(), message); + match found.path() { + Some(pointer) => record.clone().at_path(pointer).unwrap_or(record), + None => record, + } + } + None => fallback(message), + }; + let mut causes = Vec::new(); + let mut source = error.source(); + while let Some(cause) = source { + causes.push(cause.to_string()); + source = cause.source(); + } + record.with_causes(causes) +} + +/// The record of a failure that holds no coded error: the code `candler.internal`, side Candler, +/// and `message`. +#[must_use] +pub fn fallback(message: String) -> RefusalRecord { + RefusalRecord::new( + RefusalCode::from_checked("candler.internal"), + Side::Candler, + message, + ) +} + /// The refusal that answers for `inner`: what the walk of causes finds from it, or `inner` itself /// when the walk finds nothing. pub(crate) fn answer_of(inner: &E) -> &dyn Refusal { diff --git a/crates/candler-core/tests/it/guard_engine.rs b/crates/candler-core/tests/it/guard_engine.rs index a6253039..c8cc8347 100644 --- a/crates/candler-core/tests/it/guard_engine.rs +++ b/crates/candler-core/tests/it/guard_engine.rs @@ -648,16 +648,21 @@ async fn a_kinds_refusal_ignores_the_kinds_beside_it() { "B1 alone is refused: {:?}", report.failed_requests ); - let reason = &report.failed_requests[0].1; + let failed = &report.failed_requests[0]; + assert_eq!( + failed.refusal.code().as_str(), + "evaluation.run_part_missing", + "B1's failure carries the code of its refusal: {failed:?}" + ); + let reason = failed.refusal.message(); assert!( reason.contains("stores no `trace`") && reason.contains(&bare.to_string()), "the refusal names the missing trace and the run: {reason}" ); let document = report.to_document(); assert_eq!( - document["failed_requests"][0]["refusal"]["code"], - "evaluation.run_part_missing", - "B1's failure carries the code of its refusal: {document}" + document["failed_requests"][0]["refusal"]["code"], "evaluation.run_part_missing", + "the document carries the same code: {document}" ); } From ea7ac2ebcecfc0c380dd04d4b9621a66afe277de Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 17:50:26 +0900 Subject: [PATCH 35/38] docs(evaluation): say a failed request carries its refusal The doc comments of to_document, record_of and fallback, and the architecture paragraph on report.json, say that each failed request holds the refusal/1 record built by the one builder the job's refusal.json uses. No contract page lists the report keys, so none is regenerated. Co-Authored-By: Claude Sonnet 5 --- __design__/architecture.md | 6 ++++-- crates/candler-core/src/evaluation/engine/mod.rs | 5 +++-- crates/candler-core/src/refusal.rs | 7 ++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/__design__/architecture.md b/__design__/architecture.md index fb562019..0b6e462e 100644 --- a/__design__/architecture.md +++ b/__design__/architecture.md @@ -399,8 +399,10 @@ names. `events.jsonl` serve `watch`. Every job kind, run or evaluate, leaves `refusal.json` when an error ended it: the `refusal/1` record of that error, written before `job.ended` by one function both supervisors call. A - finished evaluate job also leaves `report.json`, and the command prints the record in place of - a report. The command stops the job on Ctrl-C only: SIGTERM or SIGHUP of the command leaves + finished evaluate job also leaves `report.json`, whose `failed_requests` each hold the request + id and the `refusal/1` record of the error that failed it, built by that same function (the code + `candler.internal` when the failure holds no coded error); the command prints the record in + place of a report. The command stops the job on Ctrl-C only: SIGTERM or SIGHUP of the command leaves the job running, as it does for any job. Two evaluations over the same runs at once may grade a run twice; the readers (`show`, `analyze`, `diff`, the pending selection) take the current record under each I4 key, so the run counts once. A claim per run is not in place. diff --git a/crates/candler-core/src/evaluation/engine/mod.rs b/crates/candler-core/src/evaluation/engine/mod.rs index ec1c2fa7..7e30524e 100644 --- a/crates/candler-core/src/evaluation/engine/mod.rs +++ b/crates/candler-core/src/evaluation/engine/mod.rs @@ -112,8 +112,9 @@ pub struct FailedRequest { impl EvaluateReport { /// The report as the document `candler evaluate` prints: `request_ids`, `counts`, - /// `outcome_files` and `failed_requests`, each failure as `{request, refusal}`, where `refusal` is - /// its `refusal/1` record. + /// `outcome_files` and `failed_requests`, each failure as `{request, refusal}`, + /// where `refusal` is the `refusal/1` record of the error that failed the request: its `code`, + /// `side`, `path`, `message` and `causes`. #[must_use] pub fn to_document(&self) -> serde_json::Value { serde_json::json!({ diff --git a/crates/candler-core/src/refusal.rs b/crates/candler-core/src/refusal.rs index 7b590db3..de8d1cb3 100644 --- a/crates/candler-core/src/refusal.rs +++ b/crates/candler-core/src/refusal.rs @@ -61,8 +61,9 @@ pub fn find<'e>(error: &'e (dyn Error + 'static)) -> Option<&'e dyn Refusal> { /// The record of `error`: the code, side and path the walk of causes finds in it, or the fallback /// code `candler.internal` when it finds none, its message and the messages of its causes. /// -/// The one builder of the `refusal/1` record: the job that an error ended and the request that -/// the evaluation engine refused both write what it returns. +/// This is the one builder of a `refusal/1` record. A job that an error ended writes what it +/// returns to `refusal.json`, and the evaluation engine attaches it to each request it refused, so +/// the two never disagree on a code, side or path. #[must_use] pub fn record_of(error: &(dyn Error + 'static)) -> RefusalRecord { let message = error.to_string(); @@ -86,7 +87,7 @@ pub fn record_of(error: &(dyn Error + 'static)) -> RefusalRecord { } /// The record of a failure that holds no coded error: the code `candler.internal`, side Candler, -/// and `message`. +/// and `message`. [`record_of`] builds on it, so a job and a request share the one fallback. #[must_use] pub fn fallback(message: String) -> RefusalRecord { RefusalRecord::new( From e8d304b3cda431d0fe3a0560b5dfd67d01c95fa5 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 17:54:58 +0900 Subject: [PATCH 36/38] reports(evaluation): close the needs refusal code Co-Authored-By: Claude Sonnet 5 --- .../m6_gaps/leaves/needs_refusal_code_v0.md | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/__reports__/m6_gaps/leaves/needs_refusal_code_v0.md b/__reports__/m6_gaps/leaves/needs_refusal_code_v0.md index 5debc3ad..fb0e46df 100644 --- a/__reports__/m6_gaps/leaves/needs_refusal_code_v0.md +++ b/__reports__/m6_gaps/leaves/needs_refusal_code_v0.md @@ -1,6 +1,6 @@ # Needs refusal code — Leaf report (v0) -Leaf: `__roadmap__/m6_gaps/needs_refusal_code.md`. Branch `fix/needs-refusal-code`. Status: step 1 done. +Leaf: `__roadmap__/m6_gaps/needs_refusal_code.md`. Branch `fix/needs-refusal-code`. Status: steps 1 to 4 done. ## Probe: where does the one record builder go, and does every path hold its typed error? @@ -16,3 +16,49 @@ Leaf: `__roadmap__/m6_gaps/needs_refusal_code.md`. Branch `fix/needs-refusal-cod `a_kinds_refusal_ignores_the_kinds_beside_it` now reads `to_document()["failed_requests"][0]["refusal"]["code"]` against the hand literal `evaluation.run_part_missing`. Red on the base, verbatim: `assertion `left == right` failed: B1's failure carries the code of its refusal: {"counts":{"pass":1},"failed_requests":[{"reason":"run 8f82869f4eb3438f27acf835f43e91f2a3c35a303264305ba58de1732a64d38d-r6-a2 stores no `trace`","request":"01a230c1-66ab-76cc-967c-865cdc8b5e88"}], ...} left: Null right: "evaluation.run_part_missing"` + +## Fix (step 2) + +- `record_of` moved to `crate::refusal`, beside `find`, with `fallback(message)` for a failure that holds no coded error. The three callers in `jobs` import it from there; `jobs/runtime/refusal.rs` keeps `write_refusal` and `end_job`. One builder. +- `EvaluateReport::failed_requests` is `Vec`, `#[non_exhaustive]`, with `request` and `refusal`. There is no `reason` field: the text is the record's `message`. `to_document()` writes `{request, refusal}`. +- `Fault` holds the record. `send`'s blocking closure returns a `Fault` built from the typed `assemble` and `materialise` errors, so `evaluation.run_part_missing` reaches the report. `Fault` boxes the record (`Box`) because `clippy::result_large_err` fires at 152 bytes on every `Result<_, Fault>`. +- Green on the tip: `a_kinds_refusal_ignores_the_kinds_beside_it` asserts the code from `EvaluateReport` (`failed.refusal.code()`) and from `to_document()`. + +## Callers migrated + +- `guard_engine::a_kinds_refusal_ignores_the_kinds_beside_it`: `.1` became `.refusal.message()`. +- `commands/evaluate.rs::print_report` and the CLI guards (`e1_`, `e4_`, `guard_cli`, `guard_cli_surface`, `guard_input_seam`, `guard_run_evaluate`, `graded_trace_e2e`) read `failed_requests` as a JSON array by emptiness or length only; they needed no change and pass. +- `jobs/orchestrate/mod.rs`, `jobs/runtime/{evaluate,session}.rs`: import `record_of` from `crate::refusal`. + +## No guard for the fallback + +The record is not optional by type, so a failure with no record cannot exist. No existing guard asserts a message-only failure (the dependency guard names "F2 depends on F1 ..." only in its Bite comment), so none was extended. A typed path that wrongly falls back is what the main guard and its bite catch. + +## Docs (step 3) + +Doc comments of `EvaluateReport::to_document`, `FailedRequest`, `record_of` and `fallback`; the paragraph of `__design__/architecture.md` on `report.json`. That paragraph named no report keys before; it now says each failed request holds the id and the record. No contract page lists the report keys, so none changed; `contract_pages::` passes without the bless variable. + +## Bite (step 4), on a scratch branch since deleted + +Building the `assemble` fault as `Fault::new(error.to_string())` again turns the guard red: `assertion `left == right` failed: B1's failure carries the code of its refusal: FailedRequest { ... refusal: RefusalRecord { ... code: RefusalCode("candler.internal"), side: Candler, ... message: "run 8f82...d38d-r6-a2 stores no `trace`" ... left: "candler.internal" right: "evaluation.run_part_missing"`. + +## Observations + +Failure paths that carry the fallback `candler.internal` (no coded error behind them), and whether a consumer would plausibly branch on each: + +| Path | Branch plausible? | +|---|---| +| cancelled request (client or engine) | Yes: it is a user act, not a fault; a caller may want to tell it from a failure | +| no evaluator slot could be taken | Yes: capacity, a caller may retry | +| `create_dir_all` of scratch or records directory | No: environment fault | +| dependency has no outcome because its request failed | Yes: it is a consequence of another failed request, and a caller may fold it into that one | +| client answered the wrong expectation id | No: a plug-in bug | +| `empty_digest` cannot build the empty context | No: internal | +| bad evaluation marker | No: internal | +| blocking task join error | No: internal | + +Giving any of them a code is a later decision and outside this leaf; `codes.toml` is unchanged. + +## Gate on the final tree + +`cargo fmt --check`, `cargo clippy -q --workspace --all-targets -- -D warnings` and `RUSTDOCFLAGS="-D warnings" cargo doc -q --workspace --no-deps` print nothing. `cargo nextest run --workspace --no-fail-fast`: 774 run, 774 passed (6 slow), 35 skipped; the same count passed once before the docs commit and once after it, with no `guard_wiring` timing failure, so no rerun was needed. `git grep -n confirm_ -- crates python` prints nothing; no `confirm_` test was written. From b46e5b1cf9434aa74f4f77b53740e935a6498238 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 18:00:00 +0900 Subject: [PATCH 37/38] reports(evaluation): review the needs refusal code Co-Authored-By: Claude Sonnet 5 --- .../m6_gaps/reviews/needs_refusal_code_v0.md | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 __reports__/m6_gaps/reviews/needs_refusal_code_v0.md diff --git a/__reports__/m6_gaps/reviews/needs_refusal_code_v0.md b/__reports__/m6_gaps/reviews/needs_refusal_code_v0.md new file mode 100644 index 00000000..6b38f09a --- /dev/null +++ b/__reports__/m6_gaps/reviews/needs_refusal_code_v0.md @@ -0,0 +1,50 @@ +# Review: needs refusal code (v0) + +Branch `fix/needs-refusal-code` against `fix/m6-gaps` (fcba6ebe, 2efdd604, 2eec0b00, a4e7efb6). Verdict: mergeable; no blocking finding. All runs are mine, in the builder's target dir; the branch holds no code change from me. I read the builder's report only after answering the questions. + +## Validity + +| Question | Answer | Evidence | +|---|---|---| +| Every path that fails a request carries a record | Yes. A typed error carries its code; an untyped one carries the fallback `candler.internal` with its message. | Every `Fault` is made by `Fault::new` (fallback) or `Fault::of` (`record_of`), and `Fault` holds no text field now (run.rs `Fault`). `Fault::of` is used for: assemble and materialise (`send`), the client error (`send`), the publish error (`publish`), the outcome error (`attempt`'s `fail`), `write::not_applicable` (`core_only`). `Fault::new` is used only where the source was already text on the base: cancel, missing evaluator, missing dependency, wrong expectation id, marker, directory creation, `empty_digest`, the blocking join error. | +| A path that had a typed error loses it | No. | Diff: each place that did `error.to_string()` now calls `Fault::of(&error)`; none goes the other way. The strings left were strings on the base. The blocking closure now returns `Fault`, so `assemble`'s `ContextError` keeps its code. | +| One builder, same record in `EvaluateReport`, `to_document()` and `refusal.json` | Yes. | `crate::refusal::record_of` is the only builder (moved from `jobs::runtime::refusal`); `fallback` is its fallback arm, shared with `Fault::new`. `end_job`/`write_refusal` and `orchestrate`, `session`, `evaluate` import it from there. `to_document()` serialises `FailedRequest.refusal` as is, so report and document cannot differ. `refusal.json` is written for a job an error ended; a request failure is in `report.json` of a job that completed, so the two files are different events from one builder, not two copies. | +| Guard goes red under its bite | Yes. | Scratch branch, `assemble` fault in `send` back to `Fault::new(error.to_string())`: `a_kinds_refusal_ignores_the_kinds_beside_it` panics at guard_engine.rs:652: `assertion left == right failed: B1's failure carries the code of its refusal: ... code: RefusalCode("candler.internal") ... left: "candler.internal" right: "evaluation.run_part_missing"`. Scratch branch deleted, worktree clean. | +| Print and consumers | `print_report` is untouched and needs no change. | It prints the `report.json` document and counts `failed_requests` by array length (commands/evaluate.rs:289); the CLI guards only compare `failed_requests` to `[]`. No in-workspace reader of the old `reason` key or of `.0`/`.1` is left (`git grep` over crates, python, docs). | + +## Develop + +- Scope boundary kept. Touched: `evaluation/engine/{mod,run}.rs`, `refusal.rs`, `jobs/runtime/refusal.rs` (builder removed), one-line import edits in `jobs/orchestrate/mod.rs`, `jobs/runtime/{evaluate,session}.rs` (the consequence of the move), the guard and `__design__/architecture.md`. No batching, stage, wire or schema change. +- Spend, measured from the transcript (39 distinct `message.id`; input 84, output 24,561, cache write 153,647, cache read 4,594,348): **$1.32** against the $2 estimate (66 %), under the $4 cap. + +## Leave + +- One builder, no copy in `jobs` (the `jobs` module keeps `write_refusal`, `end_job` and the file name only). PASS. +- Evaluation depends on jobs as before (`jobs::slots`, already imported on the base); this change adds no edge, and the builder moved the other way, out of `jobs`. PASS. +- State stored twice: no. `reason` is gone; the text is `refusal.message`, the only copy. PASS. +- Docs at source: the `EvaluateReport`/`FailedRequest`/`to_document` doc comments and one paragraph of `architecture.md`; no contract page lists the report keys. PASS. +- `Box` in `Fault`: justified. The record holds a code, side, two optional strings, a message and a causes vector, so it would push `Result<_, Fault>` over clippy's large-error size. `settle` unboxes once. A simpler shape (a record in a `Result` with `Arc`) gains nothing. + +## Consume + +- Library: `FailedRequest.refusal.code()`; document and `report.json`: `failed_requests[i].refusal.code`; the printed report is the same document. No text parsing anywhere. PASS. +- `#[non_exhaustive]` on `FailedRequest` with public fields: outside callers can read both fields and match with `..`; they cannot build one, which no caller needs. PASS. +- `!` commit body gives the migration (`.0` to `.request`, `.1` to `.refusal.message()`, code `.refusal.code()`, `reason` key gone, `record_of` path moved). Enough for a caller outside the workspace; see F2 for the one piece missing. + +## Findings + +| # | Sev | Finding | Smallest fix | Blocking | +|---|---|---|---|---| +| F1 | Low | No test reaches the fallback arm for a request failure (run.rs `Fault::new` paths: cancel, missing dependency, wrong expectation id). The gate allows the report to say none is needed, but the fallback is the contract for every untyped failure, and a later change to `Fault::new` would go unseen. | One guard on a stub evaluator answering the wrong expectation id: assert code `candler.internal` and the message. | No | +| F2 | Low | The commit migration names `record_of`'s new path but `record_of` is also still reachable as `jobs::runtime::refusal::record_of` only if re-exported; it is not, so an outside caller of the old path breaks with no deprecation. Per the no-external-users rule this is acceptable, and the `!` body states it. | None. | No | +| F3 | Info | Four sentences of `architecture.md` line 402-405 now run past 100 columns by a few characters (comment-level only). | Rewrap. | No | +| F4 | Info | `empty_digest` and `blocking` still turn their errors into `String` before the `Fault`; they hold no code on the base either, so no regression. | None. | No | + +## Runs + +- `cargo nextest run --workspace --no-fail-fast` on the tip: **774 tests run: 774 passed (6 slow), 35 skipped** (180 s). +- Bite: the one guard red with the message above; switched back and deleted `scratch/bite-review`. + +## Open + +- Not run: fmt, clippy, doc, contract-page test (the builder reports them green; the workspace test run is mine). From 679c9bfcd962ab5de825c562612d62ca0e6870f2 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Tue, 1 Dec 2026 18:06:12 +0900 Subject: [PATCH 38/38] rdm(api): close amendment A1 of the M6 gaps campaign needs_refusal_code and its review are done. The batched-needs gate holds as approved: on a run with no trace, kind B carries `evaluation.run_part_missing`. The tip gates are met again after the merge (774 of 774, fmt, clippy, doc, contract pages, no `confirm_`), and the Docker guard G6 passes alone. The knowledge-transfer report gains the A1 section, its review findings, the second `fix(evaluation)!` in the version effect, A1's spend ($5.41) and four observations. The process lesson on gates now says that a joint which would narrow an approved gate goes to the maintainer. The pull-request text follows. Co-Authored-By: Claude Opus 5.5 --- .../m6_gaps/00-knowledge_transfer_v0.md | 81 ++++++++++++++----- __roadmap__/m6_gaps/README.md | 20 ++--- __roadmap__/m6_gaps/review/README.md | 4 +- 3 files changed, 72 insertions(+), 33 deletions(-) diff --git a/__reports__/m6_gaps/00-knowledge_transfer_v0.md b/__reports__/m6_gaps/00-knowledge_transfer_v0.md index 091b1bbb..02fceec0 100644 --- a/__reports__/m6_gaps/00-knowledge_transfer_v0.md +++ b/__reports__/m6_gaps/00-knowledge_transfer_v0.md @@ -1,10 +1,10 @@ # M6 gaps before M7: knowledge transfer (v0) -Date: 2026-12-01. Campaign `__roadmap__/m6_gaps/`, integration branch `fix/m6-gaps` (cut from `ad74ff94`, v0.19.0), tip `46516fd9`. +Date: 2026-12-01. Campaign `__roadmap__/m6_gaps/`, integration branch `fix/m6-gaps` (cut from `ad74ff94`, v0.19.0), tip `4579cebb` after amendment A1. ## Executive summary -Three gaps that M6.5 and M6d left on `main` are closed on `fix/m6-gaps`. Each is judged against the README purpose paragraph. +Three gaps that M6.5 and M6d left on `main` are closed on `fix/m6-gaps`. Each is judged against the README purpose paragraph. Amendment A1 then carried the needs refusal's code into the evaluate report, which the first close had left as text. ```mermaid graph LR @@ -14,9 +14,11 @@ graph LR L1 --> M1[e1a5769f] L2 --> M2[022db6fd] L3 --> M3[e4ee9cc6] - M1 --> T[tip 46516fd9] + M3 --> A1[A1: needs_refusal_code] + A1 --> M4[4579cebb] + M1 --> T[tip 4579cebb] M2 --> T - M3 --> T + M4 --> T ``` | Gap | Serves (README) | Closed by | Merge | @@ -24,8 +26,9 @@ graph LR | O1, `opencode_real_binary_is_interrupted_by_the_stop_script` failed with `no collect` since `8d88cb50` and no CI job ran it | run agents under controlled conditions | the guard moved to the container selection and selects the export spec by variant | `e1a5769f` | | O11, a run job's refusal ended as `job.ended {"reason":"failed"}` plus a `supervisor.log` line | one operation API, thin surfaces | every job kind writes `jobs//refusal.json` through one `end_job` | `022db6fd` | | Notice 04, a kind's stored outcome and refusal depended on the kinds sent beside it | evaluation through pluggable evaluators | `plan()` keys a request by the needs of its own dependency component (Idea A, narrowed) | `e4ee9cc6` | +| A1, the needs refusal reached the evaluate report as text only | one operation API, thin surfaces | each failed request holds its `refusal/1` record, built by the one builder `refusal.json` uses | `4579cebb` | -Gates on the tip, run after the last merge: `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo nextest run --workspace` (774 run, 774 passed, 35 skipped, 183.7 s; 772/772 after each earlier merge) and `RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps` pass. `git grep -n confirm_ -- crates python` prints nothing. The container selection (below) passed 28 of 28. The `container-e2e` gate on the integration pull request is still open, because the pull request is not opened. +Gates on the tip, run after the last merge: `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo nextest run --workspace` (774 run, 774 passed, 35 skipped, 179.3 s after the A1 merge `4579cebb`; 774/774 at the first close and 772/772 after each earlier merge) and `RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps` pass. `git grep -n confirm_ -- crates python` prints nothing. The container selection (below) passed 28 of 28 at the first close; after A1, which moved the record builder G6 reads through, `guard_harness_check_refuses` was rerun alone and passed (25.2 s), and the contract pages pass without the bless variable. The `container-e2e` gate on the integration pull request is still open, because the pull request is not opened. ## Gap 1: the OpenCode stop-script guard (O1) @@ -104,7 +107,7 @@ Guards, red then green: | `a_kinds_reuse_key_ignores_the_kinds_beside_it` | `A1's context digest under suite {A} and under suite {A, B}`: `sha256:5ac2394f...` against `sha256:5b92ae6d...` | same | | `dependencies_and_applies_to_decide_what_is_sent` | passes on the base; red with `F2 depends on F1, which has no outcome because its request failed` | keying every entry by its own needs (the review also saw `e1_engine_emits_one_outcome_event_per_committed_record` go red) | -The refusal guard asserts on the text `stores no trace`, because the engine reports a refused request as text only: `evaluation.run_part_missing` is lost at `send`'s `Fault::new(error.to_string())`. The campaign gate was amended for this (`6c3f34f3`); the code is an observation, not a fix, because carrying it changes the report document, which the campaign does not own. +At the leaf's second joint the refusal guard was set to assert the text `stores no trace`, and the campaign gate was narrowed to match (`6c3f34f3`). The reason given, that the report document lay outside the campaign, was wrong: the document is under `evaluation/**`, which the leaf owned. Amendment A1 restored the gate and carried the code (below). **Requests per run** (review measurement, engine fixtures): @@ -121,15 +124,42 @@ Growth: requests per evaluator and stage equal the number of distinct needs sets | # | Finding | What became of it | |---|---|---| | F1 | `needs_key` used `to_value(...).unwrap_or_default()`, so a serialisation failure would silently restore the old grouping. | Fixed in `22ed7d5c`: a typed `NeedsKey` that cannot fail. | -| F2 | The refusal reaches a consumer as text in `failed_requests`, not as `evaluation.run_part_missing`. | Observation (row 12 below). | +| F2 | The refusal reaches a consumer as text in `failed_requests`, not as `evaluation.run_part_missing`. | Fixed by amendment A1 (`4579cebb`). | | F3 | Digest stability across suites relied on the order of needs lists. | Fixed in `22ed7d5c`: the key is equal for equal needs whatever the list order. No test varies the order; the digest already sorted artifacts, snapshots and inputs and held metadata in a map, so list order never reached it. | | F4 | A refused first batch of an evaluator also loses the not-applicable records it would publish. | Observation (row 13 below). | | F5 | Spend 1.6x the estimate. | A process lesson (below). | | F6 | A comment line over 100 columns in `guard_engine.rs`. | Fixed in `22ed7d5c`. | +## Amendment A1: the needs refusal code + +Gap report: [01-gap_refusal_code_v0](01-gap_refusal_code_v0.md). Leaf report: [needs_refusal_code_v0](leaves/needs_refusal_code_v0.md). Review: [needs_refusal_code_v0](reviews/needs_refusal_code_v0.md). + +| Commit | What | +|---|---| +| `12135ec4` | test: B's failure carries `evaluation.run_part_missing`, in `EvaluateReport` and in `to_document()` | +| `531b0811` | `fix(evaluation)!`: a failed request is a `FailedRequest` of its id and its `refusal/1` record | +| `ea7ac2eb` | docs: `EvaluateReport`, `to_document`, `crate::refusal`, `architecture.md` | + +**Probe.** `jobs` builds on Unix only and `evaluation` does not, so the engine could not call `jobs::runtime::refusal::record_of`. The builder moved beside `crate::refusal::find`, and the three job callers import it from there: one builder for `refusal.json` and for the report. The `assemble` path lost its type inside `send`'s blocking closure, which turned the error into a string; the closure now returns a `Fault` built from the typed error. + +**Change.** `failed_requests` is `Vec`, a `#[non_exhaustive]` struct of `request` and `refusal`. The document writes `{request, refusal}` and no longer `reason`: on every path the record's `message` is that text, so a second copy would be state to reconcile (decided at joint 1). Paths that hold no coded error carry the fallback `candler.internal`. `Fault` boxes its record, because `clippy::result_large_err` asks for it. + +| Guard | Red on the base | Bite | +|---|---|---| +| `a_kinds_refusal_ignores_the_kinds_beside_it` | `B1's failure carries the code of its refusal: {...}` left `Null`, right `"evaluation.run_part_missing"` | the blocking closure's fault built as `Fault::new(error.to_string())` again: left `"candler.internal"`; the review reran it with the same result | + +**Review findings.** None blocks. + +| # | Finding | What became of it | +|---|---|---| +| F1 | No test reaches the `candler.internal` fallback of a failed request. | Not fixed: `fallback` returns a constant, and a typed path falling back is what the guard's bite catches (joint 1 decision). Observation 17. | +| F2 | `jobs::runtime::refusal::record_of` moved with no re-export. | No external users; the `!` commit body states the move. | +| F3 | The new `architecture.md` lines pass 100 columns. | Observation 18; the file already has 269 such lines. | +| F4 | `empty_digest` and the join error still turn their errors into text. | They held no typed error on the base either. Observation 16. | + ## Version effect -`JobOutcome` is a public struct without `non_exhaustive`, so the `refusal` field breaks construction outside the crate. That is why `b94889ef` is `fix(jobs)!`; its body gives the migration (`refusal: None`). At `0.y` the core goes from 0.19.0 to 0.20.0 once, and the `fix(evaluation)` change lands in the same release. There is no `schemas@` release and no `candler-evaluator@` release, and `docs/contract/codes.toml` is unchanged. The CI release cuts 0.20.0 only after the pull request merges. +`JobOutcome` is a public struct without `non_exhaustive`, so the `refusal` field breaks construction outside the crate. That is why `b94889ef` is `fix(jobs)!`; its body gives the migration (`refusal: None`). At `0.y` the core goes from 0.19.0 to 0.20.0 once, and the `fix(evaluation)` change lands in the same release. Amendment A1's `531b0811` is `fix(evaluation)!`: `EvaluateReport::failed_requests` changes type, and its body gives the migration (`.1` becomes `.refusal.message()`, the document's `reason` becomes `refusal.message`). It rides on the same 0.20.0. There is no `schemas@` release and no `candler-evaluator@` release, and `docs/contract/codes.toml` is unchanged. The CI release cuts 0.20.0 only after the pull request merges. ## Spend @@ -143,12 +173,15 @@ Measured from transcripts, counting each message id once. Sonnet rates are $2, $ | needs_batches builder | 73 | $4.99 | $2.5 | $5 | | review_needs_batches | 20 | $0.61 | $0.8 | $1.6 | | close_out writer | 12 | $0.73 | $2 | $4 | +| needs_refusal_code builder (A1) | 39 | $1.32 | $2 | $4 | +| review_needs_refusal_code (A1) | 15 | $0.50 | $0.6 | $1.2 | | Lead coordination (Opus), at close | 108 | $7.28 | $4 to $7 | | +| Lead coordination of A1 (Opus), measured before its last commit | 45 | $3.59 | | | | Lead planning and roadmap authoring (Opus), before the cap was set | 84 | $8.50 | not in the cap | | -| Total within the cap (leaves, reviews, close-out, lead coordination) | 373 | $18.93 | $14.6 to $17.6 | $25.2 to $28.2 | -| Total with planning | 457 | $27.43 | | | +| Total within the cap (leaves, reviews, close-out, lead coordination, A1) | 472 | $24.34 | $17.2 to $20.2 | $30.4 to $33.4 | +| Total with planning | 556 | $32.84 | | | -The leaf and review reports quote earlier figures given to their authors ($2.19 for the job refusal builder, $4.02 for the needs builder). The table above replaces them. +The leaf and review reports quote earlier figures given to their authors ($2.19 for the job refusal builder, $4.02 for the needs builder). The table above replaces them. A1 cost $5.41 in all, of which $3.59 was the lead's: the reopened gate, the gap report, the hand-written roadmap lines, two joints and this update. ## Process lessons @@ -158,7 +191,7 @@ The leaf and review reports quote earlier figures given to their authors ($2.19 - The fix round after review. What to change: a brief names the hand-back call for a joint report, and a leaf this size ends and restarts with a short brief rather than carrying its whole context into the fix round. -2. **Name the evidence the gate can produce.** Two gates were wrong about the code, and both were found by the builder while writing the guard: the server row named a code the path never raises (`c77c1e01`), and the needs refusal named a code that never reaches a consumer (`6c3f34f3`). A gate sentence should be checked against the call path before dispatch. +2. **Name the evidence the gate can produce, and never narrow an approved gate alone.** Two gates were wrong about the code, both found by the builder while writing the guard. The server row named a code the path never raises, and rewording it to the code the path does raise (`c77c1e01`) kept its promise. The needs refusal named a code the engine dropped; rewording that gate to the text (`6c3f34f3`) narrowed what the maintainer approved, on an ownership claim the leaf's own file list contradicted. The maintainer reversed it, and amendment A1 carried the code. A gate sentence should be checked against the call path before dispatch; a joint that would narrow one goes to the maintainer. 3. **Cleanup by `Drop`, not by a call after the assertions.** A guard that panics before an explicit removal leaks the image it built. The first bite run of the stop guard did exactly that. 4. **A guard only Docker can run is a weak net for the shared write path.** Review F1 of the job refusal leaf shows it: the workspace gate stays green when `session::run` drops the record. 5. **Timing guards fail under load and pass alone.** Three different ones failed once in a full run during this campaign (rows 9 to 11 below). Each was rerun alone before it was called a regression. @@ -180,10 +213,14 @@ Every observation the leaf and review reports name, with a place to start. "Urge | 9 | Timing guard `a_pre_stop_command_leaves_nothing_in_its_group` failed once in a full run (`the command wrote a pid: ... No such file or directory`), passed alone in 0.9 s. | `crates/candler-core/tests/it/guard_supervise.rs` | low | | 10 | Timing guard `a_deadline_beats_an_answer_that_is_already_waiting` failed once in a full run, passed alone. | `crates/candler-core/tests/it/guard_protocol_client.rs` | low | | 11 | Timing guard `wiring_stop_execs_in_the_container_with_the_observed_id` failed once (136.7 s, `children/container-000000000000.json did not appear`), passed alone in 91.9 s. It took 92 s in another full run while other builds shared the machine. | `crates/candler-core/tests/it/guard_wiring.rs` | low | -| 12 | `evaluation.run_part_missing` is dropped at `send`'s `Fault::new(error.to_string())`, so `EvaluateReport.failed_requests` holds text only. A consumer must match `stores no trace`, which the guard pins. A later leaf can carry the code in `Fault` and the report, then the guard asserts the code. | `crates/candler-core/src/evaluation/engine/run.rs` | medium (a document change) | +| 12 | Closed by amendment A1: each failed request carries its `refusal/1` record, and the guard asserts `evaluation.run_part_missing`. | `crates/candler-core/src/evaluation/engine/` | closed | | 13 | A refused request leaves no file, so the not-applicable records its batch would publish are lost too. With split batches this now loses fewer records than before. | `crates/candler-core/src/evaluation/engine/` | low | | 14 | The golden suite's request count is inferred from the m2a plan (one needs set per evaluator and stage), not counted on the htn-creator-eval 0.4.2 plug-in. | `__roadmap__/m2a-evaluation-parity/components/assembly/htn_plugin.md` | low | | 15 | Docker's default `bridge` network was recreated by the daemon during the container run. The campaign did not make it. | Docker daemon | info | +| 16 | Failed requests with no coded error carry `candler.internal`: cancel, no slot, a failed dependency, a wrong expectation id, a bad marker, an undescribed evaluator, `empty_digest`, a join error. A consumer would plausibly branch on cancel, no slot and a failed dependency; giving those codes means new rows in `codes.toml`. | `crates/candler-core/src/evaluation/engine/run.rs` | low (feeds M7 `show`) | +| 17 | No test reaches the `candler.internal` fallback of a failed request (A1 review F1). A wrong-id stub evaluator would. | `crates/candler-core/tests/it/guard_engine.rs` | low | +| 18 | The `report.json` sentence of `architecture.md` passes 100 columns, as 269 other lines of the file do. | `__design__/architecture.md:402` | info | +| 19 | `dirtree-rdm` 0.1.0 `add` puts the Nodes row after the table's blank line in a README whose Amendment Log is empty, then rejects its own write; A1's Mermaid and Nodes lines were written by hand and validated. `scripts/worktree.py add` cuts from `origin/main` unless given `--base`. | managing-roadmaps plug-in; `scripts/worktree.py` | low | ## Artifacts to preserve @@ -194,7 +231,7 @@ Every observation the leaf and review reports name, with a place to start. "Urge ## Open questions - When does the `container-e2e` gate on the integration pull request list the two named guards as PASS? It is open until the pull request is opened. -- Should the report document carry the refusal code of a failed request (row 12)? It decides whether M7 can tell a missing part from a plug-in crash without matching text. +- Should cancel, no slot and a failed dependency get codes of their own (row 16)? It decides whether M7's `show` can tell them from an internal fault without matching text. ## Pull request text @@ -219,31 +256,33 @@ Closing M6.5 and M6d left three gaps on `main`. Each one makes a promise of the - The OpenCode stop-script guard selects the export spec by variant, builds its own image and runs in the `container-e2e` job. The list of expected guards names it and `guard_harness_check_refuses`. - Every job kind ends through one `end_job` and leaves its refusal in `jobs//refusal.json` (`refusal/1`: code, side, pointer). `job.ended` gains no field. `JobOutcome` gains `refusal: Option`, so code that builds one writes `refusal: None`. That is the `fix(jobs)!` commit, and the core goes from 0.19.0 to 0.20.0. A run job whose setup failed now also leaves its record. -- An evaluator's stage is split by the needs of its dependency components. Kinds with equal needs still share a request and a digest. A kind's context digest no longer changes when a kind with other needs joins the suite, and a run that lacks a trace refuses only the kinds that need one. The `fix(evaluation)` commit lands in the same release. There is no `schemas@` or `candler-evaluator@` release. +- An evaluator's stage is split by the needs of its dependency components. Kinds with equal needs still share a request and a digest. A kind's context digest no longer changes when a kind with other needs joins the suite, and a run that lacks a trace refuses only the kinds that need one. The `fix(evaluation)` commit lands in the same release. +- A refused evaluation request carries its `refusal/1` record in `EvaluateReport` and in the printed report, built by the same function as `refusal.json`: on a run with no trace, the trace kind fails with `evaluation.run_part_missing`. `failed_requests` becomes `Vec` (`request`, `refusal`) and the document drops `reason`, whose text is the record's `message`. That is a second `fix(evaluation)!` commit, in the same 0.20.0. There is no `schemas@` or `candler-evaluator@` release. ## Hard parts -- Two campaign gates named something the code does not do. The server refusal row names `jobs.server_exited_at_start`, the code a server that exits at start raises (`jobs.server_check_failed` takes the same path). The needs refusal is gated on the failed request it leaves, because the engine reports a refused request as text, so `evaluation.run_part_missing` does not reach a consumer. +- The server refusal row names `jobs.server_exited_at_start`, the code a server that exits at start raises (`jobs.server_check_failed` takes the same path). +- The engine dropped a refused request's code where the typed error became a string, in `send`. The record builder had to move out of `jobs`, which builds on Unix only, so evaluation could call it; there is still one builder. - Outcomes stored from today's mixed batches miss reuse once. The commit body says so. - A mixed suite sends more requests: the largest engine fixture goes from 1 to 2 per run. The count equals the number of distinct needs sets among an evaluator's components. The plug-in of the golden suite is expected to declare one set per evaluator and stage; that is inferred from a plan, not counted. - Each guard was seen red before it passed, on the base or under a named bite. The review reruns of those bites gave the same results. ## Not covered -- The refusal code of a failed evaluation request still reaches a consumer as text only. +- Failed requests that hold no coded error (cancel, no slot, a failed dependency, a wrong id) carry `candler.internal`. No test reaches that fallback. - Dropping the record in `session::run` is caught by the Docker guard only, which `container-e2e` runs on this pull request. - Four refusal paths of `run_job` (plan, cells, gate_controls, session open) have no guard of their own. - Per-entry digests and refusals in one request (Idea B of the notice) are not built. ## Observations -Fifteen observations, each with its location, are in `__reports__/m6_gaps/00-knowledge_transfer_v0.md`. The ones that matter next: +Nineteen observations, each with its location, are in `__reports__/m6_gaps/00-knowledge_transfer_v0.md`. The ones that matter next: -- A document change would let a consumer tell a missing part from a plug-in crash by code. +- Cancel, no slot and a failed dependency carry `candler.internal`; codes of their own would let M7's `show` tell them apart. - M7's `jobs` and `show` can read `refusal.json`. - Three timing guards (`guard_supervise`, `guard_protocol_client`, `guard_wiring`) fail once under load and pass alone. -Gates on the tip: `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo nextest run --workspace` (774 passed, 35 skipped) and `cargo doc` with warnings denied pass. The container selection passed 28 of 28 locally, including both named guards. Nobody is being waited on; the pull request can merge once CI is green. +Gates on the tip: `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo nextest run --workspace` (774 passed, 35 skipped) and `cargo doc` with warnings denied pass. The container selection passed 28 of 28 locally, including both named guards, and `guard_harness_check_refuses` passed again after the last change. Nobody is being waited on; the pull request can merge once CI is green. -Co-Authored-By: Claude Sonnet 5.5 +🤖 Generated with [Claude Code](https://claude.com/claude-code) ``` diff --git a/__roadmap__/m6_gaps/README.md b/__roadmap__/m6_gaps/README.md index 0a543a10..b346d57c 100644 --- a/__roadmap__/m6_gaps/README.md +++ b/__roadmap__/m6_gaps/README.md @@ -35,15 +35,15 @@ Every job kind that ends on a refusal leaves that refusal's code in `jobs//r - [x] `[cmd]` `docker info` succeeds, and `df -h /System/Volumes/Data` shows at least 20 GiB free ## Success Gates -- ⬜ Every leaf is `done`, and each build leaf's report records every guard it owns seen red (on the base or under its named bite) and then green, with the failing message -- ⬜ `git grep -n confirm_ -- crates python` prints nothing on the `fix/m6-gaps` tip -- ⬜ `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo nextest run --workspace` and `RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps` pass on the tip +- ✅ Every leaf is `done`, and each build leaf's report records every guard it owns seen red (on the base or under its named bite) and then green, with the failing message +- ✅ `git grep -n confirm_ -- crates python` prints nothing on the `fix/m6-gaps` tip +- ✅ `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo nextest run --workspace` and `RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps` pass on the tip - ⬜ `container-e2e` on the integration pull request lists `opencode_real_binary_is_interrupted_by_the_stop_script` and `guard_harness_check_refuses` as PASS - ✅ A run job refused at job start leaves `jobs//refusal.json`, a `refusal/1` record that names its code, side and pointer, for each of `experiment.harness_rejected_input`, `jobs.config_check_failed` and `jobs.server_exited_at_start` (the code a server that exits at start raises; `jobs.server_check_failed` goes through the same `ServerCheckError` path and needs no row of its own) -- ⬜ For a plug-in with an artifacts- or manifest-only kind A and a trace kind B, on a run with no trace A is graded and B carries `evaluation.run_part_missing`; on a run with a trace, A's context digest is the same for suite {A} and suite {A, B} -- ⬜ Each review report answers both of its lenses with evidence, and each finding is fixed on the leaf branch or recorded as an observation with its reason before that leaf merges +- ✅ For a plug-in with an artifacts- or manifest-only kind A and a trace kind B, on a run with no trace A is graded and B carries `evaluation.run_part_missing`; on a run with a trace, A's context digest is the same for suite {A} and suite {A, B} +- ✅ Each review report answers both of its lenses with evidence, and each finding is fixed on the leaf branch or recorded as an observation with its reason before that leaf merges - ⬜ The pull request `merge(api): close three M6 gaps before M7` is opened only after the maintainer's go; after it merges, the CI release cuts 0.20.0 -- ✅ Spend is measured from transcripts per leaf, and no leaf passed its cap without stopping. Leaf estimates add to $10.6 and caps to $21.2; with the lead's $4–7, the campaign stays within the cap the maintainer approves +- ✅ Spend is measured from transcripts per leaf, and no leaf passed its cap without stopping. Leaf estimates add to $10.6 and caps to $21.2, and amendment A1's to $2.6 and $5.2; with the lead's $4–7, the campaign stays within the cap the maintainer approves ## Gotchas - The two reviewed leaves stay on their branches until their review is answered; a finding is fixed on the leaf branch by the same builder, then the leaf merges. @@ -57,8 +57,8 @@ graph TD opencode_stop_guard[OpenCode stop guard]:::done job_refusal_record[Job refusal record]:::done needs_batches[Needs batches]:::done - needs_refusal_code[Needs refusal code]:::amendment - review[Review]:::amendment + needs_refusal_code[Needs refusal code]:::done + review[Review]:::done classDef done fill:#166534,color:#bbf7d0 classDef inprogress fill:#854d0e,color:#fef08a classDef planned fill:#374151,color:#e5e7eb @@ -72,8 +72,8 @@ graph TD | `opencode_stop_guard.md` | 📄 Leaf Task | ✅ Done | | `job_refusal_record.md` | 📄 Leaf Task | ✅ Done | | `needs_batches.md` | 📄 Leaf Task | ✅ Done | -| `needs_refusal_code.md` | 📄 Leaf Task | 🔵 Amendment | -| `review/` | 📁 Directory | 🔵 Amendment | +| `needs_refusal_code.md` | 📄 Leaf Task | ✅ Done | +| `review/` | 📁 Directory | ✅ Done | ## Amendment Log | ID | Date | Source | Nodes Added | Rationale | diff --git a/__roadmap__/m6_gaps/review/README.md b/__roadmap__/m6_gaps/review/README.md index 653636e5..a9a109b1 100644 --- a/__roadmap__/m6_gaps/review/README.md +++ b/__roadmap__/m6_gaps/review/README.md @@ -25,7 +25,7 @@ Each risky change is judged on validity and on develop, leave and consume before graph TD review_job_refusal[Review: job refusal]:::done review_needs_batches[Review: needs batches]:::done - review_needs_refusal_code[Review: needs refusal code]:::amendment + review_needs_refusal_code[Review: needs refusal code]:::done close[Close]:::done classDef done fill:#166534,color:#bbf7d0 classDef inprogress fill:#854d0e,color:#fef08a @@ -39,7 +39,7 @@ graph TD |:-----|:-----|:-------| | `review_job_refusal.md` | 📄 Leaf Task | ✅ Done | | `review_needs_batches.md` | 📄 Leaf Task | ✅ Done | -| `review_needs_refusal_code.md` | 📄 Leaf Task | 🔵 Amendment | +| `review_needs_refusal_code.md` | 📄 Leaf Task | ✅ Done | | `close/` | 📁 Directory | ✅ Done | ## Amendment Log