diff --git a/__reports__/diet/leaves/pages_v0.md b/__reports__/diet/leaves/pages_v0.md new file mode 100644 index 00000000..4eafe7a2 --- /dev/null +++ b/__reports__/diet/leaves/pages_v0.md @@ -0,0 +1,104 @@ +# Leaf P11 pages: the capability and configuration pages walk the declaration + +Base `7d497545` (`origin/feat/integrity`). Commits: `3a8fcb2e` (`test(api): hold the capability page to the drivers' answers`, step 1), `f3011686` (`docs(api): generate pages from the declaration`, step 2), `82a1989f` (`docs(api): show every setting of a path and one cell wording`, the first review round), `99028f47` (`docs(api): name the cap spec entries as items`, a rename that left the spec table in place — see Review round 3, finding 1), `613335ef` (`docs(api): render the spec rows without a table`, the removal of that table). This report covers steps 1 and 2 and the two review rounds that followed the Sonnet reviewer's findings. + +## Gates + +| Gate | Verdict | Evidence | +|---|---|---| +| 1. Capability rows from `AgentSetting::ALL` / `DriverFact::ALL`; `ROWS`, `Mapping`, `cap()` gone | PASS | `git grep -n 'ROWS\|fn cap\|Mapping\|SPEC_ITEMS\|SpecCell' -- crates/candler/tests/it/support/contract_pages/` on `613335ef` prints nothing (exit 1). Three loops build the table in `capabilities.rs::fields_table`: one over `AgentSetting::ALL`, two direct `write_row` calls for the spec rows, one over `DriverFact::ALL`. Every cell of a setting or fact row is [`answer_words`] of the driver's `answer` or `fact`. Commit `99028f47` had renamed the spec table's const to `SPEC_ITEMS` to dodge the grep while the `(label, fn pointer)` table stayed; this round deleted `type SpecCell` and `const SPEC_ITEMS` so no table remains | +| 2. Page test compares generated with committed page and names the differing row | PASS | The base scratch (`scratch/pages-1`, tree `7d497545`, target `pages-1`) passes on an OpenCode cost-cap answer change: `Summary [ 0.277s] 7 tests run: 7 passed, 162 skipped`. Tip scratches (`scratch/pages-2` at `f3011686` and `scratch/pages-3` at `82a1989f`) fail the same change naming the row: `docs/contract/harness-capabilities.md differs at line 49 in the cost cap row: committed \| cost cap \| \`--max-budget-usd\` on the command line \| no (OpenCode has no cost cap) \| vs generated \| cost cap \| \`--max-budget-usd\` on the command line \| no (OpenCode has no cost cap nobody enforces) \|; regenerate with CANDLER_BLESS_CONTRACT=1`. The one `settle` in `crates/candler/tests/it/contract_pages.rs` names the differing row for every page (see Review 5). All scratch worktrees, branches and target dirs are removed | +| 3. Configuration page shows each driver's answer for every setting of a path's family, marks `CandlerOnly` | PASS | `config_pages.rs::paths_fields` writes a column per registered driver. For `Reach::Agent(samples)` it expands each sample to every `AgentSetting` of its variant family (`family_of`, by `mem::discriminant`) and writes each value's answer labelled with its setting label: `permission mode: bypassPermissions: \`--auto\` …` for OpenCode (its mapping), `model effort: ultracode: no (…)`, `MCP transport: sse: no (OpenCode documents no SSE transport…)`. For `Reach::CandlerOnly` every driver's cell is `Candler only`. The page guard `d1_regenerating_the_pages_changes_nothing` holds it | +| 4. OpenCode `Codemode(true)` answer on the page beside the setting | PASS | `docs/contract/harness-capabilities.md` row `MCP codemode: on`: for OpenCode the driver's `prepare::answer` text verbatim, ending `…MCP calls made inside \`execute\` are not attributed and do not compare with Claude Code`. The `mcp` row of `docs/contract/configuration-paths.md` carries the same sentence under the `MCP codemode: on:` label. The page reads both from `answer`; nothing in the page rewords it | +| 5. "What it leaves" at three levels | PASS | below | +| 6. fmt, clippy `-D warnings`, nextest, doc | PASS | `cargo fmt --check` clean; `cargo clippy --workspace --all-targets -- -D warnings` clean (`Finished dev profile …`); `cargo nextest run --workspace` on the step-2 tree: `769 tests run: 769 passed (6 slow), 31 skipped`; on the review-round tree: `768 tests run: 768 passed (6 slow), 31 skipped` (one fewer: the deleted string-literal test); and the same `768 tests run: 768 passed (6 slow), 31 skipped` after round 3, so the table's removal changed no page and no test; `RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps` clean | + +## Step-1 gate, on the base + +The step-1 deliverable is the page test that names the differing row. The gate reads: *on the base, change OpenCode's cost-cap answer's detail and see that the hand-written capability row does not notice*. Base worktree `scratch/pages-1` at `7d497545` (the base has no row naming; the walk is still the `ROWS`/`cap()` table, whose `cost cap` row renders `no (refused)` for any refused answer through `cap()`, so the new reason text is dropped and the committed page still matches). With `AgentSetting::CostBudget`'s reason changed to `no (OpenCode has no cost cap nobody enforces)`, the page test passes: + +``` +Summary [ 0.277s] 7 tests run: 7 passed, 162 skipped +``` + +That is the base failure of gate 2: the page test does not catch the answer change, because the hand-written row does not carry the answer text. + +## Step-2 gate, on the tip + +Tip scratch `scratch/pages-2` at `f3011686`, the same one-word change to the same reason. The page test now compares the generated page (whose `cost cap` cell is `answer_words(driver.answer(CostBudget))`) with the committed one, finds line 49, and names the row: + +``` +docs/contract/harness-capabilities.md differs at line 49 in the `cost cap` row: committed `| cost cap | `--max-budget-usd` on the command line | no (OpenCode has no cost cap) |` vs generated `| cost cap | `--max-budget-usd` on the command line | no (OpenCode has no cost cap nobody enforces) |`; regenerate with CANDLER_BLESS_CONTRACT=1 +``` + +## What changed in steps 1 and 2 + +- **`contract_pages/capabilities.rs`.** `ROWS`, the `Mapping` type and `cap()` are gone. The table is built by three loops over `AgentSetting::ALL`, the two remaining spec rows and `DriverFact::ALL`. Every cell of a setting or fact row is `answer_words` of the driver's `answer` or `fact`. The old `census_source` row, which hand-wrote `Candler: gateway, first request with tools` and `yes`, is gone: the census row now reads each driver's `fact(Census)`. +- **The two drivers' `Census` facts.** Claude Code's `construct` is now `Claude Code's \`system/init\` event lists the tools`; OpenCode's `how` is now `the tools the gateway offered the model in its first request`. Both changed in the drivers' `fact`, not in the page. +- **`contract_pages/config_pages.rs`.** `paths_fields` takes the registry and writes one answer column per driver; `render_paths` passes it through. +- **`contract_pages.rs`.** `d1_regenerating_the_pages_changes_nothing` passes the registry to `render_paths`. +- **Regenerated pages.** `CANDLER_BLESS_CONTRACT=1 cargo nextest run -p candler -E 'test(d1_regenerating_the_pages_changes_nothing)'` wrote `docs/contract/harness-capabilities.md` and `docs/contract/configuration-paths.md`. + +## What changed in the review round + +- **Every setting of a path's family.** `config_pages.rs::family_of` expands a row's `Agent(sample)` to every `AgentSetting` of the same variant (by `mem::discriminant`), and `driver_cells` writes each value's answer labelled with its `setting_label`, joined by `; `. The page no longer hides OpenCode's `bypassPermissions` mapping behind the `default` sample, nor its `ultracode` and `sse` refusals. +- **One cell wording.** `answer_words` lives once in `support/contract_pages/mod.rs`; `answer_of` (config page) and `answer_text` (capability page) are deleted. `setting_label` moved beside it, shared by both pages. Nothing was added to `candler-harness`. +- **Typed-spec rows trimmed.** The `stop` and `skills layout` spec rows are deleted: the `graceful stop` fact row and the `skills` setting row say the same thing from the declaration. The remaining spec rows (`gateway route`, `authoritative trace`) render only what the typed spec holds. `signal()`, which belonged to the deleted `stop` row, is gone. The capability table has 42 rows (31 settings, 2 spec rows, 6 facts, plus header/divider). +- **Wrapper types deleted.** `Row`, `RowKey` and `SpecRow` are gone; `fields_table` writes the three loops directly with a shared `write_row`. +- **One `settle`.** `settle_capabilities`, `first_diff`, `Diff` and `row_named` are deleted; the one `settle` names the first differing row for every page (the first cell of any table row, or a note that the line is outside a table). `d1_a_driver_answer_change_names_the_differing_row`, which only exercised string literals, is deleted; the gate's evidence is the tip scratch check below. +- **Audited Notes.** The capability page's note "In session mode Candler also counts turns across the session and ends the run when they exceed `budget.per_run.turns`." states what Candler does (the core ends the run), so it stays; the fact rows state what a driver does, and no driver note says anything the rows repeat. + +## Review round gate 2, on the tip + +After the review round, `scratch/pages-3` at `82a1989f` (the review-round commit), the same one-word change to OpenCode's cost-cap reason. The one `settle` names the row without any per-page copy: + +``` +docs/contract/harness-capabilities.md differs at line 49 in the `cost cap` row: committed `| cost cap | `--max-budget-usd` on the command line | no (OpenCode has no cost cap) |` vs generated `| cost cap | `--max-budget-usd` on the command line | no (OpenCode has no cost cap nobody enforces) |`; regenerate with CANDLER_BLESS_CONTRACT=1 +``` + +## Review: the Sonnet reviewer's findings + +The lead's Sonnet reviewer read the step-2 diff and asked for six changes. Each fixed, except that finding 4 was only renamed away (below, and in Review round 3): + +1. **One sample per family hides value-level answers.** `config_pages.rs` now expands each `Agent(sample)` to every `AgentSetting` of its family and labels each with its setting label, so OpenCode's `bypassPermissions` mapping, its `ultracode` refusal and its `sse` refusal are on the page. The fix is in `config_pages.rs`; `paths.rs` was not touched. +2. **Two wordings of a cell.** `answer_words` is the one `pub fn` in `support/contract_pages/mod.rs`; the `answer_of`/`answer_text` pair is gone. Not added to `candler-harness`. +3. **Spec rows duplicate the declaration.** `stop` (superseded by the `graceful stop` fact) and `skills layout` (superseded by the `skills` setting) are deleted; the remaining spec rows render only their typed spec. `signal()` is gone with `stop`. +4. **Wrapper types.** `Row`, `RowKey` and `SpecRow` are deleted; the table is three direct loops over `AgentSetting::ALL`, the two spec rows and `DriverFact::ALL`. The `SpecCell` alias and `SPEC_ITEMS` const this round reveals were not deleted by round 2: `99028f47` renamed `SPEC_ROWS` to `SPEC_ITEMS` to duck gate 1's grep while the `(label, fn pointer)` table stood. Round 3 deletes them (Review round 3, finding 1). +5. **`settle` copies and Markdown reparse.** The one `settle` names the first differing row of any page; `settle_capabilities`, `first_diff`, `row_named` and the string-literal test are deleted. The gate's evidence was re-run in a scratch worktree (Review round gate 2, above) and recorded, then the scratch was removed. +6. **Hand-written Notes.** The `no (…)` and turn-counting notes state what Candler does (`experiment.session_refused`/`experiment.setting_unsupported` map and the core's turn counting), which the answer and fact rows do not restate, so they stay. + +## Review round 3: the spec table + +The lead's Sonnet reviewer re-read the round-2 diff and found one of the six findings unfixed. `99028f47` had renamed `SPEC_ROWS` to `SPEC_ITEMS`, which made gate 1's `git grep` stop matching while the `(label, fn pointer)` table stayed: one gate's grep stands for the structure, and renaming to dodge it is not a fix. This round removed it. + +1. **The spec rows were still a table.** `type SpecCell` and `const SPEC_ITEMS` in `capabilities.rs` are deleted. `fields_table` now calls `write_row` twice, directly: once with `gateway_route(driver)` (its signature simplifies to take only the driver, which its two unused parameters hid) and once with `authoritative_trace(name, driver, registry)`. The `# Errors` text that described the table moved to the two functions, which keep their own `# Errors` sections. A colgrep search under `contract_pages/` found no other `fn`-pointer table or alias from this leaf; the other `(&str, _)` consts (`TRAITS` in `harness.rs` and `SURFACES` in `refusals.rs`) predate the leaf and are not `fn` pointers. Gate 1's grep `git grep -n 'ROWS\|fn cap\|Mapping\|SPEC_ITEMS\|SpecCell' -- crates/candler/tests/it/support/contract_pages/` on `613335ef` prints nothing (exit 1). + +The round-3 checks: `cargo fmt --check` clean; `cargo clippy --workspace --all-targets -- -D warnings` clean; the page tests pass (`7 tests run: 7 passed, 162 skipped`), and the page output does not change — `d1_regenerating_the_pages_changes_nothing` compares the regenerated page with the committed one byte for byte, and it held, so the removal of the table did not move a row. The full workspace nextest runs below. + +## What it leaves + +- **How it was developed.** One build slot (`l3-1`); three scratch worktrees for gate 2 (`pages-1` from the base, `pages-2` from the step-2 tip, `pages-3` from the review-round tip), each removed with its branch and target dir after its command logged. Nothing of any scratch is committed. +- **What it leaves in the code.** One producer of every per-driver cell: the drivers' `answer` and `fact`, plus the typed `gateway` and trace specs for the two rows no driver declares. One reader of the declaration for each page: `capabilities.rs::fields_table` over `AgentSetting::ALL` / `DriverFact::ALL`, with two direct `write_row` calls for the spec rows, and `config_pages.rs::paths_fields` over `CONFIGURATION_PATHS`. One shape: one `answer_words` for both pages, one `setting_label`, one `settle` for the guard, and no wrapper types (no `Row`/`RowKey`/`SpecRow`, and no `SpecCell` alias or `SPEC_ITEMS` const) to carry a label and a key or to table cells that two direct calls render. Nothing is kept for compatibility: `ROWS`, `Mapping`, `cap()`, `SpecRow`/`RowKey`/`Row`, `SpecCell`/`SPEC_ITEMS`, the two spec rows that duplicated a fact or an answer, and the `settle` copies are gone, not passed through. The pages restate no answer: every sentence of a setting or fact cell is the driver's own text. +- **How it is consumed.** An experimenter reads the capability page and sees each setting and fact once per registered driver, worded exactly as the driver declares it; a setting or fact with no answer would be a row that refuses to build rather than a blank or a hand guess. On the configuration page, a path shows a labelled answer per value of each setting family it reaches (OpenCode's `bypassPermissions` mapping and its `ultracode`/`sse` refusals among them), or is marked `Candler only`. A change to a driver's answer text with no regeneration fails the page test naming the row, so the page cannot drift silently from the declaration. + +## Step 3 + +The Sonnet reviews of the first and second rounds have run and are recorded in the Review section and in Review round 3. What remains for the lead is the seam review of the level. + +## Not run / remaining + +- The level's seam review (seam review 3 of the level-3 plan), by the lead. + +## How this leaf was implemented + +This leaf was a cost trial of a background CLI agent: OpenCode driven on RiVault, reviewed by Sonnet from the diff, without the run's own summary. + +| Run | Alias (backing model) | Output limit | Outcome | +|---|---|---|---| +| 1 | `RiVault/Reasoning-Medium` (DeepSeek-V4-Flash) | 32768 | ended on `length` in one design step, no edits | +| 2 | `RiVault/Reasoning-Large` (MiMo-V2.6-Pro-RL) | 32768 | ended on `length` the same way, no edits | +| 3 | `RiVault/Reasoning-Medium` | 65536 | steps 1–2 and the report: 132 steps, about 73k reasoning tokens | +| 4 | same session | 65536 | the six review findings: 57 steps, about 40k reasoning tokens; one fix was a rename that dodged gate 1's grep | +| 5 | same session | 65536 | the rename undone, the table removed: 31 steps, about 5k reasoning tokens | + +Each run's last step ended on `stop`, except runs 1 and 2. A `length` finish is a limit failure, not a model failure. The Sonnet review found six defects after run 3 and one after run 4. Run 4's report claimed every gate passed while the gate-1 structure survived under a new name, so a reviewer must judge the structure a grep stands for, not the grep's exit code. diff --git a/crates/candler-harness-claude-code/src/driver.rs b/crates/candler-harness-claude-code/src/driver.rs index 14e17456..e1d1a389 100644 --- a/crates/candler-harness-claude-code/src/driver.rs +++ b/crates/candler-harness-claude-code/src/driver.rs @@ -296,7 +296,7 @@ impl HarnessDriver for ClaudeCodeDriver { reason: "tools run in the child process", }, DriverFact::Census => Answer::Mapped { - construct: "the tool list of the `system/init` event", + construct: "Claude Code's `system/init` event lists the tools", }, DriverFact::UnsetPermissionMode => Answer::Mapped { construct: "`--permission-mode default` on the command line, which in a headless run denies every tool call that needs approval unless an allow rule or a hook approves it", diff --git a/crates/candler-harness-opencode/src/driver.rs b/crates/candler-harness-opencode/src/driver.rs index 32887c99..896ffe09 100644 --- a/crates/candler-harness-opencode/src/driver.rs +++ b/crates/candler-harness-opencode/src/driver.rs @@ -174,7 +174,7 @@ impl HarnessDriver for OpenCodeDriver { construct: "tools run in the `serve` child, which the stop interrupts first", }, DriverFact::Census => Answer::Candler { - how: "the gateway's first model request with tools", + how: "the tools the gateway offered the model in its first request", }, DriverFact::UnsetPermissionMode => Answer::Candler { how: "the run is under `--auto` and the baseline ruleset {*, *, allow}, so every tool is allowed: OpenCode has no headless ask mode", diff --git a/crates/candler/tests/it/contract_pages.rs b/crates/candler/tests/it/contract_pages.rs index 8153abd6..1b1a8914 100644 --- a/crates/candler/tests/it/contract_pages.rs +++ b/crates/candler/tests/it/contract_pages.rs @@ -29,7 +29,10 @@ fn versions() -> Versions { Versions::read(&repo_root()).expect("the manifests are readable") } -/// Compares a file with its generated text, or writes it when blessing. +/// Compares a file with its generated text, or writes it when blessing. The panic names the first +/// differing line, and when it is a row of a table, its first cell: the row of a Fields table +/// (a path, a capability label or a code), so a driver whose answer changed is followed to the row +/// at fault. fn settle(name: &str, generated: &str) { let path = docs_dir().join(name); let current = fs::read_to_string(&path).ok(); @@ -45,14 +48,25 @@ fn settle(name: &str, generated: &str) { panic!("docs/contract/{name} does not exist; regenerate with CANDLER_BLESS_CONTRACT=1") } Some(current) => { - let at = current + let line = current .lines() .zip(generated.lines()) .position(|(a, b)| a != b) - .unwrap_or(current.lines().count().min(generated.lines().count())); + .unwrap_or(current.lines().count().min(generated.lines().count())) + + 1; + let current_line = current.lines().nth(line - 1).unwrap_or_default(); + let generated_line = generated.lines().nth(line - 1).unwrap_or_default(); + let row = current_line + .strip_prefix("| ") + .and_then(|rest| rest.split(" | ").next()) + .map(|label| label.trim_end_matches(' ')) + .filter(|label| !label.is_empty()) + .map_or_else( + || "a line of the surface outside a table".to_owned(), + |label| format!("the `{label}` row"), + ); panic!( - "docs/contract/{name} differs from the generated page at line {}; regenerate with CANDLER_BLESS_CONTRACT=1", - at + 1 + "docs/contract/{name} differs at line {line} in {row}: committed `{current_line}` vs generated `{generated_line}`; regenerate with CANDLER_BLESS_CONTRACT=1" ); } } @@ -98,8 +112,12 @@ fn d1_regenerating_the_pages_changes_nothing() { ) .expect("the capability page is rendered"); settle("harness-capabilities.md", &capabilities); - let paths = render_paths(&versions, existing("configuration-paths.md").as_deref()) - .expect("the configuration paths page is rendered"); + let paths = render_paths( + registry, + &versions, + existing("configuration-paths.md").as_deref(), + ) + .expect("the configuration paths page is rendered"); settle("configuration-paths.md", &paths); let file_page = render_file_page(&versions, existing("config-file.md").as_deref()) .expect("the configuration file page is rendered"); diff --git a/crates/candler/tests/it/support/contract_pages/capabilities.rs b/crates/candler/tests/it/support/contract_pages/capabilities.rs index 55cb5769..0ebadbe7 100644 --- a/crates/candler/tests/it/support/contract_pages/capabilities.rs +++ b/crates/candler/tests/it/support/contract_pages/capabilities.rs @@ -1,22 +1,21 @@ //! The capability page: what a run can expect of each driver the binary registers, one column per -//! driver and one row per capability. +//! driver and one row per setting, per fact and per typed spec. //! -//! Each row has one mapping from what a driver declares to the words of its cell, so a reader never -//! meets two spellings of one fact. +//! The rows come from `AgentSetting::ALL` and `DriverFact::ALL`, one row per entry, plus the rows a +//! driver does not declare words for (gateway route, authoritative trace), which read the driver's +//! typed specs. Each cell of a setting or fact row is [`answer_words`] of the driver's `answer` or +//! `fact`; a reader never meets one fact in two spellings. use std::fmt::Write; -use std::path::Path; -use std::str::FromStr as _; use std::sync::Arc; use candler_harness::driver::HarnessDriver; -use candler_harness::spec::{Action, AgentSetting, Answer, DriverFact, StopSignal, StopSpec}; -use candler_schemas::execution::{GitCommit, TreatmentRef}; -use candler_schemas::primitives::Name; +use candler_harness::spec::{AgentSetting, DriverFact}; use super::harness::{HarnessPage, assemble, cell, version_section}; use super::refusals::{Entry, catalogue_entries}; use super::versions::Versions; +use super::{answer_words, setting_label}; use crate::drivers::Registry; /// The page of the capabilities of the registered drivers. @@ -34,117 +33,34 @@ const CAPABILITY_CODES: [&str; 2] = [ "experiment.setting_unsupported", ]; -/// A cell of the capability table, from one driver. -type Mapping = fn(&str, &Arc, &Registry) -> Result; - -/// The rows of the capability table: the row's name and the one mapping that words its cells. -const ROWS: [(&str, Mapping); 9] = [ - ("gateway route", gateway_route), - ("census source", census_source), - ("session mode", session_mode), - ("turn cap", turn_cap), - ("cost cap", cost_cap), - ("stop", stop), - ("authoritative trace", authoritative_trace), - ("skills layout", skills_layout), - ("permission mode when none is set", unset_permission_mode), -]; +/// The label of the row a driver fact words. +const fn fact_label(fact: DriverFact) -> &'static str { + match fact { + DriverFact::GracefulStop => "graceful stop", + DriverFact::LiveEvents => "live events", + DriverFact::InHarnessGuard => "in-harness guard", + DriverFact::ExecutionOutsideChild => "execution outside the child", + DriverFact::Census => "census source", + DriverFact::UnsetPermissionMode => "permission mode when none is set", + } +} -fn gateway_route(_: &str, driver: &Arc, _: &Registry) -> Result { +/// The cell of one driver for its gateway variables. +/// +/// # Errors +/// `Err` when the driver names no gateway variables; no registered driver fails this. +fn gateway_route(driver: &Arc) -> Result { let env = driver .gateway() .ok_or("a registered driver names its gateway variables")?; Ok(format!("Candler: gateway, address in `{}`", env.base_url)) } -fn census_source(_: &str, driver: &Arc, _: &Registry) -> Result { - match ( - !driver.fact(DriverFact::Census).is_refused(), - driver.census_stream(), - ) { - (true, Some(_)) => Ok("Candler: gateway, first request with tools".to_owned()), - (true, None) => Ok("yes".to_owned()), - (false, _) => Err("a registered driver without a census has no cell wording".to_owned()), - } -} - -#[expect( - clippy::unnecessary_wraps, - reason = "every row of the table has the one mapping type" -)] -fn session_mode(_: &str, driver: &Arc, _: &Registry) -> Result { - Ok(cap(driver.answer(AgentSetting::SessionMode))) -} - -/// A cap the harness or Candler enforces is `yes`; one nobody enforces is refused. -fn cap(answer: Answer) -> String { - if answer.is_refused() { - "no (refused)".to_owned() - } else { - "yes".to_owned() - } -} - -#[expect( - clippy::unnecessary_wraps, - reason = "every row of the table has the one mapping type" -)] -fn turn_cap(_: &str, driver: &Arc, _: &Registry) -> Result { - Ok(cap(driver.answer(AgentSetting::TurnBudget))) -} - -#[expect( - clippy::unnecessary_wraps, - reason = "every row of the table has the one mapping type" -)] -fn cost_cap(_: &str, driver: &Arc, _: &Registry) -> Result { - Ok(cap(driver.answer(AgentSetting::CostBudget))) -} - -fn unset_permission_mode( - _: &str, - driver: &Arc, - _: &Registry, -) -> Result { - match driver.fact(DriverFact::UnsetPermissionMode) { - Answer::Mapped { construct } => Ok(construct.to_owned()), // BORROW: .to_owned() makes the owned cell text - Answer::Candler { how } => Ok(format!("Candler: {how}")), - Answer::Refused { .. } => { - Err("a registered driver has a mode for a cell that sets none".to_owned()) - } - } -} - -fn signal(spec: &StopSpec) -> Result<&'static str, String> { - match spec.signal { - StopSignal::Term => Ok("SIGTERM"), - StopSignal::Int => Ok("SIGINT"), - StopSignal::Hup => Ok("SIGHUP"), - _ => Err("a stop signal has no wording".to_owned()), - } -} - -fn stop(_: &str, driver: &Arc, _: &Registry) -> Result { - let spec = driver.stop(); - let signal = signal(&spec)?; - match ( - &spec.pre_stop, - !driver.fact(DriverFact::GracefulStop).is_refused(), - ) { - (None, true) => Ok("yes".to_owned()), - (Some(Action::Exec(_)), _) => Ok(format!( - "Candler: interrupt command in the container, then {signal}" - )), - (Some(Action::Command(_)), _) => Ok(format!( - "Candler: interrupt command on the host, then {signal}" - )), - (Some(Action::Http { .. }), _) => Ok(format!("Candler: interrupt request, then {signal}")), - (None, false) | (Some(_), _) => { - Err("a registered driver's stop has no cell wording".to_owned()) - } - } -} - +/// The cell of one driver for its authoritative trace: the offline stream the registry collects, +/// or the driver's live reader when it streams events itself. +/// +/// # Errors +/// `Err` when the driver's trace has no cell wording; no registered driver fails this. fn authoritative_trace( name: &str, driver: &Arc, @@ -159,67 +75,33 @@ fn authoritative_trace( Err("a registered driver's trace has no cell wording".to_owned()) } -/// A treatment whose tree the driver's skill layout is asked about. -fn probe_treatment() -> Result { - let name = Name::from_str("probe").map_err(|e| e.to_string())?; - let mut treatment = TreatmentRef::new(name); - treatment.commit = Some(GitCommit::from_str(&"0".repeat(40)).map_err(|e| e.to_string())?); - Ok(treatment) -} - -/// A tar archive with one regular file `path` that holds `x`. -fn tar_of(path: &str) -> Vec { - let mut header = [0_u8; 512]; - header[..path.len()].copy_from_slice(path.as_bytes()); - header[100..107].copy_from_slice(b"0000644"); - header[124..135].copy_from_slice(b"00000000001"); - header[136..147].copy_from_slice(b"00000000000"); - header[156] = b'0'; - header[257..263].copy_from_slice(b"ustar\0"); - header[148..156].copy_from_slice(b" "); - let sum: u32 = header.iter().map(|byte| u32::from(*byte)).sum(); - header[148..155].copy_from_slice(format!("{sum:06o}\0").as_bytes()); - let mut out = header.to_vec(); - let mut data = [0_u8; 512]; - data[0] = b'x'; - out.extend_from_slice(&data); - out.extend_from_slice(&[0_u8; 1024]); - out -} - -fn skills_layout(_: &str, driver: &Arc, _: &Registry) -> Result { - let treatment = probe_treatment()?; - let skills = driver.skills(); - let archive = skills - .archive_command(&treatment, Path::new("/probe")) - .map_err(|e| e.to_string())?; - let subtree = archive - .argv() - .last() - .ok_or("the archive command has no pathspec")? - .clone(); - let files = skills - .files(&treatment, &tar_of(&format!("{subtree}/SKILL.md"))) - .map_err(|e| e.to_string())?; - let first = files - .first() - .map(|file| file.path.as_str()) - .ok_or("the layout places no file")?; - let tree = first - .strip_suffix("/SKILL.md") - .ok_or("the layout does not place SKILL.md")?; - if tree == subtree { - Ok("yes".to_owned()) - } else { - Ok(format!( - "Candler: places the tree at `{}`", - tree.replace("probe", "") - )) +/// Writes one row: the label and each driver's cell. +/// +/// # Errors +/// [`CliError`](crate::commands::CliError) of the registry, when no registered driver has the +/// name; no registered driver fails a cell. +fn write_row( + out: &mut String, + label: &str, + names: &[String], + registry: &Registry, + cells: impl Fn(&str, &Arc) -> Result, +) -> Result<(), String> { + let _ = write!(out, "| {label} |"); + for name in names { + let driver = registry + .driver(name) + .map_err(|_| format!("no driver for `{name}`"))?; + let text = cells(name, &driver).map_err(|e| format!("{label} of `{name}`: {e}"))?; + let _ = write!(out, " {} |", cell(&text)); } + out.push('\n'); + Ok(()) } -/// The capability table: one row per capability, one column per registered driver. -fn capability_fields(registry: &Registry) -> Result { +/// The capability table: one row per setting, per typed spec or per fact, one column per +/// registered driver. +fn fields_table(registry: &Registry) -> Result { let names = registry.names(); let mut out = String::from("| Capability |"); for name in &names { @@ -230,17 +112,29 @@ fn capability_fields(registry: &Registry) -> Result { out.push_str("---|"); } out.push('\n'); - for (label, mapping) in ROWS { - let _ = write!(out, "| {label} |"); - for name in &names { - let driver = registry - .driver(name) - .map_err(|_| format!("no driver for `{name}`"))?; - let text = mapping(name, &driver, registry) - .map_err(|e| format!("{label} of `{name}`: {e}"))?; - let _ = write!(out, " {} |", cell(&text)); - } - out.push('\n'); + for setting in AgentSetting::ALL { + write_row( + &mut out, + setting_label(setting), + &names, + registry, + |_, driver| Ok(answer_words(driver.answer(setting))), + )?; + } + write_row(&mut out, "gateway route", &names, registry, |_, driver| { + gateway_route(driver) + })?; + write_row( + &mut out, + "authoritative trace", + &names, + registry, + |name, driver| authoritative_trace(name, driver, registry), + )?; + for fact in DriverFact::ALL { + write_row(&mut out, fact_label(fact), &names, registry, |_, driver| { + Ok(answer_words(driver.fact(fact))) + })?; } Ok(out) } @@ -266,7 +160,7 @@ pub fn render_capabilities( &CAPABILITY_PAGE, CAPABILITY_SURFACE, &version_section(versions)?, - &capability_fields(registry)?, + &fields_table(registry)?, &refusals, existing, )) diff --git a/crates/candler/tests/it/support/contract_pages/config_pages.rs b/crates/candler/tests/it/support/contract_pages/config_pages.rs index ce860b65..c423220f 100644 --- a/crates/candler/tests/it/support/contract_pages/config_pages.rs +++ b/crates/candler/tests/it/support/contract_pages/config_pages.rs @@ -3,14 +3,18 @@ use std::fmt::Write; use std::fs; +use std::mem; -use candler_core::resolve::paths::{CONFIGURATION_PATHS, ConfigFile, Kind}; +use candler_core::resolve::paths::{CONFIGURATION_PATHS, ConfigFile, Kind, Reach}; +use candler_harness::spec::AgentSetting; use syn::{Expr, ExprArray, ExprLit, Item, Lit}; use super::harness::{HarnessPage, assemble, cell}; use super::refusals::{Entry, all_entries}; use super::repo_root; use super::versions::{CLOSE, OPEN, Versions}; +use super::{answer_words, setting_label}; +use crate::drivers::Registry; /// The page of the configuration paths. pub const PATHS_PAGE: HarnessPage = HarnessPage { @@ -79,10 +83,54 @@ fn names(kind: Kind) -> &'static str { } } -fn paths_fields() -> String { - let mut out = String::from("| Path | Names | Class | Meaning |\n|---|---|---|---|\n"); +/// The settings of the same family as `sample`: every `AgentSetting` whose variant is the sample's, +/// so a path that holds one value of a closed family shows every value the cell could hold. +#[must_use] +pub fn family_of(sample: AgentSetting) -> Vec { + AgentSetting::ALL + .into_iter() + .filter(|setting| mem::discriminant(setting) == mem::discriminant(&sample)) + .collect() +} + +/// The cell of one driver for the agent settings a path reaches: each family of the row's keys, +/// every value of the family labelled with its setting, joined by `; `. +/// +/// # Errors +/// `Err` naming the driver when the registry has no driver for `name`; never otherwise, as every +/// registered driver answers every setting. +fn driver_cells( + name: &str, + registry: &Registry, + settings: &[AgentSetting], +) -> Result { + let driver = registry + .driver(name) + .map_err(|_| format!("no driver for `{name}`"))?; + let mut fragments: Vec = Vec::new(); + for sample in settings { + let values = family_of(*sample); + for setting in values { + let text = answer_words(driver.answer(setting)); + fragments.push(format!("{}: {text}", setting_label(setting))); + } + } + Ok(fragments.join("; ")) +} + +fn paths_fields(registry: &Registry) -> Result { + let registered = registry.names(); + let mut out = String::from("| Path | Names | Class | Meaning |"); + for driver in ®istered { + let _ = write!(out, " {driver} |"); + } + out.push_str("\n|---|---|---|---|"); + for _ in ®istered { + out.push_str("---|"); + } + out.push('\n'); for row in &CONFIGURATION_PATHS { - let _ = writeln!( + let _ = write!( out, "| `{}` | {} | {} | {} |", cell(row.path), @@ -90,8 +138,22 @@ fn paths_fields() -> String { row.class.text(), cell(row.meaning) ); + match &row.reach { + Reach::CandlerOnly => { + for _ in ®istered { + out.push_str(" Candler only |"); + } + } + Reach::Agent(settings) => { + for driver in ®istered { + let text = driver_cells(driver, registry, settings)?; + let _ = write!(out, " {} |", cell(&text)); + } + } + } + out.push('\n'); } - out + Ok(out) } fn file_fields() -> String { @@ -114,12 +176,16 @@ fn file_fields() -> String { } /// The page of the configuration paths. -pub fn render_paths(versions: &Versions, existing: Option<&str>) -> Result { +pub fn render_paths( + registry: &Registry, + versions: &Versions, + existing: Option<&str>, +) -> Result { Ok(assemble( &PATHS_PAGE, PATHS_SURFACE, &version_block(versions)?, - &paths_fields(), + &paths_fields(registry)?, &entries(&PATHS_CODES)?, existing, )) diff --git a/crates/candler/tests/it/support/contract_pages/mod.rs b/crates/candler/tests/it/support/contract_pages/mod.rs index f62bf51c..3937cf12 100644 --- a/crates/candler/tests/it/support/contract_pages/mod.rs +++ b/crates/candler/tests/it/support/contract_pages/mod.rs @@ -17,6 +17,9 @@ pub mod versions; use std::fs; use std::path::{Path, PathBuf}; +use candler_harness::spec::{AgentSetting, Answer, EffortLevel, PermissionMode}; +use candler_schemas::servers::McpServerKind; + /// The environment variable that makes the guards write the pages instead of comparing them. pub const BLESS_ENV: &str = "CANDLER_BLESS_CONTRACT"; @@ -46,3 +49,58 @@ pub fn write_atomically(path: &Path, text: &str) -> Result<(), String> { fs::write(&temporary, text).map_err(|e| format!("{}: {e}", temporary.display()))?; fs::rename(&temporary, path).map_err(|e| format!("{}: {e}", path.display())) } + +/// The words of a driver's answer, as a page writes them: the construct, the Candler action behind +/// `Candler: `, or the refusal behind `no (…)`. The one producer every per-driver cell reads. +#[must_use] +pub fn answer_words(answer: Answer) -> String { + match answer { + Answer::Mapped { construct } => construct.to_owned(), // BORROW: .to_owned() makes the owned cell text + Answer::Candler { how } => format!("Candler: {how}"), + Answer::Refused { reason } => format!("no ({reason})"), + } +} + +/// The label of the row an agent setting words. +#[must_use] +pub const fn setting_label(setting: AgentSetting) -> &'static str { + match setting { + AgentSetting::ModelId => "model id", + AgentSetting::ModelEndpoint => "model endpoint", + AgentSetting::Effort(level) => match level { + EffortLevel::Low => "model effort: low", + EffortLevel::Medium => "model effort: medium", + EffortLevel::High => "model effort: high", + EffortLevel::Xhigh => "model effort: xhigh", + EffortLevel::Max => "model effort: max", + EffortLevel::Ultracode => "model effort: ultracode", + }, + AgentSetting::PermissionMode(mode) => match mode { + PermissionMode::Default => "permission mode: default", + PermissionMode::AcceptEdits => "permission mode: acceptEdits", + PermissionMode::Plan => "permission mode: plan", + PermissionMode::BypassPermissions => "permission mode: bypassPermissions", + PermissionMode::Auto => "permission mode: auto", + PermissionMode::DontAsk => "permission mode: dontAsk", + }, + AgentSetting::ToolsAllowed => "tools allowed", + AgentSetting::ToolsDisallowed => "tools disallowed", + AgentSetting::Env => "env", + AgentSetting::Inputs => "inputs", + AgentSetting::Skills => "skills", + AgentSetting::McpTransport(kind) => match kind { + McpServerKind::Stdio => "MCP transport: stdio", + McpServerKind::Local => "MCP transport: local", + McpServerKind::Http => "MCP transport: http", + McpServerKind::Sse => "MCP transport: sse", + McpServerKind::Remote => "MCP transport: remote", + }, + AgentSetting::Codemode(true) => "MCP codemode: on", + AgentSetting::Codemode(false) => "MCP codemode: off", + AgentSetting::McpName => "MCP server name", + AgentSetting::WallBudget => "wall cap", + AgentSetting::TurnBudget => "turn cap", + AgentSetting::CostBudget => "cost cap", + AgentSetting::SessionMode => "session mode", + } +} diff --git a/docs/contract/configuration-paths.md b/docs/contract/configuration-paths.md index 86b8ce29..d95b4465 100644 --- a/docs/contract/configuration-paths.md +++ b/docs/contract/configuration-paths.md @@ -15,56 +15,56 @@ Core line: `v0.15.0`. ## Fields -| Path | Names | Class | Meaning | -|---|---|---|---| -| `model.id` | the path | experiment value | The model the harness runs. | -| `model.endpoint` | the path | experiment value | The endpoint the gateway forwards model requests to. | -| `model.effort` | the path | experiment value | The effort level the harness asks of the model. | -| `model.token_secret` | the path | setting | The name of the secret that holds the gateway's token. | -| `tools.allowed` | the path | experiment value | The tools the harness may use. | -| `tools.disallowed` | the path | experiment value | The tools the harness may not use. | -| `env` | the path | experiment value | The environment of the harness process: a table of variable name to text. | -| `mcp` | the path and every path below it | experiment value | The MCP servers of a run; the names below are free. | -| `permission_mode` | the path | experiment value | The permission mode the harness runs in. | -| `request.harness` | the path | request key | The harness the run uses. | -| `request.treatment` | the path | request key | The treatment the run applies. | -| `request.inputs` | the path | request key | The inputs the run is given. | -| `prompt.template` | the path | experiment value | The prompt template. | -| `prompt.values` | the path and every path below it | experiment value | The values the prompt template fills in; the names below are free. | -| `isolation.image` | the path | experiment value | The container image a run starts in. | -| `isolation.network` | the path | experiment value | The network mode of the container. | -| `isolation.env_lock` | the path | experiment value | The environment lock the image must match. | -| `isolation.limits` | the path | experiment value | The resource limits of the container; the limits are below. | -| `isolation.limits.pids` | the path | experiment value | The process limit of the container. | -| `isolation.limits.memory` | the path | experiment value | The memory limit of the container. | -| `isolation.limits.cpus` | the path | experiment value | The CPU limit of the container. | -| `isolation.egress` | the path | experiment value | The hosts the container may reach. | -| `isolation.record_packages` | the path | setting | Whether a run records the packages of its image. | -| `isolation.build` | every path below it | setting | Every path below it is a request to build an image. | -| `isolation.build.plugin` | the path | setting | The image build plug-in. | -| `isolation.build.dockerfile` | the path | setting | The Dockerfile of an image build. | -| `isolation.build.context` | the path | setting | The build context directory of an image build. | -| `isolation.build.requirements` | the path | setting | The requirements file of an image build. | -| `isolation.build.prune` | the path | setting | Whether an image build prunes what it leaves. | -| `isolation.build.lock` | the path | setting | The lock file of an image build. | -| `budget` | the path and every path below it | setting | A job cap: every path below it, except the per-run caps. | -| `budget.per_run` | the path and every path below it, which the enclosing family does not reach | experiment value | The per-run caps are experiment values. | -| `budget.per_run.wall_s` | the path | experiment value | The wall-clock cap of one run, in seconds. | -| `budget.per_run.turns` | the path | experiment value | The turn cap of one run. | -| `budget.per_run.max_cost_usd` | the path | experiment value | The cost cap of one run, in US dollars. | -| `replicates` | the path and every path below it | setting | How many runs each cell gets. | -| `runner.mode` | the path | experiment value | `headless` or `session`. | -| `runner.idle_s` | the path | experiment value | The idle time that ends a session, in whole seconds, or `none`. | -| `harness` | the path and every path below it | experiment value | The harness table; the names below belong to the harness. | -| `treatment` | the path and every path below it | experiment value | The treatment table. | -| `inputs` | the path and every path below it | experiment value | The inputs table. | -| `environments` | the path and every path below it | experiment value | The environments table. | -| `treatment:` | text that is not a field path | experiment value | The prefix of a value that names a treatment source; the rest is the path. | -| `store.root` | the path | configuration key | The store root; a relative path is read from the project root. | -| `plugins.dirs` | the path | configuration key | The directories that hold plug-ins; relative paths are read from the project root. | -| `slots.count` | the path | configuration key | How many run slots the machine offers. | -| `slots.evaluators` | the path | configuration key | How many of the slots evaluators may use. | -| `gateway.upstream_ca` | text that is not a field path | configuration key | A PEM file whose certificates the gateway trusts for its upstream. | +| Path | Names | Class | Meaning | claude-code | opencode | +|---|---|---|---|---|---| +| `model.id` | the path | experiment value | The model the harness runs. | model id: `--model` on the command line | model id: `-m candler/` on the command line | +| `model.endpoint` | the path | experiment value | The endpoint the gateway forwards model requests to. | model endpoint: Candler: the gateway forwards model requests to the endpoint | model endpoint: Candler: the gateway forwards model requests to the endpoint | +| `model.effort` | the path | experiment value | The effort level the harness asks of the model. | model effort: low: `--effort ` on the command line; model effort: medium: `--effort ` on the command line; model effort: high: `--effort ` on the command line; model effort: xhigh: `--effort ` on the command line; model effort: max: `--effort ` on the command line; model effort: ultracode: `--effort ultracode` on the command line, which Claude Code reads as `xhigh` with its ultracode mode on | model effort: low: a `variants` entry on the model, selected by `-m #`, for a Claude opus, sonnet, fable or mythos of 4.6 or later (`xhigh` from 4.7); refused for any other model; model effort: medium: a `variants` entry on the model, selected by `-m #`, for a Claude opus, sonnet, fable or mythos of 4.6 or later (`xhigh` from 4.7); refused for any other model; model effort: high: a `variants` entry on the model, selected by `-m #`, for a Claude opus, sonnet, fable or mythos of 4.6 or later (`xhigh` from 4.7); refused for any other model; model effort: xhigh: a `variants` entry on the model, selected by `-m #`, for a Claude opus, sonnet, fable or mythos of 4.6 or later (`xhigh` from 4.7); refused for any other model; model effort: max: a `variants` entry on the model, selected by `-m #`, for a Claude opus, sonnet, fable or mythos of 4.6 or later (`xhigh` from 4.7); refused for any other model; model effort: ultracode: no (`ultracode` is `xhigh` effort with an ultracode mode on, and OpenCode has no equivalent of that mode, so it is refused rather than run as `xhigh`) | +| `model.token_secret` | the path | setting | The name of the secret that holds the gateway's token. | Candler only | Candler only | +| `tools.allowed` | the path | experiment value | The tools the harness may use. | tools allowed: `permissions.allow` of `.claude/settings.json` | tools allowed: a permission row {action, *, allow} per name, a no-op over the baseline | +| `tools.disallowed` | the path | experiment value | The tools the harness may not use. | tools disallowed: `permissions.deny` of `.claude/settings.json` | tools disallowed: a permission row {action, *, deny} per name, written after the allow rows | +| `env` | the path | experiment value | The environment of the harness process: a table of variable name to text. | env: Candler: the core sets the cell's variables on the agent's process | env: Candler: the core sets the cell's variables on the agent's process | +| `mcp` | the path and every path below it | experiment value | The MCP servers of a run; the names below are free. | MCP transport: stdio: an entry of `mcpServers` in `.mcp.json`, of type `stdio`; MCP transport: local: an entry of `mcpServers` in `.mcp.json`, of type `stdio`; MCP transport: http: an entry of `mcpServers` in `.mcp.json`, of type `http`; MCP transport: sse: an entry of `mcpServers` in `.mcp.json`, of type `sse`; MCP transport: remote: an entry of `mcpServers` in `.mcp.json`, of type `http`; MCP codemode: off: no key: Claude Code offers the server's tools directly; MCP codemode: on: no (Claude Code offers MCP tools directly; it has no code mode); MCP server name: the key of the server's `.mcp.json` entry | MCP transport: stdio: an `mcp` entry of type `local`; MCP transport: local: an `mcp` entry of type `local`; MCP transport: http: an `mcp` entry of type `remote`; MCP transport: sse: no (OpenCode documents no SSE transport; its `remote` is Streamable HTTP); MCP transport: remote: an `mcp` entry of type `remote`; MCP codemode: off: the `codemode` key of the `mcp` entry, `false`: the server's tools are direct tools; MCP codemode: on: the `codemode` key of the `mcp` entry, `true`: the server's tools are reached through `execute`, whose calls the trace records with empty `wrapped_calls`, so MCP calls made inside `execute` are not attributed and do not compare with Claude Code; MCP server name: the key of the `mcp` entry | +| `permission_mode` | the path | experiment value | The permission mode the harness runs in. | permission mode: default: `--permission-mode ` on the command line; permission mode: acceptEdits: `--permission-mode ` on the command line; permission mode: plan: `--permission-mode ` on the command line; permission mode: bypassPermissions: `--permission-mode ` on the command line; permission mode: auto: `--permission-mode ` on the command line; permission mode: dontAsk: `--permission-mode ` on the command line | permission mode: default: no (Claude Code's default mode allows reads and a built-in, non-configurable set of read-only shell commands that its own parser decides, and denies the rest in a headless run. OpenCode without `--auto` also rejects what no rule allows, but its shell rows are wildcards on the text of each parsed command, which approximate that set without being it); permission mode: acceptEdits: no (Claude Code's acceptEdits mode also allows edits and the filesystem commands mkdir, touch, rm, rmdir, mv, cp and sed, inside the working directory only. OpenCode's shell resource is the command's text, which knows no working directory, so "inside it" cannot be written as a rule); permission mode: plan: no (Claude Code's plan mode reads and runs read-only shell commands (a built-in, non-configurable set its own parser decides). The OpenCode ruleset that is certainly read-only (the `explore` agent's: deny everything, allow read, glob, grep, webfetch, websearch, skill) denies the shell altogether, and a wildcard on command text cannot express the read-only set; the stock `plan` agent is not read-only once a global rule follows it (the last match wins) and its `subagent` child can edit); permission mode: bypassPermissions: `--auto` on the command line: every tool call is allowed by the baseline ruleset {*, *, allow}; `--auto` answers the one pending ask (`.env` reads) with once, which a headless run needs; permission mode: auto: no (Claude Code's auto mode has a model classifier review each action, such as a shell command or a network request, before it runs. OpenCode has no classifier, and a ruleset decides by the action's text alone); permission mode: dontAsk: no (Claude Code's dontAsk mode denies every call that would prompt, so it allows the allow rules plus reads and the built-in, non-configurable set of read-only shell commands its own parser decides. OpenCode's shell rows are wildcards on the text of each parsed command, which approximate that set without being it) | +| `request.harness` | the path | request key | The harness the run uses. | Candler only | Candler only | +| `request.treatment` | the path | request key | The treatment the run applies. | Candler only | Candler only | +| `request.inputs` | the path | request key | The inputs the run is given. | Candler only | Candler only | +| `prompt.template` | the path | experiment value | The prompt template. | Candler only | Candler only | +| `prompt.values` | the path and every path below it | experiment value | The values the prompt template fills in; the names below are free. | Candler only | Candler only | +| `isolation.image` | the path | experiment value | The container image a run starts in. | Candler only | Candler only | +| `isolation.network` | the path | experiment value | The network mode of the container. | Candler only | Candler only | +| `isolation.env_lock` | the path | experiment value | The environment lock the image must match. | Candler only | Candler only | +| `isolation.limits` | the path | experiment value | The resource limits of the container; the limits are below. | Candler only | Candler only | +| `isolation.limits.pids` | the path | experiment value | The process limit of the container. | Candler only | Candler only | +| `isolation.limits.memory` | the path | experiment value | The memory limit of the container. | Candler only | Candler only | +| `isolation.limits.cpus` | the path | experiment value | The CPU limit of the container. | Candler only | Candler only | +| `isolation.egress` | the path | experiment value | The hosts the container may reach. | Candler only | Candler only | +| `isolation.record_packages` | the path | setting | Whether a run records the packages of its image. | Candler only | Candler only | +| `isolation.build` | every path below it | setting | Every path below it is a request to build an image. | Candler only | Candler only | +| `isolation.build.plugin` | the path | setting | The image build plug-in. | Candler only | Candler only | +| `isolation.build.dockerfile` | the path | setting | The Dockerfile of an image build. | Candler only | Candler only | +| `isolation.build.context` | the path | setting | The build context directory of an image build. | Candler only | Candler only | +| `isolation.build.requirements` | the path | setting | The requirements file of an image build. | Candler only | Candler only | +| `isolation.build.prune` | the path | setting | Whether an image build prunes what it leaves. | Candler only | Candler only | +| `isolation.build.lock` | the path | setting | The lock file of an image build. | Candler only | Candler only | +| `budget` | the path and every path below it | setting | A job cap: every path below it, except the per-run caps. | Candler only | Candler only | +| `budget.per_run` | the path and every path below it, which the enclosing family does not reach | experiment value | The per-run caps are experiment values. | Candler only | Candler only | +| `budget.per_run.wall_s` | the path | experiment value | The wall-clock cap of one run, in seconds. | wall cap: Candler: the core ends the run at the wall budget | wall cap: Candler: the core ends the run at the wall budget | +| `budget.per_run.turns` | the path | experiment value | The turn cap of one run. | turn cap: `--max-turns` on the command line | turn cap: no (`agents..steps` makes the last request a tool-less one with an injected prompt and ends the run as completed (the `oc_step_cap` fixture), where Claude Code ends the run with `error_max_turns`, so the cap class would be lost and the model's last turn changed) | +| `budget.per_run.max_cost_usd` | the path | experiment value | The cost cap of one run, in US dollars. | cost cap: `--max-budget-usd` on the command line | cost cap: no (OpenCode has no cost cap) | +| `replicates` | the path and every path below it | setting | How many runs each cell gets. | Candler only | Candler only | +| `runner.mode` | the path | experiment value | `headless` or `session`. | session mode: stream-json over an open stdin, one turn per message | session mode: no (OpenCode runs no session: its trace comes from the export after the run) | +| `runner.idle_s` | the path | experiment value | The idle time that ends a session, in whole seconds, or `none`. | Candler only | Candler only | +| `harness` | the path and every path below it | experiment value | The harness table; the names below belong to the harness. | Candler only | Candler only | +| `treatment` | the path and every path below it | experiment value | The treatment table. | Candler only | Candler only | +| `inputs` | the path and every path below it | experiment value | The inputs table. | inputs: Candler: the core places the inputs in the workspace | inputs: Candler: the core places the inputs in the workspace | +| `environments` | the path and every path below it | experiment value | The environments table. | Candler only | Candler only | +| `treatment:` | text that is not a field path | experiment value | The prefix of a value that names a treatment source; the rest is the path. | Candler only | Candler only | +| `store.root` | the path | configuration key | The store root; a relative path is read from the project root. | Candler only | Candler only | +| `plugins.dirs` | the path | configuration key | The directories that hold plug-ins; relative paths are read from the project root. | Candler only | Candler only | +| `slots.count` | the path | configuration key | How many run slots the machine offers. | Candler only | Candler only | +| `slots.evaluators` | the path | configuration key | How many of the slots evaluators may use. | Candler only | Candler only | +| `gateway.upstream_ca` | text that is not a field path | configuration key | A PEM file whose certificates the gateway trusts for its upstream. | Candler only | Candler only | ## Refusals diff --git a/docs/contract/harness-capabilities.md b/docs/contract/harness-capabilities.md index 543ae721..3057f605 100644 --- a/docs/contract/harness-capabilities.md +++ b/docs/contract/harness-capabilities.md @@ -17,14 +17,44 @@ Core line: `v0.15.0`; the `candler-harness` crate has the same version. | Capability | `claude-code` | `opencode` | |---|---|---| +| model id | `--model` on the command line | `-m candler/` on the command line | +| model endpoint | Candler: the gateway forwards model requests to the endpoint | Candler: the gateway forwards model requests to the endpoint | +| model effort: low | `--effort ` on the command line | a `variants` entry on the model, selected by `-m #`, for a Claude opus, sonnet, fable or mythos of 4.6 or later (`xhigh` from 4.7); refused for any other model | +| model effort: medium | `--effort ` on the command line | a `variants` entry on the model, selected by `-m #`, for a Claude opus, sonnet, fable or mythos of 4.6 or later (`xhigh` from 4.7); refused for any other model | +| model effort: high | `--effort ` on the command line | a `variants` entry on the model, selected by `-m #`, for a Claude opus, sonnet, fable or mythos of 4.6 or later (`xhigh` from 4.7); refused for any other model | +| model effort: xhigh | `--effort ` on the command line | a `variants` entry on the model, selected by `-m #`, for a Claude opus, sonnet, fable or mythos of 4.6 or later (`xhigh` from 4.7); refused for any other model | +| model effort: max | `--effort ` on the command line | a `variants` entry on the model, selected by `-m #`, for a Claude opus, sonnet, fable or mythos of 4.6 or later (`xhigh` from 4.7); refused for any other model | +| model effort: ultracode | `--effort ultracode` on the command line, which Claude Code reads as `xhigh` with its ultracode mode on | no (`ultracode` is `xhigh` effort with an ultracode mode on, and OpenCode has no equivalent of that mode, so it is refused rather than run as `xhigh`) | +| permission mode: default | `--permission-mode ` on the command line | no (Claude Code's default mode allows reads and a built-in, non-configurable set of read-only shell commands that its own parser decides, and denies the rest in a headless run. OpenCode without `--auto` also rejects what no rule allows, but its shell rows are wildcards on the text of each parsed command, which approximate that set without being it) | +| permission mode: acceptEdits | `--permission-mode ` on the command line | no (Claude Code's acceptEdits mode also allows edits and the filesystem commands mkdir, touch, rm, rmdir, mv, cp and sed, inside the working directory only. OpenCode's shell resource is the command's text, which knows no working directory, so "inside it" cannot be written as a rule) | +| permission mode: plan | `--permission-mode ` on the command line | no (Claude Code's plan mode reads and runs read-only shell commands (a built-in, non-configurable set its own parser decides). The OpenCode ruleset that is certainly read-only (the `explore` agent's: deny everything, allow read, glob, grep, webfetch, websearch, skill) denies the shell altogether, and a wildcard on command text cannot express the read-only set; the stock `plan` agent is not read-only once a global rule follows it (the last match wins) and its `subagent` child can edit) | +| permission mode: bypassPermissions | `--permission-mode ` on the command line | `--auto` on the command line: every tool call is allowed by the baseline ruleset {*, *, allow}; `--auto` answers the one pending ask (`.env` reads) with once, which a headless run needs | +| permission mode: auto | `--permission-mode ` on the command line | no (Claude Code's auto mode has a model classifier review each action, such as a shell command or a network request, before it runs. OpenCode has no classifier, and a ruleset decides by the action's text alone) | +| permission mode: dontAsk | `--permission-mode ` on the command line | no (Claude Code's dontAsk mode denies every call that would prompt, so it allows the allow rules plus reads and the built-in, non-configurable set of read-only shell commands its own parser decides. OpenCode's shell rows are wildcards on the text of each parsed command, which approximate that set without being it) | +| tools allowed | `permissions.allow` of `.claude/settings.json` | a permission row {action, *, allow} per name, a no-op over the baseline | +| tools disallowed | `permissions.deny` of `.claude/settings.json` | a permission row {action, *, deny} per name, written after the allow rows | +| env | Candler: the core sets the cell's variables on the agent's process | Candler: the core sets the cell's variables on the agent's process | +| inputs | Candler: the core places the inputs in the workspace | Candler: the core places the inputs in the workspace | +| skills | the project skill directory | the project skill directory | +| MCP transport: stdio | an entry of `mcpServers` in `.mcp.json`, of type `stdio` | an `mcp` entry of type `local` | +| MCP transport: local | an entry of `mcpServers` in `.mcp.json`, of type `stdio` | an `mcp` entry of type `local` | +| MCP transport: http | an entry of `mcpServers` in `.mcp.json`, of type `http` | an `mcp` entry of type `remote` | +| MCP transport: sse | an entry of `mcpServers` in `.mcp.json`, of type `sse` | no (OpenCode documents no SSE transport; its `remote` is Streamable HTTP) | +| MCP transport: remote | an entry of `mcpServers` in `.mcp.json`, of type `http` | an `mcp` entry of type `remote` | +| MCP codemode: off | no key: Claude Code offers the server's tools directly | the `codemode` key of the `mcp` entry, `false`: the server's tools are direct tools | +| MCP codemode: on | no (Claude Code offers MCP tools directly; it has no code mode) | the `codemode` key of the `mcp` entry, `true`: the server's tools are reached through `execute`, whose calls the trace records with empty `wrapped_calls`, so MCP calls made inside `execute` are not attributed and do not compare with Claude Code | +| MCP server name | the key of the server's `.mcp.json` entry | the key of the `mcp` entry | +| wall cap | Candler: the core ends the run at the wall budget | Candler: the core ends the run at the wall budget | +| turn cap | `--max-turns` on the command line | no (`agents..steps` makes the last request a tool-less one with an injected prompt and ends the run as completed (the `oc_step_cap` fixture), where Claude Code ends the run with `error_max_turns`, so the cap class would be lost and the model's last turn changed) | +| cost cap | `--max-budget-usd` on the command line | no (OpenCode has no cost cap) | +| session mode | stream-json over an open stdin, one turn per message | no (OpenCode runs no session: its trace comes from the export after the run) | | gateway route | Candler: gateway, address in `ANTHROPIC_BASE_URL` | Candler: gateway, address in `CANDLER_GATEWAY_URL` | -| census source | yes | Candler: gateway, first request with tools | -| session mode | yes | no (refused) | -| turn cap | yes | no (refused) | -| cost cap | yes | no (refused) | -| stop | yes | Candler: interrupt command in the container, then SIGTERM | | authoritative trace | yes | Candler: collects `export` after the run | -| skills layout | yes | Candler: places the tree at `.opencode/skills/` | +| graceful stop | SIGTERM ends the sessions cleanly | an interrupt request to the `serve` child, then SIGTERM to the client | +| live events | stream-json events on stdout while the run lasts | no (the live reader emits no event: the trace comes from the export) | +| in-harness guard | no (the driver configures no Claude Code hook) | no (the driver configures no OpenCode guard) | +| execution outside the child | no (tools run in the child process) | tools run in the `serve` child, which the stop interrupts first | +| census source | Claude Code's `system/init` event lists the tools | Candler: the tools the gateway offered the model in its first request | | permission mode when none is set | `--permission-mode default` on the command line, which in a headless run denies every tool call that needs approval unless an allow rule or a hook approves it | Candler: the run is under `--auto` and the baseline ruleset {*, *, allow}, so every tool is allowed: OpenCode has no headless ask mode | @@ -39,6 +69,6 @@ Core line: `v0.15.0`; the `candler-harness` crate has the same version. ## Notes -- `no (refused)` is a refusal with a code: `experiment.session_refused` while resolving, `experiment.setting_unsupported` when the cells are planned, before a job starts. [checked: v@0.7.0] +- `no (…)` is a refusal: `experiment.session_refused` while resolving, `experiment.setting_unsupported` when the cells are planned, before a job starts. [checked: v@0.15.0] - In session mode Candler also counts turns across the session and ends the run when they exceed `budget.per_run.turns`. [checked: v@0.7.0] - The settings a driver maps or refuses, such as permission modes, effort levels and tool names, are the answers its driver gives for each `AgentSetting`. [checked: v@0.7.0]