## Summary
Raven can now read and change its own configuration through one tool,
`raven_config`, instead of telling the user to open Settings or editing
`config.json` with file tools. The same path lets it connect preset
sub-agents and diagnose the ones that do not answer, and asks the user
only for what needs them (a key, a sign-in, a paid model).
**The tool and its catalog**
- `raven_config` actions: `describe` (every setting with its value, or a
search), `get`, `set` (one path, or several under one confirmation),
`unset`, `add` (connect presets, several at once), `test`, `restart`
(reload or restart once pending changes are gathered). `session.model`
switches only the current conversation.
- `raven/config/self_surface.py` is the catalog: 14 sections, about 93
settings, each with its value kind, its writer, and when a change takes
effect (next turn, at once, reload, restart, memory server, or inert).
Writes go through the RPC methods the settings page already uses
(`SELF_CONFIG_METHODS` allowlist), so the page and the agent share one
validation path. `tests/test_config_self_surface.py` holds every entry
against the schema and every next-turn claim against a real reader.
- A refused sub-agent comes back with one next step per refusal kind (9
Raven fixes itself, 5 the user does), with stop rules: no hunting for
keys, no credential stores, no restarting another app's services, stop
after three commands that explain nothing.
- `subagents.add` stays preset-only: every execution field comes from
the preset. Presets can be named by display name, an add can pin a model
the agent lists, and a model pick on an unmeasured agent reads the
handshake menu first.
- The companion skill `raven-self-config` describes the whole flow; its
description is injected every turn, the body is read on demand.
**Approval**
- Reads run unasked. Every write asks by default, on a dedicated config
card (what changes, before and after, when it takes effect, a sensitive
note). A grant for the session never carries a change.
- In a turn someone is at, full access, the user's allow rule, and smart
mode's reviewer let a change through; the reviewer never approves a
sensitive setting. Sensitivity is declared by the owner: catalog entries
(approval mode and review model, workspace confinement, sandbox, deny
patterns, disabled tools, MCP servers switched on, skill blocklist and
auto-install, provider endpoints, web and media proxies, remote
machines, workspace path, lent keys, sub-agent descriptions) and each
channel adapter's spec (who may instruct Raven, whether a channel is on,
where its credentials and traffic go, encryption). The gate and the tool
read a call the same way: one value decoder, one path spelling, one
channel field lookup, an object value judged field by field; a path the
tool does not write is refused at the gate, and a call naming one
setting twice is refused. A value is secret when the schema, the channel
spec or the catalog says so, a credential-named env entry, any header,
or a credential inside a URL. The reviewer's instruction counts the
agent's own non-security settings as ordinary work. Unattended turns
(cron and other scheduled runs, no one to answer) are refused; a channel
user who can answer an approval is attended.
**Secrets**
- A key never travels through a tool call. The agent names the secret
with an empty value and a credential card of its own
(`credential.request` / `submit` / `skip` / `pending` / `closed`) takes
it; the host writes it through the handler that owns it and the model
learns only saved or skipped. Channel secrets use the same card. A call
that only asks for keys goes straight to the card. Enabled on page
surfaces only.
- Tool output is scrubbed of the values Raven holds
(`config/held_secrets.py`, including JSON-escaped spellings and URL
credentials) and dotfile reads under home are redacted, once, inside
`ToolRegistry.execute`, so the trace span, the page's diffs, the
sentinel and both agent loops get the scrubbed copy. What a sub-agent
says is scrubbed where it is kept: transcripts, call labels, closing
text, the output a later DAG node renders, error records, announces, the
ACP frame journal, probe details. A key pasted into the chat is refused.
- Lent keys: an ACP sub-agent row can name Raven providers (`lendKeys`)
whose key it is started with. The row stores the provider name; each
start (the spawn path and the capability probe) reads the key into the
variable the preset reads (`presets.LENDABLE_KEYS`, Pi only for now), so
it never reaches the model and follows a rotated key. Verified live: Pi
refused without it, answered with Raven's OpenRouter key, and its row
reads connected and tested with a 398-model menu.
**Page**
- Config card and credential card; the model and permission chips
refresh after the agent changes them; the transcript names
`raven_config` calls by what they did.
- Agents page: the note on a refused connect, a failed test, or a check
that found a problem offers "Hand it to Raven" on its title line; it
opens a new conversation with a prompt naming the agent and the reason,
not sent. A connected row whose check found a problem now shows one head
line and an amber note in the body (shaped like a failure's) instead of
the check's English sentence folded under the head.
**Other**
- Memory LLM left unset follows the main model (EverOS restarts when the
main model moves).
- Reload and restart wait for page turns in flight too.
- `plugin` points agents and chat apps at `raven_config`; `cron` names
the missing `message`; a GNU `timeout` shim on hosts without one,
accepting only the durations the permission gate parses (one shared
definition); read-only package-manager subcommands allow.
- Contracts: `CONTRACTS_VERSION` 35 (this branch's credential types plus
main's `FileWrite`) with the surface repinned; paper-tier line ceiling
3,700 (measured 3,682) with its review note. `CONTEXT.md` defines the
self-configuration surface and lent key.
## Type
- [ ] Fix
- [x] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
- `uv run pytest -q -n auto`: 27187 passed, 3 failed. The 3 fail on this
machine regardless of this branch:
`test_rpc_files::test_a_host_without_libreoffice_says_so` (LibreOffice
is installed here),
`test_simulation_scenario::test_a_fresh_trial_refreshes_the_subagent_homes_before_it_runs`
and
`test_simulation_suite::test_a_stopped_run_is_marked_in_its_record_and_finished_with_its_evidence`.
`schemas/subagent.schema.json` is regenerated for `lendKeys`;
`test_import_cycle_budget` holds (the capability probe takes the launch
env from its caller rather than importing the agent layer).
- `make lint-ui` (gen:check, eslint, tsc): pass; the 4 eslint warnings
are in files this branch does not touch.
- `npx vitest run` in `ui-web`: 3116 passed; `check-css`,
`check-class-namespace`, `check-page` OK.
- `npm run lint:i18n`, `lint:rpc`, `type-check` in `ui-tui`: pass.
- `uv run ruff check` and `ruff format --check` on every changed Python
file, and `lint-imports` (10 contracts kept): pass.
- In a browser against a local gateway: credential card save, skip,
replace and reload replay; the value appears in no session, trace or
log. Agents page link opens a new task with the prompt filled and
unsent; sent, the agent reads the self-config skill and calls
`raven_config` first, and for Pi offers Raven's key before a sign-in.
- Smart-mode reviewer, run against the real model: 7 ordinary config
changes allowed; `sed` or `write_file` on Raven's config, reading an SSH
key, and `curl | sh` escalated.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed
## Risk
- Behaviour changes: the agent can now change settings and connect
sub-agents after the user confirms (or unasked under full access, and
under smart mode for non-sensitive settings). Lending gives a sub-agent
Raven's key for a provider after an explicit, sensitive confirmation;
what it spends is billed to that key.
- Memory: a memory LLM left unset now follows the main model, so
long-term memory starts working after the upgrade for anyone who never
pinned one, extracting on the main model and billed to the main
provider's key, and EverOS restarts when the main model changes. To keep
it off, set `memory.backend` to null; to keep it on a different model,
pin one of its own.
- Backward compatible: new config fields are optional, and both probe
fingerprints include `lendKeys` only when set, so recorded verdicts and
menus survive. A `config.json` written with `lendKeys` will not load on
an older build (`extra=forbid`).
- Rollback: revert this PR; nothing is migrated. To switch the feature
off without a revert, add `raven_config` to `tools.disabledTools`.
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
---------
Co-authored-by: arelchan <204152633+arelchan@users.noreply.github.com>
Co-authored-by: Claude (claude-opus-5-5) <noreply@anthropic.com>
## Summary
A file an `exec` command wrote reached the desk diff as a bare row. The
loop listed the working directory on either side of the command (#692),
so it knew a file had changed but never what it changed from: a rewrite
showed a bare `M` with no counts, and opening any such row fell back to
the file viewer instead of the diff pane. File-tool edits were
unaffected; this only concerned commands (`python3 gen.py > out.json`,
`echo x >> notes.md`, `sed -i ...`).
This supersedes #826. That PR measured the change in the loop, around a
call named `exec`. Here the exec tool measures it itself, around the
command it runs, and hands it back the way it already hands back the
files a command removed; the loop only forwards it.
How it works:
- **The tool measures.** `raven/agent/tools/command_writes.py` lists the
directory before and after the command and, where the checkpoint's
shadow repo covers it, stages the tree first, so a rewritten or removed
file is shown against what it held. The result travels on a new
`ToolResult.written` / `ToolOutput.written` (`FileWrite` on the tool
paper, contract version 32 -> 33, and 33 -> 34 for
`FileRemoval.withheld`), beside the existing `removed`.
- **The repo is handed in.** Tools do not import the loop shell
(import-linter), so `ExecTool` holds the shadow repo through a
`ShadowTree` protocol and a resolver the loop passes in
(`AgentLoop._command_shadow`: the turn's repo, only where it covers the
command's directory). The built-in is built with it, and a plugin's
same-name `exec` replacement (raven-code's `CodeExecTool`) is handed it
through `measure_writes` before it is registered, so it measures as the
built-in does, as the loop-level listing it replaces did for any tool
named `exec`. Both happen before the registry admits the tool, because
the registry reads the ceiling off the spec it admits.
- **Every command stages afresh inside its own call**, into a
per-process index of its own in the shadow repo (never the index the
per-turn commit reads), and waits up to 120 s. Whenever there is no
snapshot to measure against -- the tree cannot be staged at all
(checkpoint off, `working_dir` outside the repo, git error) or it did
not finish within the wait -- the command runs all the same and is still
listed, so its files are reported without the text they held; where a
repo covers the directory, its rules still decide what text may be
shown. A late staging is left running, so a later command usually finds
it done. What follows the command is bounded too: the shadow repo's
reads get 60 s (past it every file goes out without text) and the whole
post-command step 120 s (past it the call returns the command's output
with no record of its files), so a slow measurement never costs the
output. `measure_writes` raises the tool's registry ceiling by what
measuring may take (the 120 s wait and the 120 s bound), so the
built-in's goes from 660 s to 900 s and a replacement's own ceiling
keeps its margin. A git read whose caller stops waiting kills its
process.
- **Warm-up as a session opens.** The first staging of a directory
hashes every file. `session.create` / `session.resume` call
`ExecTool.warm` for the directory the session resolves to, and a session
opened by its first message (a channel's) is warmed at the start of that
turn. `warm` returns at once and runs on the staging thread, so it
overlaps the model's first reply.
- **One rule for what text may be shown.** Every file a command created,
rewrote or removed, including the ones its own removal watch caught by
name, carries text only where the shadow repo's rules would store it
(`git check-ignore --no-index` against its excludes and the user's
`.gitignore`, the rules alone, not what the index holds). So a `.env` or
a key never enters the event or the stored session, even one the repo
staged before an ignore rule named it, and even when the staging failed:
the rules need no tree. Where no shadow repo can vouch for a file, a
created file carries its counts only.
- **Loop.** The exec-only listing branch in `turn_path.py` is gone; the
loop turns `result.written` into `file_written`. Besides that it has the
resolver above and the one-line warm-up at turn start. The registry now
keeps `removed` / `written` on a result it rewrites as an error (a
command whose output begins with "Error" still wrote what it wrote). A
removal whose body the rules kept back goes out marked `withheld` (a new
defaulted field on `FileRemoval`), and the turn's removal watch fills in
a bare removal from what the turn wrote only when it is not: with the
checkpoint off every bare removal stays fillable, as before, and a
withheld body is never put back.
- **Wire and page** (unchanged from #826). `file_written` entries gain
optional `added` / `removed` / `diff`; the diffs share a 512 KiB budget
per call, past which the counts still go. Contract updated in
`rpc-schema/openrpc.json`, `raven/rpc/models.py` and both generated
clients. ui-web draws these rows with their hunks, so they open in the
diff pane with +/- in the desk list, and `fromUnified` now skips only a
real `---`/`+++` header pair, so a removed `-- note` line is no longer
dropped.
- **Robustness.** Stagings run on daemon threads with blocking git calls
(an asyncio subprocess still starting when its loop closes hangs the
close on CPython 3.12 macOS). `add` and `write-tree` run under one lock
per index; the staging `add` has its own 600 s ceiling; the turn commit
waits for a warm-up's repo setup instead of racing it on the config
lock. The setup's future and every staging future are running from
creation, so a cancelled waiter cannot cancel them, and the warm-up and
staging threads settle them whatever happens, so no staging is left
published for nobody to finish (the cancellation 0xKT and gloryfromca
measured on #826). Git queries now encode paths with `surrogateescape`,
so a POSIX file name that is not UTF-8 no longer raises after the
command has run (the follow-up gloryfromca raised on #826).
Behaviour that moved with the measurement: staging now happens after the
permission gate has ruled, so a denied command is never staged; a
background command (`run_in_background`) takes no listing, since its
files land after the call returns; a sub-agent's `exec` does not list
(its runner lists every call itself, as before).
Not covered: files the shadow repo excludes (`*.log`, `.env`, the user's
`.gitignore`) get no diff, text files over 256 KB get no counts, a
same-name `exec` that is not an `ExecTool` (none ships) reports no
files, and existing sessions keep the rows they stored.
## Type
- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed
- `make test-python` -- 27077 passed, 108 skipped, 3 failed (on the
previous head; the focused set below is on this one). The 3 failures
(`test_rpc_files.py::test_a_host_without_libreoffice_says_so`,
`test_simulation_scenario.py::test_a_fresh_trial_refreshes_the_subagent_homes_before_it_runs`,
`test_simulation_suite.py::test_a_stopped_run_is_marked_in_its_record_and_finished_with_its_evidence`)
fail the same way on `github/main` on this machine.
- `uv run --frozen --all-extras pytest tests/test_runtime_checkpoint.py
tests/test_runtime_checkpoint_deep.py
tests/test_agent_loop_session_stamps.py tests/test_agent_loop_workdir.py
tests/test_rpc_session.py tests/test_shell_command_writes.py
tests/test_shell_file_removals.py tests/test_tool_registry_execute.py
tests/test_tool_registry_channels.py
tests/test_tool_registry_session_overlay.py tests/test_rpc_spine.py
tests/test_workdir_snapshot.py tests/test_shell_approval.py
tests/test_contracts_two_tier_ledger.py tests/test_kernel_budget.py
tests/test_removal_watch.py tests/test_agents_code_flow_exec.py
tests/test_agents_code_tools_plugin.py
tests/test_agents_code_launcher.py tests/test_subagent_dag_runner.py
tests/test_agents_research_ask_user_text.py tests/test_living_docs.py
tests/test_tracing_compact.py -q --idle-ceiling-strict` -- 1231 passed.
- `make lint-python lint-types lint-imports` -- clean (10 import
contracts kept). `npm run gen:check --prefix ui-web`, `npm run
type-check --prefix ui-web`, `npm run lint --prefix ui-web` (0 errors, 4
pre-existing warnings), `npm run lint:rpc --prefix ui-tui` -- clean.
`npm test --prefix ui-web` -- 3107 passed.
- Mutation checks, each restored afterwards and each turning at least
one test red (48): a staging timeout not falling back to running the
command without a diff; the wiring not asking the tool to record writes,
or not handing it the repo; the resolver dropping its `covers` check, or
ignoring the turn's binding; the registry dropping `written` on unwrap
or on an error result; the loop ignoring `written`; no turn-start
warm-up; `session.create` / `session.resume` not warming; a failing
warm-up failing the open; created-file text ignoring `trackable`; the
diff budget ignored; removals losing the staged text; staging a
directory too large to list; reading the written files on the event
loop; a named removal reported twice; the ceiling under the sum of the
wait, the command cap and the measuring bound; no bound on the shadow
repo's reads after the command, or on the whole post-command step; a
late read keeping a named removal's text; a cancelled git read left
running; the checkpoint's timeout not being a `TimeoutError`; `warm`
ignoring `record_writes`; a background command measured; the setup
future not marked running; the warm-up or a command's staging not
settling its future on an unexpected error; a rewritten or removed file
read without the rule; a named removal's text kept without the rule; the
repo dropped when the staging failed, or its rules applied only where
there is a tree; a tree-less staging still read for blobs; the removal
watch refilling a withheld body, or never refilling an unknown one; a
named, listed or timed-out removal not marked withheld where the repo
kept its body back, or a listed one marked where no repo ruled;
measuring switched on only for the built-in, so a plugin's same-name
`exec` reports nothing; `measure_writes` not raising the ceiling, or
raising it on every call; the built-in or the replacement measured only
after the registry admitted it, so the admitted ceiling stays at 660 s;
a failed staging not warned about, or warned about on every command.
- Real gateway (`raven serve` from this branch, isolated `RAVEN_HOME`,
real model), in a cold 12,775-file / 428 MB directory on a machine
running endpoint protection at load average 13-14. The first message
opened the session and the warm-up started with it; the model's first
`exec` (append to a `notes.md` Raven had never touched, and create
`made_by_exec.txt`) waited out the cold staging and took 37.8 s in
total. The second `exec` took 3.7 s, with the staging under the 1 s
sampling interval. The desk lists `M notes.md +2` and `A
made_by_exec.txt +3`; `notes.md` opens in the diff pane with both
commands' hunks, and a reload draws the same rows.
## Risk
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
User-visible changes:
- An `exec` now runs only after the working directory has been staged
(or the 120 s wait has passed). On a warm directory that is well under a
second; the first command in a large directory the shadow repo has never
indexed waits for the first staging (tens of seconds on a slow disk),
which the session-open warm-up usually hides. Past 120 s the command
runs without a diff.
- Opening a session starts one background `git add` per directory per
process, writing into the same `.raven/shadow.git` the checkpoint
already uses. Each process keeps its own `exec-<pid>.index` there; files
older than 7 days are pruned.
- No file content is stored beyond what the checkpoint already commits,
and the same excludes apply. With `runtime.checkpoint.policy = "never"`
a command's rewrite is reported bare, as today, and a created file
carries counts only.
- The new `FileWritten` fields are optional, so older clients ignore
them. `ToolResult` / `ToolOutput` gain a defaulted `written` field and
`FileRemoval` a defaulted `withheld`; contract version 34.
Rollback: revert the commit. The staging indexes in `.raven/shadow.git`
are inert without the code and are pruned by age.
## Related Issues
Supersedes #826
---------
Co-authored-by: arelchan <204152633+arelchan@users.noreply.github.com>
Co-authored-by: Claude (claude-opus-5-5) <noreply@anthropic.com>
## Summary
Nothing in Raven recorded a deleted file. There is no delete tool, and a
file an `exec rm` unlinks is gone before anyone can look, so a turn that
created three files and removed two drew three additions on the desk's
diff tab, in the transcript's changed-files card and in a task's file
list, and nothing at all for the deletions. On the task side a
whole-file write onto nothing was also indistinguishable from a rewrite:
only `write | edit` reached the wire, and #656 had to guess a creation
from a zero deletion count (the one review remark on that PR). This is
the follow-up #656 named.
Backend (first commit):
- `ExecTool` notes, before a synchronous local command runs, the paths
its tokens name that resolve to regular files under the working
directory or an allowed directory (at most 64, text kept up to 256 KB),
and reports the ones that no longer exist afterwards as `removed` on the
tool result. Not for `machine=` or `run_in_background`, and a command
that removes nothing returns exactly what it returned before.
- `RemovalWatch` (new `raven/agent/tools/removals.py`) keeps what a turn
(main lane) or a run (`raven_loop`) wrote and re-stats those paths after
every later call, so a file removed under a name the shell watch could
not resolve is still seen. Bounded per path (512 KB) and across the
watch (4 MiB); past the bound the path is still reported, only its text
is dropped.
- `tool.complete` gains `file_removed: [{path, before?}]`, emitted only
when non-empty; the stored tool entry keeps `file_removed: [{path,
del}]` so a reload draws the deletion; `session.resume` passes it
through.
- The in-process lane records `op: add` for a write whose `before` is
`None` and `op: delete` for a vanished path; `merge_file_change` folds a
run's touches like a range of commits (add outlives later writes, delete
replaces a write or edit, add then delete leaves nothing, delete then a
write is a write).
- Wire: `FileRemoval`, `ToolCompletePayload.file_removed`, `TaskFile.op`
becomes `add | write | edit | delete`, `TranscriptMessage.file_removed`;
`rpc-schema/openrpc.json` mirrors it and both generated clients are
regenerated. The ACP translator is unchanged (see Risk).
Frontend (second commit):
- A removal rebuilds the turn's row for that path as kind `delete`:
every line it held as a deleted row (from `before` when the runtime
captured it, from the turn's own last write otherwise, from the stored
count alone on reload). A file the same turn created leaves no row, the
nothing git shows for it. Rows are matched by full-segment suffix,
because the model types a relative path and the runtime reports the
resolved one.
- Desk diff tab: git's own letters, `A` / `M` / `D` in git's colours
(added green, modified amber, deleted red), on both the session's rows
and a task's; a task row hides a zero count. The file-level letter and
the `+N -N` line counts beside it are two different things, and #656's
`+` for a created file read as more of the counts. Transcript
changed-files card: "Deleted". Task pane: a removed file's chip shows
only what it took out and opens a diff that ends on the node's last
write of the file taken back out. `taskChangeKind` now reads the op off
the wire; the deletion-count heuristic from #656 is gone.
- Offline fixtures: the GTM run removes a superseded note with `rm`,
exercising the live frame and the stored shape; the tasks fixture
carries an `add` and a `delete` file.
Contract tier (third commit): `FileRemoval` and the two `removed` fields
are a declared-surface change on `raven/contracts/tool.py`, so the
ledger admits the export, `CONTRACTS_VERSION` moves to 31 with the
surface digest repinned, and the papers' line ceiling moves 3,570 ->
3,620 with the reason recorded beside the earlier moves in
`tests/test_kernel_budget.py`.
## Type
- [ ] Fix
- [x] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
Run from the worktree on top of `da13bddd` (main with #656):
- `.venv/bin/ruff check raven tests`; `.venv/bin/ruff format --check
raven tests` -- clean
- `.venv/bin/python -m pytest tests/test_shell_file_removals.py
tests/test_removal_watch.py tests/test_subagent_activity.py
tests/test_subagent_manager.py tests/test_rpc_spine.py
tests/test_rpc_tasks.py tests/test_rpc_schema_match.py
tests/test_acp_updates.py tests/test_filesystem_tools.py
tests/test_agent_loop_session_stamps.py tests/test_rpc_session.py
tests/test_shell_workspace_fence.py tests/test_shell_approval.py
tests/test_turn_wire_shape_conformance.py tests/test_spine_events.py -q`
-- 1532 passed; `tests/test_contracts_two_tier_ledger.py
tests/test_kernel_budget.py` -- 14 passed with the contract-tier commit
- `make lint-python`; `make test-python` -- 25023 passed, 109 skipped
(the full Python suite, which is what caught the three contract-tier
guards the focused set missed)
- `npm test --prefix ui-web` -- 192 files, 2631 tests passed (whole
suite, gates included; the fixture-shape gate is satisfied by the
fixture sending `file_removed`, no new UNSENT pin)
- `npm run lint --prefix ui-web` (0 errors, 4 pre-existing warnings);
`npm run type-check --prefix ui-web`; `npm run gen:check --prefix
ui-web`
- `npm run lint --prefix ui-tui`; `npm run type-check --prefix ui-tui`;
`npm test --prefix ui-tui` -- 143 files, 2075 tests; `npm run lint:rpc
--prefix ui-tui`; `npm run lint:i18n --prefix ui-tui`
- Review round: `rm gone.txt;` (an operator adjacent to the path) now
records the removal -- the watch splits the command on shell operators
the way the fence does before lexing (7 parametrized cases); a
deletion's body follows the file through its edits the way `edit_file`
applies them -- every occurrence with `replace_all`, the one occurrence
otherwise, given up when the reader cannot know what the tool did -- on
the task side and the conversation side (one shared helper in
`lib/hunks.ts`; 7 new cases). Real gateway rerun with `rm
work/main_old.md;` draws the same red `D`.
- Mutation checks, each restored afterwards: ExecTool never reporting
removals, RemovalWatch returning only what the tool reported, add+delete
keeping the entry, raven_loop recording write instead of add, the outlet
dropping file_removed, record.ts never producing a delete row, the D
glyph reverting to M, taskChangeKind ignoring delete, the replay
ignoring stored file_removed, fromDelete numbering the wrong side --
every one turned at least one new test red.
- Real gateway (`raven serve` from this branch, isolated `RAVEN_HOME`,
default model `deepseek/deepseek-v4-flash`), two fresh conversations.
The main agent spawns the in-process `Raven` sub-agent, which writes two
files, edits one, runs `rm work/sub_old.md` on a pre-seeded file, then
writes and removes a scratch file: the desk diff tab shows `A` for the
two files and a red `D work/sub_old.md -3`, nothing for the scratch
file, and `tasks.list` carries `op` add / add / delete. The main agent
itself writes a new file, runs `rm work/main_old.md`, then writes and
removes a scratch file: the diff tab shows a red `D work/main_old.md
-2`, `A work/e2e_main_new.md` and, for an `edit_file` of a pre-seeded
file, `M work/main_keep.md`, nothing for the scratch file. Before this
change the same runs showed no trace of either `rm`.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
## Risk
Behaviour changes: every synchronous local `exec` now stats each command
token and reads up to 64 named files (256 KB each) before running, and
every tool call re-stats the paths the turn has written so far; a
`tool.complete` for a call that removed files carries `file_removed`,
and stored transcripts of such calls carry `file_removed: [{path,
del}]`. The wire additions are optional fields and a widened enum, so
older clients keep parsing. Known limits, unchanged here: the ACP
translator (`raven/acp/updates.py`) does not surface `file_removed`, so
an ACP client sees only the result preview for a call that deleted
files; the shell watch only sees paths the command names literally (a
glob, a directory, a computed path, or `mv a b` are not read as
deletions); two absolute spellings of one file (a symlinked root) are
not matched to the same row. Rollback: revert the three commits; nothing
stored is required by older code.
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
---------
Co-authored-by: Claude (claude-fable-5-1) <noreply@anthropic.com>
## Summary
#469 gave a bundled sub-agent nine verbs in place of six hook phases.
Reviewing it turned up a
list of things the contract said but did not yet do, and this PR closes
that list. No behaviour
change is intended: the point is that the same seam becomes something a
role can replace and
something a generated judgement can enter.
**1. The roles are named apart from the verbs, and `observe` is gone.**
`ActionModule.review`
and the participant's `review` were two different things a line apart.
The four delegating role
methods now say what they do -- they ask -- and the verbs keep their own
names, so `ask_review`
asks `review`. `observe` is removed: a verb with no return value decides
nothing and can only
keep state a participant is forbidden to keep. `outbound` says on its
own docstring that it is
the one verb with no role seat, and `StepView` gains `phase`, so a verb
asked at two moments
reads which one it is rather than inferring it from whichever other
field happens to be set
(`tools_ran` becomes a property derived from it, so the two cannot
disagree).
**2. The three verbs the seat was applying itself get a seat.**
`system_addendum`, `archive` and
`select_tools` were rendered straight onto the hook decision, so each
was the one judgement in
the set with nowhere to compose two participants, nowhere to vet what
came back, and nothing a
replacement role could decide. They join the other four:
`MemoryModule.ask_system_addendum` / `ask_archive` and
`CapabilityModule.ask_select_tools`. The
seat is not the point where narrowing takes effect -- `select` still is,
and the registry still
adjudicates every call -- so a participant narrows after the product has
spoken and never instead
of it.
**3. A participant answers with plain data.** `review`, `intake` and
`system_addendum` returned
host classes (`Verdict`, `Intake`) and `salvage` returned `Any`.
`Accept`, `Resample`, `End` and
`Intake` are now builders returning plain mappings, the host reads one
back with `read_verdict` /
`read_intake`, and an answer it cannot read is silence rather than a
refusal. That is what makes
the third invariant real and what lets a judgement compiled from source
answer the same verbs a
plugin does -- it can build a `dict`; it cannot build a host class.
**4. A dispatch's judgements are a participant.** `judge` was the one
verb a role answered by
reading the dispatch's own `checks` and `code` for itself. A Charter now
enters as a participant
like any other, `ActionModule.ask_judge` takes the list, and the merge
is a veto so the first
refusal decides. The participant list becomes the only route an external
judgement takes, which
is the thing step four needs: a judgement generated for one dispatch
joins the same list without
a second way in.
**5. The rename.** `AgentConduct` is `AgentParticipant`,
`contracts/agent_conduct.py` is
`contracts/participant.py`, `agent/hook/conduct.py` is
`agent/hook/participant.py`, and
`agent/harness/conducts.py` is `agent/harness/participants.py`.
"Conduct" was already taken in
this tree -- raven-code's Coding Conduct prompts are a different thing
-- and a reader hitting both
had no way to tell them apart. The rename was done symbol by symbol, not
by search and replace,
for exactly that reason.
**7. Review (LivXue, at 3a1bf07c).** The `judge` disclosure had reached
two of its four homes;
the other two are `ActionModule.ask_judge` on the paper and
`DefaultAction.ask_judge`, and they
survived because they phrase the claim without naming any symbol the
earlier fix touched. The test
meant to pin that claim could not fail for the reason it was written --
it asserted the refusal
rather than the argument, and built a `ParticipantHook` it dropped --
and now asserts what the
registry hands the role, mutation-checked by wiring a participant
through. `compose_judge`
exploded a one-sentence `str` refusal into one refusal per character,
because `str` satisfies
`Sequence[str]` structurally; `charter_code.run_judge` coerced it where
this composition used to
live and the handling did not move with it. Two records corrected: the
type-only
`raven.contracts` -> `raven.agent` edge, the first in the tree and the
price of moving `Verdict`
and `Intake` off the paper, is now written beside the import contract it
bends rather than left to
be discovered; and the ledger entry for the 3,200 -> 3,410 bump is
restored to the names and count
it was written with. Not taken: reading `step.phase` at
`research_flow/flow.py:1000` -- the gate
chain's phase vocabulary and `StepView.phase` coincide on
`after_iteration` only, and that call
site wants `before_execute_tools`, which is the key `_phase` dispatches
on.
**6. What the paper was claiming and not doing.** Read back over the
seam afterwards rather than
over the diff. ``judge`` read as though a plugin's override were asked
ahead of a dispatch's own
rules; it is not, and cannot be as written, because the party that asks
the verb is
``ToolRegistry.execute``, which is not the hook chain and holds no
handle on this turn's
participants. The merge order is real; nothing puts a plugin in the
list. Wiring one through is a
turn-scoped register this change does not add, and it would start
refusing calls that run today,
so it is named on the paper and pinned by a test instead.
``max_iterations`` had lost its
docstring to the property inserted between the field and the string
documenting it. No executable
line moves in this commit: the module's AST, docstrings stripped, is
identical to its parent's.
CONTEXT.md's entry is rewritten to the end state, including the two
kinds of role method, the two
verbs that are exceptions, and the note that the Coding Conduct prompts
are unrelated.
One item from the same list is deliberately not here: a `planning.*`
block on the dispatch
parameters. It is not a contract closeout but a new model-facing field,
and it needs the
generator's schema and prompt to move with it.
Contract papers: `participant.py` and `harness.py` are both factory-loop
tier, so the
contract-tier digest and `CONTRACTS_VERSION` do not move.
`CONTRACTS_LINE_CEILING` 3,440 to
3,470 to 3,500 to 3,540 to 3,550 to 3,570, each bump with its own review
paragraph in
`tests/test_kernel_budget.py`. The chain was recomputed after rebasing
onto #410, which added
seven lines to `loop_hooks.py` inside the old headroom and left one
commit here with one line of
it; every "Measured at" figure in that file is the count at that commit.
## Type
- [ ] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [x] Refactor
- [ ] Other
## Verification
Gates, run at each of the seven commits:
```
uv run ruff check --no-cache raven evolver agents plugins-dist tests scripts
uv run ruff format --check --no-cache raven evolver agents plugins-dist tests scripts
uv run lint-imports
uv run pytest -q
npx commitlint --from origin/main --to HEAD --config commitlint.config.cjs
uv run python scripts/check_commit_messages.py origin/main..HEAD
uv run python scripts/check_source_language.py origin/main..HEAD
uv run python scripts/check_large_files.py origin/main..HEAD
```
Import contracts: 10 kept, 0 broken. The suite is green: the failures
this machine shows are the
same ones it shows on an unmodified `main` in the same worktree layout
(missing browser and
optional packages), and this branch adds none.
Behaviour preservation. The oracle is the hook seam itself. `main` and
this branch were run under
the same scripted provider, outputs normalised for nonces and temp
paths, then byte-compared.
Four scenarios, all identical:
- the five-plugin hook seam, every phase's decision and metadata per
iteration (23,840 bytes)
- a whole turn with no playbook: host turn, spawned sub-agent, tool
calls and refusals
- a playbook-on worker lane in process, including the charter refusals
- six window-shrink scenarios
This is the seam the change is about, and identical output across it is
what "no behaviour
change" means here -- it is not a claim about paths the four scenarios
do not reach.
Two claims had no assertion anywhere and now do. ``phase``, and the
``tools_ran`` derived from
it, are what three of the five bundled plugins branch on -- ppt on its
close, oncall on its
counter, research on which gate runs -- and a mistyped phase string at
one of the six call sites
would have changed what they do with a green suite. The read-only test
now also covers
``mode_overlay``, the one frozen field it skipped. All three assertions
were mutation-checked:
mislabelling a phase, deriving ``tools_ran`` from the wrong one, and
dropping the freeze each
turn exactly their own test red.
New tests, each written against a claim the contract now makes rather
than against the code:
a participant cannot write through the `StepView` it is shown; an answer
the host cannot read is
silence, not a refusal; a participant that answers with a mapping it
built itself is understood;
every verb with a seat goes through its role rather than around it,
asserted as a set so a new
verb that bypasses its role fails; two seats in one chain each keep one
addendum; two turns in
flight keep their own participants; a bound role decides what a
participant's verdict does; a
plugin's own judgement speaks before the dispatch's, and a silent
participant lets the next one
speak.
Real model, Sonnet 4.5 through OpenRouter, on this branch: a query
generates a playbook, two
sub-agents are instantiated and run, each writes its `summary.md` under
its own fence, and both
results are announced back to the originating session.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
## Risk
For plugin authors: the six-phase `AgentHook` is untouched and a plugin
shipping one keeps
working. A plugin written against #469's `AgentConduct` needs the new
names and, if it answered
with `Verdict` or `Intake`, the builders instead -- the five bundled
plugins are ported here and
are the worked examples.
One verb narrowed, and silently for a plugin that used the width.
`salvage` was annotated
`Any | None` and `compose_salvage` returned whatever was not None; it is
now `str | None` and only
a non-empty string is taken. A third-party plugin that salvages with a
reply object rather than
text stops being heard rather than raising -- which is the third
invariant working as written, and
worth knowing before upgrading. The narrowing is deliberate: `salvage`
answers the text a turn
sends when it produced none, and `Any` was not a contract.
For anyone replacing a harness role: the four delegating methods are
renamed and four more are
added, so a replacement written against #469 needs them. `bind()` names
the missing member at
assembly rather than failing inside a turn.
Rollback is a revert of the merge commit. Nothing persisted on disk
changes shape.
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
## Related Issues
Follows #468 and #469.
Generated with Claude Code (https://claude.com/claude-code)
---------
Co-authored-by: yao pengfei <yaopengfei@shanda.com>
Co-authored-by: Claude (claude-opus-5) <noreply@anthropic.com>
## Summary
Follows #468 (merged as `869ad78a`), which moved the charter reads and
the window's mid-turn shrinking onto the harness roles. This branch is
rebased onto `main` and carries only its own three commits.
A sub-agent's product logic was an `AgentHook` subclass: six phase
methods over a fourteen-field context it could write, with the turn's
own state kept in the context's free-form `metadata` dict. Surveyed
before this change, the five bundled plugins had 71 phase methods, 42 of
them doing real work, reading fourteen context fields and using six
decision fields. Every one of them fits a small set of verbs. This PR
makes those verbs the contract, in three commits.
**1. A sub-agent writes a conduct instead of six hook phases.** New
factory-loop-tier paper `contracts/agent_conduct.py`: `AgentConduct`
with nine optional verbs (`intake`, `select_tools`, `advise`,
`system_addendum`, `review`, `salvage`, `outbound`, `archive`,
`observe`), answered against a read-only `StepView` of fourteen fields,
with `Intake` and `Verdict` (Accept / Resample / End) as the answers and
a `ConductFactory` because the host builds one conduct per turn.
It sits beside `loop_hooks` rather than replacing it. The six phases
remain the loop's *timing* contract: when the loop asks, in what order,
what a refusal does. This is the *judgement* contract: given one step,
what does this agent say about it. `ConductHook` seats one in the other,
so a plugin that still ships a plain `AgentHook` keeps working and the
composite's ordering, merging and rollback are untouched.
All five bundled plugins are ported: design-engine, ppt-engine,
code-flow, oncall-flow and research-flow. Research keeps its six-phase
gate chain: the gates now subclass a plugin-private `Gate` and read a
`GateCtx` the conduct builds from its `StepView` and its own
turn-private facts, so six thousand lines of gate bodies did not move
and its wrappers still see the cross-gate state they read.
The turn's conduct and the system-message addendum it splices live in
the turn's own `metadata` dict, not on the hook: one hook instance
serves every turn a process runs, and a system turn can overlap a user
one on the same chain.
**2. The conducts seat on the roles.** `MemoryModule.intake`,
`PlanningModule.advise`, `ActionModule.review` and
`ActionModule.salvage` each take this turn's conducts, so a replaced
role decides what a plugin's judgement does rather than the seat
deciding it. The composition rules live in
`raven/agent/harness/conducts.py`: the first non-Accept verdict wins,
advice joins in order, the first salvage wins, an intake threads the
text through each conduct. `run_turn` binds the harness for the turn the
way it binds the model, and the seat falls back to the same rules when
nothing is bound, which is how a plugin test drives a hook directly.
Contract papers: the conduct paper is factory-loop tier, so the
contract-tier digest and `CONTRACTS_VERSION` do not move with it.
`CONTRACTS_LINE_CEILING` 3,200 to 3,420, each bump with its own review
paragraph in `tests/test_kernel_budget.py`.
**3. What the review found.** Eleven threads, all resolved in the third
commit. The ones that changed behaviour rather than prose:
`CodeFlowHook` kept its `rolls_back_iterations = False` (inheriting
`True` from the new base had it hold every reply behind the draft gate
instead of streaming); `StepView` now publishes deep-frozen nested
values, since freezing only the outer tuple left a conduct able to write
through to `ctx.messages`; a turn's conducts are collected at the role
boundary, so a replaced role sees one batch of the turn's judgements
rather than one call per seat; an addendum is located by its own text
rather than a saved offset, which two conducts appending system text
used to shift out from under each other; `Planning` and `Action` gained
binders, so a replacement role missing a new member is named at assembly
rather than swallowed by the composite's `except Exception`.
`CONTEXT.md` carries the Agent Conduct term and the Agent Hook entry no
longer describes what this PR replaces.
## Type
- [ ] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [x] Refactor
- [ ] Other
## Verification
Gates. CI runs these at the branch tip (17 pass, 1 skipped -- the
skipped row is the disabled Claude Mention workflow). Locally, at each
of the three commits:
```
uv run ruff check --no-cache raven evolver agents plugins-dist tests scripts
uv run ruff format --check --no-cache raven evolver agents plugins-dist tests scripts
uv run lint-imports
uv run pytest -q
npx commitlint --from origin/main --to HEAD --config commitlint.config.cjs
uv run python scripts/check_commit_messages.py origin/main..HEAD
uv run python scripts/check_source_language.py origin/main..HEAD
uv run python scripts/check_large_files.py origin/main..HEAD
```
Import contracts: 10 kept, 0 broken at each of the three commits. The
suite is green at each, and no commit adds a failure that `main` does
not already show on this machine (this checkout has the heavy extras
uninstalled, so the local run carries failures `main` carries too -- CI
is the authority, and it is green). The loop's own e2e files, which the
default selection leaves out, were run too (charter, playbook,
truncation, direct chat, fallback chain, ACP stdio): no new failure.
Behaviour preservation. The oracle for this change is the hook seam
itself: all five plugins driven through every phase of a multi-iteration
turn under the same scripted provider, recording each phase's decision
and the observers it files. Outputs normalised for nonces and temp
paths, then byte-compared.
Re-run after the review fixes at the branch tip `81e6f423` (all three
commits), against `main` at `c65c2059`:
| scenario | bytes |
| --- | --- |
| five-plugin hook seam | 23,840 == 23,840 |
| a whole turn with no playbook (host turn, spawned sub-agent, tool
calls and refusals) | 12,821 == 12,821 |
| six window-shrink scenarios | 133,371 == 133,371 |
These cover the tip, not each commit separately. The seam comparison is
the one that matters most for the third commit: its first fix changed
`rolls_back_iterations` for code-flow, which decides whether replies
stream or are held, and the seam oracle records the decision at every
phase, so an unintended change there shows as a diff rather than as
silence.
A unit test proves the seat is a real decision point rather than a
pass-through: with a lenient Action role bound, a conduct's Resample is
not applied, and Planning's advice and Memory's intake are what the loop
receives.
Real model, Sonnet 4.5 through OpenRouter, at the branch tip:
- playbook on, in-process lane: two workers, each receives the charter
(3 checks), writes its file, finishes; 26 recorded model calls
- playbook on, ACP fork lane: the charter prompt crosses the process
boundary (the fork answers ZEBRA where the task text says PONG, so the
brief reached the forked model through Memory), and a charter check
blocks `write_file` to `notes/hi.txt` against a `pathPrefix: out/` rule
- Raven-Research, a fork running the full gate chain: `plain-first:
escalated_tool`, then `sufficiency-gate: released on the pages at
iteration 4 after 2 searches / 2 pages`
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed
## Risk
No user-visible behaviour change is intended, and the hook-seam
comparison is byte-identical on every phase it covers.
For plugin authors: the six-phase `AgentHook` is unchanged and a plugin
shipping one keeps working. `ConductHook` is an adapter that seats a
conduct in that same chain.
For anyone replacing a harness role: the role protocols gain `intake`,
`advise`, `review` and `salvage`, so a replacement written against the
old protocol needs them.
Rollback is a revert of the merge commit. Nothing persisted on disk
changes shape.
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
---------
Co-authored-by: yao pengfei <yaopengfei@shanda.com>
Co-authored-by: Claude (claude-fable-5-1) <noreply@anthropic.com>
## Summary
The agent loop already names four strategy roles (Memory, Planning,
Capability, Action), but two judgements a turn makes still lived in the
shell around them. This moves both onto the roles, in two dependent
commits, with no behaviour change intended.
**1. The charter reads through Memory and Action.** A dispatched
sub-agent's playbook (`_meta["raven.playbook"]`) was read from four
places inside the loop and the tool registry. `prompt` and `stopWhen`
are now read by `DefaultMemory.assemble()`, which fills `task_brief` and
`task_done_when` on the `TurnContext` the identity segment renders.
`checks` and `code` are read by `DefaultAction.judge()`, which
`ToolRegistry.execute` asks once per proposed call, the way it already
asks the permission gate. `tools` stays in `withheld_names()` and the
registry still decides what a refusal does, so a replaced role withholds
nothing it could not already withhold.
**2. Mid-turn window shrinking seats on Memory.** The five recoveries
the loop ran inline go through one method,
`MemoryModule.shrink(messages, pressure, state, model)`, with
`WindowPressure`, `WindowState` and `ShrinkResult` as the carriers:
- proactive compaction, once the last billed reading crosses the trigger
- the standing image window
- a provider's overflow error
- a picture refused inside a tool result
- pictures refused for size
The retry mechanism stays in the shell. The six `continue` sites and the
iteration rollback did not move, so a hook sees a retried call exactly
as it saw the first. `WindowState` is a per-turn object the shell owns
and hands to each call, because the role outlives the turn;
`image_window` has no default, since 0 is a real value meaning "no
picture stays".
The pure pieces both sides need move to a new package,
`raven/agent/window/`, which the import contracts treat as cargo that
may not import the loop shell. `REASONING_EFFORT_LADDER` moves to
`contracts/llm_provider.py` because the loop's empty-response descent
and the window's head summary both read it and neither package may
import the other.
Contract papers: `CONTRACTS_VERSION` 26 to 28, `CONTRACTS_LINE_CEILING`
3,040 to 3,200, each bump with its own review paragraph in
`tests/test_kernel_budget.py`.
A follow-up PR carries the third step, which gives a sub-agent nine
verbs in place of the six hook phases. It is kept separate because it
touches every bundled plugin.
## Type
- [ ] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [x] Refactor
- [ ] Other
## Verification
Gates, run at each of the two commits:
```
uv run ruff check --no-cache raven evolver agents plugins-dist tests scripts
uv run ruff format --check --no-cache raven evolver agents plugins-dist tests scripts
uv run lint-imports
uv run pytest -q
npx commitlint --from origin/main --to HEAD --config commitlint.config.cjs
uv run python scripts/check_commit_messages.py origin/main..HEAD
uv run python scripts/check_source_language.py origin/main..HEAD
uv run python scripts/check_large_files.py origin/main..HEAD
```
Import contracts: 10 kept, 0 broken at both commits. The suite is green
at both; the failures this machine shows are the same ones it shows on
an unmodified `main` (missing browser and optional packages), and
neither commit adds one. The loop's own e2e files, which the default
selection leaves out, were run too (charter, playbook, truncation,
direct chat, fallback chain, ACP stdio): no failure that `main` does not
also show.
Behaviour preservation. Each commit was run against a worktree of its
own parent under the same scripted provider, outputs normalised for
nonces and temp paths, then byte-compared. Four scenarios, eight
comparisons, all identical:
- a whole turn with no playbook: host turn, spawned sub-agent, tool
calls and refusals
- a playbook-on worker lane in process, including two charter refusals
- six window-shrink scenarios: proactive compaction, the standing image
window, overflow, a refused picture, oversized pictures, the effort
ladder
- the five-plugin hook seam, every phase's decision and metadata per
iteration
Mutation check on the second commit: breaking each of the five moves
inside `DefaultMemory.shrink` turns exactly its own scenario red, so the
comparison is not vacuous.
Real model, Sonnet 4.5 through OpenRouter, at both commits:
- playbook on, in-process lane: both workers receive the charter, write
their files and finish
- playbook on, ACP fork lane: the charter prompt crosses the process
boundary, and a charter check blocks a `write_file` outside the fence
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed
## Risk
No user-visible behaviour change is intended, and the comparisons above
are byte-identical on every path they cover.
For anyone replacing a harness role: `MemoryModule` gains `shrink`, so a
replacement written against the old protocol needs it.
`DefaultMemory.bind()` names the missing member at assembly rather than
failing inside a turn.
Rollback is a revert of the merge commit. Nothing persisted on disk
changes shape.
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
---------
Co-authored-by: yao pengfei <yaopengfei@shanda.com>
Co-authored-by: Claude (claude-fable-5-1) <noreply@anthropic.com>
Co-authored-by: KT <74288668+0xKT@users.noreply.github.com>
## Summary
Make `MemoryBackend` the only seam between the host and the memory
subsystem, so a second memory plugin can be installed without editing
host code.
The abstraction is the goal; no second backend is being added.
What the branch does:
- `health()` joins the Protocol. `raven doctor` and `raven import` read
a `BackendHealth(ready, checks)` the backend fills in with its own
vocabulary, instead of reaching into EverOS internals. Doctor prints the
checks verbatim and never interprets a label.
- A new `[[plugin.contributes.onboard]]` kind, with
`raven/contracts/onboard.py` as its paper. The host lends the wizard
shell as one `OnboardUI` and records the result; the screen returns a
`StepOutcome`. The plugin never writes `memory.backend` -- that key
stays the host's. EverOS's step-4 screen and its `everos.toml`
management move into the plugin.
- The skill source and the after-turn feedback prefix are named from
`memory.backend` rather than the literal `everos`.
- `enabled_by_default` is gone from the manifest: an installed plugin
the user has not disabled is active.
- `tests/test_plugin_boundary.py` pins the dependency direction in both
directions, with an equality assertion so the remaining exceptions
cannot grow.
That guard's allowlist started at five host files still speaking
EverOS's wire protocol. The follow-ups below close three of them.
Two things this branch itself introduced were found in manual acceptance
on an install without the plugin and fixed here: a turn printed which
backends were installed -- empty on exactly the install that needs the
sentence -- and `settings.everos` / `settings.everosSet` let
`ModuleNotFoundError` reach the dispatcher as an internal error carrying
a traceback. Both now carry the note doctor and the wizard already use,
naming the distribution to install.
Review on this PR found four blockers, all fixed and covered. A fifth
defect came out of manual acceptance rather than review, and four more
out of the rounds that followed it -- every one of those in the
embedding endpoint's own plumbing, each found by the round after the fix
that introduced it. They are listed under Risk; the blockers are:
1. `onboard` is an optional contribution, but the wizard equated "no
matching screen" with "not configured", so one `raven onboard
--skip-memory` wrote `memory.backend` back to null for a third-party
backend configured by hand. A backend with no screen now answers on the
strength of having been selected; only one whose own screen says it is
unconfigured is cleared, which is the case that rule exists for.
2. The record a sub-agent call leaves behind ran through a backend
nobody had started. The shipped adapter begins in an unknown state, so
the first flushing write only scheduled a readiness probe and answered
false -- the record said "unavailable" while the service was up the
whole time, and each per-record HTTP client was left open. One context
manager now owns start and stop around a record, in both the manager and
the DAG runner.
3. That record's write and the recall after it addressed different
owners: a real config spells its keys in camelCase and the block reaches
the backend as written, while the adapter read only the contract's
snake_case, so a sub-agent's memories were filed under the host
identity. The adapter reads both spellings.
4. Legacy embedding discovery had narrowed to the recorded plugin root,
so an install predating root recording lost its knowledge-base endpoint
with a valid file still on disk.
**The five follow-ups the seam left behind are in this PR too**, rather
than in three stacked ones, because they are one goal and the branch
protection dismisses an approval on every push:
- The embedding endpoint is raven's. A knowledge base indexes inside the
gateway process and never speaks to the memory service, yet it read its
endpoint out of everos.toml, so selecting another backend left it with
no vectors and no message naming the cause. Raven holds the block now
and hands it to the backend at start -- as a shared default, not an
override: a plugin that was given an endpoint of its own keeps it, and
only one that has none takes raven's. Discovery of an existing
everos.toml still checks all three places the plugin itself looks, read
with plain tomllib so it works where the plugin is not installed. No
data migrates: a base is keyed on its model and measured width, not on
the base url.
- `delete()` joins the Protocol. The browser used to delete a row out of
EverOS's index, in the host process, through the plugin's repository
layer -- while the markdown EverOS treats as the source of truth kept
the text, so the memory came back on the next rebuild, after the user
was told it was gone. The adapter now uses only operations EverOS
already performs, for the kinds it performs them for.
- Sub-agent memory goes through the contract. The read half is a new
optional `recall_session`; the write half needed no new surface, only
two metadata conventions written down. `agents.<name>.config.everos`
becomes `config.memory`, opaque to the host except the two keys the host
reads; the old spelling still loads.
- The memory and settings pages say why they are empty -- no plugin, or
a backend this page does not read -- instead of four zeros and a retry
button that cannot help.
- The `everos` package leaves the host's dependencies for the plugin's
own, at the same exact pin; the host reaches the tree through the
plugin. This is the package layer only: the installers already deliver
`everos-memory` as a sibling wheel from the same release, so an ordinary
install still has long-term memory.
The boundary guard's allowlist falls from five entries to two, both GUI
surfaces still shaped around EverOS's own store. Generalising their wire
is a frontend change and is deliberately not in scope.
This branch was reviewed on GitLab as merge request 639 over three
rounds, including a post-rebase range-diff check. It is being moved here
because GitHub is now the source of truth.
## Type
- [x] Refactor
## Verification
- `uv run pytest` on this branch, rebased onto `main`: 22146 passed, 4
failed, 45 skipped. Three of the four (`test_agents_oncall_launcher`,
`test_agent_loop_token_budget`, `test_agents_code_launcher`) were re-run
on a detached checkout of that same `main` commit in this environment
and fail there identically. The fourth (`test_ppt_engine_image_search`)
could not run in that checkout, whose environment lacks the deck
engine's extras; this branch's only change anywhere under
`plugins-dist/ppt-engine` is the removal of the `enabled_by_default`
manifest key, which that test does not reach. So this branch adds no
regression.
- `npx vitest run` in ui-web: 1680 passed across 103 files. `npm run
type-check` and `npm run gen:check` clean, so the generated client
matches the contract.
- Every fix in the follow-up commits was mutated away and its test
confirmed red, then restored and confirmed green. For the record path
that is three separate mutations: dropping `start()`, dropping `stop()`,
and narrowing the owner lookup back to one spelling.
- `uv run ruff check .` and `uv run ruff format --check` on the changed
files: clean.
- `uv lock --check`: consistent.
- `scripts/check_commit_messages.py`, `scripts/check_large_files.py`,
`scripts/check_source_language.py` over the branch range: clean.
- Manual acceptance against a real isolated install (temporary
RAVEN_HOME, isolated EverOS root and port), 34 cases: `raven plugins`,
`raven doctor` across four backend states, `raven onboard` interactive
and non-interactive including all three step-4 lanes, `raven import`
refusing and importing, an end-to-end write and recall, the web UI's
memory and settings pages driven through a real browser, a sub-agent
trace record, and an install with no memory plugin at all. 31 passed; 1
failed and was fixed; 1 partial; 1 carried over from the earlier round.
- The failure is the one worth reading. On a fresh managed install the
wizard reported embedding configured and the service it started the next
moment ran keyword-only: the spawned process carried no
`EVEROS_EMBEDDING__` values, and EverOS logged that the embedding key
was not configured. The rule deciding whether everos.toml already held
an operator's own endpoint asked whether its model name was a `"<...>"`
placeholder; the shipped template seeds every section with a real model
name and an empty key, so every fresh install read as a deliberate
choice and the host's endpoint was never bound. It now asks the
criterion the module already had -- model and key. The unit tests missed
it because each built its "operator's own" section with a key in it; the
regression copies the shipped template itself.
- The partial: the memory page's search returned relevant results
without error, but every memory in the test corpus was on one subject,
so narrowing could not be observed. The carried-over case is the
skill-source prefix, whose path this branch does not touch.
- Findings recorded and not fixed here, none introduced by this branch:
a progress spinner is still drawn after `import` reports it imported
nothing; an unsupported delete surfaces as a generic internal error; the
TUI log and `doctor` word "no memory plugin" differently; a turn that
did reach disk still prints that it was not written.
- The partial case: an induced agent skill is discovered through
`find_skill` with the backend's prefix, but `read_skill` / `use_skill`
on that id fail. Nothing writes the on-disk layer those tools look in,
on this branch or on `main`, and no test covers it. Pre-existing; filed
as a follow-up.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
## Risk
User-visible changes:
1. User-track recall is now strictly bounded by `top_k`. A profile row
used to ride outside that bound.
2. `raven doctor` builds the plugin factory, so a managed EverOS setup
writes its env var and config templates during a doctor run. It used to
be read-only. The `--json` memory section is reshaped around
`health.checks`.
3. A third-party drop-in plugin without `enabled_by_default = true` used
to be skipped and now loads.
4. The loader no longer back-fills the EverOS config slice's `root` /
`owned`, nor strips a legacy `mode` key; a leftover `mode` now draws an
unknown-key warning.
5. The wizard's recap shows the contribution name `everos` rather than
`EverOS`.
6. `use_skill` with an unknown prefix reports "not found" after a disk
lookup instead of "unknown source".
From the follow-ups:
7. Config gains an optional top-level `embedding` block. Absent, the
knowledge base reads the EverOS file as before and says so once. An
operator who moves the values across changes nothing else; one who names
a *different* model there gets the existing `StaleBaseError` telling
them to rebuild that base. The block is a default for the memory plugin
rather than an override, so an install that had configured the plugin
separately keeps what it had. Note that a config carrying this block
does not load on an older Raven, which rejects unknown top-level keys.
8. `agents.<name>.everos` is written back as `agents.<name>.memory`. The
old spelling still loads; a per-agent `baseUrl` is ignored with a
warning, having never had a user.
9. Deleting a memory now changes what EverOS treats as the source of
truth, so it stays deleted. Profiles and cases report that they cannot
be deleted rather than appearing to succeed.
10. `pip install raven` no longer pulls the memory engine in.
`install.sh` and `install.ps1` are unaffected: both already resolve
`everos_memory-*.whl` from the release they install and pass it as
`--with everos-memory`, and the source path installs it editable, so
those installs keep long-term memory. An install that reaches neither --
a release predating the sibling wheel, or a bare `pip install` -- now
boots without memory and says which distribution to install rather than
failing on an import.
Found after the acceptance run, in review, all fixed here. They share
one cause worth stating once: the endpoint acquired a second home, and
each fix taught one more reader about it while leaving the next one
behind.
11. The endpoint the wizard saved never reached the EverOS process it
then started. The rule for "does everos.toml already hold an operator's
own endpoint" asked whether its model name was a `"<...>"` placeholder;
the shipped template seeds every section with a real model name and an
empty key, so every fresh managed install read as a deliberate choice
and the host's endpoint was never bound. The service came out of the
wizard running keyword-only while the wizard said embedding was
configured. The rule now asks the criterion the module already had:
model and key.
12. The exported `EVEROS_EMBEDDING__*` variables are a third home,
documented by EverOS and ranked above its file. They were being
overwritten. A complete triple is now an operator's choice; an
incomplete one is not an endpoint and is replaced whole rather than
topped up from the host.
13. Raven writes those same variables itself at startup, so a reader
that asked only whether all three were set called raven's own binding an
operator's export -- a blank settings card and a save refused by naming
variables nobody had set. The module now records which of them it set.
14. That record lived in a module-level set, and `raven gateway
--restart` re-launches through `os.execv`: the values survive, module
state does not. The record now travels in a variable beside them, and is
stripped from the environment handed to EverOS.
15. A settings save the environment would outrank is refused with the
variable names, rather than written and silently ignored.
Four of the five arrived one per review round, each in the fix for the
one before it. The tests that missed them all shared a shape: each built
its "an operator configured this" fixture with a key in it, or cleared
the environment before the case, so the states the product actually
produces -- a template with no key, a live process that has just bound
its own endpoint -- were never the input. The regressions now copy the
shipped template, and run the startup sequence and a second interpreter
rather than a prepared state.
Rollback is a revert of the branch: the seam is additive, and
`memory.backend` keeps its shipped default.
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
---------
Co-authored-by: gloryfromca <23442919+gloryfromca@users.noreply.github.com>
Co-authored-by: Claude (claude-opus-5) <noreply@anthropic.com>
## Summary
Two things arrive together because the second is what made the first usable.
**Run raven from a container.** A Dockerfile builds the page, the Python
environment and the engine into one image; `cd docker && docker compose up`
serves it. nginx serves the built page and proxies the RPC socket to the engine
over the loopback they share -- the engine binds 127.0.0.1 only, so a proxy in a
second container would have no address to dial. Compose publishes on 127.0.0.1,
and the entrypoint prints a one-time sign-in link on boot.
**A first run is no longer a dead end.** The gateway used to refuse to start
until a provider was configured, while being the thing that serves the page
where a provider gets configured. It now starts, says what is missing, and picks
up a key saved in Settings on the next turn without a restart. The onboarding
overlay no longer takes the page either: New chat, the model chip and Send send
the reader to Settings > Models instead, and an empty model list is marked on
the control that fills it.
Also carried: the provider catalogue registry (capabilities, modalities and
context windows per model), the reworked Settings > Models pane, and four fixes
found in review of that work -- a sibling catalogue answering 200 with a
non-catalogue body no longer crashes the whole fetch; adding a tag no longer
erases the label and description already stored for that model; `authenticated`
no longer demands a bearer token from a local provider reached by address; and
registry rows are keyed by the spelling every lookup produces, which recovers
593 rows that no reader could reach.
## Type
- [ ] Fix
- [x] Feature
- [x] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
Commands run on the branch head, with their results:
- `uv run pytest tests -q -k "provider or registry or catalog or model or rpc or gateway or docker or i18n"` -- 4389 passed, 46 skipped
- `npx vitest run` in `ui-web` -- 1573 passed (101 files)
- `npx vitest run` in `ui-tui` -- 2037 passed (142 files)
- `uv run ruff check raven scripts tests` and `ruff format --check` -- clean
- `npx tsc --noEmit` in `ui-web` and `npm run type-check` in `ui-tui` -- clean
- `npm run lint:rpc` in `ui-tui` -- generated.ts in sync
- `make check-source-language`, `make check-large-files` -- clean
Each of the four review fixes was checked by reverting it and watching a named
test go red, then restoring it.
The container image itself has not been built by CI or by me -- no Docker daemon
was available on the machine this was written on. It has been built and run by
the author of the branch.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
## Risk
Two deliberate security trade-offs in the container deployment, both documented
in `docker/README.md`:
- nginx rewrites the `Origin` header, because the engine accepts only an Origin
naming its own loopback port and no browser reaching a published port can send
one. This drops a defence-in-depth layer. The session cookie is
SameSite=Strict, so an unauthenticated socket is still refused -- but SameSite
ignores ports, so another page on localhost counts as same-site.
- `RAVEN_AUTO_LOGIN=1` is the default: nginx attaches the session cookie to
every page load, so anyone who can reach the published port is signed in. It
is contained by Compose publishing on 127.0.0.1 only. Set it to 0 for any
deployment reachable from elsewhere. These are two settings that must agree,
and nothing warns when they do not.
Behaviour changes outside the container: the gateway now starts without a
configured provider rather than exiting 1, and the first-run onboarding overlay
no longer opens by default (`?onboard=1` still forces it).
Rollback is by revert; nothing here migrates state or changes an on-disk format.
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
## Summary
Two things arrive together because the second is what made the first usable.
**Run raven from a container.** A Dockerfile builds the page, the Python
environment and the engine into one image; `cd docker && docker compose up`
serves it. nginx serves the built page and proxies the RPC socket to the engine
over the loopback they share -- the engine binds 127.0.0.1 only, so a proxy in a
second container would have no address to dial. Compose publishes on 127.0.0.1,
and the entrypoint prints a one-time sign-in link on boot.
**A first run is no longer a dead end.** The gateway used to refuse to start
until a provider was configured, while being the thing that serves the page
where a provider gets configured. It now starts, says what is missing, and picks
up a key saved in Settings on the next turn without a restart. The onboarding
overlay no longer takes the page either: New chat, the model chip and Send send
the reader to Settings > Models instead, and an empty model list is marked on
the control that fills it.
Also carried: the provider catalogue registry (capabilities, modalities and
context windows per model), the reworked Settings > Models pane, and four fixes
found in review of that work -- a sibling catalogue answering 200 with a
non-catalogue body no longer crashes the whole fetch; adding a tag no longer
erases the label and description already stored for that model; `authenticated`
no longer demands a bearer token from a local provider reached by address; and
registry rows are keyed by the spelling every lookup produces, which recovers
593 rows that no reader could reach.
## Type
- [ ] Fix
- [x] Feature
- [x] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
Commands run on the branch head, with their results:
- `uv run pytest tests -q -k "provider or registry or catalog or model or rpc or gateway or docker or i18n"` -- 4389 passed, 46 skipped
- `npx vitest run` in `ui-web` -- 1573 passed (101 files)
- `npx vitest run` in `ui-tui` -- 2037 passed (142 files)
- `uv run ruff check raven scripts tests` and `ruff format --check` -- clean
- `npx tsc --noEmit` in `ui-web` and `npm run type-check` in `ui-tui` -- clean
- `npm run lint:rpc` in `ui-tui` -- generated.ts in sync
- `make check-source-language`, `make check-large-files` -- clean
Each of the four review fixes was checked by reverting it and watching a named
test go red, then restoring it.
The container image itself has not been built by CI or by me -- no Docker daemon
was available on the machine this was written on. It has been built and run by
the author of the branch.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
## Risk
Two deliberate security trade-offs in the container deployment, both documented
in `docker/README.md`:
- nginx rewrites the `Origin` header, because the engine accepts only an Origin
naming its own loopback port and no browser reaching a published port can send
one. This drops a defence-in-depth layer. The session cookie is
SameSite=Strict, so an unauthenticated socket is still refused -- but SameSite
ignores ports, so another page on localhost counts as same-site.
- `RAVEN_AUTO_LOGIN=1` is the default: nginx attaches the session cookie to
every page load, so anyone who can reach the published port is signed in. It
is contained by Compose publishing on 127.0.0.1 only. Set it to 0 for any
deployment reachable from elsewhere. These are two settings that must agree,
and nothing warns when they do not.
Behaviour changes outside the container: the gateway now starts without a
configured provider rather than exiting 1, and the first-run onboarding overlay
no longer opens by default (`?onboard=1` still forces it).
Rollback is by revert; nothing here migrates state or changes an on-disk format.
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
## Summary
The web file viewer refused every file a sub-agent's DAG node writes, and said the
wrong thing about why. Clicking such a report answered `403`, which the page renders
as "Raven is confined to the working directory" -- while `restrict_to_workspace` was
off and the real refusal came from the state-directory fence.
`/file` resolves a request against the session's working directory when the page names
a session. It also handed that directory to `in_state_dir` in the role that function
reserves for agent home. The fence derives its two exemptions from that argument -- the
workspace itself, and the per-channel working-directory root beside it -- so with the
session's directory in home's place the exemptions covered `~/.raven/tmp/<channel>` and
a sibling that does not exist. Everything the DAG runner writes under
`~/.raven/workspace/sessions/` then read as raven's own state and was refused, which is
the same defect the workspace exemption exists to prevent, one directory over. A
node's report was drawn on the shelf as a delivery and would not open.
`resolve_readable` now keeps the two roles apart. The caller's workspace still anchors
relative paths and the `restrict_to_workspace` fence; the state-directory fence is
anchored on `cfg.workspace_path`, and the session's directory is passed alongside it
through a new variadic parameter that adds to what the fence exempts rather than
replacing what it derives. A session pinned to a directory under the state root
therefore keeps its files, and every exemption -- derived or added -- is held to the
same direction check, so the state root itself and its ancestors still earn none.
`serve.json` and `config.json` stay refused on every path tested.
`_resolve_inside`, which backs `fs.list` and `fs.read`, carried the same substitution.
Its containment check hid the symptom, so nothing had surfaced there yet; it is
anchored the same way now, because the fence's contract is that the viewer, the `fs.*`
panel and `fs.reveal` answer alike for a given file.
## Type
- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
Commands and results, all at the branch head after rebasing onto `main`:
```console
$ uv run pytest tests/test_rpc_transport.py tests/test_rpc_console.py tests/test_rpc_knowledge.py -q
147 passed in 2.84s
$ uv run pytest tests/test_rpc_files.py tests/test_utils_office.py -q
33 passed in 2.70s
$ make lint-python # ruff check + ruff format --check
exit 0
$ make lint-imports
Contracts: 9 kept, 0 broken.
$ make lint-ui
exit 0
$ make check-source-language
exit 0
$ uv run python scripts/check_commit_messages.py origin/main..HEAD
exit 0
```
Two regression tests were added next to the existing state-directory fence cases:
- the session-workdir call reads a node's report under the sessions tree and still
refuses `serve.json`;
- a session pinned to a directory under the state root keeps serving its own files,
while one pinned at the state root itself does not.
The first was proved load-bearing by reverting the fix and re-running it, which failed
with `PermissionError: ... is inside raven's state directory` on the report path. The
second is unchanged by the fix and is there to pin the behaviour the change must not
lose.
Behaviour was also checked against the running gateway's own files, on the real paths:
with the session's working directory supplied, a node's report resolves and both
`serve.json` and `config.json` raise `PermissionError`.
Known gaps, disclosed rather than worked around:
- `make lint-tui` and `make lint-bridge` do not pass in this environment. The first
reports `src/i18n/messages.generated.ts` stale, the second `tsc: not found`. Both fail
identically on a clean `main` worktree, and this change touches neither `ui-tui/` nor
`bridge/`.
- No browser check. The refusal and the fix were exercised through the resolver and the
gateway's own file paths, not through a rebuilt page bundle.
## Risk
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
The fence's decisions are unchanged except for the one it was getting wrong. Nothing
that was refused before this change becomes readable, apart from the session-directory
subtree the fence was never meant to refuse: the added exemption is bounded by the same
direction check as the derived ones, so no ancestor of raven's state root and not the
root itself can ride it. The credential files were re-checked as refused on every path
the tests and the live probe cover.
`in_state_dir` gains a variadic parameter with no required argument, so existing calls
keep compiling and keep their previous meaning. Both in-tree callers were updated in
this change; there are no others.
Rollback is reverting the commit. The change is three files of resolver logic plus its
tests, with no migration, no stored state and no wire-format change.
## Related Issues
N/A
## Summary
The web file viewer refused every file a sub-agent's DAG node writes, and said the
wrong thing about why. Clicking such a report answered `403`, which the page renders
as "Raven is confined to the working directory" -- while `restrict_to_workspace` was
off and the real refusal came from the state-directory fence.
`/file` resolves a request against the session's working directory when the page names
a session. It also handed that directory to `in_state_dir` in the role that function
reserves for agent home. The fence derives its two exemptions from that argument -- the
workspace itself, and the per-channel working-directory root beside it -- so with the
session's directory in home's place the exemptions covered `~/.raven/tmp/<channel>` and
a sibling that does not exist. Everything the DAG runner writes under
`~/.raven/workspace/sessions/` then read as raven's own state and was refused, which is
the same defect the workspace exemption exists to prevent, one directory over. A
node's report was drawn on the shelf as a delivery and would not open.
`resolve_readable` now keeps the two roles apart. The caller's workspace still anchors
relative paths and the `restrict_to_workspace` fence; the state-directory fence is
anchored on `cfg.workspace_path`, and the session's directory is passed alongside it
through a new variadic parameter that adds to what the fence exempts rather than
replacing what it derives. A session pinned to a directory under the state root
therefore keeps its files, and every exemption -- derived or added -- is held to the
same direction check, so the state root itself and its ancestors still earn none.
`serve.json` and `config.json` stay refused on every path tested.
`_resolve_inside`, which backs `fs.list` and `fs.read`, carried the same substitution.
Its containment check hid the symptom, so nothing had surfaced there yet; it is
anchored the same way now, because the fence's contract is that the viewer, the `fs.*`
panel and `fs.reveal` answer alike for a given file.
## Type
- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
Commands and results, all at the branch head after rebasing onto `main`:
```console
$ uv run pytest tests/test_rpc_transport.py tests/test_rpc_console.py tests/test_rpc_knowledge.py -q
147 passed in 2.84s
$ uv run pytest tests/test_rpc_files.py tests/test_utils_office.py -q
33 passed in 2.70s
$ make lint-python # ruff check + ruff format --check
exit 0
$ make lint-imports
Contracts: 9 kept, 0 broken.
$ make lint-ui
exit 0
$ make check-source-language
exit 0
$ uv run python scripts/check_commit_messages.py origin/main..HEAD
exit 0
```
Two regression tests were added next to the existing state-directory fence cases:
- the session-workdir call reads a node's report under the sessions tree and still
refuses `serve.json`;
- a session pinned to a directory under the state root keeps serving its own files,
while one pinned at the state root itself does not.
The first was proved load-bearing by reverting the fix and re-running it, which failed
with `PermissionError: ... is inside raven's state directory` on the report path. The
second is unchanged by the fix and is there to pin the behaviour the change must not
lose.
Behaviour was also checked against the running gateway's own files, on the real paths:
with the session's working directory supplied, a node's report resolves and both
`serve.json` and `config.json` raise `PermissionError`.
Known gaps, disclosed rather than worked around:
- `make lint-tui` and `make lint-bridge` do not pass in this environment. The first
reports `src/i18n/messages.generated.ts` stale, the second `tsc: not found`. Both fail
identically on a clean `main` worktree, and this change touches neither `ui-tui/` nor
`bridge/`.
- No browser check. The refusal and the fix were exercised through the resolver and the
gateway's own file paths, not through a rebuilt page bundle.
## Risk
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
The fence's decisions are unchanged except for the one it was getting wrong. Nothing
that was refused before this change becomes readable, apart from the session-directory
subtree the fence was never meant to refuse: the added exemption is bounded by the same
direction check as the derived ones, so no ancestor of raven's state root and not the
root itself can ride it. The credential files were re-checked as refused on every path
the tests and the live probe cover.
`in_state_dir` gains a variadic parameter with no required argument, so existing calls
keep compiling and keep their previous meaning. Both in-tree callers were updated in
this change; there are no others.
Rollback is reverting the commit. The change is three files of resolver logic plus its
tests, with no migration, no stored state and no wire-format change.
## Related Issues
N/A
## Summary
`tests/test_agents_code_flow_exec.py` carried a pin on trunk's `DirectExecutor`
dropping a timed-out command's output. That was one of the reasons the code flow
replaced the executor, and the pin's own docstring said what should happen to
it: "pinned so a trunk fix can retire it". The trunk fix landed, the pin
asserted the opposite of the truth, and `main` went red.
**`main` is no longer red.** While this sat in review, a separate change
replaced the pin with `test_trunks_executor_preserves_output_on_timeout`. That
resolved the breakage and is the version kept here; this branch was rebased onto
it rather than carrying a competing test. What remains is what that replacement
did not cover:
- **Why the fork exists on that axis.** The replacement asserts the new fact in
one line and says nothing about what still separates the two executors. Trunk
signals a kill through the stderr line and `exit_code` and nothing more, while
`CodeExecResult` also flags `timed_out` and renders `TIMED_OUT_NOTE`, which
tells the model its output is a fragment rather than a whole run. That
difference is now asserted and explained where the pin used to sit.
- **Three prose claims that are still false on `main`.** Both module docstrings
advertise "the fork's three fixes" and describe trunk waiting on
`communicate()` and losing the buffered output, in the present tense; the exec
factory's docstring lists partial output as a difference. Each is corrected to
say what is true now and what is left.
The fork's drain now duplicates trunk's. That is noted in the docstring as the
fork owners' call, because nothing depends on which of the two performs it and
this change should not spend itself on that. No code is removed and no behaviour
changes.
## Type
- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
- `pytest tests/test_agents_code_flow_exec.py tests/test_agents_code_tools_plugin.py
tests/test_sandbox_unit.py tests/test_agents_oncall_flow_hooks.py` -- 183 passed
- `ruff check` and `ruff format --check` over the changed files -- clean
- `lint-imports` -- 9 contracts kept, 0 broken
- `python scripts/check_source_language.py origin/main...HEAD` -- exit 0
- `python scripts/check_commit_messages.py origin/main..HEAD` -- exit 0
Mutation, to show the added assertions are load-bearing rather than decorative:
```
trunk discards partial stdout again -> 1 failed (the inherited assertions)
fork stops rendering TIMED_OUT_NOTE -> 2 failed (the added pair)
```
One mutation deliberately reported because it did **not** bite. An earlier
revision asserted only that trunk's rendering lacks `TIMED_OUT_NOTE`. Making
trunk emit a partial-output note in its own wording left the file green, because
the constant is matched verbatim -- and that form of assertion is equally
satisfied by a fork that stopped marking anything at all. Both sides are now
measured in one run, so the absence reads as a difference rather than as a
feature nobody has; removing the fork's append is what the second mutation
above does.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed
Left unchecked: no user-facing document describes either executor's timeout
behaviour. The three corrected texts are module and factory docstrings. The
model-facing half was checked separately and needed nothing -- the `timeout`
parameter description says a command that hits its limit "is killed and the
output it produced so far comes back marked partial", which is still true of
this tool.
## Disclosed
Four failures in `tests/test_ppt_engine_build_tool.py` appear in a wider
selection and are **not** from this change. They reproduce at the `main` tip in
a worktree holding none of it, and the cause is local layout rather than code:
`raven_ppt` resolves to the primary checkout's `plugins-dist/ppt-engine`, which
sits at an older revision than a fresh worktree's tests. Not investigated
further here.
How the red reached `main` is worth stating, since the cause was process rather
than code. The executor fix was pushed and then rebased onto a `main` that had
gained the pin in the meantime; the rebase surfaced the collision, and the merge
landed on the pre-rebase head before the rebase was pushed. Rebasing before the
push, as the contribution rules require, would have surfaced it while that
merge request was still open.
## Risk
No behaviour change: assertions added to an existing test, three docstrings
corrected, no production statement altered and no code removed. The duplicated
drain in the fork's executor is left exactly as it is.
Rollback is a revert of the two commits. `main` stays green either way, since
the breakage itself was resolved separately; what a revert costs is the stated
difference between the two executors and the accuracy of the three docstrings.
## Related Issues
N/A
## Summary
`tests/test_agents_code_flow_exec.py` carried a pin on trunk's `DirectExecutor`
dropping a timed-out command's output. That was one of the reasons the code flow
replaced the executor, and the pin's own docstring said what should happen to
it: "pinned so a trunk fix can retire it". The trunk fix landed, the pin
asserted the opposite of the truth, and `main` went red.
**`main` is no longer red.** While this sat in review, a separate change
replaced the pin with `test_trunks_executor_preserves_output_on_timeout`. That
resolved the breakage and is the version kept here; this branch was rebased onto
it rather than carrying a competing test. What remains is what that replacement
did not cover:
- **Why the fork exists on that axis.** The replacement asserts the new fact in
one line and says nothing about what still separates the two executors. Trunk
signals a kill through the stderr line and `exit_code` and nothing more, while
`CodeExecResult` also flags `timed_out` and renders `TIMED_OUT_NOTE`, which
tells the model its output is a fragment rather than a whole run. That
difference is now asserted and explained where the pin used to sit.
- **Three prose claims that are still false on `main`.** Both module docstrings
advertise "the fork's three fixes" and describe trunk waiting on
`communicate()` and losing the buffered output, in the present tense; the exec
factory's docstring lists partial output as a difference. Each is corrected to
say what is true now and what is left.
The fork's drain now duplicates trunk's. That is noted in the docstring as the
fork owners' call, because nothing depends on which of the two performs it and
this change should not spend itself on that. No code is removed and no behaviour
changes.
## Type
- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
- `pytest tests/test_agents_code_flow_exec.py tests/test_agents_code_tools_plugin.py
tests/test_sandbox_unit.py tests/test_agents_oncall_flow_hooks.py` -- 183 passed
- `ruff check` and `ruff format --check` over the changed files -- clean
- `lint-imports` -- 9 contracts kept, 0 broken
- `python scripts/check_source_language.py origin/main...HEAD` -- exit 0
- `python scripts/check_commit_messages.py origin/main..HEAD` -- exit 0
Mutation, to show the added assertions are load-bearing rather than decorative:
```
trunk discards partial stdout again -> 1 failed (the inherited assertions)
fork stops rendering TIMED_OUT_NOTE -> 2 failed (the added pair)
```
One mutation deliberately reported because it did **not** bite. An earlier
revision asserted only that trunk's rendering lacks `TIMED_OUT_NOTE`. Making
trunk emit a partial-output note in its own wording left the file green, because
the constant is matched verbatim -- and that form of assertion is equally
satisfied by a fork that stopped marking anything at all. Both sides are now
measured in one run, so the absence reads as a difference rather than as a
feature nobody has; removing the fork's append is what the second mutation
above does.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed
Left unchecked: no user-facing document describes either executor's timeout
behaviour. The three corrected texts are module and factory docstrings. The
model-facing half was checked separately and needed nothing -- the `timeout`
parameter description says a command that hits its limit "is killed and the
output it produced so far comes back marked partial", which is still true of
this tool.
## Disclosed
Four failures in `tests/test_ppt_engine_build_tool.py` appear in a wider
selection and are **not** from this change. They reproduce at the `main` tip in
a worktree holding none of it, and the cause is local layout rather than code:
`raven_ppt` resolves to the primary checkout's `plugins-dist/ppt-engine`, which
sits at an older revision than a fresh worktree's tests. Not investigated
further here.
How the red reached `main` is worth stating, since the cause was process rather
than code. The executor fix was pushed and then rebased onto a `main` that had
gained the pin in the meantime; the rebase surfaced the collision, and the merge
landed on the pre-rebase head before the rebase was pushed. Rebasing before the
push, as the contribution rules require, would have surfaced it while that
merge request was still open.
## Risk
No behaviour change: assertions added to an existing test, three docstrings
corrected, no production statement altered and no code removed. The duplicated
drain in the fork's executor is left exactly as it is.
Rollback is a revert of the two commits. `main` stays green either way, since
the breakage itself was resolved separately; what a revert costs is the stated
difference between the two executors and the accuracy of the three docstrings.
## Related Issues
N/A
## Summary
An on-call agent submits a job, arms a wake and ends its turn saying so; the wake runs a later turn on the session on its own clock. Over ACP that turn's `end_turn` read as "finished" to the caller: a DAG judging its node spent every continuation on "still watching, wake at 13:13" while the job ran fine (ar-r4, 2026-09-08), and the main agent re-dispatched the work by hand. ACP has no stop reason for "waiting". Replaces the closed!573: **no DAG code changes**, no new node status. The node is `running` because a turn is genuinely in flight.
- **The signal.** The loop-hooks paper gains one key the ACP layer reads for itself: `acp_meta["raven.holdTurn"]` (`{"untilMs", "why"}`). oncall-flow files it at the send fire when the window's campaign is claimed, not concluded, and has one pending wake -- read the same way the owner's answer pulls that wake forward. No campaign, a wake that stood down, or a concluded campaign files nothing and the turn ends as before.
- **The hold** (`raven/acp/methods.py`). A turn that ended `end_turn` with the key filed is not answered. One `tool_call` stands for the wait (its title names the campaign and the next look), with a `tool_call_update` heartbeat every `HOLD_HEARTBEAT_S` (60 s) so a client that clocks liveness by frames sees the agent alive while its model sleeps. The turn slot is reopened with no id to correlate on, so whichever turn ends next on the session -- the wake's, a steer's -- settles it, and the handler decides again from that turn's stash. A wake that arms again keeps the hold; a turn ending with nothing pending answers `end_turn`; a cancel answers `cancelled` as before. The key itself is not passed to the client.
- **Steer.** `_raven/session/steer` is served and advertised under `agentCapabilities._meta` as `raven.steer` (the names raven's own client already uses). Accepted while a prompt is open on the session, held or running: the text is shown on the wire as the person's own line, then sent with `turn.send`'s new `busy: "inject"`. Answers `injected` / `no_turn`.
- **Wire.** `turn.send` gains the optional `busy` param (`const "inject"`): an ordinary send on an idle lane, `BusyPolicy.INJECT` into the running turn otherwise -- the merge a channel's mid-turn message already gets (`gateway_commands.py`). No slot is bound for an injected message; the running turn keeps the lane's. `openrpc.json` and both generated clients moved together.
What raven's client side already does, unchanged: the DAG stall watcher resets on any frame (the heartbeat keeps it quiet, and a stopped heartbeat raises the existing stall notice after ten minutes); a sub-agent process that dies fails the request and the node takes its ordinary path; the pool's `_responsive` treats a prompt in flight as busy.
## Review round 1 (2026-09-09, on !600, superseded by this MR)
- **`busy: inject` reads the scheduler's lane state too.** `is_turn_active` knows only the turns `turn.send` started; an armed wake is submitted to the scheduler directly (`make_on_session_wake`) and never binds that map, so a steer during a running wake queued a second turn and answered `injected`. `turn.send` now asks `Scheduler.has_inflight(lane)` as well, and merges (`BusyPolicy.INJECT`) when either record says the lane is running. Pinned: `test_busy_inject_merges_into_a_wake_the_real_scheduler_is_running` -- the reviewer's reproduction on the real `Scheduler`, a turn submitted the way `make_on_session_wake` submits one; with the lane check bypassed it reads `pending=1, inject_mailbox=0`, with it `(1, 0)` in the mailbox and the running turn drains the text.
- Branch renamed to snake_case and both commits carry the `Co-authored-by: Claude (<model-id>)` trailer, per AGENTS.md §2–3; that is why this MR replaces !600 rather than continuing it.
## Review round 2 (2026-09-10)
- **A wake re-armed during its own run survives the writeback.** `CronService._writeback_locked` reloaded the store after the run and, for a one-shot with `delete_after_run`, overwrote the id with the finished run's state and removed it -- but the turn the wake ran had just called `schedule_wake` under the same key, so the id now named the *next* look. It vanished, and the held prompt had nothing left to settle it. A stored job under the fired id whose `at` schedule the run never had is treated as the new wake it is: claim cleared, run recorded, schedule kept, not deleted. Pinned on the real service: `test_a_wake_re_armed_during_its_own_run_survives_the_writeback` (reads `[]` without the fix, the reviewer's state) and the unchanged one-shot deletion beside it. Cron, proactive, sentinel and on-call suites: 968 passed.
## Review round 3 (2026-09-10)
- **An undrained inject stays visible and cancellable.** `busy: inject` dropped the scheduler's handle; when the host turn ended past its last drain, the spine's fallback ran the text as a turn nothing owned -- `turn.cancel` a no-op, no `message.start`. The handle is now kept per lane under an id minted for the text; `turn.cancel` / `session.interrupt` reach it when the active slot is empty (mailbox, queued fallback, or running); and when the fallback turn starts, the RPC sink (`on_turn_start`, wired from bootstrap) binds the lane to it and opens it on the wire with the person's words. `turn.send` answers the inject's own id. Pinned through `build_rpc_spine` with the reviewer's shape (a loop that drains once, an inject after it): `test_an_undrained_inject_runs_as_a_turn_the_surface_can_see_and_cancel` and `test_a_pending_inject_can_be_cancelled_before_it_merges_or_falls_back`; both read the reviewer's state (`turn_ids` empty, cancel finding nothing) with the fix bypassed.
- **Line ceiling.** The contract comment is five lines; `raven/contracts` is 2,519 against 2,520, one line of headroom on the current `main` (2,514).
- Non-blocking items taken: `SchedulerDrainingError` on the inject path exits as `turn_failed`; the title is announced before the hold; the steer constants sit below the cancel constant's docstring; three edges pinned (a held prompt settled by a wake turn's uncorrelated ending through `send_frame`, the hold key never in the client's `_meta`, `raven.toolName` on the wait row).
- Focused suite (reviewer's list plus the touched files): 948 passed on Python 3.12.
## Review round 4 (2026-09-10)
- **Every pending inject is kept, per lane and per id.** One replaceable record per lane kept only the newest steer; two steers after the host's last drain fall back in turn, and the first started unowned while a cancel took out the second. The record is now `lane -> {inject id: (handle, text)}` in arrival order: each fallback promotes its own handle, and a cancel with no active turn reaches the oldest pending one -- the one the spine runs next. Pinned: `test_two_undrained_injects_each_get_their_own_turn_promoted_and_cancelled` (both promoted with their own ids and `message.start`, cancelled one after the other; runner saw all three turns). Focused suite: 949 passed.
## Type
- [ ] Fix
- [x] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
```
uv run pytest tests/test_acp_methods.py tests/test_acp_protocol.py tests/test_rpc_turn_send.py \
tests/test_rpc_schema_match.py tests/test_acp_updates.py tests/test_acp_server.py -q # 766 passed
uv run pytest tests/test_agents_oncall_flow_hooks.py tests/test_agents_oncall_flow_actions.py \
tests/test_agents_oncall_flow_budget.py tests/test_agents_oncall_flow_readings.py \
tests/test_agents_oncall_flow_escalation_tools.py -q # 99 passed
uv run ruff check raven tests agents && uv run ruff format --check raven tests agents # clean
uv run lint-imports # 9 kept, 0 broken
cd ui-tui && npm run lint:rpc && npx tsc --noEmit; cd ui-web && npm run gen:check && npx tsc --noEmit # in sync, clean
```
New tests: `TestHeldTurn` (held across an armed wake, held again on a re-arm, heartbeat on the wait call, cancel while held, a non-`end_turn` stop is not held; every frame validated against the ACP schema), `TestSteer` (advertised, `no_turn` when idle, a held prompt takes the words as a turn with `busy: inject`, refusals), `busy: inject` on a busy and an idle lane in `test_rpc_turn_send.py`, and the plugin's hold stamping through the real `CronService` grant (filed with a pending wake; not filed without one, after the wake stands down, or once the campaign concluded).
Not done: no end-to-end run of a real on-call wake through a held prompt yet -- unit tests only.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed (the hold is invisible to a person except as a "waiting for ..." tool row)
## Risk
- [x] Backward compatibility considered: a turn that files no `raven.holdTurn` is answered exactly as before; `busy` is optional and absent from every existing caller; the steer method and capability are additive.
- [x] Rollback path is clear: revert the two commits.
A held prompt holds one `max_concurrent_subagents` slot (default 8) for the wait's duration on the caller's side; raised in config if it bites.
## Related
Replaces !573 (closed). Follows !518 (stall notice) and !520 (unprompted-turn route; a wake that runs under a held prompt no longer takes it for DAG nodes).
## Summary
An on-call agent submits a job, arms a wake and ends its turn saying so; the wake runs a later turn on the session on its own clock. Over ACP that turn's `end_turn` read as "finished" to the caller: a DAG judging its node spent every continuation on "still watching, wake at 13:13" while the job ran fine (ar-r4, 2026-09-08), and the main agent re-dispatched the work by hand. ACP has no stop reason for "waiting". Replaces the closed!573: **no DAG code changes**, no new node status. The node is `running` because a turn is genuinely in flight.
- **The signal.** The loop-hooks paper gains one key the ACP layer reads for itself: `acp_meta["raven.holdTurn"]` (`{"untilMs", "why"}`). oncall-flow files it at the send fire when the window's campaign is claimed, not concluded, and has one pending wake -- read the same way the owner's answer pulls that wake forward. No campaign, a wake that stood down, or a concluded campaign files nothing and the turn ends as before.
- **The hold** (`raven/acp/methods.py`). A turn that ended `end_turn` with the key filed is not answered. One `tool_call` stands for the wait (its title names the campaign and the next look), with a `tool_call_update` heartbeat every `HOLD_HEARTBEAT_S` (60 s) so a client that clocks liveness by frames sees the agent alive while its model sleeps. The turn slot is reopened with no id to correlate on, so whichever turn ends next on the session -- the wake's, a steer's -- settles it, and the handler decides again from that turn's stash. A wake that arms again keeps the hold; a turn ending with nothing pending answers `end_turn`; a cancel answers `cancelled` as before. The key itself is not passed to the client.
- **Steer.** `_raven/session/steer` is served and advertised under `agentCapabilities._meta` as `raven.steer` (the names raven's own client already uses). Accepted while a prompt is open on the session, held or running: the text is shown on the wire as the person's own line, then sent with `turn.send`'s new `busy: "inject"`. Answers `injected` / `no_turn`.
- **Wire.** `turn.send` gains the optional `busy` param (`const "inject"`): an ordinary send on an idle lane, `BusyPolicy.INJECT` into the running turn otherwise -- the merge a channel's mid-turn message already gets (`gateway_commands.py`). No slot is bound for an injected message; the running turn keeps the lane's. `openrpc.json` and both generated clients moved together.
What raven's client side already does, unchanged: the DAG stall watcher resets on any frame (the heartbeat keeps it quiet, and a stopped heartbeat raises the existing stall notice after ten minutes); a sub-agent process that dies fails the request and the node takes its ordinary path; the pool's `_responsive` treats a prompt in flight as busy.
## Review round 1 (2026-09-09, on !600, superseded by this MR)
- **`busy: inject` reads the scheduler's lane state too.** `is_turn_active` knows only the turns `turn.send` started; an armed wake is submitted to the scheduler directly (`make_on_session_wake`) and never binds that map, so a steer during a running wake queued a second turn and answered `injected`. `turn.send` now asks `Scheduler.has_inflight(lane)` as well, and merges (`BusyPolicy.INJECT`) when either record says the lane is running. Pinned: `test_busy_inject_merges_into_a_wake_the_real_scheduler_is_running` -- the reviewer's reproduction on the real `Scheduler`, a turn submitted the way `make_on_session_wake` submits one; with the lane check bypassed it reads `pending=1, inject_mailbox=0`, with it `(1, 0)` in the mailbox and the running turn drains the text.
- Branch renamed to snake_case and both commits carry the `Co-authored-by: Claude (<model-id>)` trailer, per AGENTS.md §2–3; that is why this MR replaces !600 rather than continuing it.
## Review round 2 (2026-09-10)
- **A wake re-armed during its own run survives the writeback.** `CronService._writeback_locked` reloaded the store after the run and, for a one-shot with `delete_after_run`, overwrote the id with the finished run's state and removed it -- but the turn the wake ran had just called `schedule_wake` under the same key, so the id now named the *next* look. It vanished, and the held prompt had nothing left to settle it. A stored job under the fired id whose `at` schedule the run never had is treated as the new wake it is: claim cleared, run recorded, schedule kept, not deleted. Pinned on the real service: `test_a_wake_re_armed_during_its_own_run_survives_the_writeback` (reads `[]` without the fix, the reviewer's state) and the unchanged one-shot deletion beside it. Cron, proactive, sentinel and on-call suites: 968 passed.
## Review round 3 (2026-09-10)
- **An undrained inject stays visible and cancellable.** `busy: inject` dropped the scheduler's handle; when the host turn ended past its last drain, the spine's fallback ran the text as a turn nothing owned -- `turn.cancel` a no-op, no `message.start`. The handle is now kept per lane under an id minted for the text; `turn.cancel` / `session.interrupt` reach it when the active slot is empty (mailbox, queued fallback, or running); and when the fallback turn starts, the RPC sink (`on_turn_start`, wired from bootstrap) binds the lane to it and opens it on the wire with the person's words. `turn.send` answers the inject's own id. Pinned through `build_rpc_spine` with the reviewer's shape (a loop that drains once, an inject after it): `test_an_undrained_inject_runs_as_a_turn_the_surface_can_see_and_cancel` and `test_a_pending_inject_can_be_cancelled_before_it_merges_or_falls_back`; both read the reviewer's state (`turn_ids` empty, cancel finding nothing) with the fix bypassed.
- **Line ceiling.** The contract comment is five lines; `raven/contracts` is 2,519 against 2,520, one line of headroom on the current `main` (2,514).
- Non-blocking items taken: `SchedulerDrainingError` on the inject path exits as `turn_failed`; the title is announced before the hold; the steer constants sit below the cancel constant's docstring; three edges pinned (a held prompt settled by a wake turn's uncorrelated ending through `send_frame`, the hold key never in the client's `_meta`, `raven.toolName` on the wait row).
- Focused suite (reviewer's list plus the touched files): 948 passed on Python 3.12.
## Review round 4 (2026-09-10)
- **Every pending inject is kept, per lane and per id.** One replaceable record per lane kept only the newest steer; two steers after the host's last drain fall back in turn, and the first started unowned while a cancel took out the second. The record is now `lane -> {inject id: (handle, text)}` in arrival order: each fallback promotes its own handle, and a cancel with no active turn reaches the oldest pending one -- the one the spine runs next. Pinned: `test_two_undrained_injects_each_get_their_own_turn_promoted_and_cancelled` (both promoted with their own ids and `message.start`, cancelled one after the other; runner saw all three turns). Focused suite: 949 passed.
## Type
- [ ] Fix
- [x] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
```
uv run pytest tests/test_acp_methods.py tests/test_acp_protocol.py tests/test_rpc_turn_send.py \
tests/test_rpc_schema_match.py tests/test_acp_updates.py tests/test_acp_server.py -q # 766 passed
uv run pytest tests/test_agents_oncall_flow_hooks.py tests/test_agents_oncall_flow_actions.py \
tests/test_agents_oncall_flow_budget.py tests/test_agents_oncall_flow_readings.py \
tests/test_agents_oncall_flow_escalation_tools.py -q # 99 passed
uv run ruff check raven tests agents && uv run ruff format --check raven tests agents # clean
uv run lint-imports # 9 kept, 0 broken
cd ui-tui && npm run lint:rpc && npx tsc --noEmit; cd ui-web && npm run gen:check && npx tsc --noEmit # in sync, clean
```
New tests: `TestHeldTurn` (held across an armed wake, held again on a re-arm, heartbeat on the wait call, cancel while held, a non-`end_turn` stop is not held; every frame validated against the ACP schema), `TestSteer` (advertised, `no_turn` when idle, a held prompt takes the words as a turn with `busy: inject`, refusals), `busy: inject` on a busy and an idle lane in `test_rpc_turn_send.py`, and the plugin's hold stamping through the real `CronService` grant (filed with a pending wake; not filed without one, after the wake stands down, or once the campaign concluded).
Not done: no end-to-end run of a real on-call wake through a held prompt yet -- unit tests only.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed (the hold is invisible to a person except as a "waiting for ..." tool row)
## Risk
- [x] Backward compatibility considered: a turn that files no `raven.holdTurn` is answered exactly as before; `busy` is optional and absent from every existing caller; the steer method and capability are additive.
- [x] Rollback path is clear: revert the two commits.
A held prompt holds one `max_concurrent_subagents` slot (default 8) for the wait's duration on the caller's side; raised in config if it bites.
## Related
Replaces !573 (closed). Follows !518 (stall notice) and !520 (unprompted-turn route; a wake that runs under a held prompt no longer takes it for DAG nodes).
## Summary
A model call that returned nothing used to end a turn, and nothing in the record said why.
This branch closes that in five parts, all on the host runtime.
- **The output ceiling is the model's, not ours.** `resolve_max_output_tokens` takes the
figure the model declares instead of a repo default, reserves it against the id the
request actually goes out under, and counts cached prompt tokens toward the window so a
cached prefix stops looking free. One call is given 64k of room and says so on the wire;
the transcript summary budget goes to 32k. Two small output pins keep deliberate
headroom, and the commit says why they do not move.
- **A retry has to ask a different question.** An empty completion previously repeated the
same request and got the same answer. The ladder now descends by **what a rung sends**
rather than by its label, the transcript summary is no longer asked to think, and the
empty-completion retry differs from the call it replaces.
- **Time to first byte is bounded.** `llmFirstByteTimeout` applies on the direct adapters
as well as through the gateway, a bound of zero means off rather than a bound at the
total, and the guard's deadline is distinguished from a strategy's own `TimeoutError` so
a fallback answers for the right one.
- **An effort travels as an effort.** `glm` is out of `inferred_protocol`'s Anthropic prefix
tuple and the hand-written `_THINKING_BUDGETS` table is deleted, so a label reaches the
vendor as a label rather than as a token count this repo invented. Measured on the wire
before the change: 42 calls produced 261,980 characters of reasoning against a budget of
1024 that the route discarded, while our own `max_tokens` went out on every call because
that transport requires the field.
- **The record says what was asked and what came back.** A failed call is visible in the
turn and readable in the record; the reasoning count is kept; a failure's headers are
recorded as the failure's, not as a stream's server; `llm.input` gains a `generation`
block and the span gains `llm.request.*`, with a test pinning that no credential appears
in either. `llm.request_bytes` is documented as an estimate instead of claiming to be
the wire. A frozen turn is stopped rather than nudged once.
## Type
- [x] Fix
- [x] Feature
## Verification
- `uv run --frozen pytest` over the full suite: **20354 passed**, with 6 failures and 20
errors that are this box lacking `/usr/share/zoneinfo` -- all in `test_cron_tool.py` and
`test_cli_cron_commands.py`, which this branch does not touch. Reproduced with the
identical signature on a clean detached `origin/main` worktree, and CI ships tzdata, so
its `tests` job is the authoritative check. Gated on `set -o pipefail` and
`${PIPESTATUS[0]}`.
- `make lint-python` exit 0; `lint-imports` 9 kept, 0 broken.
- Contract pins re-derived against current `main` rather than carried over:
`CONTRACTS_VERSION` **17** (main is 16), the digest from one run of the pinning test, and
`CONTRACTS_LINE_CEILING` **2_791** against 2771 actual. 34 pinning tests pass.
- The request shape verified on real captured bodies rather than inferred: after the change
a deck call is `POST /v1/chat/completions` carrying `reasoning: {"effort": ...}` at the
top level, the configured temperature, and **no** `max_tokens`; before it, the same call
was `POST /v1/messages` carrying `thinking: {"type": "enabled", "budget_tokens": 1024}`.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
## Risk
The routing change moves every `glm` model from the native Anthropic Messages transport to
LiteLLM chat. That changes which client serves the deck agent and the host default model,
so it is the one item here worth a real run before it is relied on. Measured consequences
on a live deck: no truncations, no length-stops, no empty completions and no retries across
40 calls, and prompt-cache read rates in the same band as the Messages route -- `glm` takes
no `cache_control` breakpoints on either transport because OpenRouter caches it
automatically, so caching is unaffected. A provider that needs an Anthropic-compatible
address can still name `protocol: "anthropic"` explicitly, and a test pins that route.
Rollback is per part: each of the five is its own commit range, and the routing change is a
single line in `raven/providers/protocol.py`.
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
## Summary
The onboard wizard stored the web_search vendor's key without checking it, so a mistyped or revoked key surfaced as the tool's first failure inside a conversation. Step 5 now spends one real query on the key right after the prompt and before anything is written.
- `WebSearchTool.probe()` runs the same provider request `execute()` uses, asking for one result, and returns `(ok, detail)`. The detail carries vendor and HTTP status only. Exception text is never echoed: SerpApi puts the key in the request URL, and an unusable proxy URL can carry its own credentials, so that branch reports the exception class alone.
- Interactive step 5 loops the key prompt through the probe. On failure the user picks re-enter, retry, or continue anyway. A stored key kept with Enter is probed too, since it may have been revoked. An empty slot is not probed, since leaving web_search off is a choice, not a failure.
- The flag path (`--search-api-key`, `--serper-api-key`) writes first and then probes, warning on failure without dropping the write, because a scripted run has nobody to re-enter the key. Only the active search vendor's key is probed there.
- The page reader is not probed. Jina works with no key, and a keyed reader whose key does not resolve is replaced by Jina at registration. A keyed reader with a wrong key still fails at call time; that is unchanged and out of scope here.
- All wizard strings reuse existing zh catalog entries; README step 5 and the `--search-api-key` help mention the check.
Deliberately not done, for the reviewer: the web settings page writes the same key slot and does not probe; a key supplied only through the vendor's env var is not probed; step 5 does not feed the wizard's end-of-run warnings list. A vendor that answers 200 with zero results passes, since only HTTP status and a Firecrawl refusal count as failure.
## Type
- [ ] Fix
- [x] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
```
uv run pytest tests/test_agent_tools_web_providers.py tests/test_cli_onboard_commands.py \
tests/test_i18n_boundary.py tests/test_agent_loop_web_tools.py 410 passed
make lint-python clean
make check-source-language exit 0
uv run python scripts/check_commit_messages.py origin/main..HEAD exit 0
```
Revert-the-fix check: with the onboard change reverted, the five new step 5 tests error out on the missing probe seam. No test reaches the network: an autouse fixture in the onboard tests replaces the probe, and the provider tests patch the HTTP client. `make lint-tui` fails on a stale generated i18n file that is identical on `main`; `make lint-bridge` needs `tsc`, which this box lacks.
Not verified: a live run against a real vendor key.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
## Risk
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
User-visible change: onboarding spends one search query per key check against the chosen vendor, and a rejected key adds one prompt. The key still goes only to its own vendor's endpoint, through the configured `tools.web.proxy`. Nothing in config changes shape. Rollback is reverting the commit; no data migration.
## Related Issues
N/A
## Summary
The onboard wizard stored the web_search vendor's key without checking it, so a mistyped or revoked key surfaced as the tool's first failure inside a conversation. Step 5 now spends one real query on the key right after the prompt and before anything is written.
- `WebSearchTool.probe()` runs the same provider request `execute()` uses, asking for one result, and returns `(ok, detail)`. The detail carries vendor and HTTP status only. Exception text is never echoed: SerpApi puts the key in the request URL, and an unusable proxy URL can carry its own credentials, so that branch reports the exception class alone.
- Interactive step 5 loops the key prompt through the probe. On failure the user picks re-enter, retry, or continue anyway. A stored key kept with Enter is probed too, since it may have been revoked. An empty slot is not probed, since leaving web_search off is a choice, not a failure.
- The flag path (`--search-api-key`, `--serper-api-key`) writes first and then probes, warning on failure without dropping the write, because a scripted run has nobody to re-enter the key. Only the active search vendor's key is probed there.
- The page reader is not probed. Jina works with no key, and a keyed reader whose key does not resolve is replaced by Jina at registration. A keyed reader with a wrong key still fails at call time; that is unchanged and out of scope here.
- All wizard strings reuse existing zh catalog entries; README step 5 and the `--search-api-key` help mention the check.
Deliberately not done, for the reviewer: the web settings page writes the same key slot and does not probe; a key supplied only through the vendor's env var is not probed; step 5 does not feed the wizard's end-of-run warnings list. A vendor that answers 200 with zero results passes, since only HTTP status and a Firecrawl refusal count as failure.
## Type
- [ ] Fix
- [x] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
```
uv run pytest tests/test_agent_tools_web_providers.py tests/test_cli_onboard_commands.py \
tests/test_i18n_boundary.py tests/test_agent_loop_web_tools.py 410 passed
make lint-python clean
make check-source-language exit 0
uv run python scripts/check_commit_messages.py origin/main..HEAD exit 0
```
Revert-the-fix check: with the onboard change reverted, the five new step 5 tests error out on the missing probe seam. No test reaches the network: an autouse fixture in the onboard tests replaces the probe, and the provider tests patch the HTTP client. `make lint-tui` fails on a stale generated i18n file that is identical on `main`; `make lint-bridge` needs `tsc`, which this box lacks.
Not verified: a live run against a real vendor key.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
## Risk
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
User-visible change: onboarding spends one search query per key check against the chosen vendor, and a rejected key adds one prompt. The key still goes only to its own vendor's endpoint, through the configured `tools.web.proxy`. Nothing in config changes shape. Rollback is reverting the commit; no data migration.
## Related Issues
N/A
## Summary
`raven.permissions` imported `raven.agent.tools.shell_policy` for
`CommandDecision` and `ShellCommandPolicy`, while the agent side imports
`raven.permissions` from the loop, the turn path and the `raven_loop` backend.
Four edges down, one edge back up, and a cycle between two top-level packages.
The one edge back was the misplaced one. `shell_policy` answers whether a
command may run and whether it needs approval -- which is what the permissions
package is for. It sat under `agent/tools` because that is where the shell tool
that consumes it lives, not because the policy belongs to the tool.
Moving it is unusually cheap: its 1262 lines import `re`, `shlex`,
`contextvars`, `dataclasses`, `enum` and `pathlib` and nothing from raven, so
the module arrives in `permissions` carrying no dependency of its own. Nothing
new enters that package's dependency set.
Its three consumers are repointed rather than reading through a shim at the old
path: the shell tool, the ACP server's approval-family wiring, and the
permissions rules that started this. `agent -> permissions` and
`acp -> permissions` are both directions that already existed.
This is the third instance of one shape in this tree: a capability with no
dependencies of its own, seated inside one of its consumers, which a lower layer
then has to reach up for. The vocabulary split in MR 610 was the second.
## Type
- [ ] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [x] Refactor
- [ ] Other
## Verification
```
$ uv run --frozen --python 3.12 lint-imports
Contracts: 9 kept, 0 broken.
$ uv run --frozen --python 3.12 pytest tests/test_shell_approval.py \
tests/test_shell_comments.py tests/test_shell_policy_reasons.py \
tests/test_permissions_gate.py tests/test_acp_server.py \
tests/test_agents_ppt_launcher.py -q
407 passed in 4.65s
$ uv run --frozen --python 3.12 pytest tests/ -q -k "shell or permission or policy"
746 passed, 8 skipped, 20 warnings in 23.73s
$ uv run --frozen --python 3.12 --extra dev ruff check raven/permissions/ \
raven/acp/server.py raven/agent/tools/shell.py
All checks passed!
$ make check-commits COMMIT_RANGE=origin/main..HEAD
exit 0
```
The eight skips in the wider sweep are pre-existing and environmental: optional
extras that are not installed in this checkout (`wecom_aibot_sdk`, the render
extra). None of them exercise shell policy.
Every consumer of the module was enumerated before the move -- three in `raven/`
and six test files -- and all nine are repointed in this commit, so no import of
the old path remains anywhere in the tree.
Effect on the dependency graph:
```
permissions -> agent edges 1 -> 0
mutually importing pairs 14 -> 13
packages in an import cycle 22 -> 22 (unchanged)
```
The package count does not move. Unlike the config vocabulary split, this pair
was not the only thing holding any other package in the component -- worth
recording, because it is the case where a mutual pair disappears and the
component does not shrink.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed
No user-facing surface changes.
## Risk
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
This module decides whether a shell command runs, so the security-relevant
question is whether the decision changed: it did not. The file moves unedited --
git records it as a rename -- and the matchers, the approval families and the
policy class are byte-identical. `tests/test_shell_approval.py`,
`tests/test_shell_comments.py` and `tests/test_permissions_gate.py` cover the
deny and approval paths and pass unchanged apart from the import line.
No public surface is affected: `shell_policy` is internal to raven and its old
path had no consumers outside this repository. Rollback is reverting the one
commit, which git will apply as the reverse rename.
## Related Issues
N/A
## Summary
`raven.permissions` imported `raven.agent.tools.shell_policy` for
`CommandDecision` and `ShellCommandPolicy`, while the agent side imports
`raven.permissions` from the loop, the turn path and the `raven_loop` backend.
Four edges down, one edge back up, and a cycle between two top-level packages.
The one edge back was the misplaced one. `shell_policy` answers whether a
command may run and whether it needs approval -- which is what the permissions
package is for. It sat under `agent/tools` because that is where the shell tool
that consumes it lives, not because the policy belongs to the tool.
Moving it is unusually cheap: its 1262 lines import `re`, `shlex`,
`contextvars`, `dataclasses`, `enum` and `pathlib` and nothing from raven, so
the module arrives in `permissions` carrying no dependency of its own. Nothing
new enters that package's dependency set.
Its three consumers are repointed rather than reading through a shim at the old
path: the shell tool, the ACP server's approval-family wiring, and the
permissions rules that started this. `agent -> permissions` and
`acp -> permissions` are both directions that already existed.
This is the third instance of one shape in this tree: a capability with no
dependencies of its own, seated inside one of its consumers, which a lower layer
then has to reach up for. The vocabulary split in MR 610 was the second.
## Type
- [ ] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [x] Refactor
- [ ] Other
## Verification
```
$ uv run --frozen --python 3.12 lint-imports
Contracts: 9 kept, 0 broken.
$ uv run --frozen --python 3.12 pytest tests/test_shell_approval.py \
tests/test_shell_comments.py tests/test_shell_policy_reasons.py \
tests/test_permissions_gate.py tests/test_acp_server.py \
tests/test_agents_ppt_launcher.py -q
407 passed in 4.65s
$ uv run --frozen --python 3.12 pytest tests/ -q -k "shell or permission or policy"
746 passed, 8 skipped, 20 warnings in 23.73s
$ uv run --frozen --python 3.12 --extra dev ruff check raven/permissions/ \
raven/acp/server.py raven/agent/tools/shell.py
All checks passed!
$ make check-commits COMMIT_RANGE=origin/main..HEAD
exit 0
```
The eight skips in the wider sweep are pre-existing and environmental: optional
extras that are not installed in this checkout (`wecom_aibot_sdk`, the render
extra). None of them exercise shell policy.
Every consumer of the module was enumerated before the move -- three in `raven/`
and six test files -- and all nine are repointed in this commit, so no import of
the old path remains anywhere in the tree.
Effect on the dependency graph:
```
permissions -> agent edges 1 -> 0
mutually importing pairs 14 -> 13
packages in an import cycle 22 -> 22 (unchanged)
```
The package count does not move. Unlike the config vocabulary split, this pair
was not the only thing holding any other package in the component -- worth
recording, because it is the case where a mutual pair disappears and the
component does not shrink.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed
No user-facing surface changes.
## Risk
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
This module decides whether a shell command runs, so the security-relevant
question is whether the decision changed: it did not. The file moves unedited --
git records it as a rename -- and the matchers, the approval families and the
policy class are byte-identical. `tests/test_shell_approval.py`,
`tests/test_shell_comments.py` and `tests/test_permissions_gate.py` cover the
deny and approval paths and pass unchanged apart from the import line.
No public surface is affected: `shell_policy` is internal to raven and its old
path had no consumers outside this repository. Rollback is reverting the one
commit, which git will apply as the reverse rename.
## Related Issues
N/A
## Summary
Three reader-facing changes to the TUI transcript and the instance strip.
**A settled tool call opens itself.** A tool card had two states, shut and
full, and neither is what a reader wants by default: shut hides the result
that was the point of the call, full spends a thousand rows on a result five
rows would have answered. There are now three levels - shut, a preview capped
at `TOOL_PREVIEW_ROWS` result rows with a `+N` row standing for the
remainder, and full at `TOOL_FULL_ROWS`. The cap is what bounds the cost, so
a call that came back opens unasked and only a call that returned nothing
stays shut, its block being the argument the row above already shows. A
reader's own decision always wins over that default.
The `+N` row becomes its own two-way control: it reveals the rest, then folds
back to the cap, where the block's own click shuts the card outright. It used
to ride inside the output array, which made the one row announcing there was
more to see the row that collapsed the card.
Fold state moves out of the component that draws it into a store keyed by
tool call id. Held in the row's component state, a row that changed - a step
landing in a turn still running - unmounted and took the reader's decision
with it, so a card opened seconds ago closed itself. `useMainApp` now reads
that store when it measures: a resize drops every measured height because the
cache buckets on columns, so without the folds there, rows below the fold came
back at their default height and the transcript scrolled to the wrong place.
**The strip marks the row whose conversation is on screen.** The composer's
top border names the instance being typed to, and the strip listed every
instance without saying which of them that was. The active row now carries a
gutter bar in the strip's own leftmost column, where nothing else draws, so
the bar reads as a position and the bullet beside it goes on saying status
alone. The active row is exempt from every cap, and a line no click can switch
to - a graph line, a loose spawn - never carries it. An interrupted turn also
refreshes the instance registry now: `message.complete` already did, but the
manager moves the row on this path too, writing `cancelled` or `failed`, so
without the re-read an interrupted instance went on showing a filled bullet
while its view went on polling a turn that had ended.
**The censored ticker vocabulary splits from Raven's own.** Wrapped agents
render their status as a kaomoji plus a verb, some of it on the channel the
reasoning arrives on, and `cleanThinkingText` strips exactly that pair - but
it was reading its strip list off Raven's own `FACES` and `VERBS`. That made
the two one list, so a branding change silently changed what gets censored out
of a model's reasoning: rename a verb and the old word stops being stripped,
adopt a word another agent uses and Raven's own ticker starts eating itself.
`tickerNoise.ts` now holds that vocabulary, frozen and deliberately separate;
it describes other agents' output and changes only when one of them does.
`FACES` and `VERBS` are then free to move, and they move here: the kaomoji
become one bird wearing different expressions, and the verbs are ordered as
one round of work rather than by how close the words are in meaning, because
at one word every 2.5s a reader sees most of the list in a single turn. Each
emoji frame is a single code point on purpose - a ZWJ sequence or a variation
selector renders as two glyphs on terminals that do not compose it, which
shifts everything right of the ticker.
## Type
- [ ] Fix
- [x] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
Run on a worktree at this branch's tip, against the current main tip:
- `npx vitest run` (ui-tui): 141 files, 2052 tests passed
- `npx tsc --noEmit -p tsconfig.json` (ui-tui): exit 0, no output
- `make check-source-language COMMIT_RANGE=origin/main..HEAD`: exit 0
- `make check-large-files COMMIT_RANGE=origin/main..HEAD`: exit 0
No Python source is touched, so no pytest selection applies. `ui-tui/CONTEXT.md`
is updated for the fold levels and the gutter bar; the tool-card work carries
its design note under `docs/plans/`.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
## Risk
Three user-visible changes, all inside the terminal UI:
- a tool call that returned something now opens to a capped preview instead of
staying shut. A reader who prefers it shut clicks once, and that decision
holds for the life of the call.
- the instance strip spends one leading column on the gutter bar, so every row
has one column less for its name.
- the status ticker shows a different set of glyphs and words.
No RPC schema, config or on-disk format changes. Fold state lives in memory
and per transcript view, so nothing persists across a restart and there is
nothing to migrate. The split strip list only widens what is removed from
displayed reasoning text; it reads no new input and grants no new capability.
Rollback is a revert of the squash commit.
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
## Summary
Three reader-facing changes to the TUI transcript and the instance strip.
**A settled tool call opens itself.** A tool card had two states, shut and
full, and neither is what a reader wants by default: shut hides the result
that was the point of the call, full spends a thousand rows on a result five
rows would have answered. There are now three levels - shut, a preview capped
at `TOOL_PREVIEW_ROWS` result rows with a `+N` row standing for the
remainder, and full at `TOOL_FULL_ROWS`. The cap is what bounds the cost, so
a call that came back opens unasked and only a call that returned nothing
stays shut, its block being the argument the row above already shows. A
reader's own decision always wins over that default.
The `+N` row becomes its own two-way control: it reveals the rest, then folds
back to the cap, where the block's own click shuts the card outright. It used
to ride inside the output array, which made the one row announcing there was
more to see the row that collapsed the card.
Fold state moves out of the component that draws it into a store keyed by
tool call id. Held in the row's component state, a row that changed - a step
landing in a turn still running - unmounted and took the reader's decision
with it, so a card opened seconds ago closed itself. `useMainApp` now reads
that store when it measures: a resize drops every measured height because the
cache buckets on columns, so without the folds there, rows below the fold came
back at their default height and the transcript scrolled to the wrong place.
**The strip marks the row whose conversation is on screen.** The composer's
top border names the instance being typed to, and the strip listed every
instance without saying which of them that was. The active row now carries a
gutter bar in the strip's own leftmost column, where nothing else draws, so
the bar reads as a position and the bullet beside it goes on saying status
alone. The active row is exempt from every cap, and a line no click can switch
to - a graph line, a loose spawn - never carries it. An interrupted turn also
refreshes the instance registry now: `message.complete` already did, but the
manager moves the row on this path too, writing `cancelled` or `failed`, so
without the re-read an interrupted instance went on showing a filled bullet
while its view went on polling a turn that had ended.
**The censored ticker vocabulary splits from Raven's own.** Wrapped agents
render their status as a kaomoji plus a verb, some of it on the channel the
reasoning arrives on, and `cleanThinkingText` strips exactly that pair - but
it was reading its strip list off Raven's own `FACES` and `VERBS`. That made
the two one list, so a branding change silently changed what gets censored out
of a model's reasoning: rename a verb and the old word stops being stripped,
adopt a word another agent uses and Raven's own ticker starts eating itself.
`tickerNoise.ts` now holds that vocabulary, frozen and deliberately separate;
it describes other agents' output and changes only when one of them does.
`FACES` and `VERBS` are then free to move, and they move here: the kaomoji
become one bird wearing different expressions, and the verbs are ordered as
one round of work rather than by how close the words are in meaning, because
at one word every 2.5s a reader sees most of the list in a single turn. Each
emoji frame is a single code point on purpose - a ZWJ sequence or a variation
selector renders as two glyphs on terminals that do not compose it, which
shifts everything right of the ticker.
## Type
- [ ] Fix
- [x] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
Run on a worktree at this branch's tip, against the current main tip:
- `npx vitest run` (ui-tui): 141 files, 2052 tests passed
- `npx tsc --noEmit -p tsconfig.json` (ui-tui): exit 0, no output
- `make check-source-language COMMIT_RANGE=origin/main..HEAD`: exit 0
- `make check-large-files COMMIT_RANGE=origin/main..HEAD`: exit 0
No Python source is touched, so no pytest selection applies. `ui-tui/CONTEXT.md`
is updated for the fold levels and the gutter bar; the tool-card work carries
its design note under `docs/plans/`.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
## Risk
Three user-visible changes, all inside the terminal UI:
- a tool call that returned something now opens to a capped preview instead of
staying shut. A reader who prefers it shut clicks once, and that decision
holds for the life of the call.
- the instance strip spends one leading column on the gutter bar, so every row
has one column less for its name.
- the status ticker shows a different set of glyphs and words.
No RPC schema, config or on-disk format changes. Fold state lives in memory
and per transcript view, so nothing persists across a restart and there is
nothing to migrate. The split strip list only widens what is removed from
displayed reasoning text; it reads no new input and grants no new capability.
Rollback is a revert of the squash commit.
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
## What
Adds one section to the DAG orchestration skill, `Write the brief as the owner gave it`,
placed after `When to use`. Docs only; no code, no schema, no node fields.
## Why
On the 2026-09-08 autoresearch run the orchestrator's briefs narrowed the search without
anyone deciding to narrow it:
- the owner allowed "training configuration, data mix, architecture, algorithm";
- the round-one brief added "the hyperparameters are exhausted, so gains can only come
from three classes outside the falsified list" (the falsified list named 18 specific
hyperparameter groups; batch size was not among them);
- the round-two brief to the experiment runner opened with "you change no case".
The runner changed no training setting in 26 scored runs. Tokens per step alone was worth
0.059 of the 0.072 gap to the best known result on the same task, and was never tried.
## The three rules
1. The owner's words and scope go into every node's brief as written; the orchestrator's
own steer is marked as a suggestion, never as "gains can only come from".
2. A list of tried settings stays a list. Pass it as is and ask the node to check what is
*not* on it before it picks directions.
3. Each role's brief states the whole of its role every round, not this round's chores.
## Checks
- `tests/test_segments.py`, `tests/test_skill_forge_loader_parity.py`,
`tests/test_agent_loop_injected_skill_ids.py`, `tests/test_curator_context_engine.py`:
144 passed. The one failure (`raven_everos` not installed in a fresh venv) fails
identically on unmodified main.
- The section sits before `How it works`, so it does not overlap the two sections !573
adds later in the same file.
## What
Adds one section to the DAG orchestration skill, `Write the brief as the owner gave it`,
placed after `When to use`. Docs only; no code, no schema, no node fields.
## Why
On the 2026-09-08 autoresearch run the orchestrator's briefs narrowed the search without
anyone deciding to narrow it:
- the owner allowed "training configuration, data mix, architecture, algorithm";
- the round-one brief added "the hyperparameters are exhausted, so gains can only come
from three classes outside the falsified list" (the falsified list named 18 specific
hyperparameter groups; batch size was not among them);
- the round-two brief to the experiment runner opened with "you change no case".
The runner changed no training setting in 26 scored runs. Tokens per step alone was worth
0.059 of the 0.072 gap to the best known result on the same task, and was never tried.
## The three rules
1. The owner's words and scope go into every node's brief as written; the orchestrator's
own steer is marked as a suggestion, never as "gains can only come from".
2. A list of tried settings stays a list. Pass it as is and ask the node to check what is
*not* on it before it picks directions.
3. Each role's brief states the whole of its role every round, not this round's chores.
## Checks
- `tests/test_segments.py`, `tests/test_skill_forge_loader_parity.py`,
`tests/test_agent_loop_injected_skill_ids.py`, `tests/test_curator_context_engine.py`:
144 passed. The one failure (`raven_everos` not installed in a fresh venv) fails
identically on unmodified main.
- The section sits before `How it works`, so it does not overlap the two sections !573
adds later in the same file.
## Summary
The sub-agents page could say an agent was installed and never whether it worked. The probe answers "the command is on this machine"; the only way to learn whether Raven can actually delegate to it was to delegate and watch. `subagents.test` has answered that question since the probe design landed and the TUI roster has had the button all along -- the web page lost it when the five-button form (install / connect / enable / test / switch to) was replaced by two verbs on a row.
It comes back as a section of the card, not a third verb on the row:
- the last verdict with its age (`Worked, 3h ago`, and its zh translation), the reason under a failure, and a dot in the page's own three colours;
- **Run a test**, which becomes **Testing...** plus a **Stop** the moment it is pressed;
- for a `cli` agent only, the line saying the test dispatches it for real and spends its quota. An `acp` test reaches its verdict in the handshake and an `openai` one in the free `/models` probe, and warning about a bill neither of them sends is how a reader learns to ignore the warning on the one that does.
No server change: `subagents.test` / `subagents.test_cancel` are called exactly as the TUI calls them, and `SubagentsTestParams` is untouched.
**Where the button is deliberately absent.** `subagents.test` cannot answer for two kinds of row, so neither is offered one:
- built-in: `run_test` refuses it outright ("a built-in agent runs in this process; there is nothing to test") and the caller records the refusal, so the button could only ever put a permanent failure on the one agent that is demonstrably running;
- discovered (`vendored`): `_find` takes `config` or `preset`, and a product row is in neither pool. Reproduced against the real install rather than read: for `Raven-Code`, both sources answer `subagent_not_found`.
This is a gap, not a design. Those four rows (`Raven-Code`, `Raven-Design`, `Raven-Oncall`, `Raven-Research`) are exactly the ones whose startup warning says "launch config changed since its capabilities were measured; run a test to re-measure" -- the server asks for a test it then cannot perform. Closing it is a server change of its own shape (a `vendored` source through `_discovered_entry`, `_test_acp` recording the snapshot for it, and `_hot_apply` after), so it is not in this MR; this MR hides the button rather than shipping one that can only fail.
**The name is held for the length of the test.** `_RUNNING` (what `subagents.test_cancel` looks in) and `TestStateStore` are both keyed by the config name, so the name cannot move while a run is registered under it. Renaming mid-run left the card showing a row that matched neither: Stop vanished, Run a test came back and a second press started a second run under the new name, and the first went on for up to two minutes with nothing pointing at it and a verdict nothing would display. Reproduced through the store before fixing, then closed by rendering the name as plain text while running. The description keys nothing and stays editable throughout. (Raised as an inline blocker in review; fixed.)
**Why the running state is local as well as remote.** `subagents.test` holds the connection open for the whole run -- up to `TEST_TIMEOUT_SECONDS` (120) -- and answers with the verdict. The rows the call repaints from are therefore the first news that the test is over, and nothing before them says it began. So the store keeps the names it has a test in flight for, and the card reads the union with the row's own `test_running`: a test another client started is only ever on the row.
**Checked and deliberately not changed, for the reviewer:**
- The TUI's own test button has the same `configured ? 'config' : 'preset'` derivation and therefore the same vendored gap. Left alone: fixing it belongs with the server change above. Its name is not editable from the hub, so the rename-orphan path does not exist there.
- `migrate` while a test runs is reachable from the head and preserves the name, so the run stays cancellable -- but it is a remove-plus-add, and `TestStateStore.load` validates the stored verdict's `fingerprint(cfg)` against an entry whose transport has changed, so the verdict is discarded rather than shown. A lost measurement, not a lost run; raised in the review thread rather than folded in here.
- `runTest`'s `finally`: nothing throws through it today (`run` turns every rejection into a toast), and the comment says so. The path that does exist, a rejected call, has a case.
- The quota note has no real-machine proof: this install has no `cli` sub-agent, so that branch was covered by unit test and mutation only.
- Stale text swept for `test verdict|test button|five buttons|enable, test` across the whole tracked tree with no `--include`. Two hits were this MR's to fix and are in the diff; the server-side comments naming "the UI Test button" were true of the TUI and are now true of both.
## Type
- [ ] Fix
- [x] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
Real machine, `raven serve` on the branch's own build against a real `RAVEN_HOME` (18 rows: 1 built-in, 4 vendored, 2 config, 11 presets), driven in headless Chromium:
- every card walked: the section is present on all 13 testable rows and absent on the built-in row and the four vendored ones; no console or page errors;
- `claude_code` pressed for real: `Never tested / led off` -> `['Stop', 'Testing...(off)']` -> `Worked, just now / led` within one poll, the verdict coming off the refetched row;
- the name control goes plain the moment the test starts and comes back when it settles (`nameCtl=editable -> plain -> editable`, description editable throughout);
- `subagents.test_cancel` round-tripped through `DS.xa.act('test_cancel', row)`: accepted, no error frame;
- the same card under `language: zh`: caption, verdict and button render from the zh catalogue.
```
npm run test --prefix ui-web 101 files, 1550 passed
npm run test --prefix ui-tui 141 files, 2017 passed, 13 skipped
npm run gen:check --prefix ui-web generated client matches the contract (162 methods)
npm run type-check --prefix ui-web clean
npm run lint / lint:rpc / lint:i18n / type-check --prefix ui-tui 23 warnings, 0 errors (identical count on main)
scripts/check_commit_messages.py, commitlint, scripts/check_source_language.py pass over the branch
make build-ui dist rebuilt and served
```
The new tests are not theatre: 14 mutations were applied one at a time and the suite re-run against each; every one went red -- each half of `canTest` dropped separately; the missing-time guard in the verdict; each of the three age thresholds; `testCosts` true for every kind; `running` read from only the row or only the local flag; the failure detail shown on a pass; the second-call guard removed; `stopTest` sending `test`; the flag never cleared; the rename left live mid-test.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed (no user-facing docs cover this card; screenshots taken during verification, not shipped)
## Risk
User-visible: a new section on each testable agent's card. Pressing it dispatches the agent once (a `cli` test spends its quota; the card says so). No wire or config change; the two RPC methods already exist and are called as the TUI calls them. Rollback is reverting the single squash commit; the card returns to the description-only shape.
- [x] Security impact considered (no new data path; the test is looked up by name server-side, never by a caller-supplied command)
- [x] Backward compatibility considered (an older server without the test fields renders "Never tested"; `XaOp` gained two members read only by the two sources in this repo)
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
## Summary
The sub-agents page could say an agent was installed and never whether it worked. The probe answers "the command is on this machine"; the only way to learn whether Raven can actually delegate to it was to delegate and watch. `subagents.test` has answered that question since the probe design landed and the TUI roster has had the button all along -- the web page lost it when the five-button form (install / connect / enable / test / switch to) was replaced by two verbs on a row.
It comes back as a section of the card, not a third verb on the row:
- the last verdict with its age (`Worked, 3h ago`, and its zh translation), the reason under a failure, and a dot in the page's own three colours;
- **Run a test**, which becomes **Testing...** plus a **Stop** the moment it is pressed;
- for a `cli` agent only, the line saying the test dispatches it for real and spends its quota. An `acp` test reaches its verdict in the handshake and an `openai` one in the free `/models` probe, and warning about a bill neither of them sends is how a reader learns to ignore the warning on the one that does.
No server change: `subagents.test` / `subagents.test_cancel` are called exactly as the TUI calls them, and `SubagentsTestParams` is untouched.
**Where the button is deliberately absent.** `subagents.test` cannot answer for two kinds of row, so neither is offered one:
- built-in: `run_test` refuses it outright ("a built-in agent runs in this process; there is nothing to test") and the caller records the refusal, so the button could only ever put a permanent failure on the one agent that is demonstrably running;
- discovered (`vendored`): `_find` takes `config` or `preset`, and a product row is in neither pool. Reproduced against the real install rather than read: for `Raven-Code`, both sources answer `subagent_not_found`.
This is a gap, not a design. Those four rows (`Raven-Code`, `Raven-Design`, `Raven-Oncall`, `Raven-Research`) are exactly the ones whose startup warning says "launch config changed since its capabilities were measured; run a test to re-measure" -- the server asks for a test it then cannot perform. Closing it is a server change of its own shape (a `vendored` source through `_discovered_entry`, `_test_acp` recording the snapshot for it, and `_hot_apply` after), so it is not in this MR; this MR hides the button rather than shipping one that can only fail.
**The name is held for the length of the test.** `_RUNNING` (what `subagents.test_cancel` looks in) and `TestStateStore` are both keyed by the config name, so the name cannot move while a run is registered under it. Renaming mid-run left the card showing a row that matched neither: Stop vanished, Run a test came back and a second press started a second run under the new name, and the first went on for up to two minutes with nothing pointing at it and a verdict nothing would display. Reproduced through the store before fixing, then closed by rendering the name as plain text while running. The description keys nothing and stays editable throughout. (Raised as an inline blocker in review; fixed.)
**Why the running state is local as well as remote.** `subagents.test` holds the connection open for the whole run -- up to `TEST_TIMEOUT_SECONDS` (120) -- and answers with the verdict. The rows the call repaints from are therefore the first news that the test is over, and nothing before them says it began. So the store keeps the names it has a test in flight for, and the card reads the union with the row's own `test_running`: a test another client started is only ever on the row.
**Checked and deliberately not changed, for the reviewer:**
- The TUI's own test button has the same `configured ? 'config' : 'preset'` derivation and therefore the same vendored gap. Left alone: fixing it belongs with the server change above. Its name is not editable from the hub, so the rename-orphan path does not exist there.
- `migrate` while a test runs is reachable from the head and preserves the name, so the run stays cancellable -- but it is a remove-plus-add, and `TestStateStore.load` validates the stored verdict's `fingerprint(cfg)` against an entry whose transport has changed, so the verdict is discarded rather than shown. A lost measurement, not a lost run; raised in the review thread rather than folded in here.
- `runTest`'s `finally`: nothing throws through it today (`run` turns every rejection into a toast), and the comment says so. The path that does exist, a rejected call, has a case.
- The quota note has no real-machine proof: this install has no `cli` sub-agent, so that branch was covered by unit test and mutation only.
- Stale text swept for `test verdict|test button|five buttons|enable, test` across the whole tracked tree with no `--include`. Two hits were this MR's to fix and are in the diff; the server-side comments naming "the UI Test button" were true of the TUI and are now true of both.
## Type
- [ ] Fix
- [x] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
Real machine, `raven serve` on the branch's own build against a real `RAVEN_HOME` (18 rows: 1 built-in, 4 vendored, 2 config, 11 presets), driven in headless Chromium:
- every card walked: the section is present on all 13 testable rows and absent on the built-in row and the four vendored ones; no console or page errors;
- `claude_code` pressed for real: `Never tested / led off` -> `['Stop', 'Testing...(off)']` -> `Worked, just now / led` within one poll, the verdict coming off the refetched row;
- the name control goes plain the moment the test starts and comes back when it settles (`nameCtl=editable -> plain -> editable`, description editable throughout);
- `subagents.test_cancel` round-tripped through `DS.xa.act('test_cancel', row)`: accepted, no error frame;
- the same card under `language: zh`: caption, verdict and button render from the zh catalogue.
```
npm run test --prefix ui-web 101 files, 1550 passed
npm run test --prefix ui-tui 141 files, 2017 passed, 13 skipped
npm run gen:check --prefix ui-web generated client matches the contract (162 methods)
npm run type-check --prefix ui-web clean
npm run lint / lint:rpc / lint:i18n / type-check --prefix ui-tui 23 warnings, 0 errors (identical count on main)
scripts/check_commit_messages.py, commitlint, scripts/check_source_language.py pass over the branch
make build-ui dist rebuilt and served
```
The new tests are not theatre: 14 mutations were applied one at a time and the suite re-run against each; every one went red -- each half of `canTest` dropped separately; the missing-time guard in the verdict; each of the three age thresholds; `testCosts` true for every kind; `running` read from only the row or only the local flag; the failure detail shown on a pass; the second-call guard removed; `stopTest` sending `test`; the flag never cleared; the rename left live mid-test.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed (no user-facing docs cover this card; screenshots taken during verification, not shipped)
## Risk
User-visible: a new section on each testable agent's card. Pressing it dispatches the agent once (a `cli` test spends its quota; the card says so). No wire or config change; the two RPC methods already exist and are called as the TUI calls them. Rollback is reverting the single squash commit; the card returns to the description-only shape.
- [x] Security impact considered (no new data path; the test is looked up by name server-side, never by a caller-supplied command)
- [x] Backward compatibility considered (an older server without the test fields renders "Never tested"; `XaOp` gained two members read only by the two sources in this repo)
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
## Summary
The scent menu advertises hub skills by id and closes with "Read one with
read_skill(id)". It screens candidates on the operator blocklist and the safety
score only. `read_skill` then applied `refusal_for_detail` -- the install-time
policy, whose body lint refuses a hub skill naming another product's home
dotdir -- so a skill flagged by nothing but that lint was recommended by id and
could never be read. Seen on an A-share earnings skill whose body mentions
`~/.config` and `~/.openclaw`: the menu offered it, the read answered
`Error: refusing to read hub skill: ... references external home directories`,
and the turn spent its remaining calls on detours.
Key decisions:
- The policy now has two strengths. `refusal_for_read` keeps the blocklist and
the safety bar and drops the body lint. `refusal_for_detail` is untouched, so
`use_skill` and the segment builder's post-gate hydrate refuse exactly what
they refused before. Reading is the weaker case because it installs nothing
and hands the body back wrapped as untrusted data.
- The lint still speaks on the read path, as a note above the body naming the
flagged paths so they are not followed.
- The lint itself was too coarse. A generic root such as `~/.config` hosts other
products rather than being one, so reporting the root refused a skill for
mentioning XDG at all. The reported path now runs down to the segment naming
the owning product (`~/.config/openclaw`), and `~/.config/raven` passes.
`read_skill`'s own description already tells the model to call it "for any skill
listed by description alone". The code contradicted that sentence; this makes it
true rather than changing it.
## Type
- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
Six tests written first and watched fail; the catch-22 one reproduces the
production message verbatim before the fix.
- `pytest tests/test_skill_hub_policy.py tests/test_skill_hub_tools.py
tests/test_context_scent.py tests/test_skill_segment_builder.py` -- 121 passed
- `pytest` over every skill / scent / context test file (36 files) -- 673 passed,
3 skipped. The three skips are pre-existing and environment-bound (two
`chmod 000` cases that do not block root, one fetched-not-tracked template).
- `ruff check` and `ruff format --check` over the changed files -- clean
- `lint-imports` -- 9 contracts kept, 0 broken
- `python scripts/check_source_language.py origin/main...HEAD` -- exit 0
- `python scripts/check_commit_messages.py origin/main..HEAD` -- exit 0
- End to end against the skill that was refused: the body now returns with the
note `these instructions reference paths outside Raven (~/.config/mcporter,
~/.openclaw)`, while `refusal_for_detail` on the same metadata still refuses.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
## Risk
Behaviour change, stated plainly: a hub skill whose body names a foreign home
dotdir is now readable. It was already advertised by id, and a read installs
nothing and returns the text as untrusted data, so what changes is that the
model can see what it was told to look at. The paths are named in a note above
the body so they are not followed silently.
The install and inject paths keep the old gate. `use_skill` and the segment
builder still call `refusal_for_detail`, and the test that pins `use_skill`
refusing an `~/.openclaw` body is unchanged and still passes.
The lint narrowing does reach the install gate as well, and this is the one
place the change is a relaxation rather than a split: a body mentioning bare
`~/.config`, or `~/.config/raven`, previously refused the install and now does
not. A body naming another product under a generic root is still refused, now
reported by the segment that names it. This was the false positive the change
is for, but it is a widening of what may install and is called out here rather
than buried.
Rollback is a revert of the whole change; the two commits are independent of
anything else on the branch.
## Related Issues
N/A
## Summary
The scent menu advertises hub skills by id and closes with "Read one with
read_skill(id)". It screens candidates on the operator blocklist and the safety
score only. `read_skill` then applied `refusal_for_detail` -- the install-time
policy, whose body lint refuses a hub skill naming another product's home
dotdir -- so a skill flagged by nothing but that lint was recommended by id and
could never be read. Seen on an A-share earnings skill whose body mentions
`~/.config` and `~/.openclaw`: the menu offered it, the read answered
`Error: refusing to read hub skill: ... references external home directories`,
and the turn spent its remaining calls on detours.
Key decisions:
- The policy now has two strengths. `refusal_for_read` keeps the blocklist and
the safety bar and drops the body lint. `refusal_for_detail` is untouched, so
`use_skill` and the segment builder's post-gate hydrate refuse exactly what
they refused before. Reading is the weaker case because it installs nothing
and hands the body back wrapped as untrusted data.
- The lint still speaks on the read path, as a note above the body naming the
flagged paths so they are not followed.
- The lint itself was too coarse. A generic root such as `~/.config` hosts other
products rather than being one, so reporting the root refused a skill for
mentioning XDG at all. The reported path now runs down to the segment naming
the owning product (`~/.config/openclaw`), and `~/.config/raven` passes.
`read_skill`'s own description already tells the model to call it "for any skill
listed by description alone". The code contradicted that sentence; this makes it
true rather than changing it.
## Type
- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
Six tests written first and watched fail; the catch-22 one reproduces the
production message verbatim before the fix.
- `pytest tests/test_skill_hub_policy.py tests/test_skill_hub_tools.py
tests/test_context_scent.py tests/test_skill_segment_builder.py` -- 121 passed
- `pytest` over every skill / scent / context test file (36 files) -- 673 passed,
3 skipped. The three skips are pre-existing and environment-bound (two
`chmod 000` cases that do not block root, one fetched-not-tracked template).
- `ruff check` and `ruff format --check` over the changed files -- clean
- `lint-imports` -- 9 contracts kept, 0 broken
- `python scripts/check_source_language.py origin/main...HEAD` -- exit 0
- `python scripts/check_commit_messages.py origin/main..HEAD` -- exit 0
- End to end against the skill that was refused: the body now returns with the
note `these instructions reference paths outside Raven (~/.config/mcporter,
~/.openclaw)`, while `refusal_for_detail` on the same metadata still refuses.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
## Risk
Behaviour change, stated plainly: a hub skill whose body names a foreign home
dotdir is now readable. It was already advertised by id, and a read installs
nothing and returns the text as untrusted data, so what changes is that the
model can see what it was told to look at. The paths are named in a note above
the body so they are not followed silently.
The install and inject paths keep the old gate. `use_skill` and the segment
builder still call `refusal_for_detail`, and the test that pins `use_skill`
refusing an `~/.openclaw` body is unchanged and still passes.
The lint narrowing does reach the install gate as well, and this is the one
place the change is a relaxation rather than a split: a body mentioning bare
`~/.config`, or `~/.config/raven`, previously refused the install and now does
not. A body naming another product under a generic root is still refused, now
reported by the segment that names it. This was the false positive the change
is for, but it is a widening of what may install and is called out here rather
than buried.
Rollback is a revert of the whole change; the two commits are independent of
anything else on the branch.
## Related Issues
N/A
## Summary
Four defects in the conversation title editors, found while debugging one report:
double-clicking a rail row, pressing Enter without changing the name, and watching
the title disappear.
**The reported one.** The rail's editing box and the line it goes back to being are
both spans in one child slot, so React reconciles them onto a single DOM node and
resets every prop. Scroll offset is not a prop: it is state the browser keeps on the
element. That box is a scroll container on purpose (the stylesheet clips it with an
ellipsis and its own note says a long name scrolls inside itself), so focusing and
selecting the field scrolls it to the caret -- 316px for a forty-codepoint name in a
222px row. The finished title, drawn into that same node, inherited the offset and
rendered at x=-298, and `text-overflow: ellipsis` on a scrolled box paints nothing at
all. Any exit from the editor did it, changed name or not; only a remount or a reload
cleared it, and a store redraw did not. Distinct keys make the three states three
elements, so no browser-held state can cross between them.
**Commit once.** Committing with Enter replaces the focused input with the heading,
and Chrome fires a blur for that removal, so the whole commit ran again on a node
already off the tree: two title calls for one edit, two toasts on a refusal, and a
`replaceWith` throw from inside the first call's own mutation. The heading came back
only because the nested call had already put it there. One flag closes it, replacing
the Escape branch's `inp.onblur = null`, which was the same intent written for one
path.
**The stranded editor.** The top-bar editor stands in place of `h1#title`, so while it
is open that id resolves to nothing -- and the live layer reaches the heading through
it on both paths that change which conversation is open, plus on the reconnect that
reloads the open one. That reconnect read it unguarded, so with an editor up the
handler threw on its first line and took down everything after it: the conversation
was never reloaded and never re-subscribed after a socket gap, the reader was never
told the connection was back, the extension surfaces stayed empty for the life of the
tab, and the input sat in the top bar with the heading gone and the rename button
hidden, unrecoverable without a reload. A null check alone would be worse than the
crash -- the editor would stay open over a different conversation and its next commit
would rename that one to the name typed for the old one -- so the invariant is that no
title editor survives a conversation switch, and ending one commits to the row it
captured.
**Where that teardown has to sit.** The reconnect is the only caller that builds a
detached `{ id, title }` for `openLiveSession`; every other one hands over the live
row, whose title the commit mutates in place. So it was the only one that could read a
title, have the teardown inside `openLiveSession` commit a different one underneath
it, and then paint the value it had captured -- the rail redrew with the typed name
while the top bar went back to the pre-edit one and stayed there until the
conversation was opened again. It ends the editor before the lookup instead. The call
inside `openLiveSession` stays, being idempotent and covering the callers that do not
come through here.
The reconnect needs no heading at all in the ordinary case: the row carries the title,
and the heading was the wrong first source twice over, holding the plain form with any
leading icon stripped and holding nothing while a name is being generated. It stays
behind the row as the last resort for a current conversation absent from the list.
Every live-layer touch of the heading is now either preceded by that teardown or
null-guarded.
## Type
- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
Branch and base run in separate worktrees, both at the same base, same interpreter.
- `npx vitest run --no-file-parallelism` (ui-web): branch 1534 passed / 2 failed of
1536; base 1529 passed / 2 failed of 1531. Failing-ID sets diff empty -- 0
introduced, 0 fixed. Exit code, failure count and unhandled-error count all read:
`unhandledErrors` is 0 on both sides.
- The two failures are `deskStore` and `palette`'s "when storage refuses" cases. They
need `--localstorage-file` for `localStorage` to exist on this box at all, and with
it the store no longer refuses, so the refusal each asserts does not happen. Both
reproduce on the base, and neither file imports anything this change touches. A
second environment settles it: review ran the same head and reported 1,536 tests
passed at exit 0, so the pair is local to the machine this was authored on.
- `scripts/check_commit_messages.py`, `check_source_language.py`,
`check_large_files.py` over `origin/main..HEAD`: pass.
- `npm run gen:check`, `npm run type-check`, `node scripts/check-page.mjs` (after a
full two-step page build): pass.
- Not run, with the reason: `lint-python` and `lint-imports` (no Python in the diff),
`lint-tui` and `lint-bridge` (no files in either tree).
- Each of the five new tests was proven red before its fix: node identity, a second
`renamed` call, a missing export, a missing harness verb, and the pre-edit title.
The ordering one is driven through the real `rpc.onReconnect` rather than
`openLiveSession`, because the ordering is between the two and a test that calls the
inner one cannot see it; the live harness now compiles that handler too.
- Driven in headless Chrome against the built page, on a real conversation with a
forty-codepoint name. Before: glyph run at x=-298 with the box at x=18; after: x=18,
on Enter, Escape and clicking away. Top-bar Enter on an unchanged name: heading back,
editor gone, button back, zero title calls, no page error. Reconnect with the editor
open, forced by closing the socket from the page: before, `Cannot read properties of
null (reading 'textContent')` with the input stranded and no session reload; after,
heading restored, editor gone, reload done, no page error. Reconnect with a name
typed into an open editor: heading and rail row both settle on the committed name,
no page error. That probe renamed a real conversation, so its title was put back and
the stored metadata checked byte-identical afterwards.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed
## Risk
User-visible, all of it in the same direction: a title that used to vanish stays put.
- Ending an editor on a conversation switch commits what was typed, which is what
leaving the field already did. It cannot reach a different conversation than the one
it was typed over: the editor captures its row when it opens.
- The reconnect now prefers the row's title and keeps the heading behind it, so the
only case that changes is a name being generated, where the heading is empty and the
row is right.
- Rollback is per commit; each stands alone and none changes a stored title, a wire
shape or a schema.
Checked and deliberately not fixed: the demo layer has the same three unguarded
heading writes, and no path to them -- it has no reconnect, and every other route
blurs the editor first, which commits it. And a source removed from under an open
editor would throw out of the new teardown, which the old code would also have thrown
on; an editor cannot exist unless the source did, and the live layer never removes it.
## Related Issues
N/A
## Summary
Four defects in the conversation title editors, found while debugging one report:
double-clicking a rail row, pressing Enter without changing the name, and watching
the title disappear.
**The reported one.** The rail's editing box and the line it goes back to being are
both spans in one child slot, so React reconciles them onto a single DOM node and
resets every prop. Scroll offset is not a prop: it is state the browser keeps on the
element. That box is a scroll container on purpose (the stylesheet clips it with an
ellipsis and its own note says a long name scrolls inside itself), so focusing and
selecting the field scrolls it to the caret -- 316px for a forty-codepoint name in a
222px row. The finished title, drawn into that same node, inherited the offset and
rendered at x=-298, and `text-overflow: ellipsis` on a scrolled box paints nothing at
all. Any exit from the editor did it, changed name or not; only a remount or a reload
cleared it, and a store redraw did not. Distinct keys make the three states three
elements, so no browser-held state can cross between them.
**Commit once.** Committing with Enter replaces the focused input with the heading,
and Chrome fires a blur for that removal, so the whole commit ran again on a node
already off the tree: two title calls for one edit, two toasts on a refusal, and a
`replaceWith` throw from inside the first call's own mutation. The heading came back
only because the nested call had already put it there. One flag closes it, replacing
the Escape branch's `inp.onblur = null`, which was the same intent written for one
path.
**The stranded editor.** The top-bar editor stands in place of `h1#title`, so while it
is open that id resolves to nothing -- and the live layer reaches the heading through
it on both paths that change which conversation is open, plus on the reconnect that
reloads the open one. That reconnect read it unguarded, so with an editor up the
handler threw on its first line and took down everything after it: the conversation
was never reloaded and never re-subscribed after a socket gap, the reader was never
told the connection was back, the extension surfaces stayed empty for the life of the
tab, and the input sat in the top bar with the heading gone and the rename button
hidden, unrecoverable without a reload. A null check alone would be worse than the
crash -- the editor would stay open over a different conversation and its next commit
would rename that one to the name typed for the old one -- so the invariant is that no
title editor survives a conversation switch, and ending one commits to the row it
captured.
**Where that teardown has to sit.** The reconnect is the only caller that builds a
detached `{ id, title }` for `openLiveSession`; every other one hands over the live
row, whose title the commit mutates in place. So it was the only one that could read a
title, have the teardown inside `openLiveSession` commit a different one underneath
it, and then paint the value it had captured -- the rail redrew with the typed name
while the top bar went back to the pre-edit one and stayed there until the
conversation was opened again. It ends the editor before the lookup instead. The call
inside `openLiveSession` stays, being idempotent and covering the callers that do not
come through here.
The reconnect needs no heading at all in the ordinary case: the row carries the title,
and the heading was the wrong first source twice over, holding the plain form with any
leading icon stripped and holding nothing while a name is being generated. It stays
behind the row as the last resort for a current conversation absent from the list.
Every live-layer touch of the heading is now either preceded by that teardown or
null-guarded.
## Type
- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
Branch and base run in separate worktrees, both at the same base, same interpreter.
- `npx vitest run --no-file-parallelism` (ui-web): branch 1534 passed / 2 failed of
1536; base 1529 passed / 2 failed of 1531. Failing-ID sets diff empty -- 0
introduced, 0 fixed. Exit code, failure count and unhandled-error count all read:
`unhandledErrors` is 0 on both sides.
- The two failures are `deskStore` and `palette`'s "when storage refuses" cases. They
need `--localstorage-file` for `localStorage` to exist on this box at all, and with
it the store no longer refuses, so the refusal each asserts does not happen. Both
reproduce on the base, and neither file imports anything this change touches. A
second environment settles it: review ran the same head and reported 1,536 tests
passed at exit 0, so the pair is local to the machine this was authored on.
- `scripts/check_commit_messages.py`, `check_source_language.py`,
`check_large_files.py` over `origin/main..HEAD`: pass.
- `npm run gen:check`, `npm run type-check`, `node scripts/check-page.mjs` (after a
full two-step page build): pass.
- Not run, with the reason: `lint-python` and `lint-imports` (no Python in the diff),
`lint-tui` and `lint-bridge` (no files in either tree).
- Each of the five new tests was proven red before its fix: node identity, a second
`renamed` call, a missing export, a missing harness verb, and the pre-edit title.
The ordering one is driven through the real `rpc.onReconnect` rather than
`openLiveSession`, because the ordering is between the two and a test that calls the
inner one cannot see it; the live harness now compiles that handler too.
- Driven in headless Chrome against the built page, on a real conversation with a
forty-codepoint name. Before: glyph run at x=-298 with the box at x=18; after: x=18,
on Enter, Escape and clicking away. Top-bar Enter on an unchanged name: heading back,
editor gone, button back, zero title calls, no page error. Reconnect with the editor
open, forced by closing the socket from the page: before, `Cannot read properties of
null (reading 'textContent')` with the input stranded and no session reload; after,
heading restored, editor gone, reload done, no page error. Reconnect with a name
typed into an open editor: heading and rail row both settle on the committed name,
no page error. That probe renamed a real conversation, so its title was put back and
the stored metadata checked byte-identical afterwards.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed
## Risk
User-visible, all of it in the same direction: a title that used to vanish stays put.
- Ending an editor on a conversation switch commits what was typed, which is what
leaving the field already did. It cannot reach a different conversation than the one
it was typed over: the editor captures its row when it opens.
- The reconnect now prefers the row's title and keeps the heading behind it, so the
only case that changes is a name being generated, where the heading is empty and the
row is right.
- Rollback is per commit; each stands alone and none changes a stored title, a wire
shape or a schema.
Checked and deliberately not fixed: the demo layer has the same three unguarded
heading writes, and no path to them -- it has no reconnect, and every other route
blurs the editor first, which commits it. And a source removed from under an open
editor would throw out of the new teardown, which the old code would also have thrown
on; an editor cannot exist unless the source did, and the live layer never removes it.
## Related Issues
N/A
## Summary
Reported from real use, a second time: a sub-agent's chat kept flickering while the agent worked. The first report was a pane repainting an unchanged snapshot every two seconds, and the guard that closed it (a print of what was drawn, compared before drawing again) still holds. This is the case that guard was never about: a snapshot that changed.
A run in flight is redrawn from its newest committed row on every poll. `agentPaintLane` throws the provisional rows away and `history` draws them again from the messages, minting every row a fresh id. The views key on that id, so the same sentence came back as a new element -- and `.step`, `.answer` and `.ask` all carry `.in`, which is `animation: up .22s` on mount. While the model is writing, the last paragraph fades in again on every poll for as long as the answer grows. Since the delegated fold started being born open, every step inside it did the same on every new call.
Measured by feeding the shipped renderer a growing snapshot the way the poll does (`RavenIslands.transcript.agentStage`, one feed per row added or grown, then the same snapshot again, then settled), tagging every element on first sight and reading `getAnimations()` after each feed. Element identities per feed:
```
fold step answer entrance animation running on
current main (fold born open) 17>35>59 24>42>66 84>94>104>114>124>134 the new fold, step and answer, every feed
before the fold opened (control) 17>33>49 (shut) 24>40>56>65>75>83>92>101 the new answer, every feed
this change 17 24 44 none after a row's first appearance
```
On both existing builds the answer row is a different node after every feed, including the identical re-feed; on current main the open fold and its step are too, on every new message. The control shows the answer half predates the fold change: it is the flicker the first report was about, still present whenever the answer is genuinely growing. Opening the fold added the fold half.
**The fix.** The rows a redraw replaces adopt the identity of the rows they replace. Read by position, the way `readToggles` already carries the reader's fold state across the same redraw: the redraw walks the same messages, so a row that was there keeps its place and new rows only follow. Both places provisional rows live are covered -- past the committed prefix, and appended inside a fold that was committed before the model said anything. Adopted only where the kind agrees: a line the model said can stop being the answer and become narration inside a fold when a call follows it, and that is a different row which arrives as one, animation included. Calls match on kind and name as well as position, so a redraw that reordered the work is not read as one call growing.
The renderer only. The earlier store-level guard stays: a repaint now costs a re-read and a re-render rather than a rebuilt node, and an unchanged snapshot still has nothing to pay either for. Its comment, which stated the old measurement in the present tense, now says what is still true.
**Checked and deliberately not changed, for the reviewer:**
- `.in` stays on the rows. Taking the entrance animation off would also have hidden the symptom, but a genuinely new row arriving with a fade is the design; the defect was rows that were not new arriving as if they were.
- The provisional rows are still thrown away and redrawn. Identity is carried onto the new objects rather than the old objects being kept, so every other property of the redraw (toggles by position, the fold time, the turn count) is untouched. The existing fold-state case's `expect(again).not.toBe(first)` still holds, and its comment now says so.
- The added/removed counters in the probe are not zero on this change (3/3 per feed): that is the `.prose` body re-rendering as the text changes, inside the kept `.answer`. The animated element is the one that has to survive, and it does.
- Timing was not reproducible with the local model. Qwen3.6-35B-A3B on this box answers a 900-character essay in about ten seconds, two polls, so a live probe rarely caught a mid-answer poll; the mechanism was pinned on the renderer instead, which is also how the first report was measured. A slower endpoint, which the reporter is likely on, widens exactly that window.
- The released wheel `v0.1.13` (tagged 2026-08-24) predates the first flicker fix as well as this one. A reader installed from the wheel has neither guard; worth asking the reporter which build they are on.
## Type
- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
```
npm run test --prefix ui-web 101 files, 1537 passed (main: 1531; six added here, none introduced)
npm run type-check --prefix ui-web clean
npm run gen:check --prefix ui-web generated client matches the contract, 162 methods
scripts/check_commit_messages.py, commitlint, scripts/check_source_language.py, git diff --check pass over the branch
scripts/check_pr_body.py pass on this description
```
Six cases. Four at the store (`lane.test.ts`): the answer row keeps its id while the answer grows; a fold, its steps and their calls keep theirs when the next step arrives; steps a poll appended into an already-committed fold keep theirs; a row that changed kind gets a new one. Two at the DOM (`TranscriptPage.test.tsx`), because a kept id is only worth something if React keeps the element for it: the same `.answer` node across three growing feeds, and the same `.tfold .step` nodes with one new one after them.
Five mutations, each red on its own: the adoption past the prefix removed (4 cases); the adoption into a committed fold removed (1); the kind check dropped (1); steps inside a redrawn fold not carried (1); call ids not carried (1).
Real machine, this change's build served against a scratch `RAVEN_HOME`: the renderer probe above (third row of the table), and a live `Raven-Code` direct chat driven in headless Chromium with a `MutationObserver` on the pane -- the fold kept one element id across the whole run while its steps grew from one to two, where the same run on current main gave the fold a new id on every new message.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed (no user-facing docs describe this pane's repaint; nothing to update)
## Risk
User-visible: rows in a sub-agent pane stop re-animating while a run is in flight; nothing else on screen changes. Confined to `ui-web`'s transcript renderer, no wire or config change. Rollback is reverting the single squash commit; the pane returns to redrawing rows as new elements.
- [x] Security impact considered (none: a render-side identity handoff, no new data path)
- [x] Backward compatibility considered (the segment shape and every field but `id` are untouched; ids were never persisted or sent)
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
## Summary
Reported from real use, a second time: a sub-agent's chat kept flickering while the agent worked. The first report was a pane repainting an unchanged snapshot every two seconds, and the guard that closed it (a print of what was drawn, compared before drawing again) still holds. This is the case that guard was never about: a snapshot that changed.
A run in flight is redrawn from its newest committed row on every poll. `agentPaintLane` throws the provisional rows away and `history` draws them again from the messages, minting every row a fresh id. The views key on that id, so the same sentence came back as a new element -- and `.step`, `.answer` and `.ask` all carry `.in`, which is `animation: up .22s` on mount. While the model is writing, the last paragraph fades in again on every poll for as long as the answer grows. Since the delegated fold started being born open, every step inside it did the same on every new call.
Measured by feeding the shipped renderer a growing snapshot the way the poll does (`RavenIslands.transcript.agentStage`, one feed per row added or grown, then the same snapshot again, then settled), tagging every element on first sight and reading `getAnimations()` after each feed. Element identities per feed:
```
fold step answer entrance animation running on
current main (fold born open) 17>35>59 24>42>66 84>94>104>114>124>134 the new fold, step and answer, every feed
before the fold opened (control) 17>33>49 (shut) 24>40>56>65>75>83>92>101 the new answer, every feed
this change 17 24 44 none after a row's first appearance
```
On both existing builds the answer row is a different node after every feed, including the identical re-feed; on current main the open fold and its step are too, on every new message. The control shows the answer half predates the fold change: it is the flicker the first report was about, still present whenever the answer is genuinely growing. Opening the fold added the fold half.
**The fix.** The rows a redraw replaces adopt the identity of the rows they replace. Read by position, the way `readToggles` already carries the reader's fold state across the same redraw: the redraw walks the same messages, so a row that was there keeps its place and new rows only follow. Both places provisional rows live are covered -- past the committed prefix, and appended inside a fold that was committed before the model said anything. Adopted only where the kind agrees: a line the model said can stop being the answer and become narration inside a fold when a call follows it, and that is a different row which arrives as one, animation included. Calls match on kind and name as well as position, so a redraw that reordered the work is not read as one call growing.
The renderer only. The earlier store-level guard stays: a repaint now costs a re-read and a re-render rather than a rebuilt node, and an unchanged snapshot still has nothing to pay either for. Its comment, which stated the old measurement in the present tense, now says what is still true.
**Checked and deliberately not changed, for the reviewer:**
- `.in` stays on the rows. Taking the entrance animation off would also have hidden the symptom, but a genuinely new row arriving with a fade is the design; the defect was rows that were not new arriving as if they were.
- The provisional rows are still thrown away and redrawn. Identity is carried onto the new objects rather than the old objects being kept, so every other property of the redraw (toggles by position, the fold time, the turn count) is untouched. The existing fold-state case's `expect(again).not.toBe(first)` still holds, and its comment now says so.
- The added/removed counters in the probe are not zero on this change (3/3 per feed): that is the `.prose` body re-rendering as the text changes, inside the kept `.answer`. The animated element is the one that has to survive, and it does.
- Timing was not reproducible with the local model. Qwen3.6-35B-A3B on this box answers a 900-character essay in about ten seconds, two polls, so a live probe rarely caught a mid-answer poll; the mechanism was pinned on the renderer instead, which is also how the first report was measured. A slower endpoint, which the reporter is likely on, widens exactly that window.
- The released wheel `v0.1.13` (tagged 2026-08-24) predates the first flicker fix as well as this one. A reader installed from the wheel has neither guard; worth asking the reporter which build they are on.
## Type
- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
```
npm run test --prefix ui-web 101 files, 1537 passed (main: 1531; six added here, none introduced)
npm run type-check --prefix ui-web clean
npm run gen:check --prefix ui-web generated client matches the contract, 162 methods
scripts/check_commit_messages.py, commitlint, scripts/check_source_language.py, git diff --check pass over the branch
scripts/check_pr_body.py pass on this description
```
Six cases. Four at the store (`lane.test.ts`): the answer row keeps its id while the answer grows; a fold, its steps and their calls keep theirs when the next step arrives; steps a poll appended into an already-committed fold keep theirs; a row that changed kind gets a new one. Two at the DOM (`TranscriptPage.test.tsx`), because a kept id is only worth something if React keeps the element for it: the same `.answer` node across three growing feeds, and the same `.tfold .step` nodes with one new one after them.
Five mutations, each red on its own: the adoption past the prefix removed (4 cases); the adoption into a committed fold removed (1); the kind check dropped (1); steps inside a redrawn fold not carried (1); call ids not carried (1).
Real machine, this change's build served against a scratch `RAVEN_HOME`: the renderer probe above (third row of the table), and a live `Raven-Code` direct chat driven in headless Chromium with a `MutationObserver` on the pane -- the fold kept one element id across the whole run while its steps grew from one to two, where the same run on current main gave the fold a new id on every new message.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed (no user-facing docs describe this pane's repaint; nothing to update)
## Risk
User-visible: rows in a sub-agent pane stop re-animating while a run is in flight; nothing else on screen changes. Confined to `ui-web`'s transcript renderer, no wire or config change. Rollback is reverting the single squash commit; the pane returns to redrawing rows as new elements.
- [x] Security impact considered (none: a render-side identity handoff, no new data path)
- [x] Backward compatibility considered (the segment shape and every field but `id` are untouched; ids were never persisted or sent)
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
## Summary
The turn path's four strategy decisions become named seams the loop delegates
to, with no behaviour moving. Memory owns the turn's window, Planning passes
the turn's messages through, Capability reports what the tool registry offers,
and Action dispatches the one streaming-or-retrying model call the loop made
inline. The shell keeps everything that made the loop worth trusting:
iteration accounting, hook phases, tool execution and approval, the three
in-turn recoveries, persistence and event order.
This is the minimal step on purpose. The seam is what the change buys: those
four points can now be replaced without touching the loop's machinery. Widening
Action to own extract-and-verify (the three in-turn recoveries, a billing-wrapped
call service, a repair budget) is deliberately left for a follow-up, because
"reproduces the previous revision exactly" is provable for a single call and
much harder once several hundred lines move with it.
Key decisions:
- Memory is more than an adapter over the context engine. Two decisions that
sat in the shell move onto the role that owns them: which history slice is
even a candidate (it turns on whether the engine archives for itself), and
how much of the window a prompt may occupy (that window's own arithmetic).
organ_glue keeps both method names and forwards.
- Every input reaches a role through a callable, never a captured instance.
A live model switch rebuilds the provider and the window, and trajectory
replay rebinds loop.tools after the constructor returns. The context engine
is the exception and is bound directly: nothing rebinds it, and a
generation's window is its engine.
- contracts/harness.py is factory-loop tier beside loop_hooks, not the frozen
contract tier: a replacement loop may name its own strategy points, so these
four are this loop's rather than a cross-loop promise.
- Planning's seat is after the origin stamp, so a planner returning a different
list cannot move which message gets marked.
## Type
- [ ] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [x] Refactor
- [ ] Other
## Verification
Behaviour preservation was measured, not asserted. A full turn runs through a
real AgentLoop on a scripted provider (context assembly, a tool call, its
observation, the answer) and every provider request is recorded: model, sorted
tool names, message roles and contents, plus the final answer.
- Captured on this branch and twice on its parent commit. Raw diffs contain
only wrap_untrusted fence nonces, which are random per invocation; capturing
the parent twice shows those are the sole variance. After normalising them
all three files share one MD5.
- `uv run pytest tests/` on the branch and the same failures on the parent
commit, so nothing here introduces one.
- `uv run pytest tests/test_harness_modules.py` -- 23 new cases covering the
default set, the two decisions Memory took over, both Action paths, the
callable indirection, and the frozen module set.
- `uv run ruff check raven/ tests/` and `ruff format --check` clean.
- `uv run lint-imports` -- 9 contracts kept, with raven.agent.harness added to
the one that keeps cargo out of the loop shell.
- `make check-source-language` clean.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed
## Risk
No user-visible behaviour changes, which is the claim the capture comparison
above is there to support. The rollback path is the revert: the seam is
additive, the four defaults reproduce the inline code, and no caller outside
the loop reaches the new package.
The contracts line ceiling moves 2520 to 2730 for the new paper, reviewed in
test_kernel_budget's own docstring the way the previous move was. Without this
paper the package stands at 2515, five lines under the number it has been
passing on, so the ceiling is not absorbing unrelated growth.
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
## Summary
Reported as "deliver_files is broken". It is not: **the tool never ran.**
Every `deliver_files` call on one install was refused before dispatch -- five in a row in a single session -- and nothing was ever delivered:
```
Error: Invalid parameters for tool 'deliver_files': files should be array
```
What the model sent was the array, spelled as a string:
```json
{"files": "[{\"path\": \"...poster.png\", \"title\": \"...\"}]", "message": "..."}
```
`cast_params` already forgives that spelling for every scalar type -- `"3"` for an integer, `"true"` for a boolean -- and did not for arrays or objects, which are exactly the types a model is most likely to stringify.
## Type
- [x] Fix
- [ ] Feature
## The edge of the forgiving is the design
When the value is a string, try `json.loads`, and take the result **only if it is the type the schema asked for**. A string that is not JSON, or is JSON of the wrong shape, is returned unchanged so the validator still names the real problem -- the point is to widen what is accepted, not to swallow a type error.
**Nothing here can raise.** Turning "your argument has the wrong type" into a traceback would be worse than the refusal it replaces, so the parse is wrapped and failure falls through.
**A `type: "string"` field is never parsed.** JSON is ordinary text in a message body or a file's content, and replacing it would hand the tool something it never asked for. Two independent things prevent it today (the string branch returns before the parse is reached, and the parse only wins on a type match), which is why the case pinning it is a tripwire rather than a load-bearing assertion -- said so in its own docstring rather than left to look like coverage.
## Not just deliver_files
Six built-in tools declare an array or object parameter and were all exposed:
| tool | parameter |
|---|---|
| `deliver_files` | `files` |
| `ask_user` | `questions` |
| `image_generate` | `images` |
| `message` | `media` |
| `create_playbook` | `skills` |
| `video_generate` | `params` |
The same failure was already seen from the other side: `acp_client/acp_agent.py` records `update_task_state` and `operations should be array` from a real dispatch.
## Verification
```
make lint-python ruff check + ruff format --check, 1850 files
make lint-imports 9 contracts kept, 0 broken
pytest tests/ 19,699 passed, 7 failed (all pre-existing, see below)
```
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots -- no user-facing string
**End to end, through the real tool**, with the exact payload that failed five times in production:
```
files sent as: str -> [{"path": ".../poster.png", "title": "..."}]
returned: Delivered 1 file(s): poster.png (72 B).
still "should be array": False
registered in the store: True
```
Twelve cases, five mutations, each killing at least one:
| mutation | red |
|---|---|
| drop the whole branch (the old behaviour) | 3 |
| raise instead of falling through on a parse failure | 5 |
| accept the parse whatever type it yielded | 1 |
| do not re-cast the parsed value, so items are not cast | 1 |
| widen the tuple to include `string` | **survived -- unreachable** |
The last is worth stating rather than hiding: that mutation cannot change behaviour, because the `type == "string"` branch returns earlier and the type check would refuse the result anyway. I also tried moving the new block above that branch, alone and combined with widening the tuple, and neither reddens anything either. The invariant holds by construction; the case that documents it says so.
**Pre-existing failures, checked against the base.** 7 failed in the full run, all in `tests/test_security_network.py` (`test_a_redirect_to_a_dangerous_address_is_refused` and siblings). Running that file alone on this same tree gives 4 -- the count is order-dependent -- and the change touches only `raven/agent/tools/params.py` plus a new test file, neither of which `raven/security/network.py` imports. The failures are the box's resolver: it returns poisoned answers roughly half the time, which I measured separately (`en.wikipedia.org` came back as `2001::1` on 3 of 6 lookups). Not introduced here, and worth someone's attention on its own.
## Risk
- [x] Security impact considered -- widens what reaches a tool's own validation, not what bypasses it. A parsed value is still validated against the same schema, and a parse that yields the wrong type is refused exactly as before
- [x] Backward compatibility considered -- a call that worked before takes the identical path; the new branch is reached only by a `str` where an array or object is declared, which previously always failed
- [x] Rollback path is clear -- single-commit revert
## Related Issues
N/A
## Swept
`mr-review-patterns` pre-submit sweep, over `git diff origin/main...HEAD`.
- **1 (a write location moved)** -- nothing moved; a branch was added to an existing dispatch on `target_type`. Grepped every caller of `cast_params`: the registry is the only one, and it runs `validate_params` right after, which is the reader this affects.
- **2 (a value with several entry points)** -- the cast is the single funnel every tool argument passes through, which is why the fix belongs here and not in `deliver_files`.
- **3 (a guard)** -- checked both directions: what it wrongly lets through (JSON of the wrong type, non-JSON text -- both refused, with cases) and what it wrongly refuses (a real list, unaffected, with a case).
- **4 (tests)** -- five mutations above, one honestly reported as unreachable. Failing-ID sets diffed against the base rather than counts.
- **6 (stale text)** -- the module docstring enumerated what is coerced ("a string that should be an integer"); it now names arrays and objects too. Grepped the tracked tree for other statements of the rule: none.
- **9 (error handling)** -- the new path adds one way to end and it is caught: `json.loads` raises `ValueError` on bad text and `TypeError` on a non-string, and both fall through to the untouched value.
- **11** -- `git ls-files | grep -c node_modules` is 0; the commit-message gate was run, not eyeballed.
Not applicable, with reasons: **3b, 3c, 3d, 3e** (no tool schema produced, no state moved, one lane, no assertion lost its symbol); **4b, 4c, 4d** (no platform branch, no shell, no rendered number); **5, 5b** (no dependency; `json` is stdlib and already imported across this package); **6b, 6c** (no backup, no generated artifact); **7, 7b** (nothing on disk); **8** (no asset, no secret); **10** (no prompt text).
## Deliberately not fixed
The error text still ends with `[Analyze the error above and try a different approach.]`, and the model plainly did not -- it sent the same shape five times. A message naming the expected spelling (`files must be a JSON array, not a string containing one`) would give it something to act on. That is a change to the registry's error surface, affects every tool, and deserves its own argument.
## Moved from !594
Opened on a compliant source branch. AGENTS.md 2.1 asks for a 3-5 word snake_case description and the previous branch had seven; GitLab cannot change an existing merge request's source branch, so the change moves rather than the name.
Same commits, rebased onto `c2a9768f`. Both code findings from the review on !594 are already in them -- `RecursionError` caught with its regression case, and the implementation comment reduced to the two non-obvious reasons. Nothing else changed, so that review carries.
## Summary
Overhaul the interactive `raven trajectory` browser end to end, fixing
every
issue from real-terminal testing:
- Navigation: every screen opens with a help area under its title (page
purpose plus "[Key] function" hotkey hints, rendered in a new readable
help color). Esc walks one level up (action -> attempt -> session); on
the
top-level session screen Esc stays put and quitting is Ctrl+C only,
which
prints a single exit notice. Esc inside a running action cancels just
that
action through a dedicated exception at the action boundary, so the back
sentinel can never reach a conversion or the data layer; a cancelled
report keeps its pre-confirm bundle-and-pin side effects (the existing
declined-report contract). Back/Exit menu entries are gone; answered
prompts erase themselves and navigation is echoed as breadcrumb lines
with markup-escaped untrusted text.
- Tables: the session list is TITLE | ATTEMPTS | LAST ACTIVITY and the
attempt list is # | STARTED | TURNS | SPANS | VERDICT | PIN | MERGED |
PREVIEW with green check cells. Time cells keep the year. The layout is
budgeted per screen build from the live terminal width (row indent, a
safety margin, and inter-column gaps are all part of the math); PREVIEW
drops as a whole column when it no longer fits, and below the dynamic
minimum width the tightest layout is kept while the renderer clips
overlong lines at the terminal edge. Every dynamic cell passes a
single-line sanitization gate before width math (verdict sidecars only
guarantee a non-empty string), cells are measured and truncated by
terminal display width (CJK is 2 cells), and fixed column widths always
fit their headers.
- Space preview: Space on an attempt row prints that attempt's per-turn
input/output previews, collected in the same snapshot scan and sorted by
a fully-stringified key so ordering never follows log source order (the
table PREVIEW cell derives from the same sorted collection). Any key,
arrow keys included, returns with the cursor kept on the row; the waiter
passes the terminal's CPR reply through to the renderer instead of
treating it as a keypress, and Ctrl+C keeps the browser-wide cancel.
- Merge hotkey: with two or more attempts, m/M opens the multi-select
merge
(advertised in the help line; the old "Merge attempts" menu entry is
gone). The checkbox screen carries its own help line for toggle,
confirm,
and cancel. A single attempt neither binds nor advertises the key.
- Theme and feel: new success (green check) and help (readable hint
text)
colors in both palettes, all WCAG AA on their backgrounds; a lone ESC is
flushed after 50ms instead of prompt_toolkit's 0.5s default, removing
the
laggy Esc feel.
The data layer is untouched: changes are confined to
raven/cli/trajectory_browse.py, raven/cli/_theme.py, and their tests.
The
id-taking subcommands (raven trajectory save/list/...) behave as before.
## Type
- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
- `COLORTERM=truecolor uv run pytest tests/test_cli_theme.py
tests/test_cli_trajectory_browse.py
tests/test_cli_trajectory_commands.py -q` -> 220 passed
- `COLORTERM=truecolor uv run pytest tests/ --ignore=tests/integration
-q` -> 6917 passed; the 10 failed + 20 errors are the pre-existing
environment-dependent set, identical file-by-file on a clean main
checkout (cron, everos server, config loader, tracing viewer)
- `uv run ruff check` and `uv run ruff format --check` on the four
touched files -> clean
- PTY smoke on a CPR-answering pseudo terminal at 100 and 58 columns:
full flow (preview, merge cancel, action screen, staged Esc backout,
Ctrl+C quit) and the narrow-width degradation contract
- New coverage includes real pipe-input key-binding tests (Esc on all
four prompt kinds, Space/m/M hits, waiter key paths with CPR
pass-through), table budget/clipping boundaries at the computed minimum
width, and corrupt verdict/timestamp corpora
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed
## Risk
- The interactive browser's look and key protocol change wholesale (that
is
the point of this PR): Esc no longer quits from the top level (Ctrl+C
does), Back/Exit entries are gone, and lists render as tables. The
machine-facing subcommands and the trajectory data layer are untouched.
- Rollback: revert the squash commit; the browser returns to the
previous
interaction wholesale, no data migration involved.
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
---------
Co-authored-by: 江国庆 <guoqingjiang@deepglint.com>
Co-authored-by: Claude (claude-fable-5) <noreply@anthropic.com>
## Summary
Every third-party sub-agent in the web roster drew the same generic robot glyph.
Each row now wears its vendor's own mark.
The mark is chosen by preset key, never by the row's name: what a row draws is a
fact about the package behind it, and a configured row's name is the user's to
change. On the machine this was measured from, three of the thirteen rows are
renamed, so keying on the name would have left those three blank. A hand-written
row that merely spells itself `codex` gets the glyph instead, which is the
boundary `ACP_REGISTRY_INSTALL_HINTS` already draws for the same reason.
Twelve of the thirteen files are byte-identical to
`@lobehub/icons-static-svg@1.95.0`, the package the provider marks under
`ui-web/src/assets/providers/` already come from, so `cmp` settles the
attribution rather than trust, and `LICENSES/README.md` scopes that notice to
those twelve. The thirteenth is MiroMind's own mark, taken verbatim from its
favicon, and carries no third-party notice because none applies to it. There is
no new dependency: these are static assets, and `ui-web/build.py` already
copies the assets tree into the bundle.
An `<img>` resolves `currentColor` against the SVG's own document rather than
the page, so what a file draws in decides what the dark theme may do with it.
Three answers, each derived from the shapes in the file and held against them by
`tests/test_ui_agent_marks.py`:
- a file whose shapes all carry their own fill renders the same in both themes
and is filtered not at all;
- one drawn entirely in `currentColor` renders black, and is inverted, which is
what the provider marks already do;
- `qoder` mixes the two, brand green beside one adaptive tone. A plain invert
lifts the adaptive half correctly and takes the green with it (measured:
`#2ADB5C` to `#D524A3`), so it is inverted with the hue rotated back.
`kimi` takes the monochrome file although a colour one exists, for the
neighbouring reason: that file draws its letter in white for a dark tile it does
not carry, so on the light theme's near-white surface the whole mark disappears
and only its accent dot is left. Both cases were found by rendering the roster
in each theme, which is the only place either shows up.
One file answers the theme from inside itself: the MiroMind mark is a favicon
and carries a `prefers-color-scheme` rule. An `<img>` evaluates that against the
used colour-scheme of the element embedding it, not against the page's
`data-theme`, so it followed the operating system while the rest of the roster
followed the switch -- and since the app's default is explicitly light, a fresh
install on a dark OS was a normal way to see the mismatch. `color-scheme` is
declared on the tile, which puts that one file back in step; on `:root` it would
also hand every native scrollbar and form control to the dark palette, which is
a change to the page rather than to a mark.
The slot is one 20px framed tile, for a brand mark and for the generic glyph
alike, so a roster of presets and hand-written rows still starts its names at
one x. The frame is the idea `.provider-icon.fallback` already uses for a
provider with no icon, at this row's weight, and it is what makes thirteen logos
from thirteen houses read as one column; it also settles the MiroMind file,
which carries a rounded card of its own.
Deliberately left out, and disclosed rather than silent:
- Raven's own six built-in rows carry no preset and keep the generic glyph. The
five images already under `ui-web/src/assets/ravens/` are a natural follow-up;
widening the scope here was not.
- `ui-web/src/assets/providers/lmstudio.svg` and `nvidia.svg` are not from Lobe
Icons 1.95.0 (different formatting, different origin), while the licence line
attributes that whole directory to it. That pre-existing inaccuracy is
untouched here; the sentence rewritten for `agents/` scopes its byte-identity
claim to the twelve files it holds.
## Type
- [ ] Fix
- [x] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
Commands and their results, run on the rebased head:
```
npx vitest run --root ui-web src/shell/agent-mark.test.tsx \
scripts/agent-mark-css.test.mjs src/features/subagents/SubagentsPage.test.tsx
-> 3 files, 95 tests passed
uv run --frozen --python 3.12 --all-extras pytest -q tests/test_ui_agent_marks.py \
tests/test_ui_css_token_gate.py tests/test_hatch_build.py
-> 59 passed
node ui-web/scripts/check-css.mjs -> OK
node ui-web/scripts/check-page.mjs -> OK (1,311,021 bytes, 2 scripts parse)
make lint-python -> exit 0 (1,844 files formatted)
npm run gen:check --prefix ui-web -> generated.ts matches the contract (162 methods)
npm run type-check --prefix ui-web -> clean
npm run build --prefix ui-web && python3 ui-web/build.py -> 13 marks in dist/assets/agents
make check-large-files -> exit 0
make check-source-language -> exit 0
scripts/check_commit_messages.py origin/main..HEAD -> exit 0
```
Full `ui-web` suite, A/B against `origin/main` in a separate detached worktree,
same command and same interpreter:
```
origin/main 21 files failed | 76 passed (97) 367 tests failed | 1062 passed (1429)
this branch 21 files failed | 78 passed (99) 367 tests failed | 1075 passed (1442)
```
The failing-file sets are identical in both directions, so 0 introduced. Those
367 are a pre-existing environment failure on this machine, not this branch:
`happy-dom` under node v26 leaves `localStorage` undefined, and they are red at
`origin/main` too. The delta is 2 added files and 13 added passing tests, which
is exactly the count of tests this branch adds.
Every new assertion was checked against a mutation of the thing it guards, and
each one turns it red: reverting the `Object.hasOwn` lookup to a bare index;
spelling `qoder` as `mono`; spelling a monochrome file as `hybrid`; dropping the
hue rotation; making the invert blanket; deleting the invert rules; dropping the
slot's fixed width; keying the mark off the row's name instead of its preset;
deleting the two `color-scheme` declarations; and moving them from the tile to
`:root`, which is the app-wide version this deliberately avoids. The tree was
restored after each and the suites are green again.
Colours were read out of rendered screenshots rather than reasoned about. In the
light theme `qoder` renders `#2ADB5C`, the unfiltered brand green, and in the
dark theme `#008203`; a colour mark such as `claudecode` reads `#D97757` in both,
confirming no filter reaches it.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed
The last box is unchecked because no documentation describes the roster's glyph,
so there was nothing to update; the change is visual and was verified by
rendering rather than by prose.
## Risk
The roster's appearance changes and nothing else does. No behaviour, no wire
shape, no stored state: `SubagentRow.preset` was already on the wire and this is
its first front-end reader, so a row without one renders exactly as before.
Rollback is a revert of the single commit. The assets, the component and its
tests are additive, and the one edited call site returns to the glyph it drew
before.
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
On security: no dependency was added, no request is made, and no new input path
opened. The one guard the change introduces is a `hasOwn` lookup on the mark
table, so a preset name that collides with an inherited property (`constructor`,
`toString`, `__proto__`) resolves to nothing rather than to a truthy prototype
member. Nothing reaches that today, because `_resolve_preset_provenance` refuses
an unknown preset at config load; the guard is here because that refusal is in
another language with nothing tying it to this table, and it costs one call.
## Related Issues
N/A
## Summary
Every third-party sub-agent in the web roster drew the same generic robot glyph.
Each row now wears its vendor's own mark.
The mark is chosen by preset key, never by the row's name: what a row draws is a
fact about the package behind it, and a configured row's name is the user's to
change. On the machine this was measured from, three of the thirteen rows are
renamed, so keying on the name would have left those three blank. A hand-written
row that merely spells itself `codex` gets the glyph instead, which is the
boundary `ACP_REGISTRY_INSTALL_HINTS` already draws for the same reason.
Twelve of the thirteen files are byte-identical to
`@lobehub/icons-static-svg@1.95.0`, the package the provider marks under
`ui-web/src/assets/providers/` already come from, so `cmp` settles the
attribution rather than trust, and `LICENSES/README.md` scopes that notice to
those twelve. The thirteenth is MiroMind's own mark, taken verbatim from its
favicon, and carries no third-party notice because none applies to it. There is
no new dependency: these are static assets, and `ui-web/build.py` already
copies the assets tree into the bundle.
An `<img>` resolves `currentColor` against the SVG's own document rather than
the page, so what a file draws in decides what the dark theme may do with it.
Three answers, each derived from the shapes in the file and held against them by
`tests/test_ui_agent_marks.py`:
- a file whose shapes all carry their own fill renders the same in both themes
and is filtered not at all;
- one drawn entirely in `currentColor` renders black, and is inverted, which is
what the provider marks already do;
- `qoder` mixes the two, brand green beside one adaptive tone. A plain invert
lifts the adaptive half correctly and takes the green with it (measured:
`#2ADB5C` to `#D524A3`), so it is inverted with the hue rotated back.
`kimi` takes the monochrome file although a colour one exists, for the
neighbouring reason: that file draws its letter in white for a dark tile it does
not carry, so on the light theme's near-white surface the whole mark disappears
and only its accent dot is left. Both cases were found by rendering the roster
in each theme, which is the only place either shows up.
One file answers the theme from inside itself: the MiroMind mark is a favicon
and carries a `prefers-color-scheme` rule. An `<img>` evaluates that against the
used colour-scheme of the element embedding it, not against the page's
`data-theme`, so it followed the operating system while the rest of the roster
followed the switch -- and since the app's default is explicitly light, a fresh
install on a dark OS was a normal way to see the mismatch. `color-scheme` is
declared on the tile, which puts that one file back in step; on `:root` it would
also hand every native scrollbar and form control to the dark palette, which is
a change to the page rather than to a mark.
The slot is one 20px framed tile, for a brand mark and for the generic glyph
alike, so a roster of presets and hand-written rows still starts its names at
one x. The frame is the idea `.provider-icon.fallback` already uses for a
provider with no icon, at this row's weight, and it is what makes thirteen logos
from thirteen houses read as one column; it also settles the MiroMind file,
which carries a rounded card of its own.
Deliberately left out, and disclosed rather than silent:
- Raven's own six built-in rows carry no preset and keep the generic glyph. The
five images already under `ui-web/src/assets/ravens/` are a natural follow-up;
widening the scope here was not.
- `ui-web/src/assets/providers/lmstudio.svg` and `nvidia.svg` are not from Lobe
Icons 1.95.0 (different formatting, different origin), while the licence line
attributes that whole directory to it. That pre-existing inaccuracy is
untouched here; the sentence rewritten for `agents/` scopes its byte-identity
claim to the twelve files it holds.
## Type
- [ ] Fix
- [x] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
Commands and their results, run on the rebased head:
```
npx vitest run --root ui-web src/shell/agent-mark.test.tsx \
scripts/agent-mark-css.test.mjs src/features/subagents/SubagentsPage.test.tsx
-> 3 files, 95 tests passed
uv run --frozen --python 3.12 --all-extras pytest -q tests/test_ui_agent_marks.py \
tests/test_ui_css_token_gate.py tests/test_hatch_build.py
-> 59 passed
node ui-web/scripts/check-css.mjs -> OK
node ui-web/scripts/check-page.mjs -> OK (1,311,021 bytes, 2 scripts parse)
make lint-python -> exit 0 (1,844 files formatted)
npm run gen:check --prefix ui-web -> generated.ts matches the contract (162 methods)
npm run type-check --prefix ui-web -> clean
npm run build --prefix ui-web && python3 ui-web/build.py -> 13 marks in dist/assets/agents
make check-large-files -> exit 0
make check-source-language -> exit 0
scripts/check_commit_messages.py origin/main..HEAD -> exit 0
```
Full `ui-web` suite, A/B against `origin/main` in a separate detached worktree,
same command and same interpreter:
```
origin/main 21 files failed | 76 passed (97) 367 tests failed | 1062 passed (1429)
this branch 21 files failed | 78 passed (99) 367 tests failed | 1075 passed (1442)
```
The failing-file sets are identical in both directions, so 0 introduced. Those
367 are a pre-existing environment failure on this machine, not this branch:
`happy-dom` under node v26 leaves `localStorage` undefined, and they are red at
`origin/main` too. The delta is 2 added files and 13 added passing tests, which
is exactly the count of tests this branch adds.
Every new assertion was checked against a mutation of the thing it guards, and
each one turns it red: reverting the `Object.hasOwn` lookup to a bare index;
spelling `qoder` as `mono`; spelling a monochrome file as `hybrid`; dropping the
hue rotation; making the invert blanket; deleting the invert rules; dropping the
slot's fixed width; keying the mark off the row's name instead of its preset;
deleting the two `color-scheme` declarations; and moving them from the tile to
`:root`, which is the app-wide version this deliberately avoids. The tree was
restored after each and the suites are green again.
Colours were read out of rendered screenshots rather than reasoned about. In the
light theme `qoder` renders `#2ADB5C`, the unfiltered brand green, and in the
dark theme `#008203`; a colour mark such as `claudecode` reads `#D97757` in both,
confirming no filter reaches it.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed
The last box is unchecked because no documentation describes the roster's glyph,
so there was nothing to update; the change is visual and was verified by
rendering rather than by prose.
## Risk
The roster's appearance changes and nothing else does. No behaviour, no wire
shape, no stored state: `SubagentRow.preset` was already on the wire and this is
its first front-end reader, so a row without one renders exactly as before.
Rollback is a revert of the single commit. The assets, the component and its
tests are additive, and the one edited call site returns to the glyph it drew
before.
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
On security: no dependency was added, no request is made, and no new input path
opened. The one guard the change introduces is a `hasOwn` lookup on the mark
table, so a preset name that collides with an inherited property (`constructor`,
`toString`, `__proto__`) resolves to nothing rather than to a truthy prototype
member. Nothing reaches that today, because `_resolve_preset_provenance` refuses
an unknown preset at config load; the guard is here because that refusal is in
another language with nothing tying it to this table, and it costs one call.
## Related Issues
N/A
## Summary
A request carrying earlier assistant text is refused by the gateway:
```
HTTP 400: 3 validation errors for ValidatorIterator
0.ResponseOutputTextParam.annotations
Field required [type=missing, input_value={'type': 'output_text', …
```
`annotations` is required on a `ResponseOutputTextParam`. It is the reply's own field rather than a request one, so an assistant **message** being replayed has none to carry -- the empty list is the shape, not a placeholder. It was simply absent.
## What actually triggers it
Any request that carries earlier non-empty assistant text. That is broader than the case that found it:
- the second Iteration of a Turn whose first Iteration said something before calling a tool;
- equally, the **first** Iteration of every Turn after the first in a conversation, because the previous Turn's answer is replayed with it.
A post-tool Iteration is only affected when that assistant response included text. An assistant message with no text produces no `output_text` part at all and is not a case.
So the practical shape is: the first model call of a fresh conversation is fine, and a conversation that has said anything is refused from then on. The loop spends its three retries on it and hands the reader the validation error as the answer.
## Type
- [x] Fix
- [ ] Feature
## How it was found, and that it is not mine
Three separate attempts to drive a real turn on a live `raven serve` died here while I was verifying an unrelated branch. I deployed clean `origin/main` with the same probe and it reproduced identically -- five occurrences, same three retries -- so it is not the branch I was checking. The payload is built in `_convert_messages`, reached whenever the codex/Responses protocol is in force, and a local vLLM validates the param strictly.
## Verification
```
make test-python 19,856 passed, 141 skipped
make lint-python ruff check + format, clean
```
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
Five failures, all five identical on clean `origin/main` -- `test_doctor_answers_where_the_memories_are` and four NAT64 cases. Run on the base rather than inferred.
Two cases, one mutation: removing `"annotations": []` reds both. The second case pins the property **per message** rather than for the first one only, and that an assistant message with no text is not a case:
```
[user, assistant "first", user, assistant "second", assistant "" + tool_calls]
→ parts == ["first", "second"], every one with annotations == []
```
## Measured on a live `raven serve`
Before -- three attempts, each dying on the model call that replayed an earlier assistant message:
```
Tool call: spawn(…)
Tool result: … (35s)
Iteration 2/40 → HTTP 400: 3 validation errors … ×3 retries
Response to tui:user: Error calling LLM (unknown@custom): HTTP 400: …
```
After, deployed and driven through the browser -- a Turn that takes two tool calls and four Iterations:
```
04:04:05 Tool call: read_file {"path": "…/generate_rl_ppt.py", "limit": "3"}
04:04:16 Tool result: read_file
04:04:16 Iteration 2/40
04:04:21 Tool call: read_file {… "limit": "50"}
04:04:21 Iteration 4/40
04:04:26 Response to tui:user: 这个 Python 脚本 … 是一个**自动…
```
## Risk
- [x] Security impact considered -- one empty list added to a request body. Nothing is read, sent or logged that was not before
- [x] Backward compatibility considered -- `annotations` is a required field of the param this code already claims to be building, so a gateway that ignored its absence ignores its presence too
- [x] Rollback path is clear for risky changes -- one-line revert, and the failure it restores is loud
## Related Issues
N/A
## Summary
A request carrying earlier assistant text is refused by the gateway:
```
HTTP 400: 3 validation errors for ValidatorIterator
0.ResponseOutputTextParam.annotations
Field required [type=missing, input_value={'type': 'output_text', …
```
`annotations` is required on a `ResponseOutputTextParam`. It is the reply's own field rather than a request one, so an assistant **message** being replayed has none to carry -- the empty list is the shape, not a placeholder. It was simply absent.
## What actually triggers it
Any request that carries earlier non-empty assistant text. That is broader than the case that found it:
- the second Iteration of a Turn whose first Iteration said something before calling a tool;
- equally, the **first** Iteration of every Turn after the first in a conversation, because the previous Turn's answer is replayed with it.
A post-tool Iteration is only affected when that assistant response included text. An assistant message with no text produces no `output_text` part at all and is not a case.
So the practical shape is: the first model call of a fresh conversation is fine, and a conversation that has said anything is refused from then on. The loop spends its three retries on it and hands the reader the validation error as the answer.
## Type
- [x] Fix
- [ ] Feature
## How it was found, and that it is not mine
Three separate attempts to drive a real turn on a live `raven serve` died here while I was verifying an unrelated branch. I deployed clean `origin/main` with the same probe and it reproduced identically -- five occurrences, same three retries -- so it is not the branch I was checking. The payload is built in `_convert_messages`, reached whenever the codex/Responses protocol is in force, and a local vLLM validates the param strictly.
## Verification
```
make test-python 19,856 passed, 141 skipped
make lint-python ruff check + format, clean
```
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
Five failures, all five identical on clean `origin/main` -- `test_doctor_answers_where_the_memories_are` and four NAT64 cases. Run on the base rather than inferred.
Two cases, one mutation: removing `"annotations": []` reds both. The second case pins the property **per message** rather than for the first one only, and that an assistant message with no text is not a case:
```
[user, assistant "first", user, assistant "second", assistant "" + tool_calls]
→ parts == ["first", "second"], every one with annotations == []
```
## Measured on a live `raven serve`
Before -- three attempts, each dying on the model call that replayed an earlier assistant message:
```
Tool call: spawn(…)
Tool result: … (35s)
Iteration 2/40 → HTTP 400: 3 validation errors … ×3 retries
Response to tui:user: Error calling LLM (unknown@custom): HTTP 400: …
```
After, deployed and driven through the browser -- a Turn that takes two tool calls and four Iterations:
```
04:04:05 Tool call: read_file {"path": "…/generate_rl_ppt.py", "limit": "3"}
04:04:16 Tool result: read_file
04:04:16 Iteration 2/40
04:04:21 Tool call: read_file {… "limit": "50"}
04:04:21 Iteration 4/40
04:04:26 Response to tui:user: 这个 Python 脚本 … 是一个**自动…
```
## Risk
- [x] Security impact considered -- one empty list added to a request body. Nothing is read, sent or logged that was not before
- [x] Backward compatibility considered -- `annotations` is a required field of the param this code already claims to be building, so a gateway that ignored its absence ignores its presence too
- [x] Rollback path is clear for risky changes -- one-line revert, and the failure it restores is loud
## Related Issues
N/A
## Summary
Four sub-agent orchestration defects found on 2026-09-08 while running the research
sub-agent from the TUI and the page; all share one root, the host loop not seeing what
its sub-agents are doing right now.
1. A sub-agent's result relay into a page session ran on the gateway spine while the
page's own turns to that session ran on the RPC spine, so a relay and a user turn ran
at once: the same tool calls were drawn twice and the result delivered twice, and
`turn.send`'s one-turn-per-session guard saw neither. The RPC stack now exposes its
turn scheduler (`RpcStack.turn_scheduler`, surfaced on `PageMount.submit`), and
`raven.gateway.submit_router.route_submit` hands turns whose conversation carries
the page prefix (`tui:`) to the page lane and everything else to the gateway lane.
The sub-agent manager and the deep-research submit both take the routed callable;
a gateway without a page keeps the gateway submit unchanged.
2. The watch-work judgement (one model call on a turn's first look) was paid on relay
and sentinel turns, whose "last user message" is the runtime's re-injected report,
and ran unbounded: one relay turn spent 1229 seconds in it on a reasoning runaway.
The turn's origin now reaches the loop; a re-injected origin (SUBAGENT, SENTINEL)
reads as no request, and the judgement is cut at 60 seconds and treated as no
verdict. CRON and heartbeat turns are deliberately still judged: their text is the
owner's own instruction.
3. The direct-chat handoff recorded a turn only when it landed, so an instance the user
was mid-conversation with rendered to the main agent as "no turns yet"; the model
read that as free and spawned onto it. The handoff now reads the manager's live
direct turns (`live_direct_turns`) and renders an answering instance with the time
it began answering (handle lock held) and a line saying it is the user's conversation. The spawn that lands
behind such a turn no longer writes `running` before it holds the handle lock (it
stays the `pending` it was announced as), and no longer takes over the instance's
live view: `activity.watching_instance` registers only when the slot is free and
pops only what it registered, so the direct chat's steps stay on screen and the
spawn's appear once it runs.
4. When reasoning ran to the model's output ceiling with no content and the
empty-response recovery fed it back as a prefill, the continuation opened on the
rest of the cut thought and that fragment streamed and was stored as the head of the
answer. `cut_reasoning_head` drops an opening fragment that starts in lowercase or
whitespace and ends at the first sentence or line boundary within 200 characters;
`ContinuationGate` holds streamed deltas until the same rule can decide, so what the
reader sees matches what the session stores. Only a continuation after
ceiling-cut reasoning (`finish_reason == "length"`) is treated this way.
Decisions worth knowing:
- The `tui:` prefix is spelled in `raven.gateway.submit_router` and as
`RoutingQuestionBroker`'s default; the layer contract keeps `raven.gateway` from
importing `raven.rpc`, so a test holds the two equal instead of one importing the
other.
- The gateway wiring has no import seam, so its test pins the source of the mounted
block, the same way the neighbouring cron-partition test does.
- The `subagent.status` payload shape is unchanged; only the `running` frame's timing
moved (after the handle lock). The page's spawn card reads identity from `pending`
and the record id from `running`, both still present.
- A CJK boundary class in the head-cut regex is spelled as escapes because the
source-language gate reads the literal marks as non-English source.
Review round 1 (all findings non-blocking, all taken):
- The lane key is now one definition, `raven.spine.conversation_id`; the scheduler's
method, the rpc spine and the submit router call it, and the router test pins the
identity and compares against the scheduler's method instead of literals.
- The loop's wiring of the handoff to the manager's live turns has its own test (a bare
`DirectChatHandoff()` went green before).
- `activity.live_instances_of` is gone: nothing called it.
- The watch-work judgement now reads any exception as no verdict, not only a timeout.
The enclosing handler already kept the turn alive, but left the verdict unset, so a
failing judgement was paid again on every path-touching tool call; the comment that
claimed a raise was handled is corrected.
- A direct chat's start time is stamped once the handle lock is held, not when the slot
is claimed, so a chat queued behind another holder is not reported as answering.
- The continuation cut deliberately leaves a continuation that opens directly on CJK
whole (no case, so no mid-sentence signal); the comment and a test now say that the
CJK stops end an admitted fragment rather than open one.
## Type
- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
```
uv run pytest tests -q -p no:cacheprovider -n 8 --ignore=tests/integration
-> 7 failed, 19705 passed, 153 skipped. The same 7 fail on a detached origin/main
worktree through the same interpreter (doctor memories path 1, NAT64 resolution 4,
design-engine rendering 2): 0 introduced.
uv run pytest tests/test_agent_loop_empty_recovery.py tests/test_watch_work.py \
tests/test_gateway_submit_router.py tests/test_subagent_activity.py \
tests/test_subagent_handoff.py tests/test_subagent_direct_chat.py \
tests/test_rpc_bootstrap.py tests/test_cli_gateway_page.py tests/test_cli_gateway_commands.py
-> 279 passed (before round 1); round 1 adds 5 tests and removes 1, see the pipeline
uv run ruff check raven tests; uv run ruff format --check raven tests -> clean
uv run lint-imports -> 9 kept, 0 broken
make check-source-language -> exit 0
scripts/check_commit_messages.py origin/main..HEAD -> exit 0
```
Red-checked (fix reverted, test goes red, fix restored): activity.py alone reverted
-> `a second lane never unseats the first`; the spawn-path hunk of manager.py alone reverted
-> `['pending', 'running'] == ['pending']`; turn_path.py alone reverted -> the continuation
test sees the `Lagg in an token` head. Round 1: the handoff wiring test goes red on a bare
`DirectChatHandoff()`; the queued-direct-chat test goes red with the stamp back on the slot;
the raising-judgement test goes red with the narrow catch (two calls instead of one). The other new tests fail without their change by
construction (missing symbol or signature), which proves less and is noted as such.
Live check of the shipped page: the served `ui-web/dist` bundle booted under happy-dom in
stub and live mode against a gateway running this branch, desk mounted, no console
errors; `subagents.list` and `subagents.instances` answer as before.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed (CHANGELOG, CONTEXT.md
Handoff Block)
## Risk
- A relay into a page session now waits behind the page's running turn on that session
instead of running beside it. That is the intended serialisation; the cost is latency
on a relay while a long page turn runs.
- A judgement that takes over 60 seconds is dropped and the turn runs unwatched for
that turn only; before, the same turn hung. No configuration knob: the bound is a
class attribute.
- The head cut only runs on the continuation after a ceiling-cut prefill. A
continuation whose intended answer begins with a lowercase word and a full stop within
200 characters would lose that first clause; the test file names the shapes kept.
- Rollback: revert the squash commit. No persisted format changes.
- [x] Security impact considered (no new surface; routing stays in-process)
- [x] Backward compatibility considered (payload shapes unchanged; a gateway without a
page mount is unaffected)
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
## Summary
Four sub-agent orchestration defects found on 2026-09-08 while running the research
sub-agent from the TUI and the page; all share one root, the host loop not seeing what
its sub-agents are doing right now.
1. A sub-agent's result relay into a page session ran on the gateway spine while the
page's own turns to that session ran on the RPC spine, so a relay and a user turn ran
at once: the same tool calls were drawn twice and the result delivered twice, and
`turn.send`'s one-turn-per-session guard saw neither. The RPC stack now exposes its
turn scheduler (`RpcStack.turn_scheduler`, surfaced on `PageMount.submit`), and
`raven.gateway.submit_router.route_submit` hands turns whose conversation carries
the page prefix (`tui:`) to the page lane and everything else to the gateway lane.
The sub-agent manager and the deep-research submit both take the routed callable;
a gateway without a page keeps the gateway submit unchanged.
2. The watch-work judgement (one model call on a turn's first look) was paid on relay
and sentinel turns, whose "last user message" is the runtime's re-injected report,
and ran unbounded: one relay turn spent 1229 seconds in it on a reasoning runaway.
The turn's origin now reaches the loop; a re-injected origin (SUBAGENT, SENTINEL)
reads as no request, and the judgement is cut at 60 seconds and treated as no
verdict. CRON and heartbeat turns are deliberately still judged: their text is the
owner's own instruction.
3. The direct-chat handoff recorded a turn only when it landed, so an instance the user
was mid-conversation with rendered to the main agent as "no turns yet"; the model
read that as free and spawned onto it. The handoff now reads the manager's live
direct turns (`live_direct_turns`) and renders an answering instance with the time
it began answering (handle lock held) and a line saying it is the user's conversation. The spawn that lands
behind such a turn no longer writes `running` before it holds the handle lock (it
stays the `pending` it was announced as), and no longer takes over the instance's
live view: `activity.watching_instance` registers only when the slot is free and
pops only what it registered, so the direct chat's steps stay on screen and the
spawn's appear once it runs.
4. When reasoning ran to the model's output ceiling with no content and the
empty-response recovery fed it back as a prefill, the continuation opened on the
rest of the cut thought and that fragment streamed and was stored as the head of the
answer. `cut_reasoning_head` drops an opening fragment that starts in lowercase or
whitespace and ends at the first sentence or line boundary within 200 characters;
`ContinuationGate` holds streamed deltas until the same rule can decide, so what the
reader sees matches what the session stores. Only a continuation after
ceiling-cut reasoning (`finish_reason == "length"`) is treated this way.
Decisions worth knowing:
- The `tui:` prefix is spelled in `raven.gateway.submit_router` and as
`RoutingQuestionBroker`'s default; the layer contract keeps `raven.gateway` from
importing `raven.rpc`, so a test holds the two equal instead of one importing the
other.
- The gateway wiring has no import seam, so its test pins the source of the mounted
block, the same way the neighbouring cron-partition test does.
- The `subagent.status` payload shape is unchanged; only the `running` frame's timing
moved (after the handle lock). The page's spawn card reads identity from `pending`
and the record id from `running`, both still present.
- A CJK boundary class in the head-cut regex is spelled as escapes because the
source-language gate reads the literal marks as non-English source.
Review round 1 (all findings non-blocking, all taken):
- The lane key is now one definition, `raven.spine.conversation_id`; the scheduler's
method, the rpc spine and the submit router call it, and the router test pins the
identity and compares against the scheduler's method instead of literals.
- The loop's wiring of the handoff to the manager's live turns has its own test (a bare
`DirectChatHandoff()` went green before).
- `activity.live_instances_of` is gone: nothing called it.
- The watch-work judgement now reads any exception as no verdict, not only a timeout.
The enclosing handler already kept the turn alive, but left the verdict unset, so a
failing judgement was paid again on every path-touching tool call; the comment that
claimed a raise was handled is corrected.
- A direct chat's start time is stamped once the handle lock is held, not when the slot
is claimed, so a chat queued behind another holder is not reported as answering.
- The continuation cut deliberately leaves a continuation that opens directly on CJK
whole (no case, so no mid-sentence signal); the comment and a test now say that the
CJK stops end an admitted fragment rather than open one.
## Type
- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
```
uv run pytest tests -q -p no:cacheprovider -n 8 --ignore=tests/integration
-> 7 failed, 19705 passed, 153 skipped. The same 7 fail on a detached origin/main
worktree through the same interpreter (doctor memories path 1, NAT64 resolution 4,
design-engine rendering 2): 0 introduced.
uv run pytest tests/test_agent_loop_empty_recovery.py tests/test_watch_work.py \
tests/test_gateway_submit_router.py tests/test_subagent_activity.py \
tests/test_subagent_handoff.py tests/test_subagent_direct_chat.py \
tests/test_rpc_bootstrap.py tests/test_cli_gateway_page.py tests/test_cli_gateway_commands.py
-> 279 passed (before round 1); round 1 adds 5 tests and removes 1, see the pipeline
uv run ruff check raven tests; uv run ruff format --check raven tests -> clean
uv run lint-imports -> 9 kept, 0 broken
make check-source-language -> exit 0
scripts/check_commit_messages.py origin/main..HEAD -> exit 0
```
Red-checked (fix reverted, test goes red, fix restored): activity.py alone reverted
-> `a second lane never unseats the first`; the spawn-path hunk of manager.py alone reverted
-> `['pending', 'running'] == ['pending']`; turn_path.py alone reverted -> the continuation
test sees the `Lagg in an token` head. Round 1: the handoff wiring test goes red on a bare
`DirectChatHandoff()`; the queued-direct-chat test goes red with the stamp back on the slot;
the raising-judgement test goes red with the narrow catch (two calls instead of one). The other new tests fail without their change by
construction (missing symbol or signature), which proves less and is noted as such.
Live check of the shipped page: the served `ui-web/dist` bundle booted under happy-dom in
stub and live mode against a gateway running this branch, desk mounted, no console
errors; `subagents.list` and `subagents.instances` answer as before.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed (CHANGELOG, CONTEXT.md
Handoff Block)
## Risk
- A relay into a page session now waits behind the page's running turn on that session
instead of running beside it. That is the intended serialisation; the cost is latency
on a relay while a long page turn runs.
- A judgement that takes over 60 seconds is dropped and the turn runs unwatched for
that turn only; before, the same turn hung. No configuration knob: the bound is a
class attribute.
- The head cut only runs on the continuation after a ceiling-cut prefill. A
continuation whose intended answer begins with a lowercase word and a full stop within
200 characters would lose that first clause; the test file names the shapes kept.
- Rollback: revert the squash commit. No persisted format changes.
- [x] Security impact considered (no new surface; routing stays in-process)
- [x] Backward compatibility considered (payload shapes unchanged; a gateway without a
page mount is unaffected)
- [x] Rollback path is clear for risky changes
## Related Issues
N/A
## Summary
Observed on a real run, and the sequence is the whole argument for this change.
Three approvals expired unanswered in a row. The model was told `User denied this action`, so it stopped asking, went looking for another way, and finished by telling the reader:
> 抱歉,PPT 制作任务遇到了系统错误。让我尝试用另一种方式来完成这个任务。
Nothing had been refused. And nothing on the page said an approval had lapsed: the sheet closed exactly the way an answered one closes. The reader saw a task announce a system error for no reason they could see, and then hand over the wrong file.
Both halves of that were an existing signal being thrown away.
## What was already known and unused
**The backend knew.** `ApprovalBroker` distinguishes a timeout from a click internally -- `close_reason` is `"timeout"`, `"error"`, or the choice -- and then returns the same `ApprovalOutcome(DENY)` for all of them. Failing closed is right; sharing one sentence is not. `AcpPermissionBroker` keeps an even finer tally (eleven names for "no answer": `no-session`, `connection-closed`, `timeout`, `malformed`, …) and flattens it the same way at the door.
**The page knew.** `approval.closed` has always carried `reason`. The handler read `approval_id` and dropped the rest.
## Type
- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## The change
`ApprovalOutcome` gains `answered`, defaulted true so a transport that predates the field keeps meaning what it meant. It is false on the RPC broker's timeout and transport-error paths, and on every ACP outcome that is not `allowed` or `rejected`.
The gate then says the two differently:
```
Error: This action needed the user's approval, and the request expired with no
answer. Nobody refused it. Tell the user the approval lapsed and ask whether to
retry; do not repeat this call in this turn, and do not look for another way
around it.
```
A real refusal keeps `Error: User denied this action.` and its feedback.
**The second ask needed fixing too.** A lapsed digest went into `denied_digests`, so a retry within the turn was answered `User denied this action earlier in the current turn` -- the same false sentence, one step further down. `lapsed_digests` is the subset nobody answered, and the repeat message for it is true. Both still suppress the second ask: a request that expired unseen will expire again, and forty iterations of a 35-second wait is a turn spent waiting rather than working.
**On the page**, a close nobody chose now says so. The three a reader caused stay quiet -- telling someone what they just did is noise. It is not scoped to the conversation on screen: a request that lapsed elsewhere stalled that run just as completely, and the reader is the only person who can unstick either.
## Measured on the running page, end to end
The branch was deployed to a live `raven serve`, a command needing approval was sent, and the sheet was deliberately left alone.
```
+0.0s sent: 请执行这条命令:rm -rf /tmp/appr-probe-dir
+1.7s Tool call: exec({"command": "rm -rf /tmp/appr-probe-dir"})
+2.0s the approval sheet is on screen
+37.2s "An approval request expired unanswered - the action did not run"
```
What the model was handed, from the server log:
```
Tool result: exec duration=35004ms result=Error: This action needed the user's
approval, and the request expired with no answer. Nobody refused it. …
```
And what it then told the reader:
> 抱歉,这条命令需要您的批准才能执行,但批准请求已过期。
Against the run at the top of this description, which is the same lapse before the change, that is the whole of the difference.
## Review round two: every no-answer producer
The first revision propagated the distinction through two of five producers. Review caught the other three, and each of them reached the gate spelled exactly like a person choosing Deny.
- **`ApprovalViaAsk`**, the responder every gateway channel uses: `None` for a round trip the turn cannot make and `""` for the ask timing out or being skipped. A Telegram agent was told the user had refused when the user had never been reached.
- **`ApprovalBroker.cancel_all`**, whose synthetic `"cancelled"` is not a wire choice and lands in the same `ValueError` fallback as a client sending something outside the enum. A turn torn down mid-approval reported a refusal nobody made.
- **The terminal countdown**, which answered `deny` of its own accord at zero. Not a propagation gap but the place a lapse was *manufactured* into a refusal: the runtime's hard ceiling sits a few seconds past the visible deadline precisely so it can be the party that decides, and answering first took the decision away from it. It now answers nothing; `approval.closed` clears the overlay, which it already did, and a key pressed inside that remaining window is still a real answer and still lands.
That last one retires a hazard rather than re-testing it. The expiry callback had to carry the rendered prompt's id so a queued one could not refuse a replacement request nobody had been shown; with no callback there is nothing to mis-target. The case is kept, saying so.
## Measured both ways on a live `raven serve`
The branch and clean `origin/main` deployed in turn, same probe, same machine — an approval raised and deliberately left alone:
```
sheet lapse notice
origin/main +2.0s never
this branch +2.0s +37.2s
```
All four model-facing sentences, on the deployed branch:
```
lapsed, first ask Error: This action needed the user's approval, and the request
expired with no answer. Nobody refused it. …
lapsed, second ask Error: This action was already sent for approval in this turn
and the request expired with no answer. …
refused, first ask Error: User denied this action. The user said: "…"
refused, second ask Error: User denied this action earlier in the current turn
```
And the five no-answer producers against the installed code: gateway-unreachable, gateway-empty, `cancel_all` and the backend hard timeout all answer `deny / answered=False`; a real `Deny`, with and without a note, answers `deny / answered=True`.
## Verification
```
make test-python 19,970 passed, 143 skipped
make test-tui 140 files, 2,014 passed
make test-ui 98 files, 1,445 passed
make lint-python ruff check + format, clean
make lint-ui gen:check 162 methods, type-check
make lint-tui lint, lint:rpc, lint:i18n, type-check
```
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed -- the new string is in `i18n/messages.json` in both locales, with `ui-tui/src/i18n/messages.generated.ts` regenerated
**Five tests failed, and all five fail identically on `origin/main`** -- `test_doctor_answers_where_the_memories_are` and four NAT64 cases in `test_security_network.py`. Checked on the clean base rather than inferred from their names.
Ten mutations, each killing at least one case:
| mutation | red |
|---|---|
| the page stops reading `reason` | 2 |
| the page toasts on every close | 1 |
| broker: drop `answered=False` on the timeout path | 1 |
| broker: drop it on the transport-error path | 1 |
| ACP: drop the `_ANSWERED` distinction | 2 |
| gate: stop recording `lapsed_digests` | 1 |
The transport-error path **survived my first pass** -- the existing `test_send_failure_denies_request` asserted the verdict and not who gave it -- and the case now asserts both. The page's handler is driven through the **assembled** live layer, because `live/*.js` are fragments of one IIFE that cannot be imported and a copied handler would go on passing after the shipped one changed.
## Two guards stopped me, and both were right
`raven/contracts/permissions.py` is a contract paper.
- **The line ceiling.** 2,506 against 2,500. Rather than raise a ceiling the test explicitly says is a reviewed change and not a bump in passing, the reasoning moved to the gate, where the branch it explains actually lives; the paper carries one clause. It is at 2,500 now.
- **The surface digest.** Adding a field moved the declared surface, which is exactly what that gate is for: `CONTRACTS_VERSION` 12 → 13 and `PINNED_CONTRACT_SURFACE` repinned.
## Risk
- [x] Security impact considered -- nothing is allowed that was refused before. Every path that failed closed still fails closed; only the sentence describing it changed, and one new field says which kind of close it was. `answered` defaults true, so a transport this MR does not touch cannot accidentally start reporting lapses
- [x] Backward compatibility considered -- one defaulted field on a frozen dataclass, one new set on a per-turn object, one new i18n key, and a handler that reads a field the frame already carried. No wire method, schema or RPC signature changed
- [x] Rollback path is clear for risky changes -- single-commit revert, including the contract version bump; nothing persists across it
## Related Issues
N/A
## Swept
`mr-review-patterns` pre-submit sweep, over the branch diff.
- **1 (a write location moved)** -- nothing moved. `turn.denied_digests.add` still happens for every refusal; `lapsed_digests` is written beside it, never instead of it, so the dedup this change reasons about is the one that was already there.
- **2 (a value with several entry points)** -- `ApprovalOutcome` has three producers: the RPC broker, the ACP broker, and test stubs. All three were visited; the default keeps stubs meaning what they meant, and both real ones now set the field on every path they own.
- **3d (several lanes through one sink)** -- two transports into one gate, which is why the ACP side is in this MR: leaving it flattened would have the gate word an ACP lapse as a refusal while wording an RPC one correctly.
- **4** -- failing test IDs diffed against the base, not counts: 0 introduced, 5 pre-existing and named above.
- **6b (both states)** -- both read: a lapse and a real refusal each have a case, on the model-facing text and on the page.
- **9 (error handling)** -- the transport-error path is deliberately `answered=False` rather than a third kind: from the reader's and the model's side, a request that never arrived and one nobody saw are the same fact, and inventing a third sentence for it would be a distinction neither can act on.
- **11** -- `uv run --frozen` and `npm ci` in both front ends; this worktree was fresh.
Not applicable: 3, 3b, 3c, 3e, 4b-4d, 5, 5b, 6, 6c, 7, 7b, 8, 10.
## What
Adds a `RAVEN_WHEEL_SLIM=1` build switch to `hatch_build.py`: when set, the wheel build skips the vendored sub-agent tree and the prebuilt TUI/web bundle inclusion. Default builds are byte-identical to before.
## Why
The release wheel is ~106 MiB compressed; ~94% is the `subagents/` snapshots (raven-ppt alone carries 74 MiB of `.pptx` templates and fonts) plus UI bundles. A cloud provisioner that only ever runs `raven acp` inside a sandbox uploads all of that per instance for assets nothing there opens. The slim wheel is ~3.0 MiB with the full python package intact, cutting sandbox provisioning upload from 15-23s to under a second.
## Behavior on slim installs
- Sub-agents: absent by design; onboarding step 5 reports no tree (headless installs never reach it). Their own distribution channel is future work.
- `raven tui` / `raven serve`: fall back to the source-checkout resolvers exactly as a dev build without prebuilt bundles does today; headless installs never call them.
## Verified
- `RAVEN_WHEEL_SLIM=1 uv build --wheel` -> 3.0 MiB wheel, 734 files, `raven/acp` complete, no `raven/subagents` or UI dist entries.
- The slim wheel provisioned a real E2B-compatible sandbox and served a full `raven acp` session end to end (delegated task with shell execution, ask_user elicitation round trip, multi-turn session continuity).
- Default build without the variable is unchanged.
## What
Adds a `RAVEN_WHEEL_SLIM=1` build switch to `hatch_build.py`: when set, the wheel build skips the vendored sub-agent tree and the prebuilt TUI/web bundle inclusion. Default builds are byte-identical to before.
## Why
The release wheel is ~106 MiB compressed; ~94% is the `subagents/` snapshots (raven-ppt alone carries 74 MiB of `.pptx` templates and fonts) plus UI bundles. A cloud provisioner that only ever runs `raven acp` inside a sandbox uploads all of that per instance for assets nothing there opens. The slim wheel is ~3.0 MiB with the full python package intact, cutting sandbox provisioning upload from 15-23s to under a second.
## Behavior on slim installs
- Sub-agents: absent by design; onboarding step 5 reports no tree (headless installs never reach it). Their own distribution channel is future work.
- `raven tui` / `raven serve`: fall back to the source-checkout resolvers exactly as a dev build without prebuilt bundles does today; headless installs never call them.
## Verified
- `RAVEN_WHEEL_SLIM=1 uv build --wheel` -> 3.0 MiB wheel, 734 files, `raven/acp` complete, no `raven/subagents` or UI dist entries.
- The slim wheel provisioned a real E2B-compatible sandbox and served a full `raven acp` session end to end (delegated task with shell execution, ask_user elicitation round trip, multi-turn session continuity).
- Default build without the variable is unchanged.
Three hygiene gaps the completeness audit named, closed the way this repo
guards its seats -- the roster beside the assertion, so growth is a reviewed
change rather than a drift:
- raven/contracts had no size budget while spine's ceiling guarded the kernel
alone; the papers get their own line ceiling (1,922 measured, 2,500 ruled)
in the same budget file the reviewer already reads.
- the factory_loop tier says "versioned with the factory loop", but the hook
vocabulary grew five context fields and a phase with no number moving;
loop_hooks now declares FACTORY_LOOP_SURFACE_VERSION (2) and the hook
contract tests pin the field and phase rosters to it, so growing one without
the other is red.
- ServiceLocator, RuntimeHandles and PluginManifest are promises to plugins
that outlive any host refactor (everos-memory is its own distribution, the
bundled shelf rides the same shapes), but lived outside every ledger; a
contribution-surface ledger pins their grants, kinds, frozenness, and the
two decline shapes.
Co-authored-by: Claude (claude-fable-5) <noreply@anthropic.com>
Two guards kept a second copy of the thing they check. The L3 open-world guard
walked fifteen hand-listed inner packages while the import-linter contract
seated thirty-one, so half the inner tree was never scanned for module-level
knowledge of shelf cargo. It reads the contract now, the way the L4 guard
already does, and walks single-module seats such as raven/home.py too. The
wider walk finds one edge: core/eval_stack.py names the eval engine at module
level. Whether that stack gets wired or dissolved is a product ruling still
open, so the edge sits on a ledger the guard also checks is still real, rather
than being hidden by leaving the assembly root off the roster.
The socket conformance suite checked seven response members while the provider
paper declares ten. The tuple is derived from the paper's dataclass fields, so
a member the paper adds is checked the day it lands; the seven the campaign
measured stay pinned as the floor the paper may not drop below, and every
declared member must draw blood in the mutation audit, not just the three that
killed the seven-swap runs.
The L0 booklet froze a budget for raven/spine and measured it true by hand, but
no guard carried it. tests/test_kernel_budget.py does: at most 2,000 lines, no
import of another raven package, no third-party name but loguru, no
TODO/FIXME/HACK. The thresholds are constants with the booklet's reasoning
beside them, because a tight number keeps its authority only while raising it
is a reviewed change and not a bump in passing.
Four sentences had outlived what they described. The kernel contract's comment
still explained three lazy edges that closed when the span vocabulary moved to
raven/observability and RAVEN_HOME resolution to raven/home.py; it says the set
carries no exceptions and why. The two-tier ledger, the papers' package
docstring and the glossary all placed a turn contract among the seven shapes in
raven/contracts, where there is none: the turn contract is spine's, the
re-export paper that once stood in for it is gone, and the contract tier is
every paper stamped so.
Co-authored-by: Claude (claude-fable-5) <noreply@anthropic.com>