Repository navigation
Conversation
`--mcp-server name=https://host/path` (and the `mcp_server` config key) now connects to a remote MCP server over Streamable HTTP, next to the stdio form, inside the existing `mcp` feature of `tole-core`. - Token only from TOLE_MCP_<NAME>_TOKEN, re-read on every reconnect, sent only to that endpoint; token and url scrubbed from every error. - https required (plain http only for loopback); urls the url crate refuses, credentials, whitespace, backslashes and percent-encoded hosts are refused; cross-origin redirects are not followed. - Tools stay Risk::Write; pre-authorize with --allow 'mcp_<name>_*'. - rmcp >= 3.9.0 (RUSTSEC-2026-0462); ring installed once as the TLS provider; a failing client build degrades to a startup warning. Breaking for embedders: McpServerConfig holds `transport: McpTransport` instead of `command` / `args`. Closes #530
`tole mission` builds its registry like `run`, including the auto-attached `mcp_cora_*` tools, but its pinned system prompt never named the review flow, so the unattended command did not know it existed. When both review tools are registered, a fresh mission prompt now carries the same review section as run/chat/tui plus one sentence asking for a review (and its verdict in the final message) before the mission ends. Resumed missions keep their pinned prompt. serve/acp/mcp sessions are unchanged on purpose: they attach no external MCP servers, so they have no review tools. Documented in the README. Closes #536
…538) Runs the fixed `cargo install cora-code --locked` (the same constant `tole doctor` prints) after a [y/N] at a terminal or --yes; with neither it refuses (exit 2). A supported cora is left alone, --check only reports, no cargo prints the manual command. The result is verified at $CARGO_HOME/bin/cora and a still-too-old result is an error. `tole doctor` now ends its cora lines with "(or run `tole setup cora`)". Same trust model as `tole upgrade`: cargo verifies the registry checksum, tole downloads nothing. No tool exposes the command to a model. Closes #535
## What While both cora review tools are attached, a `git commit` is refused until the staged diff has a validated review, and the refusal tells the model how to get one. Covers the `git` tool's `commit` op and `run_command` / `job_start` running `git commit`. Supersedes #539 (same change, squashed to one commit because the old branch had a commit trailer the Message Standard check rejects and history cannot be rewritten here). Closes #534. ## Why AGENTS.md makes a review of the staged diff mandatory before every commit, but an agent session could commit without ever reviewing; the review flow was guidance only. ## Design change from the issue #534 proposed hashing `git diff --cached` in tole. `cora-code` 0.20.0 already ships this (cora #674): `review_finalize` leaves a marker bound to a fingerprint of the exact change set, and `cora hook verify` answers whether the staged diff may be committed (exit 0 validated or nothing to review, 10 reviewed but blocking, 11 not validated). tole asks `cora hook verify` before the commit runs instead of defining "this diff" a second time. Needs cora >= 0.20.0; with an older cora the gate fails open with one warning. ## Changes - New `review_gate.rs`: `Gate` (inactive until both `mcp_cora_cora_review_prepare` and `_finalize` are registered; 15 s timeout, child-env scrub; tooling trouble fails open with one warning), `Gated` decorator (forwards everything, asks the gate only for a commit), `Policy` = `off | warn | block` (default `block`). - Commit recognition: `git commit` behind `env`, `VAR=x`, a path to git and git global options. The commit is verified in the repo it targets (`-C dir`, `-Cdir`); commits redirected by `--git-dir`, `--work-tree`, `GIT_DIR`-style env, `core.worktree`, or `env -C/--chdir` are refused under `block`. - `tool_roster.rs` wraps `git`, `run_command`, `job_start` when the policy is not `off` and MCP servers are attached; `TOLE_REVIEW_GATE` / global `--review-gate`; `tole doctor` prints a gate line. - README, CHANGELOG, `docs/threat-model.md` (new section). Not a config key yet: an untrusted project config could set `off`; follow-up to make it trust-gated. ## What it is not A guardrail for a cooperating agent, not a security boundary (the approver is). `sh -c "git commit"`, scripts, aliases and `merge` / `cherry-pick` / `am` are not recognized; the review is self-review; a human `git commit` is not gated. Documented in the threat model. ## Testing - [x] `cargo test --workspace`, `cargo fmt --all -- --check`, `cargo clippy --workspace --all-targets -- -D warnings` - [ ] Local `cora review --staged`: not run (cora is not installed in this environment); the CI Cora Review job is the verdict. - [x] 14 unit tests (commit-call parsing including `-Cdir` and `env -C` forms, policy, gate against a fake `hook verify`, decorator, real git tool in a temp repo) and 8 e2e tests with the real binary, scripted provider, fake cora and a real repo; mutation checked. - Not tested: a real cora 0.20 binary. ## Related Issues Closes #534. Supersedes #539. --- _Generated by [Claude Code](https://claude.ai/code/session_01GwJr9GzLbDFeXo3HZHZpyP)_ Co-authored-by: Claude <[email protected]>
## What Step 1 of #531: a read-only script, `evals/shell_usage.py`, that scans session JSONL and reports how often `run_command` / `job_start` inputs use shell features, and how those calls ended. ## Why `run_command` runs argv with no shell, so `a | b`, `cd sub && cmd` and `cmd > file` are literal characters. Whether that costs agents turns is unknown for tole: there is no data. #531 asks to measure before changing anything. ## Changes - `evals/shell_usage.py`: scans any directory or file recursively for `*.jsonl` (one entry per line or batched arrays). Per call it records the categories pipe, chain (`&&` `||` `;`), redirect, substitution (`$(` / backtick, not inside single quotes), leading `cd`, and `sh|bash -c` wrapper; operators inside quotes are not counted. It also counts failed calls (tool_result `ok=false`) and calls that directly follow a failed one. Text or `--json` output. - `evals/test_shell_usage.py`: 4 tests (feature table, quoted operators, unparsable input, a scan with a batched line, an ignored tool and a bad line). - `evals/README.md` section and CHANGELOG entry. - No change to `run_command`, tole-core or tole-cli. ## Result of the first run (2026-11-10) All session files in this repository: 8 files, 9 `run_command` calls, 5 shell-shaped (4 `bash -c` wrappers, 1 redirect), 0 failures. Those come from scripted Tier 2 missions that were written to use `bash -c`, so the sample says nothing about real use. **Decision recorded here: inconclusive, leave `run_command` as is.** The script has to be run on real daily-use sessions and live missions before choosing `workdir` or pipeline support, so this PR does not close #531. ## Testing - [x] `python3 evals/test_shell_usage.py` passes - [x] Script runs on `evals/` and `docs/e8-session-log.jsonl` - [ ] Local `cora review --staged`: not run (cora is not installed in this environment); the CI Cora Review job is the verdict. - No Rust changed. ## Related Issues Refs #531 (step 1 only). Related: #438. --- _Generated by [Claude Code](https://claude.ai/code/session_01GwJr9GzLbDFeXo3HZHZpyP)_ Co-authored-by: Claude <[email protected]>
#542) ## What With `TOLE_WEB_FETCH_URL` set, `web_fetch` asks that backend for the page instead of fetching directly, so JS-rendered and bot-protected pages can work. It stays a `ReadOnly` tool with the same trust model as `web_search`. Unset: the direct fetcher is untouched. Closes #532. ## Why `web_fetch` is direct HTTPS only (no JavaScript, no browser), so many real pages come back empty. #215/#436 gave search a configurable backend; fetch had none. Doing it through MCP would make every page fetch a `Write` approval. ## Changes - `web.rs`: new `WebBackendFetchTool` registered under the name `web_fetch` **instead of** `WebFetchTool` when `TOLE_WEB_FETCH_URL` is set (`WebFetchTool` itself is not modified, so the unset case is byte-for-byte the same). - Contract: `GET {url}?url=<target>` → `{"content": "..."}`; `TOLE_WEB_FETCH_METHOD=POST` sends `{"url": "<target>"}`; `TOLE_WEB_FETCH_HEADERS` (`Name=${VAR}`, same parser and rules as the search headers, now parametrized by variable name so errors name the right variable); `TOLE_WEB_FETCH_FIELDS='content=<field>'`. A malformed value fails startup. - The target is vetted before anything is sent: https only, no credentials in the URL, host must resolve to public addresses (`TOLE_WEB_ALLOW_PRIVATE=1` opts out as for direct fetch). A refused target never reaches the backend. - Backend only, no direct fallback (the issue's proposal; revisit with data). Backend redirects are not followed; headers go only to the backend; errors never carry a header value. The backend's JSON envelope is bounded to 1 MiB and the text is truncated to the direct-fetch limits (512 KiB, 20k chars). - Output keeps the direct fetcher's shape (`url`, `content_type`, `truncated`, `text`). - `tool_roster.rs`: choose the backend tool when configured. - README row, threat model paragraph (new disclosure: the target URL goes to the backend operator; the local check is not a DNS-rebinding defense at the backend), CHANGELOG. ## Open questions from the issue (decisions taken here) - Fallback order: backend only. Format hint to the backend: not sent. Tool description: the summary says a fetch backend is attached ("may render JavaScript-heavy pages"). - The response shape of a specific real backend is **not verified**; `TOLE_WEB_FETCH_FIELDS` exists for that. ## Testing - [x] `cargo fmt`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo test --workspace` (1150 passed) - [ ] Local `cora review --staged`: not run (cora is not installed in this environment); the CI Cora Review job is the verdict. - [x] 5 new tests with a local mock backend: off unless configured and 6 malformed-config cases fail with the variable named; 9 bad targets (http, credentials, loopback, localhost, private, link-local, file, ftp, missing) are refused and the mock sees no connection; GET sends the percent-encoded target and the header only to the backend; POST body; a failing backend's error does not contain the header value; truncation, missing field, non-JSON and oversize envelope. - Mutation: removing the target vetting makes the refusal test fail (it tries the real target and hangs without network instead of returning quickly). - Not tested: a real backend, and the roster choice end to end (the roster change is a two-arm match). ## Related Issues Closes #532. Related: #215, #436. --- _Generated by [Claude Code](https://claude.ai/code/session_01GwJr9GzLbDFeXo3HZHZpyP)_ --------- Co-authored-by: Claude <[email protected]>
…pproval round trip (#543) ## What Fixes the flaky `serve_approvals::approval_allow_round_trip_executes_the_work` (it failed on CI for #539 and #542, both times unrelated to the PR's diff). ## Why After `POST /approvals/{id}/decision` returns `202 resuming`, the test waited for the resumed turn by polling `GET /sessions/{sid}/status` until `busy != true`. Right after the 202 the resume may not have set `busy` yet, so the very first read says "not busy", the loop exits at once, the queue entry already reads `approved`, and the file assertion runs before the replayed `write_file` has landed ("the approved write must have executed"). A "not busy" read proves nothing at that moment. ## Changes - `crates/tole-cli/tests/serve_approvals.rs`: poll for the effect itself (`approved.txt`, up to 10 s), then keep the existing wait for the session to settle. No production code and no assertion weakened: the same checks run, after the condition they depend on. ## Testing - [x] Reproduced under CPU load (6 busy loops on 4 cores), `approval_allow_round_trip` run 25 times in a row: **old code failed 9/25, the fix 0/25**. - [x] `cargo fmt --check`, `cargo clippy -p tole-cli --all-targets -D warnings`, `cargo test -p tole-cli --test serve_approvals` (3 passed). - [ ] Local `cora review --staged`: not run (cora is not installed in this environment); the CI Cora Review job is the verdict. ## Not included: the `tui_e2e` /quit race An earlier CI failure suggested tests send `/quit\r` before the turn is idle (the text would be queued as steering input instead of running as a command), and adding `t.idle()` before `/quit` looked like the fix. I could not reproduce it: 23 runs of the old `tui_e2e` binary under heavier load (8 busy loops, 8 test threads) all passed, so that change is not in this PR. It should be revisited if it fails on CI again, with the failing test name in hand. ## Related Issues Related to #539 and #542 (CI failures that were not theirs). --- _Generated by [Claude Code](https://claude.ai/code/session_01GwJr9GzLbDFeXo3HZHZpyP)_ Co-authored-by: Claude <[email protected]>
## What First of three parts of #524 (UI epic #523): `GET /sessions/{id}/entries?after=<seq>&limit=<n>` on `tole serve`, a paginated transcript read so a graphical client that connects late or reconnects can render history. The other two parts (resume-by-id, SSE event stream) are separate PRs. Refs #524, does not close it. ## Why A UI client has no way to read a session's history today. `GET /sessions/{id}/status` only returns counts. This is the lowest-risk piece of #524 (read-only, additive) and gives clients history now. The split (entries, then resume, then SSE) and the open design choices (resume shape `POST /sessions {"resume": "<id>"}`, serde structs without a schema dependency yet, a separate stream cap of 8 for SSE) were agreed with the owner on 2026-11-10. ## Changes - `crates/tole-cli/src/protocol.rs` (new, lib): the wire types. `EntriesPage {id, entries, nextAfter, hasMore, lastSeq}` (camelCase), query parsing (`after` default 0, `limit` default 100, clamped to 500, junk is a 400) and `entries_page`. Entries are exactly the log's `Entry` values, so a client sees what `tole resume` replays; nothing is reformatted. - Reads the session **file** with `JsonlStorage::open_read_only` (a torn tail is skipped and never truncated), not the live storage handle: a running turn holds that lock for its whole duration, and the transcript has to stay readable meanwhile. `SessionState` gains the file `path` for this. - A page also stops at about 1 MiB of serialized entries (always at least one, so a huge entry cannot wedge paging); `hasMore` can therefore be true with fewer than `limit` entries. - `serve.rs`: splits the query string off the path before matching the session action (`entries?after=5` is the `entries` action); the existing status route is unchanged (tested). Auth is the existing bearer token. - Docs in the same PR (AGENTS.md §7): README status line, `docs/mobile-control.md` (route table and a Transcript read section), `docs/daemon-design.md` (owner un-parked the serve-face part, the socket daemon stays parked), `docs/epics.md`, CHANGELOG, `serve.rs` header. ## Limits (stated, not hidden) - Live sessions only: a session that is not in the serve process's live map (e.g. after a restart) is a 404 until resume-by-id lands (next PR). - Each call replays the whole file (the issue's open question about an index on very large sessions is not addressed here); `seq` is not dense, so clients must page with `nextAfter`. - The route adds no new trust (the token already grants approval authority and prompting) but entries carry tool inputs and outputs, which every token holder can now read; noted in `mobile-control.md`. ## Testing - [x] `cargo fmt --all -- --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo check -p tole-cli --no-default-features`, `cargo test --workspace` (1160 passed) - [ ] Local `cora review --staged`: not run (cora is not installed in this environment); the CI Cora Review job is the verdict. - [x] 7 unit tests: query defaults/clamp/junk, paging covers the log exactly once in order, empty/past-the-end/exact-fit edges, seq gaps, byte budget always makes progress, the camelCase wire shape, and a file read equals the replayed entries and ignores a torn tail. - [x] 3 e2e tests against the real `tole serve` binary with a mock provider: paging two at a time equals the replayed JSONL (and `status` still works); 401 without the token, 404 unknown session, 400 for `after=x`, `after=-1`, `limit=0`, `limit=many`, and an over-ceiling `limit` clamps; **the transcript is readable in under 1.5 s while a 3 s turn is in flight**. - Mutation: changing `seq <= after` to `seq < after` fails 3 unit tests. ## Related Issues Refs #524, part of #523. --- _Generated by [Claude Code](https://claude.ai/code/session_01GwJr9GzLbDFeXo3HZHZpyP)_ Co-authored-by: Claude <[email protected]>
) ## What Second of three parts of #524 (UI epic #523): `POST /sessions {"resume": "<id>"}` on `tole serve` reopens an existing session, so a UI client can pick a session up again after a serve restart (the live map is in memory; the JSONL is what survives). Part 1 (`GET /sessions/{id}/entries`) is merged (#544). Part 3 (SSE events) follows. Refs #524, does not close it. ## Why `POST /sessions` only creates, and `GET /sessions` lists only live sessions, so a client cannot reopen history it can now read. The request shape was agreed with the owner on 2026-11-10. ## Changes - `serve.rs`: `resume_session` + `open_serve_session`. Create and resume now share the approver, `open_session` and admission code (extracted from the create path; behavior of creating a session is unchanged, covered by the existing tests). - The id is validated (`is_valid_session_id`) and only joined into the session directory (`--sessions-dir`, else `<cwd>/.tole/sessions`); the client never supplies a path. `cwd` goes through the same jail-of-jails check as a new session (`403` outside it), and a session is found only under the workspace it was created in (`404` otherwise). - **Already live**: `200 {"resumed": false, "alreadyLive": true, "busy": <bool>}`. It is checked first and nothing is reopened or replaced: the writer lock is held by this very process (a second open would be refused as locked), and a running turn must not be disturbed. A client that reconnects mid-turn gets its id and the `busy` flag. - `404` no such file; `400` bad id or a non-string `resume`; `409` another process (a TUI, a second serve) holds the session's writer lock; `503` at the live-session cap with every session busy (unchanged rule). - A resumed session uses the same `QueueApprover`: non-preauthorized Writes queue for a remote decision exactly as for a new session. Resuming grants no authority; the token is the same. - Docs in the same PR (AGENTS.md §7): README status line, `docs/mobile-control.md` (route table and a Resume by id section, and the "not readable until resumed" note from part 1), `docs/epics.md`, `docs/daemon-design.md`, CHANGELOG, `serve.rs` header. ## Testing - [x] `cargo fmt --all -- --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo check -p tole-cli --no-default-features`, `cargo test --workspace` (1163 passed) - [ ] Local `cora review --staged`: not run (cora is not installed in this environment); the CI Cora Review job is the verdict. - [x] 3 new e2e tests against the real `tole serve` binary (same file and harness as the transcript tests): - a session is gone from a restarted serve (`GET …/entries` is a 404), `resume` brings it back with its full history, a new prompt extends the same log; - resuming a live session is a no-op even mid-turn (`alreadyLive`, `busy: true`), and the 2.5 s turn still completes normally; - refusals: `../etc/passwd`, empty and non-string ids (400), an unknown id (404), `cwd: "/"` (403), a jailed sibling directory (404 for a session that is not live), and a second serve process over the same workspace while the first holds the lock (409, nothing opened), then 200 once the holder is gone. - Mutation: skipping the live-session check makes the live-session test fail. ## Limits - Resume does not replay an unfinished turn by itself: a session that was mid-turn when the server died resumes into whatever state its log holds, and the client continues with a prompt (the existing resume rules apply). - A live session ignores a mismatching `cwd` in the request (it is already open under its own workspace). ## Related Issues Refs #524, part of #523. --- _Generated by [Claude Code](https://claude.ai/code/session_01GwJr9GzLbDFeXo3HZHZpyP)_ Co-authored-by: Claude <[email protected]>
## What Third and last part of #524 (UI epic #523): `GET /sessions/{id}/events?after=<seq>`, a Server-Sent Events stream so a graphical client can show a session live. Parts 1 and 2 (transcript read #544, resume-by-id #545) are merged. This completes #524. Closes #524. ## Why `POST /sessions/{id}/prompt` blocks until the turn ends, so a UI could not show streamed text, tool cards or approval requests as they happen. Design choices were agreed with the owner on 2026-11-10: SSE, durable frames from the log plus best-effort ephemeral frames, and a separate cap of 8 streams. ## Changes - `crates/tole-cli/src/events.rs` (new, lib), pure and unit-tested: - SSE framing; **durable** `entry` frames use the entry's `seq` as the SSE `id` (so `Last-Event-ID` and `?after=` replay losslessly), **ephemeral** frames carry no id so a reconnect can never skip a real entry. - `Bus` / `BusRegistry` / `BusObserver`: fan-out of a turn's `TurnObserver` callbacks (`text_delta`, `reasoning`, `tool_started`, `tool_finished`) to open streams through a **bounded, non-blocking** queue per stream; a full queue drops the frame, counts it and the stream says `resync`. A slow client can never slow a turn. - `EntryTail`: follows the session file by `seq` (one `stat` while unchanged; a read-only replay when it changed, a torn tail is skipped, never truncated), so it works while a turn holds the live storage lock. Writes that land between the stat and the replay are picked up next poll, never missed (seq filters duplicates). - `ApprovalWatch`: `approval_requested` / `approval_resolved` frames from the existing approvals queue (a late joiner sees what is pending; old decisions are not replayed). - `StreamLimiter`: at most 8 open streams (`429` beyond that), freed on drop. - `Heartbeat`: a pure clock that is only reset by a real write (injected time, unit-tested); `TOLE_SERVE_HEARTBEAT_SECS` (1 to 3600, default 15) overrides the interval, e.g. behind a proxy with a short idle timeout. - `serve.rs`: `Last-Event-ID` is parsed; the stream is served before normal routing and owns its connection (`ready` marks the end of the replay, then durable entries, approvals and ephemeral frames, a heartbeat comment after 15 s without a write, and `closed` when the session leaves the live map). Streams count within the 32-connection cap but cannot starve `/approvals` and `/prompt`. Approval frames go out before the durable entries of the same pass, so a decision is announced ahead of its effects. - The prompt route attaches an observer **only while a stream is open on that session**. Attaching an observer turns on provider streaming, so with nobody watching a turn runs exactly as before streams existed (zero change for existing REST users). Consequence, documented: a stream opened mid-turn gets durable entries but no text deltas for that turn. - Tests: the serve process, provider mock and a small SSE client moved into a shared `tests/serve_harness` (the entries/resume tests from #544/#545 use it too). - Docs in the same PR (AGENTS.md §7): README status line, `docs/mobile-control.md` (route table and an Event stream section with the frame table, replay semantics, limits and the browser `EventSource` caveat), `docs/epics.md`, `docs/daemon-design.md`, `docs/threat-model.md` (new Event streams section), CHANGELOG, `serve.rs` header. ## Not included (stated, not hidden) - An observer for the turn that resumes after an approval `allow`: that path (`resume_turn_with_cancel`) has no observer variant in `tole-core`, so adding one is a core change beyond this issue. Its entries (the final answer) still arrive as durable frames; only live text/tool frames are missing for it. - A stream token for browser `EventSource` (cannot send `Authorization`): left to the web client (#529). - A log index: each change replays the session file, so a very large session costs more per change. ## Testing - [x] `cargo fmt --all -- --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo check -p tole-cli --no-default-features`, `cargo test --workspace` (1178 passed) - [ ] Local `cora review --staged`: not run (cora is not installed in this environment); the CI Cora Review job is the verdict. - [x] 10 unit tests (`events`): frame format and escaping, ephemeral shapes, bus fan-out/drop counting/unsubscribe, observer only while watched, limiter, approval diff (late joiner, resolve, expiry, decided-between-polls), tail (each entry once, torn tail, unchanged = no replay, start after a seq), the heartbeat clock (only a real write resets it) and its interval parsing. - [x] 5 e2e tests against the real `tole serve` binary: replay then follow a live turn (entries equal the stored log, ids are seqs, ordered, no duplicates, a `text_delta` arrives, the prompt answer is unchanged); reconnect with `Last-Event-ID` and with `?after=` gets exactly the entries it missed, no stray frames, `after` beats a stale header; 401/404/400 and the cap (8 open, the 9th is 429, `/sessions` and `/approvals` still answer); approval flow (`approval_requested`, allow, `approval_resolved` before the resumed turn's answer, the work executed); an idle stream heartbeats (interval set to 1 s). - Mutations, each caught: no observer attached (live-turn test), `seq >=` in the tail (duplicates: e2e + unit), cap off by one (e2e + unit), an empty approvals pass resetting the heartbeat clock (the bug Cora found: heartbeat e2e times out). ## Related Issues Closes #524, part of #523. Follow-ups in the epic: #525, #526. --- _Generated by [Claude Code](https://claude.ai/code/session_01GwJr9GzLbDFeXo3HZHZpyP)_ --------- Co-authored-by: Claude <[email protected]>
…oster (#547) ## What First part of #525 (UI epic #523): `session_host.rs` no longer contains tool registration. `UpdatePlanTool`, `PlanEmitter`, `register_gitea`, `detect_github_repo` and `github_repo_from_remote_url` (with their tests) move to `tool_roster.rs`, where the rest of the roster already lives. Refs #525, does not close it. ## Why `session_host.rs` mixed session hosting (open, turn, resume, cancel, interrupt, detach, list) with tool setup, which is one of the acceptance criteria of #525 and a prerequisite for merging `TuiSession` onto one host. Owner decisions on 2026-11-10: do #525 as a module inside `tole-cli` first (a new crate only when a second consumer exists), keep the API synchronous, and deliver in small PRs. ## Changes - Pure move: `session_host.rs` 1019 → 777 lines, `tool_roster.rs` +254. Only edits inside the moved code: `StdArc` → `std::sync::Arc` (the alias is not imported in `tool_roster`) and the self-call `crate::session_host::github_repo_from_remote_url` → a local call. - Callers updated to the new path: `acp.rs` (`PlanEmitter`), `main.rs` tests (`github_repo_from_remote_url`, `detect_github_repo`), `tests/tool_specs.rs` (`UpdatePlanTool`), `tool_roster.rs` itself, and `session_host.rs` imports `PlanEmitter` for `open_session`'s parameter. **No re-export** from `session_host`, so there is one way to reach each item; this changes five library paths of the published `tole-cli` crate (noted in CHANGELOG under Changed). - CHANGELOG and `docs/epics.md` updated in the same PR (AGENTS.md §7); README unaffected. ## Testing - [x] `cargo fmt --all -- --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo check -p tole-cli --no-default-features`, `cargo check -p tole-cli --no-default-features --features shell-tools`, `cargo check -p tole-core --no-default-features` - [x] `cargo test --workspace`: 1178 passed, the same count as `develop` before the move (no test lost or duplicated). The moved `plan_tests` and the `github_repo_from_remote_url` tests run from their new location. - [ ] Local `cora review --staged`: not run (cora is not installed in this environment); the CI Cora Review job is the verdict. - `grep` of `session_host.rs` for `register(`, `Box::new(…Tool`, `gitea`, `github`, `update_plan` finds nothing. ## Next in #525 Part 2: merge `TuiSession` (`tui_host.rs`) onto the shared session-host machinery so the TUI stops keeping its own session lifecycle. ## Related Issues Refs #525, part of #523. --- _Generated by [Claude Code](https://claude.ai/code/session_01GwJr9GzLbDFeXo3HZHZpyP)_ Co-authored-by: Claude <[email protected]>
## What Part 2a of #525 (UI epic #523): `session_host::create_session(dir, id, system_prompt, name, face)` creates a session file and registers it in the global session index in one call. Every face that created a session used to do `JsonlStorage::create_*` and then `session_index::record(...)` by hand; they now share the helper. Refs #525, does not close it. ## Why #525 is about not keeping the same session lifecycle logic in several places. Part 2 was agreed with the owner on 2026-11-10 as shared primitives with the TUI keeping a thin single-session wrapper (not a literal merge of `TuiSession` into `Sessions`), delivered as small behavior-preserving PRs: this is the lifecycle one (create + index registration); a shared turn runner and the register settings follow. With one place that creates AND registers, a face cannot create a session and forget to index it. ## Changes - `session_host.rs`: `create_session` (calls `JsonlStorage::create_named`, then `session_index::record` when `face` is `Some`; `None` = do not index, which the TUI host uses when it was built without an index, i.e. in tests). - Adopted at six sites: `run` and `chat` and the TUI start in `main.rs`, `mission.rs`, `open_session` (server faces, face `server`), and `TuiSession::new_session` (`/new`). Each keeps its own error context and any directory creation it already did, so error messages and index contents are unchanged. - Not changed on purpose: `branch` and `import` register sessions created through other APIs (fork, import), and opening an existing session has about six variants with different id rules and messages (not the same duplication). - CHANGELOG (Changed) and `docs/epics.md` updated in the same PR (AGENTS.md §7); README unaffected. ## Testing - [x] `cargo fmt --all -- --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo check -p tole-cli --no-default-features`, `cargo test --workspace` (1179 passed: the previous 1178 plus one new test) - [ ] Local `cora review --staged`: not run (cora is not installed in this environment); the CI Cora Review job is the verdict. - [x] New integration test `tests/session_create.rs` (one test, one process, because the index path is global state read from `CODECORA_HOME`): a created session has the file, the pinned system prompt and alias, and one index row under its face with the right file path; `face: None` indexes nothing; `TOLE_NO_SESSION_INDEX=1` wins over a face; a second face gets its own row; an unsafe id (`../evil`) is refused and nothing is indexed. Before this the only index coverage was `run` (`session_index_e2e.rs`); chat, tui, mission and the server faces had none. - Mutation: removing the index registration from the helper fails the new test. ## Next in #525 Part 2b: one turn runner (build the provider, resume a parked turn, optional compaction, run) shared by `run_session_turn` and `TuiSession::run_turn`. Part 2c: the register settings (model, effort, name, compaction request). ## Related Issues Refs #525, part of #523. --- _Generated by [Claude Code](https://claude.ai/code/session_01GwJr9GzLbDFeXo3HZHZpyP)_ Co-authored-by: Claude <[email protected]>
…#549) ## What Part 2b of #525 (UI epic #523): `turn_runner::{TurnPlan, run_turn_on, run_turn_with, resume_turn_on}` describe how one turn is run, and `run_session_turn` and `resume_session_turn` (serve, ACP, MCP) and `TuiSession::run_turn` all go through it. Refs #525, does not close it. ## Why The server faces and the TUI each had their own copy of the sequence "build the session's provider, run the turn". The TUI also settles a turn parked mid-flight first and compacts when due; the server faces do neither. With one runner, "how a turn is run" lives in one place a new client (desktop, remote) can use, and the differences between faces are explicit fields, not diverging copies. Agreed with the owner on 2026-11-10 as part of the shared-primitives plan for #525 (not a literal merge of `TuiSession` into `Sessions`). ## Changes - `turn_runner.rs`: - `TurnPlan { cfg, registry, system_prompt, cancel, observer, resolve_parked, compaction }`: `resolve_parked` and `compaction` are the TUI's two extras (the server faces set neither, which is exactly their old behavior). - `run_turn_on` (build the provider, then `run_turn_with`), `run_turn_with` (settle a parked turn when asked: a non-`Final` outcome there IS the answer and the new prompt is not run; compact when asked and due; run), `resume_turn_on` (the approvals-only resume of #200). - `TurnRunError::{Provider, Storage}`, so each face keeps its own error text: the server faces use `into_message()` (provider text, or the storage error as is), the TUI keeps its `storage error:` prefix. - `session_host.rs`: `run_session_turn` and `resume_session_turn` build a plan and call the runner. The memory recall before the turn and the memory write after it, the busy claim and the storage lock stay where they were. - `tui_host.rs`: `run_turn` builds a plan with `resolve_parked: true` and `compaction: Some(..)`; its old inline sequence and two imports are gone. - CHANGELOG and `docs/epics.md` updated in the same PR (AGENTS.md §7); README unaffected. Behavior and error text are unchanged: same order (provider, settle parked, compaction, run), same observer wiring, same outcome mapping. One thing the new tests pin down: on a parked session the core's `run_turn` refuses ("resolve the session first"), so the server faces, which never settled, still surface that error; that is exactly why the TUI asks for settling. ## Testing - [x] `cargo fmt --all -- --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo check -p tole-cli --no-default-features`, `cargo test --workspace` (1182 passed: the previous 1179 plus 3). The unchanged `tui_e2e`, `serve_*`, ACP and MCP e2e suites run through the new runner. - [ ] Local `cora review --staged`: not run (cora is not installed in this environment); the CI Cora Review job is the verdict. - [x] 3 new unit tests with the scripted `MockProvider` (no network): a plain turn runs the prompt and appends to the log; a parked turn (parked the way a crash does: user message durable, machine in `Planning`) is settled first only when the plan asks (TUI-style: the settling output goes to the parked turn and the next one answers the prompt; not settling: the core's refusal and nothing written; settling that does not end `Final` returns that outcome and the prompt never starts); compaction runs only when the plan asks (a forced pass of #481 is consumed with the plan on, left pending with it off or with `enabled: false`). - Mutations, each caught: always settling a parked turn, never settling, always compacting. ## Next in #525 Part 2c: the register settings (model, effort, name, compaction request) shared by `TuiSession` and the other faces. After that I will check the acceptance criteria of #525 against what shipped. ## Related Issues Refs #525, part of #523. --- _Generated by [Claude Code](https://claude.ai/code/session_01GwJr9GzLbDFeXo3HZHZpyP)_ Co-authored-by: Claude <[email protected]>
## What Part 2c of #525 (UI epic #523): `session_settings` owns a session's durable settings: the register names (`fact/model`, `fact/reasoning_effort`, `fact/session_name`), the label validation and the writers. The TUI's `/model`, `/effort`, `/name` and `/compact` and ACP's model picker write through it, and the readers use the same constants. Refs #525. ## Why The same registers were written in two places (`tui_host.rs` and ACP's `set_model_option`) and named by repeated string literals in the writers and readers (`turn_runner`, `status`, `acp`). A rename or a validation tweak had to be found in each. Agreed with the owner on 2026-11-10 as the last piece of the shared-primitives plan for #525. ## Changes - `session_settings.rs` (new): `MODEL` / `EFFORT` / `NAME` register constants; `clean_label` (moved from `tui_host.rs`: non-blank, at most 120 chars, no control characters); `set_model`, `set_effort` (validated and canonicalised, or `None` clears the override back to the process default), `set_name`, `request_compaction` (the forced pass of #481), and `write_model` (store as given, for ACP, which validates against its own model list first). - `tui_host.rs`: the setters call the module (its private `commit` helper and `clean_label` are gone; the window cache is still reset after a model switch). - `acp.rs`: `set_model_option` writes through `write_model` (its own validation, busy check and error text stay); `MODEL_REGISTER` is the shared constant. - `turn_runner.rs` (`session_model`, `session_effort`) and `status.rs` read through the constants. - CHANGELOG and `docs/epics.md` updated in the same PR (AGENTS.md §7); README unaffected. Behavior and error text are unchanged (`invalid model id`, `invalid name`, `invalid reasoning effort ...`, and the `storage error:` prefix on a failed write). ## Testing - [x] `cargo fmt --all -- --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo check -p tole-cli --no-default-features`, `cargo test --workspace` (1187 passed: the previous 1182 plus 5) - [ ] Local `cora review --staged`: not run (cora is not installed in this environment); the CI Cora Review job is the verdict. - [x] 5 new unit tests: label rules (trim, blank, control characters, the 120-char limit); the model is stored where the readers look and a bad id writes nothing; effort is validated, canonicalised (` HIGH ` → `high`), a rejected level changes nothing, and `None` clears to the process default; the name register renames and a bad name is refused (the core's `session_name()` reads it); a compaction request is a durable pending flag. The existing `tui_host` tests (`switches_write_the_registers_the_next_call_and_resume_read`, `name_and_compact_request_are_durable_registers`) run unchanged through the new module. - Mutations, each caught by the new tests and by those unchanged `tui_host` tests: the name register key drifting from what the core reads, clearing the effort being a no-op, and label validation disabled. ## What #525 looks like after this Done as shared primitives inside `tole-cli`, per the owner's decision (no new crate until a second consumer exists, sync API): tool registration moved to the roster (#547), session create + index registration (#548), one turn runner (#549), session settings (this PR). I will post the acceptance-criteria status on the issue, including what is not done: `TuiSession` still owns its single swappable storage handle and `switch_session` (open an existing session by id through the index), and the crate/publish decision is deferred with the crate. ## Related Issues Refs #525, part of #523. --- _Generated by [Claude Code](https://claude.ai/code/session_01GwJr9GzLbDFeXo3HZHZpyP)_ Co-authored-by: Claude <[email protected]>
## What First part of #526 (UI epic #523): the TUI's key logic takes a UI-neutral `Input` instead of a crossterm `KeyEvent`. `App::on_input(Input)` holds the logic; a crossterm adapter maps key events onto it. Refs #526, does not close it. ## Why A second UI (the GPUI desktop, #527) can only reuse `tole-tui`'s state machine if that logic is not welded to the terminal. `App::on_key` took a crossterm `KeyEvent` and mixed key decoding with state. The issue's plan is to do this inside `tole-tui` (no new crate until a second consumer exists), in small behavior-preserving steps; this is the input one, the biggest of the three. ## Changes - `input.rs` (new, no terminal types): `Key::{Char, Enter, Esc, Tab, BackTab, Backspace, Up, Down, Other}`, `Mods { ctrl, alt, shift }`, `Input { key, mods }` with small constructors. These are exactly the keys the logic distinguishes today; `docs/tui.md`'s key table stays the behavior contract. - `term_input.rs` (new, crossterm adapter): `input_from(KeyEvent) -> Option<Input>` (a key **release** is dropped, as before) and `App::on_key(KeyEvent)`, kept as the terminal entry point. - `lib.rs`: `on_key` becomes `on_input`; `picker_key` and `answer` take a `Key`. The key-matching logic is unchanged apart from the types. The crossterm key imports are gone from the production code (the event loop keeps its terminal imports; `App`'s input path has none). - **`Key::Other` is deliberate**: every key the logic does not distinguish (Left, Home, F5, ...) still counts as "a key was pressed", so it still disarms a pending Ctrl+C and re-asks an approval, exactly as before. Mapping them to `None` would have silently changed Ctrl+C, Left, Ctrl+C from "arms twice" to "quits". - `docs/tui.md` (Architecture: the input seam), CHANGELOG (Changed; new public items `tole_tui::{Input, Key, Mods}`) and `docs/epics.md` updated in the same PR (AGENTS.md §7); README unaffected. ## Testing - [x] `cargo fmt --all -- --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo check -p tole-cli --no-default-features`, `cargo test --workspace` (1195 passed: the previous 1187 plus 8). The 55 existing `tole-tui` tests pass **unchanged** (they drive `on_key` through the adapter), and the real-terminal `tui_e2e` suite (a pty against a scripted provider) passes. - [ ] Local `cora review --staged`: not run (cora is not installed in this environment); the CI Cora Review job is the verdict. - [x] 8 new tests: the adapter maps every distinguished key and each modifier (alone and combined), maps ignored keys to `Key::Other` (not dropped), drops a release and acts on a repeat, and a release does not disarm Ctrl+C; and `App` driven with `Input`s alone (no crossterm): type and submit, Shift/Alt/Ctrl+J newlines versus plain Enter, an ignored key still disarming Ctrl+C, and BackTab being its own key. - Mutations, each caught: unmapped keys dropped instead of `Other` (adapter test), the Enter-newline rule `shift || alt` turned into `&&` (four tests, including a new one), and the adapter reading Ctrl from the Alt flag (caught as a hang of an existing scripted event-loop test that never reaches its quit key, which the timeout reported as a failure, not as a clean assertion). ## Next in #526 Part 2: collapse the per-command `TuiHost` methods into one `apply(HostCmd)` path plus `run_turn`, `footer` and `sessions`, with a fake host in tests for the interface a remote adapter will implement. Part 3: model a pending approval as source-agnostic UI state that carries its risk tier (a UI never offers allow-always for `Destructive`). ## Related Issues Refs #526, part of #523. Related: #464, #463. --- _Generated by [Claude Code](https://claude.ai/code/session_01GwJr9GzLbDFeXo3HZHZpyP)_ Co-authored-by: Claude <[email protected]>
## What Second part of #526 (UI epic #523): `TuiHost` shrinks from eleven methods to three (`footer`, `run_turn`, `apply`). `apply(HostCmd) -> Result<HostReply, String>` replaces `models`, `set_model`, `set_effort`, `request_compaction`, `new_session`, `sessions`, `switch_session`, `status_lines` and `set_name`. Refs #526, does not close it. ## Why Eight of the eleven methods defaulted to `unsupported()` and duplicated the `HostCmd` enum, and the trait had one adapter, so a second UI (GPUI, a remote client) had a wide interface to implement for what is really "apply this command". With one call, a remote adapter writes three methods. Agreed as part of the #526 plan (the issue's item 3); the input seam (#551) was part 1. ## Changes - `tole-tui`: - `HostReply { Done, Session(id), Models, Sessions, Lines }`: data only. The wording shown to the user ("model → x", "new session s-9", "(failed: ...)") and the pickers stay in the UI (`run_host_cmd`), so a host has no UI text to produce. - `TuiHost::apply` default: supports `Status` (no lines) and refuses the rest with "not supported by this host", exactly what the removed defaults did. - `run_host_cmd` decides what to say before handing the command over, then maps the reply. A reply of the wrong kind (e.g. a model list for a model change) is reported in the transcript as `(failed: unexpected host reply ...)`, never a panic. - `tole-cli` `TuiSession`: `footer` and `run_turn` stay in the trait impl; the nine operations become plain inherent methods (same bodies, same errors), and `apply` dispatches to them. Its existing unit tests call those methods and are unchanged. - No slash command is lost; user-visible behavior is unchanged. - CHANGELOG (Changed), `docs/tui.md` (Architecture: host seam) and `docs/epics.md` updated in the same PR (AGENTS.md §7); README unaffected. - **Breaking for anyone implementing `TuiHost` outside this repository** (override `apply` instead of the removed methods); new public item `tole_tui::HostReply`. Called out in the CHANGELOG. ## Testing - [x] `cargo fmt --all -- --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo check -p tole-cli --no-default-features`, `cargo test --workspace` (1203 passed: the previous 1195 plus 8). The 63 existing `tole-tui` tests, including the loop-level footer-refresh test (its host now overrides `apply`), and the real-terminal `tui_e2e` suite pass. - [ ] Local `cora review --staged`: not run (cora is not installed in this environment); the CI Cora Review job is the verdict. - [x] The acceptance item "a fake host in tests exercises the same interface a remote adapter will use": `FakeHost` has only the three methods, records every command and answers with scripted replies. 7 new `tole-tui` tests: each change is exactly one `apply` call with the UI's wording and a stale footer; New/Switch report the session id the host names; model and session pickers open from the host's data, and empty or failed ones say so; status lines are shown as given; a failing host is reported and leaves the footer alone; a wrong-kind reply is reported; a host that implements nothing supports `Status` and refuses the rest. - [x] 1 new `tole-cli` test: `TuiSession::apply` dispatches every command to its session operation (what each wrote, read back through the session's own readers; bad input refused with the operation's own error; `New`/`Switch` answer with the session now in use; `Status` lines; `PickSession` without an index). - Mutations, each caught: New/Switch wording swapped, the footer never marked stale (3 tests), the adapter's `Compact` doing nothing, and `Name` routed to the wrong operation. ## Unrelated flake seen while testing One full-workspace run failed `tole-core` `turn_loop::turn_survives_reopen_between_steps` with `Locked { holder: <our own pid> }`; it passed on the next full run (1203). It is the same signature as an earlier flake, and I reproduced the cause with a throwaway probe (207 of 3000 reopens fail while other threads spawn child processes, 0 of 3000 without) and filed it as #552 with the evidence and a proposed fix. Not part of this PR. ## Next in #526 Part 3: model a pending approval as source-agnostic UI state that carries its risk tier (a UI never offers allow-always for `Destructive`; today the in-process `Prompter`, remotely the `/approvals` queue). ## Related Issues Refs #526, part of #523. Related: #464, #463, #552. --- _Generated by [Claude Code](https://claude.ai/code/session_01GwJr9GzLbDFeXo3HZHZpyP)_ Co-authored-by: Claude <[email protected]>
…k tier (#554) ## What Third part of #526 (UI epic #523): a pending approval is modelled as source-agnostic UI state. `ApprovalRequest` (what the UI shows and decides on, with the `Risk` tier) and a `Pending` whose reply is a one-shot closure replace the `Sender`-based `Pending { text, destructive, reply }`. Refs #526. ## Why Today the only approval source is the in-process turn thread: `Pending` held a `Sender<Verdict>`, and "fail closed" was an accident of dropping that sender. A remote UI (the server's `/approvals` queue, #200) needs the same UI state with a different way to answer, and the rule that a `Destructive` call is never offered "allow always" must not be re-implemented in each UI. This is item 4 of the #526 plan. ## Changes - `ApprovalRequest { text, risk }`: `new` reduces the text to one safe line (control characters escaped, as `Prompter::ask` did), `risk()` is the real `tole_core::tool::Risk`, and `can_allow_always()` is false only for `Destructive` (the approver never allowlists it): the rule lives in one place for every UI. - `Pending { request, reply }`: the reply is a `FnOnce(Verdict) + Send`. The verdict is delivered **exactly once**, and `Drop` delivers `Deny` if it was never answered, so "dropped unanswered denies" is now structural (a cancelled turn, a newer request replacing an unanswered one, the UI going away with requests still queued) instead of relying on a dropped channel sender. - `Prompter::ask(request)` blocks for an in-process turn as before. New `Prompter::post(request, reply)` does not block: a remote source calls it and `reply` is where the verdict goes (for example the decision `POST`); it returns `false` and has already denied if the UI is gone. - `tole-cli` `TuiPrompt` builds an `ApprovalRequest` from the tool request (same text, same risk). The transcript still tags `? destructive:` / `? write:`. - CHANGELOG (Changed; **breaking for code outside this repo** that uses the removed API: `Prompter::ask(text, destructive)` is now `ask(ApprovalRequest)` and `Pending`'s fields are private; new public items `ApprovalRequest` and `Prompter::post`), `docs/tui.md` (Architecture: approvals) and `docs/epics.md` updated in the same PR (AGENTS.md §7); README unaffected. No behavior change for users: same keys (y / n / Esc), same texts, same fail-closed outcome. ## Testing - [x] `cargo fmt --all -- --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo check -p tole-cli --no-default-features`, `cargo test --workspace` (1209 passed: the previous 1203 plus 6) - [ ] Local `cora review --staged`: not run (cora is not installed in this environment); the CI Cora Review job is the verdict. - [x] One existing assertion adapted, deliberately: a cancelled approval used to leave the test's reply channel with *no value* (the sender-drop signal); it now receives an explicit `Deny`, exactly once. `Prompter::ask` returns `Deny` either way. Everything else in the 63 prior `tole-tui` tests and the `tui_e2e` pty suite passes unchanged. - [x] 6 new tests: the request is one safe line carrying its risk; allow-always is offered for `ReadOnly`/`Write` and never for `Destructive`; a remote-style source (`post` with a closure, never blocking) gets the user's verdict exactly once for y and n and nothing before the answer, with later keys changing nothing; Esc denies and cancels for a remote source too; a destructive request is shown as destructive; and an approval that never gets an answer is denied once whatever ended it (the turn ends, a newer request replaces it, the UI goes away with requests queued, posting to a UI that is already gone). - Mutations, each caught: dropping a `Pending` no longer denies, allow-always offered for `Destructive`, and `post` reporting success with the UI gone. ## Next in #526 The issue's item 2: move `draw` and its helpers into a rendering module that only reads `App` state (a mechanical move; no state changes there). With it the acceptance criteria are covered; I will post the status on the issue. ## Related Issues Refs #526, part of #523. Related: #464, #463, #200. --- _Generated by [Claude Code](https://claude.ai/code/session_01GwJr9GzLbDFeXo3HZHZpyP)_ Co-authored-by: Claude <[email protected]>
## What Moves `App::draw` and the styling helpers (`tail`, `styled`, `diff_style`, `inline_spans`, `wrap`) out of `crates/tole-tui/src/lib.rs` into a new private `render` module that only reads `App`. ## Why Part 4 of #526. A second front end should be able to reuse the state machine (and replace or reuse drawing) without the ratatui drawing code living in the same file. ## Changes - New `crates/tole-tui/src/render.rs` (moved verbatim, helpers `pub(crate)`). - `lib.rs`: removed the moved code and the now-unused ratatui imports; tests import what they need. - CHANGELOG (Changed), `docs/tui.md` architecture bullet, `docs/epics.md` status. ## Testing - `cargo fmt`, `cargo clippy --workspace --all-targets -- -D warnings` clean. - 76 `tole-tui` unit tests and the 5 `tui_e2e` pty tests pass. Pure move: no new tests, no behavior or public API change. Closes #526 --- _Generated by [Claude Code](https://claude.ai/code/session_01GwJr9GzLbDFeXo3HZHZpyP)_ Co-authored-by: Claude <[email protected]>
…#556) ## What Adds a `review_gate` config key (`off | warn | block`) for the review gate before `git commit` (#534), usable in the project config and the user config. ## Why The gate shipped env/flag only, because a project's `.tole/config.toml` is untrusted and `review_gate = "off"` there would let a cloned repo switch the gate off. Users want to set it once in their user config. ## Changes - `config.rs`: new key, validated at parse (`off|warn|block`). `layered` merges it differently from every other key: the STRICTER of the two layers wins (`block` > `warn` > `off`), so a project can keep or tighten the gate but never loosen what the user config chose. A project-only value is used as given, behind the existing content-bound trust gate. - `config_apply.rs`: `Settings.review_gate`, precedence flag > env > config > user config > default `block`, shown by `tole config check` with its source. - `main.rs`: a config value is exported as `TOLE_REVIEW_GATE` (like the flag) so the roster and child agents see it; flag/env already win inside `resolve`. - README, threat model and CHANGELOG updated. ## Testing - New tests: validation, strictness merge (every layer combination), precedence, and that the env name matches `review_gate::ENV`. - Mutation check: flipping the strictness comparison makes the merge test fail; restored. - `cargo fmt`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo test --workspace` pass; `tole-cli --no-default-features` builds. --- _Generated by [Claude Code](https://claude.ai/code/session_01GwJr9GzLbDFeXo3HZHZpyP)_ Co-authored-by: Claude <[email protected]>
## What `lock_writer` now retries for up to 150 ms (5 ms steps) when the writer lock is held and the recorded holder is our own pid. ## Why Fixes #552. An `flock` belongs to the open file description, so a child forked by another thread of the same process (a command, job or hook) briefly holds a duplicate of our lock descriptor until it execs, even with `O_CLOEXEC`. A reopen right after `drop(storage)` in that window failed with `Locked { holder: <our pid> }`. It caused a spurious `409` on `POST /sessions {"resume"}`, failures in the TUI `/resume` and `/new`, and two flaky `tole-core` tests. ## Changes - `crates/tole-core/src/storage.rs`: bounded retry in `lock_writer`, only for a hold that names our own pid. A holder with another pid still fails at once, and a genuine second open in this process (#475) still fails after at most the bounded wait. The lock file is re-read from the start on each attempt. - `crates/tole-core/tests/writer_lock.rs`: the probe from the issue as a regression test, plus a test that both real refusals stay (other pid: under 50 ms; same process: bounded). - CHANGELOG (Fixed). ## Testing - Regression test: 6000 create/drop/reopen rounds against three threads spawning children. Before the fix 8 to 12 rounds failed; after, 0 (three runs). Mutation check: setting the retry to 0 makes it fail again. - The two flaky tests named in the issue pass under parallel load. - `cargo fmt`, `cargo clippy --workspace --all-targets -- -D warnings` and `cargo test --workspace` pass. Closes #552 --- _Generated by [Claude Code](https://claude.ai/code/session_01GwJr9GzLbDFeXo3HZHZpyP)_ --------- Co-authored-by: Claude <[email protected]>
Images can ride on any user message: `/image` in chat, a pending-image queue on the TUI host, and ACP image content blocks (bytes sniffed, client uri never read, promptCapabilities.image advertised). Owner decision: no model-callable image tool for now; recorded in docs/threat-model.md.
…562) POST /sessions/{id}/images (raw body, type sniffed, same jail/cap/hash path as --image, content-addressed per session), "images": [<id>] on POST /prompt (references recorded, never the blob), and GET /sessions/{id}/images/{fnv1a64} serving only images recorded in that session's log with jail and hash re-checked. Per-session and total upload quotas (TOLE_SERVE_IMAGE_SESSION_QUOTA, TOLE_SERVE_IMAGE_TOTAL_QUOTA). The 10 MiB ceiling applies only with the right token; an oversized declared body is authenticated through the per-IP limiter before any 413.
Bracketed paste is enabled in the TUI: a pasted block arrives as one UI-neutral Input::Paste and is inserted as one edit (CRLF/CR become LF, control characters other than newline and tab dropped); it never submits, steers or answers an approval. Before, a multi-line paste was replayed as keys and its first line was sent.
/image <path|data-url>, /image clear and bare /image attach images to the next message through new HostCmd::{AttachImage, ClearImages, Images} mapped onto the #559 pending-image queue; queued images show as a row above the editor. A paste that is exactly one image path or data:image URL is attached instead of inserted. Non-ASCII pastes no longer panic the detection. No OS clipboard images in the TUI (owner decision). Input in tole-tui is now an enum (breaking).
Adds the owner's standard to the branch and merge rules in AGENTS.md: no session link, AI co-author trailer or tool footer in commits, merge messages, PRs, issues, comments, code or docs. Documents the two ways it leaks in (the GitHub tool footer and the trailer a default squash message adds), that the Message Standard check does not see the final squash message, and a check to run before every push and merge.
/fork [entry-id] forks the open session at a settled entry (default: the last one, as `tole branch` does) into a new session and switches to it in place; /tree is a picker over the open session's fork family (parent chain, siblings, grandchildren) that switches on selection. Forking a session whose writer lock this process holds is safe: the source is replayed read-only and the new file takes its own lock. `sessions --tree` shares the same scan and ordering. Part of #463.
/copy sends the last assistant answer to the terminal clipboard as one OSC 52 sequence (base64 payload only, 64 KiB cap, never claims success). /export [path] writes the transcript as .jsonl (entries as stored) or a self-contained .html (all text escaped, no script, CSP meta), inside the workspace jail, refusing to overwrite or follow symlinks. Part of #463.
The TUI gets a Theme (semantic role to style) with three built-in themes (default, light, mono), NO_COLOR support, and optional per-role color overrides. The default theme reproduces the previous look exactly. A theme has no background colors and no hidden, reversed or blink modifiers, and the approval and note roles are never dim. It is read from TOLE_THEME and the user config only; a project config's [tui] table is ignored with a warning. In a build without the tui feature, `config check` says the theme is not validated. Also waits for the idle footer before /quit in the escape-sequence e2e test. Part of #463.
[tui.keys] in the user config rebinds ten convenience actions (tool output, reasoning, model picker, cycle model, cycle thinking, newline, queue follow-up, pop queue, history) to a key spec or a list; the default keymap is the keys the TUI always had. y, n, Esc, Ctrl+C, Enter, Backspace, Tab and every bare character are never rebindable, and at an approval prompt only y, n, Esc and Ctrl+C act whatever the keymap says. A project config cannot set keys (ignored with a warning), and an invalid keymap falls back to the default with one startup note. Closes #463 with #567, #568 and #569.
…ts and plugins (#602) Design notes and a new epics track (Track E) for safe agent automation: scheduler/cron/webhooks, dormant profiles with delegation and model routing, skills retrieved by meaning, secret handling at every egress sink, and third-party plugin controls. Reference for epics #577, #583, #589 and #594 (issues #576, #578-#601). Documentation only.
…part 2c) (#689) Adds tole_cli::discussion_host: inline participants, the round loop with the pass-1 sanitizer, the scribe call whose digest is parsed only through the existing validator (anything else falls back to the verbatim pass-1 text), the separate claim-checker call behind report, the deterministic gate (continue, escalate, report), the budget carved from the goal and crash resume without spending twice or re-running a finished round. Nothing starts a discussion yet: the entry point is an open question. docs/automation-design.md gets an Entry point: open question section comparing an owner-only tole discuss, a model-facing tool bounded by the delegation rules, and both, with the security consequences of each and a recommendation (both, owner-only first), plus a threat-model row. Refs #588
…child scrub, wider name rule (#682) (#690) BREAKING: more variables are now treated as secrets and scrubbed from child processes. The name rule gains endings (PASS, _KEY, _DSN, _SK, _COOKIE, _AUTH, _BEARER, DATABASE_URL), beginnings (AUTH_, BEARER_) and PASSPHRASE anywhere in the name, while SSH_AUTH_SOCK, GPG_KEY (a key fingerprint), public keys and names ending BYPASS stay ordinary. The scrub also removes a variable whose value is a URL with a password (REDIS_URL), whatever its name, and any value tole holds by role (webhook keys, the serve token, ${NAME} header expansions) whatever the variable is called; those values join the redaction set too. *_PROXY variables are not removed for their URL password (network commands behind an authenticated proxy need them) but the password is still redacted. Child agents keep TOLE_BASE_URL, OPENAI_BASE_URL and TOLE_FALLBACK_BASE_URL. [secrets] keys may now also be *_URL or *_URI names so a scrubbed connection string can be granted back. serve --token now warns; the new --token-file is the alternative (the two conflict); tole approvals --token keeps the argument form, a written residual. The CHANGELOG has the migration note. Refs #682
…und documents (#588 part 2e) (#692) Independent participants run read-only through the existing delegation path (Delegator::consult and poll_node) with carved budgets, leases and the machine resource guard; they are offered only for review and critique. Each round's digest (never a raw contribution) is written to uteke as a flat document goal-<id> and goal-<id>-r<n> with the parent argument, redacted and capped. A crash between a child's start and the binding of its node id can no longer start it twice: the reservation is written to the ledger before the child starts, the child's task carries a marker naming that call, the node id is bound afterwards, and on resume an unbound reservation first looks for the marked child with Delegator::find_child (direct children of the goal, or of the session's own node, never deeper, so a child cannot plant a match) and starts one only if there is none, under the same reservation. Refs #588
tole doctor prints process guard: non-dumpable (or dumpable, flagged) on Linux, naming no secret, so an owner can see that the guard against reading tole's environment through /proc is active. A unit test and an end-to-end test against the real binary cover it; with the guard in main disabled, the end-to-end test fails. Refs #675
…t, GitHub deliveries dedupe on the signed body (#678) (#694) BREAKING (the webhook feature is unreleased): native deliveries use a v2 signature, X-Tole-Signature: v2=<hex>, an HMAC over v2, the timestamp, the delivery id, the event and the body joined by newlines (the event is empty when there is none). The id and the event are validated (no newline) so one field cannot be shifted into another; an invalid event gets 400 and a missing or invalid delivery id is rejected with 400 before the HMAC is computed. The 300 second window is unchanged. The v1 sha256= native form is refused with 401 and a reason that names v2 (accepting it would keep the replay hole open); tole hook test --fire already signs v2. GitHub deliveries are deduplicated on the signed body: the idempotency key is gh: plus the SHA-256 of the body, so the same body re-sent under a fresh X-GitHub-Delivery gets 200 duplicate. What stays open for GitHub is in the threat model: a replay verifies again after the 7-day retention, X-GitHub-Event is unsigned (so events is not a security boundary for GitHub routes; filter on the signed body is), and two deliveries with byte-identical bodies count as one; the native scheme and TLS are recommended for allow_writes routes. Closes #678
…ave the turn loop (#677) (#695) The turn loop now redacts every observer event with the same set the session log uses (the new Storage::egress_secrets, which defaults to the process set): the tool_started input, the tool_finished preview of an output or an error (redacted first and only then cut at 200 characters) and reasoning. Serve SSE, ACP and the TUI all go through that one place. Streamed answer text (text_delta) comes from the provider delta sinks and is not redacted live; it is model output whose committed entry is redacted, and the gap is a written residual. Closes #677
… servers are never started (#696) A server the plugin lock refuses is not started and contributes no resources, prompts or extras (#680). Approvals are bound to the configured command or URL and the stdio program file, so a re-pointed or rebuilt server is refused until re-approved (#679). The lock entry's secrets are now the server's real launch grant. BREAKING: an MCP server whose binary or command line changed since approval needs one re-approval (tole plugin approve <name>). Closes #680 Closes #679
read_file, the git diff filter and cora_search hits now also withhold *.env, *.env.*, credentials, .git-credentials, .pgpass, .htpasswd, .pypirc, .dockercfg, .docker/config.json, *.tfvars, kubeconfig, secrets.y*ml and key stores (*.p12, *.pfx, *.jks, *.keystore). A new sensitive_files config list adds names; a project can add but never remove. BREAKING: a verbatim read of these files now needs read_file_raw. Closes #683
#588 part 3a) (#697) Adds tole discuss start|resume|list|show, the owner-typed entry point of the discussion mode. Participants are read-only inline profile voices at depth 0, the budget is a hard cap with an escalation to the owner, --dry-run prints the cost without any call or write, and resume continues from the ledger after a crash. The model-facing tool follows separately. Refs #588
…capes and zero-width splits (#699) SecretSet::redact now also matches a known secret inside a larger base64 payload (standard and URL-safe, all three offsets), as lower or upper hex, with JSON \/ and \uXXXX escapes, and split by invisible format characters, with at most 24 needles per value. The residual (arbitrary transforms) is documented in the threat model. Closes #681
…588 part 3b) (#701) Adds discuss, discuss_status and discuss_stop. All three are Risk::Write and are registered only where delegate is, so never at the depth limit, in plan mode or without a provider. The budget is carved from the caller's remaining budget, participants must be user-config profiles within the caller's allow list and are inline voices without tools, the input accepts five fields only, and status and stop work only on discussions the same session started. A stop is the ledger's own escalation (new Reason::Stopped). Refs #588
…der a session (#700) run_command and job_start refuse an argv whose program is the tole binary and carry TOLE_UNDER_SESSION=1 into every process they start. tole cron create|resume|edit, plugin approve, skills approve, skills drafts promote and config trust refuse to write under that marker or TOLE_AGENT_DEPTH >= 1. File tools refuse to write when the workspace holds the tole data dir. This is defense in depth, not a boundary; the sandbox (#601) closes the rest. BREAKING: see the CHANGELOG entries under Behavior change. Closes #684
…G entry and a migration guide (#707) Promotes Unreleased to 0.11.0 (unreleased), groups the entries as Security, BREAKING, Added, Fixed, Deprecated and Changed, and adds docs/migrating-0.11.md checked against the code. Webhook v2, plugin lock v2, owner-only subcommands, cron, hooks, plugin and discuss are new since v0.10.1 and are listed as nothing to migrate. Refs #706
…the code before 0.11.0 (#708) README status, tools table, quickstart, config keys and docs index now match the CLI and tole --help. The threat model gains rows for the discuss entry points, skill drafts and the curator, and the hard-link residual. docs/epics.md marks #579, #582, #593 and 0.10.0 as done. Refs #706
…one hard link (#709) A hard link to a sensitive file under an innocuous name was read verbatim. On Unix read_file now refuses a regular file with nlink > 1 and points to read_file_raw, using only the metadata it already has. read_file_raw still reads such a file; other platforms are unchanged. The git diff filter and cora_search hits stay name-based. Closes #703
…size guideline (#710) Adds CHANGELOG.md and docs/** to ignore.files in .cora.yaml and a PR size bullet to CONTRIBUTING (about 600 changed lines of code, split otherwise). In cora 0.20.0 ignore.files scopes only the symbol index and context chain, not the diff the reviewer reads, so this does not shrink what Cora reviews; the upstream part stays open on #705. Refs #705
…g_apply tests (#711) agents tests run with their own CODECORA_HOME and an opened machine guard instead of the real home; the doctor window test reads the context window line instead of the whole report; temp dirs carry a clock stamp instead of a reusable pid; the delegate test waits are bounded at 60 s. The tests that could not be reproduced (session_effort_e2e, wire_size_missions) are unchanged. Refs #702
Workspace and path-dependency versions go to 0.11.0 and Cargo.lock changes only the three workspace package versions. The CHANGELOG heading stays 0.11.0 unreleased; the date is set at tag time. Nothing is tagged or published. Refs #706
…nt-started discussions (#704) (#715) discuss takes an optional modes array (inline or reviewer per participant, a closed enum). A reviewer is a consult child under the rules of delegate, launched read-only with plan mode, an empty allow list and a participant marker in its environment, so it cannot start a discussion or delegate. A Write it wants is denied fail closed until the owner approval surface of #714 exists. The owner's tole discuss is unchanged. Refs #704
…document (#719) One shared room id validator now backs both tools. It accepts today's ids unchanged and uteke's category:title grammar (one colon, lowercase, at most 64 bytes), and still refuses flag-shaped values, more than one colon, uppercase in the colon form, and empty ids. The room stays a positional argument, and every accepted id starts with a letter, digit or underscore, so none can parse as a flag. Closes #716
… doctor tests hermetic (#718) The writer lock registers its file identity in a process-wide set while held. A hold that names our own pid is now retried for up to 20 s only when no handle of this process holds the lock (a child forked by another thread briefly holds a duplicate of a just-closed descriptor until it execs); a real second open in this process and any other holder still fail at once. Tests: a long-lived duplicate, a resume that is never refused by children forked by other threads, and a doctor provider test that no longer reuses a freed port. Closes #646 Refs #712 Refs #702
… production path (#720) Driver::from_config is now the single place that wires UtekeDocs, so tole discuss start and resume, the dry run and the discuss tool (including reviewer participants) all write goal-<id> and one digest per round when the uteke binary is available. Without uteke there is one visible note per discussion, and a failed write is surfaced as a note without aborting the discussion or changing the gate. The discuss tool now keeps the outcome notes instead of dropping them. Closes #717
The 0.11.0 heading gets its release date, 2026-11-14. Refs #706
…again (#725) ## What Gate the #718 lock-identity probe (`std::os::unix::fs::MetadataExt`, dev/ino) behind `#[cfg(unix)]`; on non-unix it returns `None`. ## Why `tole-core` stopped compiling on `x86_64-pc-windows-msvc` (E0433 `os::unix`, E0599 `dev`/`ino` at `storage.rs:1169`), which failed the v0.11.0 release train's Windows build job (run 43574225374) while Linux×2 and macOS stayed green. Windows has no fork, so the transient duplicate-of-closed-descriptor retry (#552, #712) cannot occur there — `None` restores the pre-#718 behavior where a self-pid hold is a real hold. Unix behavior unchanged. ## Testing - [x] `cargo check -p tole-core` clean - [x] `cargo test -p tole-core --lib storage` 4/4 passed - [ ] CI Windows job builds on this PR Co-authored-by: ajianaz <[email protected]>
Contributor
Author
|
Superseded: direct develop->main conflicts after the #724 squash (stale merge-base). Following the release-branch recipe instead: chore/release-v0.11.0-main from main, merge develop, resolve --theirs, PR from that branch. |
This was referenced Nov 14, 2026
ajianaz
added a commit
that referenced
this pull request
Nov 14, 2026
## What Release sync for v0.11.0 as ONE squash commit on a main-based branch: main + the develop delta (release prep #723/#724 and the storage fix #725). The commit's tree is identical to develop's tree (verified: git diff of the two trees is empty), so the tagged tree equals the fully validated tree. ## Why The first v0.11.0 run (tag on e833469) failed x86_64-pc-windows-msvc: #718's std::os::unix::fs::MetadataExt use had no cfg gate, so tole-core did not compile on Windows (run 43574225374). #725 gates the probe (Windows returns None; no fork there, so the transient-duplicate retry never applies) and is on develop with 15/15 checks green. A merge-commit sync (#727, closed) trips the message-standard check on 17 pre-ban Co-authored-by trailers still in develop's v0.9/v0.10 history; a direct develop->main PR (#726, closed) conflicts after the #724 squash merge. The one-commit squash on a main-based branch carries the same content with none of those problems. ## Testing - [x] PR #725 (the fix): 15/15 checks green on develop - [x] Local cargo check + storage tests 4/4; cross-check vs x86_64-pc-windows-msvc shows no tole-core errors - [x] This branch's tree == develop tree (content parity proven) - [ ] This PR's CI green, then re-tag v0.11.0 to the new main HEAD Co-authored-by: ajianaz <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Sync develop to main for v0.11.0: the release prep (#723, #724) plus the storage fix from #725 (gate the lock-identity probe to unix).
Why
The first v0.11.0 release run (tag on e833469) failed its x86_64-pc-windows-msvc job: #718's use of std::os::unix::fs::MetadataExt had no cfg gate, so tole-core did not compile on Windows (run 43574225374). #725 fixes that and is now on develop; main must carry it before v0.11.0 is re-tagged, so the tagged tree builds on all four release targets.
Testing