174 Commits

Author SHA1 Message Date
userName20260323
259d1f52fc
fix(*): regenerate sub-agent prompt files on every launch (#987)
## Summary

The research, code, oncall and ppt agents keep prompt files in their
workspace that the model reads on every turn:
`agent_memory/profile/soul.md`, `agent_memory/profile/agent.md` and
`TOOLS.md`. They were written only when absent (`seed_once`), so after a
raven upgrade or a config change the model kept reading the text of the
first launch while the gates enforced the current release. A
Raven-Research install seeded before the reader layout still asked the
model for the `## Answer` / `## Findings` / `## Limitations` report
while its shape gate checked the reader layout.

These files are now generated output:

- `write_generated()` in `raven/config/product_render.py` rewrites a
product-owned file from the release and the rendered config on every
launch.
- An operator's own lines go in the sibling `*.local.md` file
(`agent_memory/profile/agent.local.md`, `soul.local.md`,
`TOOLS.local.md`) and are appended after the product text at the next
launch. They must be UTF-8: one in another encoding (an editor's legacy
code page, GBK for example) raises a decode error that names the
`*.local.md` and asks for UTF-8, rather than one naming the generated
file.
- A receipt beside each file (`.<name>.generated.sha256`) records
`<owner> <digest>` for the last text written. A file the caller's own
receipt lines do not name (edited in place, written by another product,
or left by an older release) is backed up to `<name>.bak-<time>-<pid>`
before it is replaced, and the log says which of those it is when the
receipt can tell. A backup is never readable by more accounts than the
original: on POSIX an owner-only copy; on Windows, where a new file
takes its folder's inherited ACL whatever mode it is created with, a
hard link to the file itself, so it keeps the file's security descriptor
and no bytes are written. A Windows volume that cannot hard-link refuses
the backup, and a failed backup leaves the file untouched. While the
target changes, the receipt names both texts, so a failure between the
two writes never leaves a file the next launch cannot recognise.
- `product_text=None` (raven-code's `CODE_CONDUCT=off`) removes only a
file this product wrote; an edited one, or another product's file and
receipt, is left alone.
- The launchers pass `adopt=True`, since their home is the product's own
ACP home, and refuse to start with the file named when a prompt cannot
be written. On a raven without `write_generated` they fall back to
seeding once and log that the file will not be refreshed.
- The ppt engine writes into whatever home its plugin is granted, which
can be a host's or another product's, so it passes `adopt=False`: it
replaces only a seat its own receipt, or the digest of a prompt it has
shipped, shows it wrote. A test fails when a ppt prompt changes without
its digest being added. It marks its identity written only once the
write lands and retries on the next turn otherwise. A seat that fails
does not stop the other seats; the host's template sync waits for the
retry, since it would fill the failed seat and a seat the engine did not
write is never replaced. A seat it leaves alone is logged at DEBUG, not
WARNING: in a host's home those are the host's own, every process, with
nothing to act on. The notice says how to hand a seat back (move the
lines into `*.local.md`, delete the file), which is what a seat edited
in Raven-PPT's own home before this release needs; the docs name that
exception.
- raven-code's earlier per-file receipts and legacy digests are still
honoured, so untouched copies are refreshed without a backup.
- `atomic_replace()` takes a `newline` argument so generated files stay
LF on every platform. It also removes its temp file when the replace
fails, and removes a temp file already present before it writes,
clearing the read-only attribute first: Windows refuses to replace a
read-only target once the temp file has taken its mode, and the
read-only temp file left behind used to fail every later launch even
after the target was made writable again.
- The temp file `atomic_replace()` writes is created no more open than
the target from its first byte. On Windows a new file takes its folder's
inherited ACL and `os.replace` (`MoveFileExW`) moves that descriptor
onto the target, so a prompt kept private in a folder other accounts may
read came back readable by them, `*.local.md` lines included. When the
target exists, the temp file is now made by `CreateFileW` with the
target's DACL as `GetFileSecurityW` reads it, and the save is refused
when that DACL cannot be read. On POSIX it is created with the target's
mode rather than the umask default, closing the span in which the new
text sat in a wider file until the chmod. This holds for every caller
that passes no explicit mode, `config.json` included. The Win32 bindings
behind it are declared once per process, behind a cache: a structure
defined per call left a new ctypes pointer type, about 6 KB, alive for
every save.

Docs: `agents/README.md` (the seed-once contract becomes "Regenerated
prompts", with rollback steps), `docs-site` agent integrations (en and
zh), `CONTEXT-MAP.md`, and `CHANGELOG.md` (an unreleased entry that
promised the old behaviour, plus a Fixed entry).

Tests whose meaning changed: seven existing tests asserted that an
edited prompt is never overwritten; they now assert it is backed up and
regenerated. The raven-code launcher test fixture now pins
`CODE_CONDUCT` and `CODE_CONDUCT_DISCIPLINE` to `on`: a deleted switch
fell back to the developer's `.env`, and two conduct tests on main
already failed with `CODE_CONDUCT_DISCIPLINE=off` for that reason.

Checked and deliberately not changed (documented in `agents/README.md`):

- The processes of one product (one per model binding) share these
files, so a launch can change what an older process still running reads
on its next turn. Closing that needs a per-process snapshot or
in-process injection of the prompt, which is a separate change.
- Backups are never deleted automatically.
- Host workspace templates (`USER.md`, `HEARTBEAT.md` and the rest) are
the user's files and stay write-if-missing.
- A file removed from a release is not removed from an installed
`~/.raven/agents` copy. Nothing loads such a leftover today: modes are
read by label, tools are imported by name, and no release has removed a
skill directory.

## Type

- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

Run at the head of this branch, rebased on the current main:

- `uv run pytest -q`: 32739 passed, 17 failed, 147 skipped, 2 xfailed.
The same 17 test IDs fail on the current main in a clean worktree with
the same interpreter and the same fetched tokenizer dictionary (proxy
redaction, tokenizer data, network-safety resolution, install script,
document converters, node runtime, trajectory time zone); none is
introduced here.
- `uv run pytest tests/test_agents_code_launcher.py -q` with
`CODE_CONDUCT` and `CODE_CONDUCT_DISCIPLINE` each set to `off` in the
environment, alone and together: 79 passed in all four runs.
- `make lint-python lint-imports lint-types lint-deps`: all pass, 10
import contracts kept, no dependency issues.
- `scripts/check_commit_messages.py`, `scripts/check_source_language.py`
and `scripts/check_large_files.py` over `origin/main..HEAD`, and `git
diff --check`: pass.
- Each fix was reverted on its own and its test went red: the receipt
written after the target, a failed target write, the backup mode, the
ppt `adopt=False` guard, receipts without an owner, an undeletable
earlier receipt, the `*.local.md` read-back from the assembled system
prompt, the temp file a failed replace leaves behind, and the temp
file's mode while it holds the new text.
- Windows review findings:
`test_a_windows_backup_is_the_edited_file_itself_so_its_acl_comes_with_it`
and `test_a_windows_backup_the_volume_cannot_link_is_refused_not_copied`
force the link path on Linux;
`test_a_failed_replace_takes_its_tmp_with_it` and
`test_a_read_only_tmp_a_dead_writer_left_does_not_block_the_replace`
cover the temp file on every platform;
`test_the_tmp_is_never_more_open_than_the_target_while_it_holds_the_new_bytes`
pins the POSIX mode from creation;
`test_a_read_only_prompt_regenerates_once_it_is_writable_again`
(read-only retry) and
`test_a_private_windows_prompt_keeps_its_own_dacl_when_regenerated_and_backed_up`
(a private prompt in a folder every local user may read keeps its own
DACL through regeneration and backup, read back with `icacls /save`) run
on Windows only.
- The `Windows ACP stdio` CI job gains a step that runs
`tests/test_config_product_render.py` and the two temp-file tests
natively. On the Windows runner: 158 passed, 2 skipped (the two
POSIX-mode tests), the DACL, read-only retry and hard-link backup tests
among the passes.
- Diff coverage over `raven/` with the related suites: 94.12%, above the
90% gate.
- Second-round review findings, each test red without its fix:
`test_an_addendum_that_is_not_utf8_is_named_and_nothing_is_written`,
`test_a_local_file_that_is_not_utf8_is_named_when_the_launch_stops` and
`test_an_addendum_that_is_not_utf8_names_itself_and_holds_back_no_other_seat`
(the decode error names the addendum; the ppt engine writes the other
seats and holds the sync);
`test_a_hosts_own_seats_are_left_alone_without_a_warning_in_every_process`
and `test_a_seat_left_alone_says_how_to_hand_it_back` (DEBUG level, and
the notice's instructions);
`test_the_windows_bindings_are_declared_once_not_per_save` (Win32
stand-ins on Linux, two saves load each DLL once).

Windows is covered by the CI step above, not by a local run. The CRLF
fold of an older copy is reasoned, not run. `npx commitlint` is not
installed on the machine this was run on; the Python commit check above
was run instead.

- [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: on the first launch after upgrading, each agent rewrites
its prompt files. A file edited in place, or left by an older release
without a receipt, is copied to `<name>.bak-*` and the launcher log
names the copy; an in-place edit stops taking effect until its lines are
moved into `*.local.md`. A `*.local.md` that is not UTF-8 stops the
launch with the file named. In Raven-PPT's own home a seat edited before
this release keeps the edit, and its `*.local.md` is not applied, until
the seat is deleted. A Raven-Research install seeded before the reader
layout switches to it at that launch.
- Security: a backup is never readable by more accounts than the file it
keeps (an owner-only copy on POSIX, a hard link keeping the file's ACL
on Windows), and a replaced file keeps its own mode, and on Windows its
DACL, from the temp file's first byte; receipts hold product names and
digests only; `*.local.md` is operator-owned and carries the same trust
as editing `agent.md` did before.
- Compatibility: a launcher running on a raven without `write_generated`
seeds once and logs it; the ppt engine on such a raven keeps
write-if-missing. On a Windows volume that cannot hard-link (FAT32,
exFAT, some network shares), an edited prompt file stops the launch with
the file named, until its lines move to `*.local.md` and the file is
deleted. On Windows, a save through `atomic_replace()` whose target's
DACL cannot be read is refused rather than made with the folder's ACL.
- Rollback: revert this change, then stop the product's processes,
delete each generated file whose `.<name>.generated.sha256` receipt
still names its current text, and relaunch so the older code seeds its
own. `*.local.md` files, backups and edited files are left as they are.

- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes

## Related Issues

N/A

---------

Co-authored-by: userName20260323 <270284818+userName20260323@users.noreply.github.com>
Co-authored-by: Claude (claude-opus-5-5) <noreply@anthropic.com>
2026-10-19 17:36:03 +08:00
Dizhan Xue
916761ed4c
perf(*): trim the resident memory of the gateway and the web supervisor (#954)
## Summary

A gateway, and the supervisor `raven web` leaves running beside it, held
memory from startup on for things they never use or may never be asked
to use. Two of them are no longer kept, and three are loaded on first
use. On a key-less gateway with a warm home and no terminal, as `raven
web` runs it, PSS 90 seconds after start goes from 257.2 MiB to 211.8
MiB, and the supervisor's from 77.3 MiB to 35.2 MiB. Nothing on the
wire, on disk or in the page changes shape.

- **The supervisor no longer imports the command table** (77.3 to 35.2
MiB). It only restarts its gateway, but it reached its loop through
typer and the table. `raven/cli/entry.py` now hands the argv that `raven
web` and `system.upgrade` start it with, `web --supervise --port N` with
N in ASCII digits, to `serve_commands.supervise_from_argv`, which calls
`_web` with the arguments the `web` command passes; a refusal ends the
process with the code the command would have exited with. Any other argv
is parsed by the table as before. Two process-wide settings stay ahead
of the fast path in the entry point: the TLS switch, as before, and,
moved there from the table's import, the switch of a Windows process's
stdout and stderr to UTF-8 with `PYTHONIOENCODING` set for its children.
The table's own setup, the saved language and the config migration
notices, is skipped with it: the supervisor prints no translated text
and never reads the config.
- **Two tokenizer copies left by litellm's import are freed** (25.3
MiB). `litellm.utils` keeps the dict it parses from the bundled
Anthropic tokenizer beside the string it re-serializes from it, and only
the string is read: the Claude tokenizer is built from it. cl100k's
registered encoding keeps a Python dict of its ranks beside the copy
tiktoken's core encodes with; tiktoken reads the Python one only to
pickle an encoding outside the registry, since a registered one pickles
by name. `import_litellm` now drops the dict, only while the string is
there, and the Python ranks. A failure is logged at debug level and
leaves the import standing.
- **A process whose terminal cannot be asked for its colours finds the
console's host modules on its first console command** (6.2 MiB).
Registering the console feature imported every CLI module to find the
ones that host console commands. `cli_socket.register_cli` now also
accepts a function, run once on the first `console_hosts()`. That covers
a process with no terminal, as the gateway `raven web` detaches has
none, and Windows, SSH, screen or tmux, and CI, which
`_theme._can_probe` rules out. Where the terminal can be asked, as from
`raven tui`, the host modules are still found at registration:
`raven.cli._styles` asks the terminal for its colours as it is imported,
and that question has to come before the Ink screen starts.
- **The RPC models build each validator on first use** (6.0 MiB).
`_Strict`, the base every model in `raven/rpc/models.py` derives from,
sets `defer_build=True`. The reason is a comment rather than the
docstring, because pydantic copies the docstring into the JSON schema.
- **Loading the deck engine's plugin no longer loads python-pptx** (7.9
MiB). `plugins-dist/ppt-engine/raven_ppt/services/state.py` imported the
template service, and with it python-pptx, so a gateway with the plugin
installed held it even with the plugin's config slice off, which is the
default. The service is now imported where a deck is read. With the
slice enabled, python-pptx is still loaded by the check that decks can
be made.

The upgrade regression tests also use the native launcher filename
(`raven.exe` on Windows, `raven` elsewhere), so the complete
relaunch-argv and supervisor-handoff assertions run on both platforms.
This follow-up changes test expectations only.

## Type

- [ ] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [x] Other

## Verification

The original author's Linux performance and suite measurements below
were recorded before the Windows test-fixture follow-up and rebase. The
seven original patches remain equivalent after rebasing; the Windows
measurements below are from the final tree. No new memory or
live-provider measurements are claimed.

- **Memory:** an isolated gateway with a key-less config and
`memory.backend` null, started without a terminal on an exported copy of
the base commit and of this head, each on its own home warmed by an
earlier start, base and head runs alternating; PSS from
`/proc/self/smaps_rollup` 90 seconds after start. The base read 257.2
MiB and this head 211.8 MiB, each within 0.1 MiB from run to run. The
figure on each change above is what taking that change back out of this
head, alone, puts back; the four add up to the difference. The
supervisor's figures are its PSS under `raven web` started on each tree.
- **Behaviour, base against this head on the same trees:**
- Token ids and counts over the repo's docs, the `raven/agent` sources
and the message catalogs, through raven's two estimators, cl100k
directly and `litellm.token_counter` for Claude, GPT, GLM, DeepSeek and
Gemini model names, with decoding, copying and pickling the encoding:
identical.
- The console: the same host modules, found at registration on the base
and on the first lookup here. On a pseudo-terminal the colour query is
written during registration on both.
- Every model in `raven/rpc/models.py`: validation and serialization
schemas, fields, and the outcome of validating the same probe payloads,
identical. On the base all but eight were built at import, here none.
Sixteen threads using every model for the first time at once: no error,
one set of answers.
- The deck engine's plugin imports without python-pptx here; on the base
it loads it.
- `raven web` end to end: it starts and serves the page; after a SIGKILL
of the gateway the supervisor brings it back on the same port with
`RAVEN_SERVE_PORT_STRICT=1`; `raven web --stop` leaves no process and no
`web.json`; `web.log` carries the same lines, and the gateway's
environment is the same key by key.
- A streamed turn and a tool-calling turn on glm-5.3-flash through a
live config's LiteLLMProvider: the same reply, the same tool call, the
same prompt usage, and the same Raven estimate.
- **New tests, against the base code:** of the 33 new or changed cases,
29 fail there. Four pass there by design: the token counts, a near-miss
argv that goes to the table, a process whose terminal can be asked
finding the host modules at registration, and the streams left alone off
Windows. All 33 pass here.
- **Mutation:** each construct was removed or bent one at a time, with
the backup outside the tree, and each mutant failed the tests written
for it:
- the supervisor: no fast path, `isdigit` as the port check, extra
arguments accepted, a refusal swallowed, every refusal ending with code
1, the port ignored;
- the Windows streams: no switch, the switch after the fast path, no
`PYTHONIOENCODING`, the switch off Windows too, strict errors, no guard
around the switch;
- the tokenizer copies: none freed, the dict dropped without its string,
the string dropped too, the ranks kept (in this process and in a fresh
one), no guard around the freeing;
- the console: the finder run on every lookup, a reset keeping a finder
that never ran, lazy everywhere, eager everywhere (in this process and
in a fresh one), registration importing one of the finder's modules;
- the validators built at import; the template service imported with the
state module.
- **Directly affected and neighbouring files:** `uv run --frozen
--python 3.12 --all-extras pytest -q -p no:cacheprovider
--idle-ceiling-strict` over the seven changed test files and
`tests/test_ppt_engine_state.py`, `tests/test_ppt_engine_prepare.py`,
`tests/test_rpc_console.py`, `tests/test_cli_tui_commands.py`,
`tests/test_cli_gateway_commands.py`,
`tests/test_rpc_contract_shapes.py`, `tests/test_cli_smoke.py`,
`tests/test_updates_upgrade.py` and `tests/test_security_tls.py`. Result
at this head: 1522 passed.
- **Full suite at this head:** `uv run --frozen --python 3.12
--all-extras pytest -q -p no:cacheprovider` (repo addopts: `-n 4`,
integration and e2e deselected; proxy variables unset). Result: 3
failed, 31663 passed, 164 skipped, 2 xfailed. The three are this box's
environment and fail the same way on an exported copy of the base
commit:
`tests/test_install_script.py::test_resolve_node_dir_answers_each_case_it_exists_for`,
`tests/test_knowledge_parser_excel.py::test_a_legacy_workbook_is_converted_and_read`
(no LibreOffice) and
`tests/test_subagent_node_runtime.py::test_what_cannot_be_read_names_nothing`
(run as root).
- **Exported trees:** the same suite on exported copies of the base
commit and of this head, compared case by case: every case they share
has the same outcome, apart from two timing-sensitive cases that failed
in the base run and pass in this head's run and on repeated runs of both
trees:
`tests/test_subagent_acp.py::test_an_interrupted_first_turn_still_binds_its_session`
and
`tests/test_subagent_cli_remote.py::test_a_cancel_ends_the_agent_s_whole_process_tree_on_the_machine`.
- **Diff coverage:** `uv run --frozen --python 3.12 python
scripts/coverage_gate.py diff --base-ref origin/main --threshold 90`
over the neighbouring run's coverage. Result: 100.00%, 50 of 50
executable changed lines. The gate measures `raven/`;
`tests/test_ppt_engine_*.py` executes both imports moved in the deck
engine.
- **Lint and gates:** `make lint-python lint-imports lint-deps
lint-types check-large-files check-source-language`, and `commitlint
--from origin/main --to HEAD --config commitlint.config.cjs` plus
`scripts/check_commit_messages.py origin/main..HEAD`. Result: all exit
0; import contracts 10 kept, 0 broken.

**Native Windows follow-up (2026-10-15):** Windows 10.0.26300, Python
3.13.12, `PYTHONUTF8=1`, isolated Raven/pytest homes and a dedicated
worktree. Setup: `uv sync --frozen --python 3.13 --all-packages --extra
dev`. Imports were verified against the tested worktree. The same frozen
sync was repeated after the rebase picked up the memory-plugin
dependency update.

- Before the fix, `uv run --frozen --no-sync pytest
tests/test_rpc_system.py -n 0 --tb=short` returned **3 failed, 40
passed**. The gateway-hosted handoff, standalone handoff and dev-flag
regression each expected `raven` where native Windows correctly selected
`raven.exe`.
- After the fix, `uv run --frozen --no-sync pytest
tests/test_rpc_system.py
tests/test_cli_serve_commands.py::TestTheSupervisorStartsWithoutTheCommandTable
tests/test_cli_system_ca.py -n 0 --idle-ceiling-strict --tb=short`
returned **66 passed, 4 skipped**.
- On the final rebased tree, the following command returned **631
passed, 4 skipped**, exit 0 with the idle ceiling enforced. The four
skips require the Linux certificate store; none are counted as Windows
passes. JUnit output paths are omitted from these commands.

```powershell
uv run --frozen --no-sync pytest tests/test_rpc_system.py tests/test_cli_serve_commands.py::TestTheSupervisorStartsWithoutTheCommandTable tests/test_cli_system_ca.py tests/test_litellm_setup.py tests/test_ppt_engine_plugin.py::test_loading_the_plugin_leaves_python_pptx_for_the_first_deck tests/test_ppt_engine_state.py tests/test_rpc_cli_dispatch.py tests/test_rpc_schema_match.py -n 0 --idle-ceiling-strict --tb=short
```

- `uv run --frozen --no-sync ruff check raven evolver agents
plugins-dist tests scripts docs-site` and the matching `ruff format
--check`: passed (2,337 files formatted).
- `uv run --frozen --no-sync lint-imports`: 10 contracts kept. `uv run
--frozen --no-sync ty check raven/cli/_console_feature.py
raven/cli/commands.py raven/cli/entry.py raven/cli/serve_commands.py
raven/providers/litellm_setup.py raven/rpc/cli_socket.py
raven/rpc/models.py
plugins-dist/ppt-engine/raven_ppt/services/state.py`: passed.
- `uv run --frozen --no-sync pre-commit run --from-ref origin/main
--to-ref HEAD`, `node node_modules/@commitlint/cli/cli.js --from
origin/main --to HEAD --config commitlint.config.cjs`, `uv run --frozen
--no-sync python scripts/check_commit_messages.py origin/main..HEAD`,
`uv run --frozen --no-sync python scripts/check_large_files.py
origin/main...HEAD`, `uv run --frozen --no-sync python
scripts/check_source_language.py origin/main...HEAD`, and `git diff
--check origin/main...HEAD`: passed.

The test correction retains the complete executable path, argv,
credentials, delayed shutdown and supervisor-handoff assertions, without
adding a skip. Upgrade spawning and the supervisor loop are substituted
in these tests. No real upgrade or resident restart, live provider call,
Windows memory measurement, full Windows suite or new Linux/macOS run
was performed by this follow-up.

- [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 change, because no command, flag, setting or file
format does.

## Risk

User-visible behaviour changes:

- **The first console command in a process whose terminal cannot be
asked** imports the finder's modules then, once, on the event loop and
under the console's dispatch lock, instead of at startup: about 0.1 to
0.2 seconds on this box. A CLI module that fails to import then fails
each console command, where before it failed the process's startup.
- **Each RPC model builds its validator the first time it is used**, so
a method's first call pays for its own models, and a model whose fields
pydantic cannot build a validator for fails there rather than when
`raven.rpc.models` is imported.
- **An unhandled exception in the supervisor** reaches `web.log` as
Python's plain traceback rather than typer's formatted one.
- **The deck engine's template service is imported at the first deck
read** instead of when the plugin loads. A python-pptx that cannot be
imported therefore no longer stops the plugin from loading: with its
config slice enabled, the check that decks can be made withholds the
deck tools, and the turn hook's note on deck state, which logs an
unreadable state at debug level and goes on, meets the import error
there.
- **Code in the same process that reads the private `_mergeable_ranks`
off the registered cl100k encoding**, as the extension example in
tiktoken's README does, gets an `AttributeError` once raven has imported
litellm. In raven, its plugins and the locked dependencies, only
tiktoken's educational module does.

Left as today:

- **Any other supervisor argv**, for example one typed by hand with
`--port=N` or the flags reordered, goes through the command table and
keeps today's memory.
- **Freeing the tokenizer copies relies on litellm's and tiktoken's
internals.** The tests read each copy where it lives, check in a fresh
interpreter that litellm's own import registers the encoding whose ranks
are freed, and pin the token counts, so a release that moves a copy,
starts reading one or stops registering the encoding fails them.

- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes

Rollback is a revert. Nothing written to disk or sent over the wire
changes.

## Related Issues

N/A
2026-10-15 11:24:20 +08:00
zhanghui
16784d3a1e
build(*): upgrade everos and the memory plugin to 1.4.2 (#950)
## Summary

EverOS 1.4.2 shipped today. It fixes what a memory server that stays up
for
days runs into: a LanceDB index reader leaked file descriptors until
searches
took seconds, an interactive search queued behind the cascade's
background
embedding (vector search p50 46 s under three concurrent writers, 0.60 s
now),
and a cascade pass sent one embedding request per entry instead of one
per
file. The memory plugin's exact pin moves from
`everos[multimodal]==1.4.1` to
`==1.4.2`, and the plugin's own version from `1.4.0` to `1.4.2` -- the
same
number as the EverOS it ships. Both EverOS releases declare the same 36
requirements, so nothing else in the lock follows everos down.

**No adapter change.** Every internal everos symbol the adapter reaches
is
present in 1.4.2 with the same signature, the package layout churn
underneath
included: `infra.persistence.lancedb.tables` became
`infra.persistence.records` and `infra.persistence.backends` became
`lancedb.LanceIndexBackend`, but the adapter imports `episode_repo` and
`agent_skill_repo` from the `lancedb` package, which re-exports both the
way
it did before.

**The derived index repairs itself, once.** 1.4.2 makes a table's
primary key
`(app_id, project_id, id)` rather than `id` alone, and the first full
cascade
pass after the upgrade re-reconciles every indexed markdown file against
the
index, re-embedding only the rows that are missing and recording that it
ran
in `.index/.index_reconcile_version`. A healthy root pays one read pass
and no
embedding; markdown is the source either way and was never affected by
the bug
this fixes. The two roots EverOS says need `everos cascade rebuild` by
hand are
a Milvus derived index and a root where reflection already ran across
projects;
raven writes one project into a LanceDB root and reaches neither, though
a user
who pointed raven at a root of their own might.

**The plugin version now equals the EverOS it pins.** The only precedent
was
plugin `1.2.0` pinning EverOS `1.2.3` and plugin `1.4.0` pinning EverOS
`1.4.1`: the plugin tracked EverOS major.minor and kept its patch for
itself,
and nothing said so anywhere. The result reads as a version one release
behind
the thing it ships, so step 5 of the upgrade SOP now says to hold the
two
equal, and this upgrade skips `1.4.1` to close the gap. That step also
named a
test that no longer exists for the literal assertion
(`test_bundled_shadows_lower_priority_source`); it is
`TestPackageSurface::test_imports_clean`, and the step now lists all
three
files that carry the version rather than the manifest alone.

Recorded in `docs/memory-plugin-architecture.md` section 7.5, which the
upgrade
SOP in section 7.2 asks for.

## Type

- [ ] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [x] Other (external dependency upgrade)

## Verification

```
uv run --frozen --python 3.12 --all-extras pytest -q \
  tests/test_everos_plugin_discovery.py tests/test_everos_backend.py \
  tests/test_everos_backend_contract.py tests/test_everos_http_adapter.py \
  tests/test_everos_config.py tests/test_everos_server.py \
  tests/test_everos_discover.py tests/test_memory_backend_protocol.py \
  tests/test_memory_backend_contract.py tests/test_cli_plugin_commands.py \
  tests/test_config_update_everos.py tests/test_dependency_constraints.py \
  tests/test_release_plugin_list.py tests/test_skill_router_everos_source.py \
  tests/test_agent_loop_everos_pipeline.py
-> 567 passed, 1 skipped (the skip is Linux-only inotify)

uv run --frozen --python 3.12 --all-extras pytest -q \
  tests/test_everos_plugin_discovery.py tests/test_cli_plugin_commands.py \
  tests/test_release_plugin_list.py tests/test_plugin_manifest.py \
  tests/test_plugin_discover.py tests/test_everos_discover.py
-> 91 passed (re-run after the plugin version moved to 1.4.2)

make lint-types                           -> all checks passed

make lint-python lint-imports lint-deps   -> clean, 10 import contracts kept
make check-source-language check-large-files COMMIT_RANGE=github/main..HEAD -> clean
```

Against a copy of a real 55 MB store (568 episodes, seven LanceDB
tables)
written under 1.2.x and last served by 1.4.1, booted on a scratch root:

- 1.4.2 opens it with no schema complaint, `/health` answers
`version 1.4.2` with `cascade.healthy true`, and the reconcile pass
writes
  `.index/.index_reconcile_version` with no error in 441 log lines.
- The same keyword search (`POST /api/v2/memory/search`, the body the
adapter
sends) returns the same five episode ids in the same order under 1.4.1
and
under 1.4.2; BM25 scores drift in the third decimal, as they did on the
  1.2.3 to 1.4.1 move.
- Raven's own `installed_everos_version()` reads 1.4.2, and every
internal
  symbol the adapter imports resolves with the signature it had.

- [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 change: memory searches stop queueing behind background
writes,
and a long-lived server stops leaking file descriptors. An existing
index pays
one read pass on the first start after the upgrade.

Rollback is `git revert`. The reconcile pass only re-embeds rows the old
primary key had lost, and `lancedb` does not move, so 1.4.1 reads an
index
1.4.2 has written. The new `.index/.index_reconcile_version` file is
ignored by
1.4.1; a re-upgrade later would skip the pass it records, which is the
intent.

Not exercised here: a Milvus derived index (raven configures LanceDB), a
multi-project root, and a real embedding or LLM round trip (the scratch
root
ran without provider keys, so the checks above are the keyword leg and
the
cascade's own reconcile).

- [x] Security impact considered
- [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>
2026-10-15 11:01:45 +08:00
zhanghui
d106a5c6ef
feat(plugins): add the everos-cloud-memory plugin and its host wiring (#883)
## Summary

Adds `everos-cloud-memory`, a separately distributed memory plugin for
EverOS Cloud, and wires the host so a second memory plugin is a
first-class choice.

The plugin (`plugins-dist/everos-cloud-memory`) is a thin REST client
over httpx: one API key (the config slice
`plugins.config.everos-cloud-memory.api_key`, or
`EVEROS_CLOUD_API_KEY`), owner ids from the host's `ServiceLocator`
(never from the slice), every add in `agent` mode, and a flush only when
a caller marks the conversation over (`metadata.flush` /
`metadata.is_final`: the sub-agent handoff and the importer's final
batch) and once at stop. It ships its own onboard screen (env or on-file
key used without a prompt; 401 / 403 / unreachable get their own
sentences with Re-enter or Skip), `delete` answers False (the cloud
deletes by scope, nothing calls it), and `health()` classifies seven
answers for `raven doctor` and the settings card.

Host changes, each guarded so `memory.backend` `everos` and `null`
behave exactly as before:

- `raven onboard` step 4 asks "Which memory backend?" when more than one
plugin contributes a screen (preselects the current backend, `Off`
clears it, cancel exits 1 and writes nothing); with one plugin the step
is byte-identical to today.
- The memory page reads whichever backend `memory.backend` names: the
cloud slice's key goes out as a Bearer header and the `/health` probe is
skipped for the cloud; a missing distribution is named in the page's
note.
- `settings.everos` reports `reason: "other_backend"` for any non-EverOS
backend, so the Model page hides the three EverOS-only roles (embedding
stays: knowledge bases use that pin); `settings.everosSet` refuses those
three sections for another backend; `settings.set` admits
`plugins.config.<id>.<field>` against the plugin's manifest through the
same admission door channels use; new `settings.everosCloud` feeds the
card (key source, endpoint, health).
- Provider-key and main-model saves no longer restart the local EverOS
when another backend is active.
- ui-web: an EverOS Cloud card (status chip, key row, endpoint) and the
`settings.everosCloud` data behind it. No page mounts the card: it drew
on Model settings until the owner ruled that a memory backend's endpoint
and credential answer neither question that page asks, and where it
belongs is the Memory section's to say once that section has a design.
Until then the key is entered through `raven onboard` or
`EVEROS_CLOUD_API_KEY`. The fixture gate pins the four optional fields
the offline library never sends.
- Gates: the plugin boundary test scans both memory plugins, coverage
and the release workflow build the second wheel, deptry's ignore list
names the plugin beside `raven_everos`, and a conftest fixture keeps the
second plugin out of entry-point discovery for the existing onboarding
tests (they describe a one-plugin install).

A second topic rides along, because it is what makes the hosted backend
reachable from an agent product at all. Every product under `agents/`
pinned its memory at the stock EverOS address and only `raven-design`
read the host's, so the other four addressed whatever answered on 18791
-- the wizard moves a managed server when the port is taken, and a
server the user runs themselves is wherever they put it.
`inherit_memory_backend` in `raven/config/product_render.py` now carries
`memory.backend`, the endpoint, and (only when the product holds none
itself) the credential from the host into every render, beside the host
denials and plugin opt-outs that already travel there; `raven-design`'s
private copy is deleted and the five product configs stop naming an
address. Identity never travels, which is what keeps five products apart
inside one store. `memory.backend: null` travels like any other value,
because that null is how an operator turns long-term memory off and a
product that kept writing would be the one surface ignoring them; the
product's own default stands only when the host carries no key at all.
Which store memories live in is not a product's choice either: the host
reads a sub-agent's memories back through its own backend, so a product
writing anywhere else left that record empty with nothing reporting it.
`owned` is forced off whenever the local backend is in force, because a
product infers ownership from a slice naming no root -- the shape all
five ship -- and so answered a host that was merely not serving by
starting a second server against a root of its own, stranding every
memory written so far.

Decisions worth a reviewer's eye: the fake cloud
(`tests/_everos_cloud_fake.py`) honours or refuses every field the
backend can send and serves both an in-process transport and an HTTP
face for the real-host acceptance; the live tests
(`tests/integration/test_everos_cloud_real_cloud.py`) skip without
`EVEROS_CLOUD_API_KEY`; run with a real key on 2026-10-09 all six pass
against api.evermind.ai (round trip, get by session, empty flush, 401
wording, probe with and without a key, and extraction without a flush
within two minutes), so the documentation and the service agree on
everything the plugin sends. Design, acceptance cases and plan are under
`docs/specs/2026-10-08-everos-cloud-memory-*.md` and `docs/plans/`.

## Type

- [ ] Fix
- [x] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed

Rebased onto main `182dacac0` on 2026-10-13. What that rebase and the
four commits on top were verified with:

- Full suite, `uv run --frozen --python 3.12 --extra dev pytest -q` ->
**29748 passed, 8 failed** in 4m10s. All eight fail identically with
these four commits' sources reverted in-tree at the same base, so none
of them is this branch's: the two `test_the_products_tool_face_*` cases
in the code and oncall launchers (an extra `web_search` in the visible
tool set), `test_agent_loop_token_budget`,
`test_rpc_files::test_a_host_without_libreoffice_says_so`,
`test_ppt_engine_image_search`, `test_shell_background`, and the two
`test_simulation_*` cases.
- Real-host before and after for the inheritance, driving the launcher
the host spawns (`agents/raven-research/run.py`) against an isolated
`RAVEN_HOME` whose EverOS address is `19701`, not the stock port.
Before: the product rendered `base_url: http://localhost:18791` with no
`owned` key, ignored the host, and started an EverOS of its own -- an
orphaned `everos server start --root <its own state root>/everos`
holding 18791, which is the stranding this change exists to stop. After:
it rendered `{"base_url": "http://localhost:19701", "owned": false}` and
said so itself, "the EverOS you manage is not running at
http://localhost:19701 ... Raven does not start or stop it", with `ps`
and `lsof` confirming nothing was started. On the cloud the product
rendered `memory.backend: everos-cloud` with the host's key and left the
out-of-force local slice untouched, and `raven doctor` over that
rendered config answered `everos-cloud: ok https://api.evermind.ai`, so
the credential reached the service. Identity stayed `raven-research-ng`
throughout, and a fingerprint of the operator's own EverOS root was
identical before and after.
- The first CI round on this head found one that the local gates did
not: `tests/test_import_cycle_budget.py`. `inherit_memory_backend` read
the backend-to-distribution pairing from `raven.core.plugin_stack`, and
that edge from `raven.config` into `raven.core` -- which imports
`raven.config` back -- took mutual pairs from 13 to 14 and packages
inside a cycle from 18 to 22. `make lint-imports` keeps ten contracts
and none of them covers that pair, so it was green throughout. The
pairing now lives in `raven/config/raven.py` beside the two fields it
joins (`MemoryConfig.backend` names a contribution,
`PluginsConfig.config` is keyed by the distribution), which `raven.core`
may import and which imports nothing back; `plugin_stack` re-exports the
two names its own callers read from it. An intermediate commit put it in
`raven.contracts` instead, which broke the cycle but took the papers
ceiling from 3700 to 3719 lines -- `tests/test_kernel_budget.py` says a
new paper is a reviewed change to that ceiling, so it moved again rather
than raising it.
- The review round on this head raised one non-blocking finding, fixed
rather than carried forward: the inheritance read `memory.backend` with
`.get()`, which collapses an explicit `null` into an absent key, so a
host with long-term memory off left every packaged agent on its own
shipped backend and still writing. Reproduced by calling the function
directly before the change and after, now read on presence, and pinned
by a case whose mutation (restoring the `.get()`) turns it and nothing
else red.
- One ordering problem found while checking the above, pre-existing and
not fixed here: `tests/test_rpc_settings.py` run before
`tests/test_cli_onboard_commands.py` leaves
`raven.home._current_config_path` pointing at a dead tmp config, so the
onboard cases write somewhere else. With main's own copies of both files
and main's conftest in the tree it is 57 failures; with this branch's,
19. Which cases turn red changes run to run as xdist distributes them
differently.
- `cd ui-web && npx vitest run` -> 876 files, 3728 passed, 0 failed;
`npm run lint` -> 0 errors (4 warnings, all in files this change does
not touch); `npm run gen:check` -> in sync (228 methods); `npm run
type-check` -> clean; `cd ui-tui && npm run lint:i18n && npm run
lint:rpc` -> in sync
- `make lint-python` / `lint-imports` (10 contracts kept) / `lint-types`
/ `lint-deps` -> all pass; `uv lock --check` -> exit 0 with both sides'
new packages present; `scripts/check_source_language.py` and
`scripts/check_large_files.py` on `github/main..HEAD` -> exit 0;
commitlint over every commit -> ok
- Semantic-conflict audit of the rebase, beyond what the suite answers:
21 of the branch's 66 files are also in main's 499, and every one of
main's changes in them is additive and elsewhere in the file. The one
that could have broken silently is main's new `vision.model` /
`vision.provider` simple keys meeting this branch's new
`plugins.config.<id>.<field>` branch in `settings_set`; nothing in the
suite exercises `vision.*` through that method, so it was run directly
-> `{'applied': True}` and `{"model": "..."}` on disk. The subtraction
decisions were re-checked against the new base: no new caller of a
memory backend's `delete`, main's new onboard cases are about TLS and
not the memory step, `inherit_everos_address` exists nowhere, and
`DEFAULT_EVEROS_BASE_URL` is still defined.
- Mutation runs on the new code, restored afterwards: dropping `owned:
false`, letting the host's credential overwrite the product's own, not
writing the host's backend name, and carrying every memory slice instead
of the one in force each turn their own cases red; making the cloud card
render nothing turns 4 of its 5 new cases red and leaves the fifth
("draws nothing when not selected") green.

From the earlier round, on base `6d509a8c5`:

- `uv run --frozen --python 3.12 --extra dev pytest -p no:cacheprovider
-q tests/test_everos_cloud_fake.py tests/test_everos_cloud_backend.py
tests/test_everos_cloud_backend_contract.py
tests/test_everos_cloud_onboard.py tests/test_everos_cloud_discover.py
tests/test_cli_onboard_commands.py tests/test_rpc_memory.py
tests/test_rpc_settings.py tests/test_plugin_boundary.py
tests/test_rpc_schema_match.py tests/test_rpc_registration.py
tests/test_release_plugin_list.py
tests/integration/test_everos_cloud_real_cloud.py` -> 1001 passed, 6
skipped (the six live tests, no key)
- `cd ui-web && npx vitest run` -> 214 files, 3211 passed; `npm run
lint` -> 0 errors (4 warnings, all in files this change does not touch);
`npm run gen:check` -> in sync (207 methods); `cd ui-tui && npm run
lint:rpc && npm run lint:i18n` -> in sync
- `make lint` (ruff, ruff format, ui tsc, deptry) -> ok; `make
lint-types` -> All checks passed; `make build-ui` -> boot snapshots
match; `scripts/check_large_files.py` and
`scripts/check_source_language.py` on `6d509a8c5..HEAD` -> exit 0;
commitlint and `scripts/check_commit_messages.py` on each commit -> ok
- Mutation runs per change (restored afterwards, `git diff` clean): a
host import of the plugin turns the boundary test red; `import
raven_everos` in the plugin turns the import-isolation test red;
removing the chooser's cancel exit, the Bearer header, the restart
guard, the slice-admission guard, the Roles filter and the fake's two
fixes each turn their own test red
- Real-host acceptance (64 cases,
`docs/specs/2026-10-08-everos-cloud-memory-acceptance.md`) run against a
fake EverOS Cloud: the wizard in tmux (chooser, key typed / from env /
on file, 401 / 403 / unreachable wording, back, Off, Ctrl-C,
non-interactive, base-tree transcript byte-identical with one plugin),
`raven agent` turns (user and agent-track recall, agent-mode adds, 4 s
recall bound, a 300 KB message dropped with a warning, a sub-agent trace
stored under its own ids, flushed and read back, one exit flush per
unflushed session), `raven import run` (3 adds then one flush; a hung
flush retried 4x and the exit sweep defeated), `raven doctor` under
seven cloud conditions (seven sentences, exit 2 only for the five
faults) and with the distribution hidden, and the web page through
playwright-cli (memory page counts and the fake's episode, empty and
refused stores, the Model page hiding the three EverOS-only roles while
the embedding row stays, the cloud card rotating a key and showing the
401 wording, three refused settings.set frames over the gateway
WebSocket, the local everos / null / mem0 backends drawing the page as
before, and a provider-key save that restarts the local EverOS on the
base tree and does not on this branch). Evidence and the per-case
verdicts are kept outside the repo. The live service was reached with a
real key after the acceptance run: six tests, six passes, the service's
replies archived with the evidence.

## Risk

- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes

User-visible changes: the wizard's step 4 chooser (only when two memory
plugins are installed); Model settings hides the three EverOS-only role
rows when `memory.backend` is not `everos`/`null` and draws no cloud
card; the memory page sends a Bearer header for the cloud backend.

Two behaviour changes for agent products, both on the `agents/` lane
only. An agent product now follows the host's `memory.backend` and
endpoint instead of its own, which is a fix for the four products that
never followed the host and a change for `raven-design`, which followed
the endpoint but not the backend. And a product no longer starts an
EverOS server of its own: where it used to answer a host that was not
serving by starting one against an empty root of its own, it now reports
long-term memory as unavailable, which is what the host does. Rollback
for this part is the one commit; the product configs it edits are
shipped files, not user config. The plugin is not installed by default
(its wheel is built by the release workflow; nothing changes for an
install without it). Rollback: revert the squash commit; the config
schema gains no new key (the slice is a plugin slice), so an older raven
reads a config written by this one.

Credentials: the cloud key is written only by `set_plugin_config_fields`
into the plugin's slice; the settings page's key row goes through
`settings.set` with a manifest-declared field, and
`settings.everosCloud` reports `api_key_set` / `key_source`, never the
value.

## Related Issues

N/A

---------

Co-authored-by: gloryfromca <23442919+gloryfromca@users.noreply.github.com>
Co-authored-by: Claude (claude-fable-5-1) <noreply@anthropic.com>
2026-10-14 11:08:11 +08:00
Dizhan Xue
2f0a09dcfc
feat(*): let the image role run on an OpenAI-compatible provider (#866)
## Summary

The image role in Settings offered OpenRouter alone, although
`image_generate` already speaks the OpenAI Images API
(`/images/generations`, `/images/edits`) on any other base. A user with
an OpenAI or OpenAI-compatible provider could reach it only by
hand-editing `tools.media.image.apiKey` and `apiBase`.

`tools.media.image` gains `provider`. A section naming one runs on that
provider's address, key and headers as one group, taken from the
endpoint the key comes from and resolved at call time the way the
embedding pin is (`provider_connection`, factored out of
`resolve_provider_credentials`); the section's own `apiKey`, `apiBase`
and `extraHeaders` stand aside. Every media request sends the section's
`extraHeaders` (a new field, secret like a provider's own) after the
bearer key, the order the chat route gives a provider's `extra_headers`.
The registry declares which providers the image tool can run on
(`ProviderSpec.image_api`: OpenRouter, OpenAI, Custom), `model.options`
carries the flag per row, the roles card offers exactly those for the
image slot, and `settings.set` refuses any other. An OpenRouter pick
writes an empty provider, so existing sections keep their current
meaning. Speech and video keep to OpenRouter: their sections have no
`provider` field, so one written there is ignored on every reader, and
`settings.set` and `set_media` refuse it.

Two fixes on the same path:

- The OpenRouter key, `providers.openrouter.apiKey` or
`OPENROUTER_API_KEY`, is borrowed only by a section that calls
OpenRouter's address. A keyless section pointed at another endpoint used
to send that endpoint the OpenRouter key as its bearer token.
- Off OpenRouter, every image model goes to the Images API. The chat
route with output modalities is OpenRouter's own; an OpenAI-compatible
relay answered it with its own 404 (`model is not found`), which the
OpenRouter-only fallback did not recognise, so a model outside the
Images API name list could not generate there.

The live config reader resolves the named provider's section exactly as
boot does: every spelling, former name and field alias of it goes
through `ProvidersConfig`, which folds them into one section, and no
other provider's section is validated. A section header replaces the
key's header of the same name in any case.

raven-ppt and raven-design inherit the host's image section through the
same resolver. When raven-ppt pins an image setting, the section becomes
a snapshot read as written: it drops the provider name and takes the
Wire Model that provider uses. A pinned key or base leaves the inherited
headers behind, since they complete the host's key at the host's
address. A pinned base also clears whatever key the host resolved, so
the deck's key slot decides afresh: `PPT_IMAGE_API_KEY`, the host
section's own key, or, toward OpenRouter only, the key that pays for the
words. That closes a leak every 0.2 release has, the OpenRouter key the
host borrowed for OpenRouter's address going to a pinned deck base. On a
named provider's own address the deck sends that provider's key or none.
The launcher can outlive its raven, since a stamped home tree outranks a
checkout's own `agents/`, so it calls only what every 0.2 release has:
the reader's two-argument form, and `media_provider` looked up where it
exists.

The settings dialog's design and acceptance specs (C14, A22, A24 and
their decisions) are amended to the new rule.

Overlap: open #432 and #433 (MiniMax images and video) edit
`_generate_one`, the video tool's `execute`, a `_resolve_key` override
on each tool, and the lines beside the removed `borrows_openrouter_key`.
Their MiniMax routes return before the routing this change touches and
their overrides delegate to the base resolver, so the conflicts are
textual.

## Type

- [ ] Fix
- [x] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

- `uv run --frozen --python 3.12 --all-extras pytest -q`: 27601 passed,
7 failed, 115 skipped. The 7 fail identically on `origin/main` 3632e6040
on this machine (five proxy tests in `test_config_update_providers.py`
under the shell's proxy variables,
`test_install_script.py::test_resolve_node_dir_answers_each_case_it_exists_for`,
and
`test_subagent_node_runtime.py::test_what_cannot_be_read_names_nothing`
run as root); 0 introduced.
- ui-web, `node node_modules/vitest/vitest.mjs run
--no-file-parallelism` (both test roots, 214 files): 3188 passed, 0
failed, 0 unhandled errors. Measured before the review commits, which
touch no TypeScript, generated file or RPC contract.
- ui-tui, the same command (144 files): 2089 passed, 9 failed, 0
unhandled errors. The 9 are rendering tests in four files that fail with
identical ids on `origin/main`'s ui-tui on this machine; 0 introduced.
- `tsc --noEmit` in ui-web and ui-tui, `gen-rpc-client.mjs --check`,
`gen-rpc-types.mjs --check`, eslint over the touched ui-web directories,
and `ruff format --check` / `ruff check` over the changed Python files:
all clean.
- `scripts/check_commit_messages.py origin/main..HEAD`, commitlint over
the same range, `scripts/check_source_language.py origin/main...HEAD`,
`scripts/check_large_files.py origin/main...HEAD`: all exit 0.
- The new tests were written first and watched fail for the missing
behaviour, the review rounds' tests on the head before each fix. A
mutation pass then removed each construct this change adds, one at a
time: 40 Python and 3 TypeScript mutants, all killed but one, controls
green. The survivor matches a provider on its name instead of its
`route_names`, which is equivalent today because every former name in
the registry is also a field alias.
- Each commit added in review passes the touched test files on its own.
- Live, against an OpenAI-compatible relay serving
`sensenova-u1.5-lite`: before, `image_generate` with the section's own
`apiKey`/`apiBase` posted to `/chat/completions` and got 404. After, on
an isolated `raven web` in Chromium, the image row offered Custom,
OpenAI and OpenRouter (speech and video OpenRouter only), the typed id
was added to Custom as an image model and saved as `{model, quality,
provider: "custom"}`, and one call through the live config reader
returned a 2048x1536 PNG from `/images/generations` with the Custom
provider's key.

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed

No user-facing documentation covers the media tools; the settings
dialog's specs carry the rule.

## Risk

- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes

- Security: credentials travel to fewer places. A section borrows only
from the provider it names, address and key together, and a provider
with no known address supplies no key. `tools.media.image.provider`
joins the `settings.set` whitelist with the reach the subsystem pins
already have: it moves the tool to a provider the operator configured,
and names no address and carries no key.
- Provider headers can carry credentials: they travel with the key to
the provider's own address only, a video poll or content URL on another
origin gets neither, and a media section's `extraHeaders` is masked like
a provider's. The OpenRouter default lane still borrows only the
OpenRouter key, not that provider's headers.
- A keyless image, speech or video section whose `apiBase` is not
OpenRouter's now reports a missing key instead of borrowing the
OpenRouter key. A relay in front of OpenRouter at another address needs
`apiKey` on the section.
- On such a base, a model outside the Images API name list (a Gemini
image model, say) now goes to `/images/generations` instead of
`/chat/completions`.
- Choosing a provider other than OpenRouter in Settings sets aside a
hand-written `apiKey`/`apiBase` on the image section; they stay in the
file and apply again once an OpenRouter model is picked.
- A `provider` hand-written into `tools.media.speech` or
`tools.media.video` is now ignored: that section runs on OpenRouter,
with the OpenRouter key.
- raven-ppt: a deck pinning `PPT_IMAGE_API_KEY` no longer sends the
host's `extraHeaders`, so an endpoint that also routes by header cannot
take the deck's own key; before this change no header travelled at all.
A deck pinning `PPT_IMAGE_API_BASE` without a key of its own no longer
receives the OpenRouter key the host borrowed; it needs
`PPT_IMAGE_API_KEY`, the host section's own key, or a base on
OpenRouter's address.
- The raven-ppt launcher still renders under every 0.2 release, which
lacks `media_provider`; a test runs it against a reader with the 0.2
signature.
- Rollback: revert the squash commit. The previous config models ignore
a saved `provider`, so the image tool returns to OpenRouter with the
earlier key rules.

## Related Issues

Fixes #828

---------

Co-authored-by: Claude (claude-opus-5-5[1m]) <noreply@anthropic.com>
2026-10-08 17:33:39 +08:00
arelchan
9c1cdaed97
feat: let raven read and change its own configuration (#833)
## 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>
2026-10-03 12:14:04 +08:00
zhanghui
2b3cce70fa
feat(*): upgrade everos to 1.4.1, lift the windows gate, guard the embedding width (#791)
## Summary

EverOS 1.4.0 runs natively on Windows and 1.4.1 pins `openai` below 3,
so the memory plugin's exact pin moves from `everos[multimodal]==1.2.3`
to `==1.4.1`. The lock follows: `pyarrow` 24.0.0 -> 25.0.1 (EverOS's new
floor), `everalgo-boundary` 0.2.0 -> 0.2.1, `everalgo-core` 0.4.0 ->
0.3.0 (EverOS now pins its everalgo layer with `==`), and `msvc-runtime`
on `win32` only. `lancedb` stays at 0.34.0. Every internal everos symbol
the adapter reaches is present in 1.4.1 with the same signature, so the
adapter itself is unchanged. The plugin manifest and package version
move to 1.4.0.

**The Windows gate is gone.** `everos_platform_note` (#737) and its five
call sites, `ServiceState.UNSUPPORTED`, the import.scan refusal (#750),
the wizard's WSL notice and its zh catalogue line are removed;
`_everos_executable` looks for `everos.exe` on `win32`. Spawning,
probing and reusing the server were already portable. Identifying and
stopping a stale server was not: `_cmdline_of` asked `ps`, and the
marker `everos server start` never matched a Windows command line
(`...\Scripts\everos.exe server start`). The command line now comes from
WMI through PowerShell on `win32` and the marker accepts both shapes;
`_listening_port` asks the TCP table through PowerShell there, walking
the launcher's descendants: the socket belongs to the base interpreter
two launchers below `everos.exe`. The server is spawned in a process
group of its own (the Windows counterpart of `start_new_session`, which
also keeps a Ctrl-C at the gateway off it) and stopped with Ctrl-Break,
which uvicorn takes as a shutdown; one that ignores it for ten seconds,
or one no group can be addressed to, gets `TerminateProcess` as before.
And because Windows cannot replace a running executable, the upgrade
helper stops whatever still runs from under the tool environment before
it installs (the server outlives the gateway by design); without that,
`uv` failed on `Scripts\everos.exe` with os error 32. Recorded in
`docs/memory-plugin-architecture.md` section 7.4.

**Two guards, found while verifying against a copy of a real 1.2.x
store:**

- `set_embedding_endpoint` measures the model's vector width before
writing the pin and refuses anything narrower than the 1024-wide memory
index (`REQUIRED_EMBEDDING_DIMENSIONS`), but only where an EverOS
backend will read the pin: the `everos-memory` distribution is installed
and the config names `everos` as the memory backend (an absent key is
the schema default; an explicit `null` or another backend is not gated,
and a knowledge base sizes itself to whatever width the model returns).
The wizard's own check imports the same constant and probe. A
768-dimension model pinned through the settings page had left every
memory store and search answering 500 about a mismatched width, with
nothing on the page saying why. A probe that cannot reach the provider
is not a verdict: the pin is written and a warning logged. The two RPC
writers run the (now network-touching) writer in a thread.
- `ensure_everos_server` reads the running server's `/health` version
and, for a root raven owns, sends a mismatch with the installed everos
through the same precheck / stop / spawn chain a rotated credential
takes (`stale_reason`). Raven used to reuse whatever answered on the
port, so an upgrade left the old server serving until something
unrelated restarted it. A root the user manages is never touched.

**The wire contract is pinned.** Every request body the plugin and the
memory page send (`/add` with a tool exchange, `/flush`, the four
`/search` shapes, the four `/get` kinds) is validated against everos
1.4.1's own request models in `TestRequestBodiesMatchEverosModels`, so a
schema move on the next upgrade fails in the suite rather than as a 422
in a gateway log.

**A six-angle review then hardened the degraded paths** (turn survival
under every EverOS failure, Windows lifecycle, upgrade paths, the
embedding guard, the wire contract, concurrency). The rule: memory
degrades with a notice and never blocks a turn, a start or an upgrade.

- A gateway starts the server again when it finds nothing listening (or
a probe that timed out) and nothing holding the OME lock: only for a
root raven owns, never over a child of its own, at most once per thirty
seconds. The only spawn used to be in `start()`, so a server that went
away left a running gateway without memory until restarted by hand. A
stop that was sent and did not finish is not adopted (uvicorn closes the
port at once and finishes what it had), so the version-mismatch restart
after an upgrade cannot leave the gateway on a dying server.
- A command-line lookup that failed (no `ps`, PowerShell blocked, WMI
wedged, timeout) is distinct from a process that is gone: the stop keeps
waiting, the lock names nothing, and a settings save over a server that
answers but cannot be identified is reported as not applied. A losing
spawn no longer overwrites the live server's pidfile. `stop_pid` counts
wall time and takes a grace; on Windows a backend drains the server it
started at `stop()`.
- The upgrade helper asks again after `Stop-Process` and refuses to run
`uv` while anything from the environment survives (an elevated or
another user's process): `--force` removes the environment before
writing and would have left every file but the one that could not go.
- An embedding pin narrower than the index is measured at backend start
(once per pin per process) and withheld from the spawn: EverOS runs
keyword recall and keeps storing, and the notice names the model and
width. This covers a pin written around the write-time check (before
memory was on, unreachable at save time, edited by hand). The probe no
longer raises on an odd response, times out at ten seconds, honours
`plugins.disabled`; `migrate_roles` runs off the event loop it had put a
provider round-trip onto.
- The memory page uses the `/api/v2` routes (v1 is EverOS's legacy
alias), asks `/health` before a search the way the chat adapter does,
and shows the server's own sentence on a refusal. The recalled profile
is rendered as lines rather than a `namespace(...)` repr with its
evidence fields; a tool-call-only row stores empty content, not
`"None"`; `top_k` stays within 1..100; an empty query asks nothing; a
failed capability probe is not cached. The wizard accepts a model wider
than 1024 (EverOS keeps the first 1024, as the settings page already
allowed) and re-prompts on the host's refusal instead of a traceback.

`docs/memory-plugin-architecture.md` section 7 records the upgrade (7.4)
the way 7.3 recorded 1.2.1 -> 1.2.3.

## Type

- [ ] Fix
- [x] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

Unit and RPC tests over every touched area:

```
env -u SERPER_API_KEY uv run --frozen --python 3.12 --extra dev pytest -q tests/test_everos_server.py tests/test_everos_backend.py tests/test_cli_onboard_commands.py tests/test_everos_discover.py tests/test_rpc_settings.py tests/test_everos_config.py tests/test_everos_plugin_discovery.py tests/test_cli_plugin_commands.py tests/test_core_plugin_stack.py tests/test_rpc_memory.py tests/test_rpc_import_sync.py tests/test_everos_http_adapter.py tests/test_memory_backend_protocol.py tests/test_memory_backend_contract.py tests/test_plugin_boundary.py tests/test_i18n_boundary.py tests/test_config_update*.py
# 1312 passed, 1 skipped (inotify is Linux-only) on the first commit; 960 passed after the review round; full suite 26214 passed, 2 failed, 120 skipped, the 2 failing on an untouched github/main checkout too (LibreOffice path, background child env)
uv run --frozen --python 3.12 --extra dev ruff check <changed files>   # All checks passed!
uv run --frozen --python 3.12 --extra dev ruff format --check <changed files>   # 20 files already formatted
```

Against a 46 MB copy of a store written by everos 1.2.x (568 episodes,
5528 atomic facts, seven LanceDB tables), never touching the live one:

- `everos server start` on 1.4.1 opens it with no schema complaint;
`/health` reports `version 1.4.1`, `cascade.healthy true`.
- The same four `/api/v2/memory/search` requests on 1.2.3 and 1.4.1
return the same ids in the same order; BM25 scores drift in the third
decimal place.
- `raven agent -m` on this branch spawns everos 1.4.1, a "remember this"
turn lands in `episodes/episode-2026-09-24.md` and `.atomic_facts/`, a
fresh one-shot session recalls it, and a third session recalls episodes
written under 1.2.x months earlier.
- With a 1.2.3 server left on the port, the next `raven agent -m` logs
`runs everos 1.2.3 while this raven installs 1.4.1; restarting`, the old
pid exits and `/health` reports 1.4.1. The 1.2.3 server had opened the
index 1.4.1 wrote with no complaint.
- Windows 11 box, this branch checked out and synced: `raven serve`
spawns `everos.exe` natively, the Memory page shows its four tabs
instead of the platform sentence, a chat turn lands as an episode
(`/add` 200, `/flush` 200, cascade `upserted=1`), and after a memory
role change the next start logs `holds credentials raven has since
changed; restarting`, the old everos pid exits and the new one answers
`/health` 1.4.1.
- The settings page refuses `BAAI/bge-base-en-v1.5` on deepinfra with
`returns 768-dimension vectors and the memory index is 1024 wide` (real
probe), and the pin stays unchanged.
- Adapter import smoke against 1.4.1: all 13 internal symbols present,
signatures unchanged.
- Windows 11 box, second round: with the server up, `uv pip install
--reinstall --no-deps everos==1.4.1` fails on `Scripts\everos.exe` (os
error 32, exit 2); after the helper's sweep (`Stopped what was still
running from the old install (pid ...)`) the same command succeeds and
the relaunched gateway spawns a fresh 1.4.1. A stop from the spawning
console runs the full uvicorn shutdown (`Shutting down` ... `Finished
server process`) in 3 s; a stop from another console falls back and the
process is gone in 2 s. `lock_holder(root).port` reads 18997 (launcher
-> venv python -> base python).
- `tests/test_everos_server.py tests/test_updates_upgrade.py`: 261
passed, 1 skipped; `tests/test_everos_backend.py -k RequestBodies`: 7
passed.
- Review round (`env -u SERPER_API_KEY uv run --frozen --python 3.12
--extra dev pytest` over the everos, config, settings, memory page,
import, onboard, plugin-stack, boundary, cycle-budget and contract
files): 1225 passed, 1 skipped; `test_everos_server.py` 124,
`test_everos_backend.py` 188.
- Windows 11 box, review round: with the gateway serving, the everos
launcher was terminated by hand (`Stop-Process`, nothing on 18997); the
next turn answered without memory (`recall failed ...
state=unresponsive`), and six seconds after it began the gateway logged
`started everos server` / `everos server ready`, the pidfile named the
new pid and `/health` answered 1.4.1. The first attempt did not fire
because a dead port there takes 2-4 s to be refused, longer than the 1 s
probe; the respawn now fires on a timed-out probe as well, guarded by
the lock holder. The memory page's four counts and a search on the Cases
tab went through the v2 routes.

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed

## Risk

- Windows installs that used to read "long-term memory is not available
on Windows yet" now spawn EverOS, and a stale server is identified and
replaced there too. The stop there is Ctrl-Break with a ten-second
fallback to `TerminateProcess`. An upgrade on Windows first stops every
process whose executable lives under the tool environment: raven's own
gateway, sub-agents and server, nothing outside that directory.
- An embedding pin narrower than 1024 dimensions is refused at the
settings page and the wizard, with the width in the message, only for an
install whose memory runs on EverOS (plugin installed, backend `everos`
or the default). Knowledge-only installs, memory off, and other backends
keep any width. Existing pins are not touched.
- An owned EverOS server whose version differs from the installed
package is restarted on the next session start. A root the user manages
is never restarted.
- A gateway may now start an EverOS server on its own when its probe
finds nothing listening and nothing holding the lock (owned roots only,
at most every thirty seconds). On Windows a backend stops the server it
started when it shuts down (Ctrl-Break, sixty seconds to drain), so a
settings change or an upgrade there restarts the server rather than
leaving it. An upgrade on Windows refuses to proceed while a process
from the tool environment cannot be stopped, and says which pid.
- An embedding pin narrower than 1024 that reached the config around the
settings check is no longer handed to EverOS: recall runs on keywords
with a notice naming the model, until a 1024-dimension model is pinned.
- Rollback: revert the commit and `uv sync`. `lancedb` did not move, so
an index written by 1.4.1 opens under 1.2.3 (exercised on the copy).

- [x] Security impact considered
- [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-fable-5-1) <noreply@anthropic.com>
2026-09-25 19:33:18 +08:00
arelchan
1fa1cc77d7
feat(*): tighten the onboarding wizard after an acceptance walk (#751)
## Summary

Fixes found walking the web onboarding wizard end to end on a fresh
home, plus the settings page pieces it shares.

**Model step (shared with Settings > Models)**
- Connect saves first and tests on the side. The row says "testing"
until the verdict lands; a failed test is marked with a retry and never
holds the key back, since a probe can be wrong (public catalogue, proxy,
vendor down).
- The test is stricter: OpenRouter's public `/models` no longer passes
any key (decoy check, then `/key`); a refused env proxy is reported as
`proxy_unreachable`; a key that cannot go in an HTTP header (non-ASCII,
e.g. the wrong text pasted) is answered `invalid_key` instead of
crashing into `internal_error`, and the add form refuses it up front.
- The picker offers what the vendor last listed. A successful live read
(`model.fetch_models`) is kept per provider in
`cache/served-models.json` with each id's kind and unioned into
`model.options`; disconnect forgets it; the page reloads the offer after
the read. OpenRouter went from 110 bundled ids to 500+.
- Layout: fixed-height vendor listbox, equal-width add fields, form
errors beside the Connect button instead of a screen below, one divider
under the provider block, vendor name shown once, params summary kept on
one line.
- Role slots: a text role takes any connected vendor and accepts a typed
id; the no-provider pill opens the add form; a plain save no longer
toasts "saved" (server warnings still do).
- Embedding can be cleared from the page (`clear_role(...,
deliberate=True)` from `settings.everosSet`); the CLI wizard's skip
still cannot erase it, and llm stays unclearable because EverOS will not
start without it.

**Agents step**
- Subtitle on what connecting buys, an empty state when the machine has
no agent of its own, and Raven's shipped specialists as their own group
with no disconnect (roster and sheet).

**Data sync step**
- Always shown. When no embedding model is set it says so and offers the
embedding picker in place, and the import waits on it. Agents the
importer cannot read yet say "Coming soon".

**Header**
- Language switch as a dropdown; step three named "Agent Connector" to
match the nav.

Contract change: `model.fetch_models` takes an optional `verify`
(default false), mirrored in `raven/rpc/models.py` and both generated
clients.

Known gap, not in this PR: EverOS itself still requires the llm role to
start, so an import with embedding set but no llm role fails with the
server's message.

## Type

- [ ] Fix
- [x] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

Rebased on github/main, then:

- `make lint` - pass (ruff, import and dep checks, gen:check, eslint
with 4 pre-existing warnings, type-check for ui-web and ui-tui,
lint:rpc, lint:i18n, bridge build)
- `make test-ui` - 209 files, 2940 tests pass
- `make test-tui` - 144 files, 2106 tests pass
- `uv run pytest tests -q -rf` - 26154 passed, 1 failed:
`tests/test_rpc_files.py::test_a_host_without_libreoffice_says_so`,
which fails the same way on a clean github/main checkout on this machine
- `npx commitlint --from github/main --to HEAD`,
`scripts/check_commit_messages.py`, `check_large_files.py`,
`check_source_language.py` - pass
- Mutation checks: each new branch was reverted in turn and a test
failed for every one
- Walked the wizard in a real browser against an isolated `RAVEN_HOME`
(connect, probe, pickers, agents step, data sync step with and without
an embedding model)

- [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 these screens.

## Risk

- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes

- The probe reaches OpenRouter `/key` with the stored key and once with
a fixed decoy key; nothing else is sent anywhere new.
- `served-models.json` is a disposable cache under the cache directory;
a missing or unreadable file only shortens the list.
- `verify` is optional and defaults to the old behaviour, so older
clients are unaffected.
- Embedding is now clearable from the page by an explicit click;
clearing it falls recall back to keyword search and leaves knowledge
bases without an embedding endpoint until one is set again.
- Rollback: revert the squash commit.

## Related Issues

N/A

Co-authored-by: Claude (claude-opus-5-5) <noreply@anthropic.com>
2026-09-23 23:27:16 +08:00
Tchen-data
08482231ed
fix: ppt lane inherits host vendor web keys and ppt_fetch names itself (#736)
## Summary

Two faults that left the template-based deck lane (Raven-PPT) without
search and without web pictures on a current raven install.

1. **Web keys were not inherited from a vendor-table host.**
`agents/raven-ppt/run.py` only merged the two pre-vendor leaves
(`tools.web.search.apiKey`, `tools.web.jinaApiKey`). A host configured
on a current raven keeps those keys under
`tools.web.providers.<vendor>.apiKey`, so the rendered product config
carried no web key: `web_search` was withheld and `ppt_image_search`
declined. In a live run the author called both, got "tool is not
available", and spent six minutes paging a wiki API for picture file
names instead. The render now inherits every vendor slot the host fills,
unless the product already holds a key for that vendor (its own config,
or `PPT_SERPER_API_KEY` / `PPT_JINA_API_KEY`, which land in the leaf
trunk reads after the vendor slot, so inheriting the host slot would
outrank them). The host's `search.provider` / `fetch.provider` follow
where the product names none, so a key and its vendor choice travel
together. The engine slice's `imageSearch.apiKey` is taken in trunk's
order: vendor slot, then leaf. `raven-design` already copies the host's
`tools.web` whole; `raven-research` already reads the vendor table.

2. **`ppt_fetch` was refused by Wikimedia and others.** Downloads used
httpx's default `python-httpx/<version>` user agent, which
upload/thumb.wikimedia.org, en.wikipedia.org and sz.gov.cn answer with
403. All five Commons pictures in that run failed and the author fell
back to `curl`, which lands pictures without their captions (the figure
catalogue then held 19 images with `caption: null`). Downloads now send
`raven-ppt/<version> (+https://github.com/EverMind-AI/Raven)`. Measured
with curl on macOS: the same URLs return 403 with the httpx agent and
200 with this one (also checked bbc.com, arxiv.org, github.com: 200).

Not in this PR: `agents/raven-code` and `agents/raven-oncall` read the
same two legacy leaves only and likely have the same gap on a
vendor-table host.

## Type

- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

- `uv run pytest tests/test_agents_ppt_launcher.py
tests/test_ppt_engine_fetch_tool.py -q`: 93 passed.
- The 5 new tests with the source changes reverted: 4 failed (the
own-key-precedence test is a guard and passes either way); with the
changes: all pass.
- `uv run pytest tests/test_subagent_vendored_agents.py
tests/test_config_product_render.py
tests/test_ppt_engine_prompt_claims.py
tests/test_agents_design_launcher.py -q`: 188 passed, 1 skipped.
- `uv run ruff check` and `uv run ruff format --check` on the four
changed files: clean.
- curl on macOS against the Wikimedia, Wikipedia and sz.gov.cn URLs from
the failing run, with both user agents (results above).

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed

## Risk

A deck lane on a vendor-table host now gets the host's web keys and
vendor choice, so `web_search` and `ppt_image_search` appear where they
were missing; a product-level key still wins. The fetch user agent
changes for every download; a site that only accepted browser agents
would still refuse, as before. Rollback is reverting this commit; the
env keys (`PPT_SERPER_API_KEY`) keep working either way.

- [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-opus-5-5) <noreply@anthropic.com>
2026-09-23 23:07:22 +08:00
Zuyi Zhou
72fe7e4aa1
fix(*): find a homebrew libcairo and refuse an svg the ppt engine cannot draw (#719)
## Summary

On an Apple silicon Mac with Homebrew,
`ctypes.util.find_library('cairo')` returns None and `import cairosvg`
raises `OSError`; it only worked when the process was started with
`DYLD_FALLBACK_LIBRARY_PATH=/opt/homebrew/lib`. `ppt_fetch` swallowed
that failure in `_rasterised_svg`, so a fetched SVG logo was saved as a
`.md` full of path data, with no `figure_id` and no log line. `raven
doctor` did not mention cairo at all. The design engine draws SVG
through Chromium and is not affected.

Head: b84764f33, on top of main at 8ee5ae0d8.

- **Finding libcairo.** New `raven/utils/cairo.py`. `libcairo_path()`
tries the default lookup and then `/opt/homebrew/lib`, `/usr/local/lib`
and `/opt/local/lib`. The `libcairo_reachable()` context manager adds
that directory to `DYLD_FALLBACK_LIBRARY_PATH` only while the import
runs, holding a lock, and puts back any value the user had set. This
works because `find_library` on macOS reads the variable from
`os.environ` at call time and then hands cairocffi an absolute path.
Loading the dylib by absolute path beforehand does not work (tried and
measured): dyld does not match a bare leaf name against an image that is
already loaded. The variable is set only around the import, so later
subprocesses do not inherit it. The `cairosvg` import itself lives in
the ppt engine (`_load_cairosvg`), because deptry refuses a core import
of a plugin-only dependency.
- **Clear failure instead of silent downgrade.** A download whose root
element is `<svg>` (after any XML declaration, comment or doctype) now
either becomes a PNG or is refused. If cairo cannot load, the fetch
fails with the first line of cairocffi's error and the install command.
If the SVG will not draw, the fetch fails with the parser's error. Both
cases log a warning and write nothing to the deck's sources. An HTML
page with inline `<svg>` icons stays an `.html` document and no longer
goes to the rasteriser; before, any text with `<svg` in its first 4 KB
did.
- **Doctor.** `External tools` gains a `Cairo:` row that shows the
library path, or `not found` with what that costs and the install
command. Like the LibreOffice row, it does not change the exit code.
`--json` carries `external_tools.cairo`.

Behaviour change: an SVG that cannot be drawn was kept as a text
document and is now refused. This is on purpose; path data was never
usable as a source.

## Type

- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

Head b84764f33, rebased onto origin/main 8ee5ae0d8; the rebase replayed
both commits unchanged (`git range-diff` shows `=` for each) and the
focused command below reran at this head. The full-suite line is from
5f4051e8f on afdc04f89. The second commit answers the two review
findings: `_SVG_ROOT` allows a UTF-8 byte-order mark before the root
element (`_sniff(b"\xef\xbb\xbf<svg ...")` returned a document before,
and now returns a PNG, or a refusal without cairo), and the two
LibreOffice doctor tests read the LibreOffice row alone, so a runner
without libcairo no longer fails the healthy case on the Cairo row's
"not found".

```
uv run --frozen --python 3.12 --all-extras pytest -q tests/test_ppt_engine_fetch_tool.py tests/test_cli_doctor_commands.py tests/test_utils_cairo.py
  142 passed
COLORTERM=truecolor uv run --frozen --python 3.12 --all-extras pytest -q -p no:cacheprovider
  25916 passed, 108 skipped, 1 failed: tests/test_rpc_files.py::test_a_host_without_libreoffice_says_so
  (local only and pre-existing: it fails the same way on origin/main afdc04f89 on this machine, which has
  LibreOffice installed; this branch does not touch rpc/files)
```

Revert-to-red for the second commit: without `\ufeff?` the new BOM test
fails; with `libcairo_path` forced to None across the doctor file (the
CI shape), the old LibreOffice assertion fails and the new one passes.

The numbers below are from the first head and are kept for the record.

```
uv run --frozen --all-extras pytest -q tests/test_utils_cairo.py tests/test_cli_doctor_commands.py tests/test_ppt_engine_fetch_tool.py
  141 passed
```

`test_a_brand_mark_arrives_as_svg_and_is_kept_as_a_picture` used to skip
on this machine (no DYLD variable set). It now runs and passes.
`test_cairosvg_imports_with_no_dyld_variable_where_brew_installed_cairo`
repeats the reported failure in a fresh interpreter with every `DYLD_*`
variable removed.

Revert-to-red: I restored the parent's `fetch.py` and
`doctor_commands.py`, kept the new tests, and 6 of them failed (both
doctor cairo tests, the refused-SVG tests, the declaration-prefixed SVG
test, and the end-to-end no-file-written test).

```
COLORTERM=truecolor uv run --frozen --python 3.12 --all-extras pytest -q
  25872 passed, 108 skipped   (before the rebase and the install-hint test)
make coverage
  25894 passed, 108 skipped   (at this head)
COVERAGE_BASE_REF=origin/main make coverage-diff
  Diff coverage: 100.00% (53/53 executable changed lines)
uv run --frozen --python 3.12 --extra dev ruff check raven evolver agents plugins-dist tests scripts
uv run --frozen --python 3.12 --extra dev ruff format --check raven evolver agents plugins-dist tests scripts
make lint-imports lint-deps lint-types
PYTHONPATH=. uv run --frozen --python 3.12 --extra dev python scripts/check_source_language.py origin/main...HEAD
make check-commits
COMMIT_RANGE=origin/main...HEAD make check-large-files
git diff --check origin/main...HEAD
  all clean
```

I have not run it on Linux or Windows locally. Off macOS
`libcairo_reachable()` does nothing and `libcairo_path()` is plain
`find_library`. The per-platform install hints are unit-tested.

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] 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

`DYLD_FALLBACK_LIBRARY_PATH` affects the whole process, but it is only
changed inside the import block, under a lock, and is restored
afterwards. A fetched SVG that cannot be rasterised now returns `ok:
false` instead of landing as a document. Roll back by reverting this
commit.

## Related Issues

N/A

---------

Co-authored-by: Claude (claude-opus-5-5) <noreply@anthropic.com>
2026-09-23 22:54:01 +08:00
zhanghui
93e1e1f027
fix(*): say long-term memory is not on Windows yet instead of reporting it unreachable (#737)
## Summary

On native Windows, EverOS cannot run: it is spawned, found and stopped
through POSIX tooling. Today a Windows install gets the worst possible
reading of that fact. The memory page shows four zeros, "everos
unreachable" and a retry button that cannot help, and changing a memory
model on the settings page runs a restart chain that can only fail.
Support is coming; until it lands, Raven should say so in one sentence
and stop trying.

One sentence in one place, `everos_platform_note()` in
`raven/core/plugin_stack.py` (beside the existing
`everos_plugin_missing_note()`), returns the note on `win32` and `None`
everywhere else. Three surfaces ask it first:

- `memory.stats` / `memory.list`: the page renders the answer as its
existing `note`, so the frontend needs no change.
- `precheck_spawn()` in the EverOS plugin: the settings-page restart
chain reads it before stopping anything and reports it through the
`memory.health` banner the page already shows.
- `EverosBackend.start()`: the session notice already gated Windows with
wording of its own; it now says the same sentence.

A second commit closes what the first left open, found by a real turn on
the shimmed gateway and by self-review:

- `EverosBackend.start()` used to leave `_state` at `UNKNOWN` on Windows
(before this PR too), so every turn's memory write came back as a failed
write: the host retried it for 52 seconds, logged `backend.store gave up
on a turn`, and after three turns raised the memory banner over a
service that was never going to exist. A new terminal
`ServiceState.UNSUPPORTED`, in both `_TERMINAL_STATES` and
`_NO_MEMORY_TO_LOSE`, makes the write a no-op and stops the probes.
- `EverosBackend.health()` said `server: not running (starts on demand)`
on Windows, which is false there; the importer's refusal and `raven
doctor` now carry the platform sentence instead.
- `_unavailable_note()` asked the platform before the configured
backend, so a Windows install whose memory runs on mem0 would have been
told it has no long-term memory. The sentence is now returned only where
the page would otherwise send the reader to EverOS.

Frontend untouched. Removing the gate when Windows support lands is
deleting the one function, its call sites and the `UNSUPPORTED` member.

## 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

```
uv run --frozen --python 3.12 --extra dev pytest tests/test_everos_backend.py tests/test_rpc_memory.py tests/test_everos_server.py tests/test_core_plugin_stack.py tests/test_plugin_boundary.py tests/test_rpc_import_sync.py tests/test_everos_backend_contract.py tests/test_memory_backend_contract.py tests/test_rpc_settings.py -q
# 485 passed, 1 skipped (the pre-existing Linux-only inotify case)
uv run --frozen ruff check <the 7 changed files> && uv run --frozen ruff format --check <the 7 changed files>
# All checks passed! / 7 files already formatted
uv run --frozen python scripts/check_source_language.py github/main
# exit 0
```

Reverse checks: with the platform test in `everos_platform_note()`
replaced by an unconditional `None`, the first three new cases fail (3
failed in 1.36s). With the `UNSUPPORTED` assignment, the `health()`
short-circuit and the note reorder removed, four of the five later cases
fail, and re-introducing the platform-first order fails the fifth (the
mem0 case). Every file was restored byte for byte.

Real-host check on macOS (no Windows machine was available): three
isolated `raven serve` instances, each with its own `RAVEN_HOME` and an
EverOS address pointing at an unused port, driven with playwright-cli. A
`sitecustomize.py` made `sys.platform` read `win32` only for the gate
file (and, for the baseline, the plugin's `backend.py`); every other
reader kept the real value.

- Baseline (GitHub `main` + shim): memory section shows four zeros,
"everos unreachable: All connection attempts failed" and a retry button;
gateway log has four `memory.stats: ... unavailable` warnings.
- This branch + shim: memory section shows the one-sentence note;
`memory.stats` logs the same sentence; no EverOS process appears.
Picking a different memory model writes the config and logs `everos
restart ... end: precheck refused, server left running`; the transcript
banner carries the sentence.
- This branch, no shim (macOS control): EverOS starts normally (`everos
server ready`), the page shows the empty store.
- This branch + shim, one real turn through the page (DeepSeek V4 Pro):
the reply arrives; the gateway log carries no `backend.store gave up`
line and no `memory.health` alarm 90 seconds later. The same turn
against main's own Windows gate (which leaves the state at `UNKNOWN`, as
the first commit still did) logged `backend.store gave up on a turn ...
after 5 attempts` 52 seconds after the reply.

Not verified: whether the `everos` package installs and `raven` starts
on a real Windows machine.

## Risk

- [ ] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes

User-visible only on native Windows: the memory section and the
settings-save banner show the sentence instead of an unreachable-server
error, and no EverOS spawn is attempted from the settings page. No
change on macOS or Linux. Rollback: revert the commit.

## Related Issues

N/A

---------

Co-authored-by: gloryfromca <23442919+gloryfromca@users.noreply.github.com>
Co-authored-by: Claude (claude-fable-5-1) <noreply@anthropic.com>
2026-09-23 21:40:20 +08:00
Tchen-data
f178990780
fix: give the renderer a Han face rather than hoping the host has one (#668)
## Summary

Chinese in a deck came out as boxes (or as nothing) in the preview
panel, the delivery thumbnail, the template gallery, and the pages the
model renders to check its own work. LibreOffice reports success and the
PDF is well formed, so nothing flagged it.

Why, per platform:

- **Linux**: apt's `libreoffice` brings no CJK face.
- **macOS**: the system already ships Han faces (Songti, STHeiti,
Hiragino Sans GB, PingFang). Since 26.8 the macOS build renders headless
through a bundled fontconfig (`--enable-headless
--without-system-fontconfig` in `distro-configs/LibreOfficeMacOSX.conf`)
that looks for `/usr/local/etc/fonts/fonts.conf`, which an Apple Silicon
Mac does not have; without it that fontconfig lists 0 fonts, and a face
in `~/Library/Fonts` or a per-user fontconfig file is ignored. That is
why installing a font on a Mac never helped, and why the Macs that
worked had a CJK face copied into `LibreOffice.app` by hand.
openai/codex#32968 reports the same symptom from Codex's own
headless-only LibreOfficeDev build, whose fontconfig carries a
`/@..._OOO/etc/fonts` prefix; the cask build looks in
`/usr/local/etc/fonts`, so that thread's workaround is not the one
needed here.

What the PR does (the net diff; earlier commits on the branch tried
render-time detection, environment injection and then an
installer-written fontconfig file, and the later commits replace them):

1. **Linux font.** The LibreOffice offer installs `libreoffice
fonts-noto-cjk`. Where that did not run and `fc-list :lang=zh` is empty,
a pinned Noto Sans SC (size and sha256 checked before it is put in
place) goes into `~/.local/share/fonts` and `fc-cache` is rerun.
2. **macOS: the Mac's own faces, linked into LibreOffice's profile.**
LibreOffice always reads the `user/fonts` folder of the profile it runs
with. `office.link_han_faces(profile)` links Songti, STHeiti, Hiragino
Sans GB and PingFang (found under `AssetsV2` each time, so a link a
macOS update left dangling is replaced) into `profile/user/fonts`.
`office.to_pdf` does it for its throwaway profile (preview panel,
delivery thumbnail, template covers, ppt engine), the design engine for
its two profiles, and `ExecTool` for LibreOffice's default profile,
which the model's own `soffice --convert-to` uses. No download, no
password, nothing written outside the user's home, and it reaches users
who upgrade without rerunning `install.sh`.
3. **LibreOffice on a Mac without Homebrew.** This used to be a warning
and no preview at all. The installer now fetches the release dmg
(26.8.0, sha256 pinned per arch, from the stable directory and then the
archive), mounts it read-only, copies `LibreOffice.app` into
`/Applications` or `~/Applications`, never over an existing app, and
writes a two-line `~/.local/bin/soffice` launcher the way the cask does.
A failed `brew install` falls back to it too.
4. **Finding it.** `office.find_soffice` falls back to the launcher
inside `LibreOffice.app` in either Applications folder when nothing is
on PATH; the design engine now asks the same resolver.
5. **Stale renders.** The pdf-preview and deck-template cover cache keys
mix in `office.RENDER_GENERATION` (3), which retires every picture drawn
before this change. The Linux font step also clears both caches whenever
it installs a face.

Removed relative to earlier revisions: `raven/utils/fonts.py`
(`render_env`, `han_face`, `can_draw_han`, `host_han_faces`,
`install_hint`; several were never called), the exec-environment
wrapping, the ppt-engine face lookup, and the installer's sudo-written
`/usr/local/etc/fonts/fonts.conf`.

Known limits:

- A `soffice` run with a profile raven did not prepare (a caller passing
its own `-env:UserInstallation`) gets no faces on a Mac.
- A `deck.pdf` rendered beside a deck before the fix is still preferred
by the viewer until the deck is re-rendered or touched.
- Verified on macOS 15.7.1 arm64, and by review on macOS 26.5 arm64
(LibreOffice 26.8.0.3 from the cask); macOS 14 and Intel Macs have not
been run.

## Type

- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

macOS 15.7.1 arm64, LibreOffice 26.8.0.3 run from the stock dmg (no CJK
face in its bundle), fontconfig handed an empty configuration (so no
`fonts.conf` of any kind), HOME pointed at an empty directory:

- `main`: the model's own `soffice --convert-to` (default profile, after
building an `ExecTool`), `pdf_preview.pdf_for` / `png_for`, the ppt
engine's `to_pdf` and the design engine's `LibreOfficeBackend` each
embedded only Carlito and LinuxLibertineG (`pdffonts`).
- This branch: the same four paths each embedded PingFangSC, STHeitiSC
and STSongti-SC; the default profile held links to the five faces.
- No-Homebrew path, with PATH stripped of `/opt/homebrew`, an empty HOME
and a read-only Applications folder: the step downloaded the dmg,
matched its digest, installed into `~/Applications` (`codesign --verify
--deep --strict` valid, `spctl --assess` accepted) and wrote the
launcher; a second run downloaded nothing.
- Linux (container with every CJK face hidden): the font step downloaded
Noto Sans SC and the render embedded NotoSansSC; a second run did
nothing.
- `uv run --frozen --all-extras pytest -q tests/test_utils_office.py
tests/test_install_script.py
tests/test_design_engine_rendering_office.py
tests/test_rpc_deck_templates.py tests/test_shell_background.py
tests/test_ppt_engine_render_service.py`: 142 passed, 1 skipped.
- `uv run --frozen lint-imports`: 10 kept, 0 broken. `ruff check` /
`ruff format --check` on the changed files: clean. `shellcheck -s sh
install.sh`: no new findings. `scripts/check_source_language.py`: pass.

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed (no docs
describe this step)

## Risk

- [x] Security impact considered: the dmg and the font are checked
against pinned sha256 digests before use; the macOS change only creates
symlinks under LibreOffice profiles in the user's home, never replaces a
real file there, and runs no privileged command.
- [x] Backward compatibility considered: Linux hosts that already have a
CJK face are untouched; on a Mac, a profile that already holds its own
fonts keeps them. The cache-key bump costs one re-render.
- [x] Rollback path is clear for risky changes: deleting the links in
`~/Library/Application Support/LibreOffice/4/user/fonts` returns
LibreOffice to its previous behaviour; reverting the PR restores the old
installer.

User-visible: a Mac without Homebrew downloads about 300 MB of
LibreOffice once; nothing asks for a password.

## Related Issues

N/A

---------

Co-authored-by: litong <litong02@shanda.com>
Co-authored-by: Claude (claude-opus-4-6) <noreply@anthropic.com>
Co-authored-by: KT <74288668+0xKT@users.noreply.github.com>
2026-09-23 19:10:53 +08:00
zhanghui
e5c7de12a0
fix(*): follow a rotated provider credential into the memory service (#713)
## Summary

Rotating a provider's API key in raven left the running EverOS process
on the
old one, with nothing on any screen saying so.

EverOS builds its model clients once, in the API lifespan, from
environment
variables raven hands it at the spawn. A credential edited afterwards
reached
`config.json` and never reached that process. `/health` never touches a
model,
so every surface stayed green while memory failed on a revoked key in
EverOS's
own log. Restarting raven did not help either: `ensure_everos_server`
adopts a
server that is already answering, so the stale process outlived it.

Only the four memory-role pins had a restart hook. The provider
credential they
resolve through did not, and it is written from five other places.

Two layers, because the write paths and the read path fail differently:

- `ensure_everos_server` records a digest of what a spawn hands the
server, and
compares it before adopting a running one. Every session passes through
it,
  so this covers what the gateway never sees: `raven provider set`, a
hand-edited `config.json`, and an install that predates the record (it
heals
  once, then is adopted normally).
- `model.save_key`, `model.set_fields` (api_base only),
`model.disconnect`,
`model.add_endpoint` and `model.remove_endpoint` restart the service
when one
of the four roles is pinned to the provider they just wrote, so the
change
  takes effect when the person made it rather than at the next session.

One bug found while driving a real spawn: a stop returning `None` counts
as a
failure on the adopt path and does not in `restart_for_config_change`.
That one
may run with nothing serving; this one has just probed a healthy server,
so
`None` means the lock could not name it. Reading it as "nothing to stop"
left
the old process holding the port while the poll below found its
`/health` and
called the restart a success. The unit tests mock the stop and cannot
see it.

## Type

- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

Full suite:

```
env -u SERPER_API_KEY uv run --frozen --python 3.12 --extra dev pytest -q
25608 passed, 121 skipped, 133 warnings in 193.95s
```

The 121 skips are missing optional deps (channel SDKs, chromium, cairo),
Linux-only cases, and not-applicable parametrisations. Nothing was
skipped,
xfailed or weakened to reach green.

Reverse verification, to confirm the new cases can fail: stubbing the
digest
comparison reds 3, stubbing the restart call reds 4, making the provider
match
always-true reds 1, dropping the `api_base` guard reds 1.

Acceptance against a real `everos` binary on a throwaway root and port,
with
the key read back from the new process's own environ via `ps -E`
(15/15):

| Case | Result |
| --- | --- |
| `model.save_key` rotates a pinned provider's key | pid replaced, new
process on the new key |
| `model.set_fields` moves api_base | pid replaced, new base_url in
effect |
| `model.add_endpoint` / `remove_endpoint` | pid replaced, follows the
first endpoint holding a key |
| `model.disconnect` on a pinned provider | old server left serving,
page told why |
| A provider no role uses | no restart |
| A field EverOS never sees (extra_headers) | no restart |
| A CLI-side rotation raven's gateway never saw | picked up at the next
session |
| An unchanged config | adopted, not restarted |
| A server with no recorded digest | heals once, adopted after |
| A root raven does not own | never stopped |
| A replacement that cannot boot | old server left serving |

Lint:

```
uv run ruff check   # clean
uv run ruff format --check   # clean
```

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed

## Risk

Behaviour change: a session may now restart the memory service on
startup when
the running one holds credentials raven no longer has. That is the
point, and
it costs a few seconds of memory downtime; measured at 1.7-3.1s on this
machine. Installs that predate this change restart once, because they
have no
record to compare, and are adopted normally from then on.

Guards against the one genuinely bad state, stopped-and-not-started: the
precheck runs before the stop, and any stop that does not reach
`STOPPED`
leaves the old server serving. A root raven does not own is never
touched.

Rollback is a revert: without the digest file the code is inert, and a
stale
file only causes one extra restart.

- [x] Security impact considered
- [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>
2026-09-23 17:01:39 +08:00
zhanghui
1aac70ed10
fix(*): ship the deck template covers so a boot draws none (#699)
## Summary

Starting a gateway started LibreOffice. Fifteen seconds after every boot
the
template picker's covers were drawn on the host: ten conversions, three
at a
time, for a gallery most readers never open. On macOS those are three
icons
in the Dock on a start that was asked to do nothing of the kind.

The covers only depend on the templates the engine ships, so the release
renders them once instead of every installation rendering them again.
`scripts/bake_deck_template_covers.py` walks the template directory and
every
phrasebook beside it, writes one JPEG per template per language into
`raven_ppt/assets/templates/covers/`, and the ppt-engine wheel carries
that
directory. `deck_templates.shipped_cover` reads it before anything is
started, `cached_cover` and `cover_for` answer from it, and the warm-up
introduced in #624 then finds nothing missing and starts nothing. Twenty
covers, 398 KB.

The warm-up itself is unchanged, and so is the rendering path:
`shipped_cover`
answers None rather than raising, so a template dropped into the
directory by
hand, a language added after the build, and an install from source all
still
draw their own. Both the bake and the release gate read the directory
rather
than a list, so a new template or a new language is a new file and not a
code
change.

Two packaging lines were measured rather than assumed. Hatch reads the
ignore
file at the built project's root, and the rule lives at the repository
root,
so the `include` list alone ships the covers today; adding a
`.gitignore`
under `plugins-dist/ppt-engine` drops them to zero, which is what
`artifacts`
is there for. Both states were built and inspected.

## Type

- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

- `uv run --frozen --python 3.12 --extra dev pytest
tests/test_rpc_deck_templates.py
tests/test_rpc_console.py tests/test_cli_serve_commands.py
tests/test_cli_gateway_commands.py
tests/test_ppt_engine_default_templates.py
tests/test_ppt_engine_templates.py -q`
  -> 417 passed.
- Reverse check: with the two `shipped_cover` short circuits removed,
the two
new cases fail on the symptom they name (`a cover the wheel carries must
not
  be drawn again`) -> 2 failed, 28 passed.
- End to end on one build, the only variable being whether the covers
are in
the package. Covers hidden: `drawing 10 missing cover(s)` and three
`soffice`
processes. Covers shipped: no log line, nothing queued, no `soffice`.
Run
  against an empty RAVEN_HOME, in both `zh` and `en`.
- `scripts/bake_deck_template_covers.py` against the real package -> 20
covers,
  398 KB; the `en` set carries English copy, checked by opening one.
- `uv build --wheel plugins-dist/ppt-engine` four times across the
include and
artifacts combinations -> 20 covers in the wheel, 0 without `artifacts`
when
  a project-local `.gitignore` exists.
- `ruff check` and `ruff format --check` on the changed Python -> clean.
`scripts/check_source_language.py` and `scripts/check_large_files.py`
over
  `github/main..HEAD` -> exit 0. `commitlint` on the commit -> exit 0.

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed

## Risk

- Nothing a reader sees changes: the picker shows the same pictures,
drawn by
  the build rather than by their machine.
- The release job gains an apt install of `libreoffice-impress` and one
bake
step. If the bake fails the release fails there, rather than publishing
a
wheel whose covers are silently absent; the ppt-engine gate asserts one
cover
  per template per language in the built wheel.
- An install from source has no baked covers and behaves exactly as it
does
  today, rendering them once at boot.
- Rollback: revert the squash commit. Nothing is stored, cached or
migrated,
  and a host with the old wheel keeps drawing its own covers.

- [ ] Security impact considered
- [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>
2026-09-23 14:56:44 +08:00
Tchen-data
1b83ffdfee
feat(rpc): show the template picker in the reader's language (#661)
## Summary

The bundled templates ship written in Chinese, so a reader on an English
page saw ten Chinese covers and picked one blind. Translating each
template into a file of its own would double what the wheel carries for
every language, so the templates stay as they are and a phrasebook
beside them (`assets/templates/i18n/en.json`, 843 entries, 59 KB) says
each of their stand-in strings in the other language. The reader's copy
is built from that once and kept in the cache; a language with no
phrasebook, or a copy that cannot be built, falls back to the shipped
file.

The new text is then fitted to the box it landed in, which is the part
worth reading. A Chinese label breaks between any two glyphs, so a
narrow box holds a long one by stacking it and the label's own length
says nothing about how wide the box is. English cannot break inside a
word, so the box is measured instead -- from its own size and the number
of glyphs it held -- and a shape whose text now wants more room is told
to scale that text down. Shapes drawn to one size are given one scale,
so a row of cards does not come back at five sizes. Without this, card
titles wrapped onto a second line that landed on the body text beneath
them, section titles overran their card and covered the subtitle, and
one label came out cut mid-word.

The same pass takes the vendor's marks off the templates themselves.
Every one was cut from a commercial kit that signs the file in places a
slide never shows: core and application properties, the theme's name and
its font and colour schemes, an add-in's tag records, a credit run on a
layout, and a bare web address on the cover and closing pages. The
engine already stripped all of that from a built deck before measuring
it, so a delivered deck was clean; the templates were not, and the
picker is what a reader sees. The cover's second field now says a date
rather than losing the box the address held.

Three things the templates get wrong on their own go with it: a pyramid
whose third tier is numbered 02 like the one above it, a five-item list
that counts 1 3 3 4 5, and two type-size notes ("-12px", "-48px") left
in placeholder copy.

This is stacked on #624 -- `gateway_commands.py` passes the reader's
language into `warm_covers_in_background`, which that PR adds. Merge it
first and this retargets to main.

## Type

- [ ] Fix
- [x] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

`uv run --frozen pytest tests/test_rpc_deck_templates.py
tests/test_rpc_console.py tests/test_cli_gateway_commands.py
tests/test_cli_serve_commands.py tests/test_rpc_files.py
tests/test_utils_office.py -q` -> 370 passed.

`uv run --frozen ruff check` and `ruff format --check` on the touched
files -> clean. `make check-large-files` -> passed.
`plugins-dist/ppt-engine/fetch_templates.py --verify` -> all ten pins
hold. A wheel built from the engine carries the phrasebook and all ten
templates.

Rendered all ten templates in both languages through LibreOffice, 210
pages each, and read every English page. Three checks over the same
renders: no word broken across a line (16 such labels at the start, 0
now), no text overlapping another shape's text that the Chinese does not
also overlap, and no box whose ink runs past it in English alone. The
two circles a reader would have seen cut ("Teamwor/k Matters",
"Communi/cation") and the chart axis that came back rotated and
truncated are in that count.

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed

## Risk

A reader whose language is the source language sees exactly what they
saw before: the phrasebook is consulted only for another language, and
`source_for` returns the shipped file. The template bytes changed for
everyone, so a cached cover is redrawn (the cache key carries the file's
size and mtime) and a deck built on one of these templates no longer
inherits the vendor's name in its PDF title. Rolling back is reverting
the three commits; the pins in `templates.manifest.json` move with the
bytes, so a revert leaves the payload and the manifest agreeing.

- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes

## Related Issues

N/A
2026-09-22 23:09:10 +08:00
Zuyi Zhou
0332ec3d5f
fix(design-engine): name the session directory a caller resolves against (#648)
## Summary

A design subagent's artifacts live in a directory of its own, one level
below the directory its spawning turn dispatched it into. The dispatch
receipt the parent holds names the directory it dispatched into, and the
run's reply names its files as relative paths. Resolving one against the
other looked one level too high: measured on a real dispatch, the
parent's first `deliver_files` for `index.html` came back with no files,
and only a disk search run by the model itself found them on the second
attempt. A run that does not self-diagnose fails there instead of
delivering.

Two routes were available. The first was a new channel for a subagent to
report the working directory it actually moved into. The ACP pool tracks
`cwd` only as a launch parameter, the live binding is process-local, and
the host is forbidden from deciding anything out of Response Meta, so
that route meant a new protocol crossing the `agent` and `design-engine`
scopes, plus a host that reads a product's directory. The second was to
fix the handoff contract at its source: the reply names the directory it
worked in. This PR takes the second.

- `DesignParticipant.outbound` appends a final line: `Design session
directory: <abs>`, followed by `Paths in this reply resolve against it.`
It is emitted only for a directory this engine minted, recognised by the
same rule that owns it, so shared-directory mode and any turn that never
repointed are untouched.
- The directory name is now minted by one helper, `session_dirname`,
read from two seats: the one that makes the directory and the one that
recognises it again.
- The deck engine (`ppt-engine`) already names its artifact absolutely
in its reply tail, and an appended tail reaches an ACP caller over the
same `StreamDelta` path, so this makes the two engines agree.
- The host is unchanged: the receipt still names the dispatch directory,
and the run's own report rides through `_announce_result` inside the
untrusted fence, unread. The caller holds both facts, each true.
- `agents/README.md`'s raven-design note documents the new line.

Deliberately not done: no "search the disk when a path is missing"
heuristic in `deliver_files`, and `workdir_per_session` is unchanged.

Not covered: an in-process subagent dispatch (`Origin.SUBAGENT`) skips
the send chain entirely (`_SKIP_AFTER_SEND_ORIGINS`), so no reply tail
runs on that lane. That is pre-existing and separate; both shipped
engines run over ACP.

## Type

- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

- `uv run pytest tests/test_design_engine_plugin_face.py
tests/test_subagent_manager.py tests/test_subagent_workdir.py
tests/test_agents_design_launcher.py -q` -- 298 passed, run after
rebasing onto `origin/main`.
- `uv run pytest tests/test_subagent_*.py -q` -- 1966 passed.
- `uv run pytest tests/test_design_engine_*.py -q` -- 163 passed.
- `uv run pytest tests/test_external_consumer_surface.py
tests/test_living_docs.py tests/test_ppt_engine_plugin.py -q` -- 103
passed.
- `uv run --frozen --python 3.12 --extra dev ruff check` and `ruff
format --check` on the changed files -- passed.
- `uv run --frozen --python 3.12 --all-extras ty check
plugins-dist/design-engine` -- passed.
- `make check-source-language` -- passed, and every added line was
verified ASCII by a character scan of the diff.

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed

Cases added, each falsifiable:

- `test_the_reply_names_the_session_directory_the_run_wrote_into` drives
the real loop, writes `poster.txt` through `write_file`, and asserts the
reply names the directory the write landed in and that the
reply-relative path resolves against it. Without the tail the reply
names nothing and the path does not resolve.
- `test_no_session_directory_line_for_a_binding_the_engine_did_not_mint`
pins the gate: no line when the engine never minted the directory.
- `test_announce_passes_through_a_run_that_reports_its_own_directory`
pins the receipt: the dispatch line and the run's own line both present,
with the run's line inside the untrusted fence. It fails if the host
ever lifts that report out of the fence into its own voice.
- `test_concurrent_sessions_keep_files_state_and_completion_separate`
now reads the tail for the completion notice rather than for `None`,
which keeps the property it held: a finished task is not nagged, an
unfinished one is.

## Risk

- User-visible: a design turn's reply carries one extra line, two with
the resolution note. Machine-written, in the same shape the deck
engine's `Deck:` / `MEDIA:` lines already use; a reader that ignores it
sees an ordinary reply.
- Backward compatibility: in place. The line is appended only when the
engine minted the session directory; the host's receipt, the fence
around the report, and the workdir binding are untouched.
- Rollback: revert the commit. The appended line disappears and the
previous behaviour returns exactly.
- Security: the appended text stays inside the untrusted fence on the
way back, and the host still reads none of the report. No new path is
trusted, and nothing new is resolved against a caller-supplied value.

- [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>
2026-09-22 20:59:52 +08:00
zhanghui
77f5ffc4a7
fix(plugins): the role rules hold at every door, not one each (#633)
## Summary

Follow-up to #614, which merged with a blocking finding open. Two
consequences
of one shape, both confirmed by reproducing them on the merged branch
before
anything was touched: a rule enforced at one door while another door
reaches
the same operation.

**`clear_role` never consulted `REQUIRED_ROLES`.** The RPC door did, and
refused
to clear `llm` or `embedding`. The wizard reached the same function
through its
own older answer, whose table says `optional: true` for embedding --
which
answers "may be left unset", not "may be erased". Clicking Skip on a
configured
embedding role called `set_embedding_endpoint({"model": "", "provider":
""})`
and emptied raven's own top-level block, the one endpoint every
knowledge base
embeds with. Reproduced:

```
before                     {'model': 'text-embedding-3-small', 'provider': 'openrouter'}
CONTROL  clear_role(rerank)      block unchanged
SUBJECT  clear_role(embedding)   not refused; block = None
                                 log: "config/update: embedding endpoint cleared"
```

The rule now lives with the operation. `clear_role` raises
`RoleRequiredError`;
the RPC translates it instead of restating it, so there is one rule
rather than
two copies that drifted; the wizard stops offering Skip for a role that
is set
and required, while still offering it for one that is merely unset. A
test that
asserted the old behaviour is replaced -- it pinned the defect as the
contract.

**`restart_for_config_change` never asked `everos_owned`.**
`_require_owned`
sits on the write primitives "so a new caller cannot opt out"; the
restart is a
new caller and is not a write primitive, so it did. The embedding role
is exempt
from the ownership gate by design, so a save of it on a user-managed
root fell
through to `stop_for_reload` -> `stop_pid`, which SIGTERMs whatever
`lock_holder`
names for that root: the user's own server. Reproduced as far as the
exemption,
which is the part that can be driven without harming a running service:

```
owned=False   llm  rerank  multimodal -> REFUSED (EverosRootNotOwnedError)
              embedding                -> got past the ownership gate
```

That contradicts this feature's own written rule three times:
`everos_owned`'s
docstring ("never start or stop the process"), the file header, and C13
in the
design document. The chain now refuses before it stops anything, and
says the
root is theirs to restart.

Also, smaller, all named in the same review: the design document used
"role
block", which the CONTEXT entry it ships beside puts on its `_Avoid_`
list; the
vendor table spelled the rerank protocol `rerank_provider`, the word
that entry
says to avoid, while EverOS's own `rerank.provider` field and the
`EVEROS_RERANK__PROVIDER` variable keep their names; and A18 stated a
criterion
that is false about the code, since the protocol legitimately reads
`deepinfra`
and `dashscope` where it belongs.

## Type

- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

- `uv run --frozen --python 3.12 --all-extras pytest
tests/test_everos_config.py tests/test_everos_backend.py
tests/test_everos_server.py tests/test_everos_discover.py
tests/test_config_update_everos.py tests/test_config_update_providers.py
tests/test_plugin_boundary.py tests/test_rpc_contract_shapes.py
tests/test_rpc_settings.py tests/test_cli_onboard_commands.py -q` --
1018 passed, 1 skipped
- `ruff check raven/ tests/ plugins-dist/` -- all checks passed
- `ruff format --check raven/ tests/ plugins-dist/` -- 1839 files
already formatted
- `make check-source-language` over this range -- clean

Each fix was mutated back to the defect to confirm the new cases bite:

- `clear_role` stops consulting `REQUIRED_ROLES` -- reddens the config
case and
the RPC case, which is what says the RPC now depends on the one rule
rather
  than carrying a second copy
- the wizard offers Skip for a required role again -- reddens the wizard
case
- the restart stops asking `everos_owned` -- reddens the unowned-root
case

Each mutation was reverted and the file hash compared afterwards.

## Risk

User-visible: Skip disappears from the wizard menu for an embedding role
that is
already configured, and a save of the embedding role against a
user-managed root
now reports that the server was not restarted instead of restarting it.
Both are
the behaviour the feature's own documents already describe.

Rollback: one commit, reverts cleanly.

## Related Issues

Follow-up to #614.

---------

Co-authored-by: gloryfromca <23442919+gloryfromca@users.noreply.github.com>
Co-authored-by: Claude (claude-opus-5) <noreply@anthropic.com>
2026-09-22 16:29:02 +08:00
zhanghui
96d3b888ad
refactor(plugins): serve the four EverOS memory roles from raven's own config (#614)
## Summary

EverOS's four memory roles -- llm, embedding, rerank and multimodal --
lived in
`~/.everos/raven/everos.toml`, a file raven wrote and EverOS read once
at startup.
Three defects followed from that arrangement and none was fixable in
place:

- a model changed on the settings page did not take effect until
something
  unrelated restarted the service, with nothing on screen saying so;
- the rerank section needs a request shape (`deepinfra` / `vllm` /
`dashscope`)
that only the wizard's own vendor table knew, so reranking configured
from the
settings page posted to the wrong path against DeepInfra and
SiliconFlow;
- an EverOS root the user manages is read-only to raven, so those users
had no
  way to configure a role at all.

raven now records a **pin** per role -- a model and the vendor serving
it, never a
credential -- and resolves the address and key from that vendor at the
moment they
are needed. Rotating a key is one edit, and every role on that vendor
follows.
The values reach EverOS as `EVEROS_*` variables, emitted on every spawn
and bound
into raven's own process so the in-process multimodal tool reads the
same models
the service does. `everos.toml` keeps its runtime knobs, which EverOS
merges per
key; raven writes only `[api]` there now.

**A save applies itself.** The spawn precheck runs before anything is
stopped, so a
restart that cannot succeed leaves the old server serving; a stop that
does not
finish never falls through to the spawn, which would otherwise adopt the
old
server and report success for a configuration that never took. The
outcome
reaches every session waiting on it as `memory.health` -- success
included, since
that frame is the only thing that clears the standing banner.

**Upgrades migrate themselves.** An install upgrading into this still
has its roles
in the file. The migration runs on the first memory start: it names the
vendor
from the address and the key, creates the provider row when raven
carries none,
and leaves a role it cannot name unset with a notice rather than
guessing. It is
idempotent and never edits `everos.toml`. Measured against the real
shape on a
maintainer's machine, where two of the four roles point at DeepInfra, a
vendor
raven carries no provider spec for.

Key decisions, recorded in
`docs/specs/2026-09-21-everos-role-config-design.md`:

- the pin holds no credential, so nothing on the settings wire carries
one in
  either direction;
- an operator who exports `EVEROS_<ROLE>__*` still outranks raven, and
the slot
  says so rather than accepting a save that would never take effect;
- the rerank request shape comes from the vendor table where it is
known, and is
recorded on the role only for a self-hosted endpoint no table can answer
for;
- the migration is scheduled from the plugin, not from raven's config
migrations,
because the host may know this plugin only through the plugin contract.

Rebased onto `main` after #613, which settles the lint and contract
drift the
branch replay left behind. This branch briefly carried its own partial
fix for
that; it is dropped, and #613's is the one in force.

## Type

- [x] Refactor

## Verification

```
uv run --all-extras pytest -q
# 24517 passed, 4 failed, 111 skipped -- the 4 are pre-existing, confirmed by
# checking out the branch base in the same environment and re-running them there

uv run pytest <the 28 files that reference the changed modules> -q
# 1516 passed, 1 skipped

npm --prefix ui-web test          # 2496 passed, 191 files
npm --prefix ui-web run gen:check # generated.ts matches the contract (192 methods)
npm --prefix ui-tui run lint:rpc  # in sync
npm --prefix ui-tui run lint:i18n # catalogue up to date
uv run ruff check raven/ plugins-dist/ tests/        # All checks passed
uv run ruff format --check raven/ plugins-dist/ tests/  # 1835 files already formatted
make check-large-files            # exit 0
```

A real gateway was started on a fixture built from a maintainer's own
config in
the pre-upgrade shape. The migration moved all four roles, created the
`deepinfra` provider row, resolved reranking to `/v1/inference` rather
than the
chat endpoint, and left `everos.toml` byte-identical (sha256 unchanged).
That run
is also what found the defect described in the next section.

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed

The remaining real-host acceptance cases in
`docs/specs/2026-09-21-everos-role-config-acceptance.md` have not been
run yet;
they are the next step and will be reported on this PR.

## Risk

User-visible changes:

- the four role slots on the settings page now show the vendor as stored
rather
than deriving it from an address, and offer every vendor that can serve
the
  role;
- a save restarts the memory service, which takes a few seconds and
reports its
  outcome in the standing banner;
- a role whose endpoint comes from exported `EVEROS_*` variables is
read-only,
  and so are all four on a root the user manages;
- reranking on a self-hosted endpoint asks for its request shape once.

Rollback: revert the branch. The migration only ever adds to raven's
config and
never edits `everos.toml`, so an install that has migrated still has its
original
file and falls back to it.

One defect worth naming, because it was invisible to every unit test: an
embedding role with no width pinned emitted
`EVEROS_EMBEDDING__DIMENSIONS=""`,
which EverOS's own settings model refuses as an integer -- the server
exited
before serving anything. Fixed, and the case that catches it now builds
EverOS's
real `Settings` from the emitted environment in a subprocess, which is
the layer
that owns the fact.

- [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-opus-5) <noreply@anthropic.com>
2026-09-22 15:43:40 +08:00
zhanghui
07623fd606 feat(*): follow, resume and finish the cold-start import from the web (#570)
## Summary

The onboarding wizard's data-sync step started a full cold-start import
and closed; nothing on the page showed the run again, a gateway restart
lost it silently, and the web path never landed the profile mirror or
the skills the CLI does. This PR closes all of that in one piece,
backend first.

Backend (`raven.importer`, `import.*` RPC):

- The two post-import phases move out of the CLI into
`raven/importer/phases.py` and run per platform on both paths. Hermes
keeps its `USER.md` entries and skills tree; Claude Code now contributes
the memory files it marks as being about the user (`metadata.type` of
`user` or `feedback`, deduplicated on the text) and the skills under
`~/.claude/skills` through a new `ClaudeCodeSkillSource`. The installer
lands each platform under `skills/<platform>/` and reports progress per
copy.
- `import.run` records the tier and platforms it was asked for in the
state file's `meta`; `import.status` returns them together with a `phase
{kind, current, total}` object while a phase is in flight (both
nullable, additive fields on the contract). A client that finds a run
stopped short can start the same request again without having remembered
it.
- A stop is honoured between the batches of one source, not only between
sources. The interrupted source keeps no entry and is sent whole next
time.
- The CLI keeps its own bar labels and TTY-aware provider; its
skills-only path and scan preview count every platform's skills.
- The store budget fix measured on 2026-09-20 rides along, folded from a
PR first opened against main and closed in favour of this one at the
maintainer's request (everything lands on the architecture branch): an
import write is tagged `bulk` and the EverOS backend gives it the
extraction budget instead of the per-message estimate, and the import
batch drops from 100 to 50 messages. Without it every real-size source
dies on the shipped 10 s store timeout, which is exactly what the new
row would then report.

Frontend (`ui-web`):

- A new `importSync` domain draws one row in the rail's foot, above
Settings, from `import.status` alone. States: scanning, the message pass
with its settled share, the phase in flight with its own count, paused
(nothing running, counts short of the total), finished (with how many
did not make it). It polls only while a run is on, stops a run with its
close button, and asks for the recorded request again when a paused or
partly failed row is clicked. A finished row is dismissed per run and
stays dismissed across reloads.
- The wizard's sync step imports memory files only (the store used to
start a full import silently). The maintainer's call: conversations take
many hours and are not offered from the web at all; the full tier stays
a CLI option (`raven import run --tier full`). The step shows each
agent's memory-file, conversation and skill counts so the reader knows
what is there.
- Found during acceptance and fixed here: the row's first status read
sat with the seam installers, before the socket connects, and was
refused as not connected; it now runs in the boot sequence after the
connection is up and again on reconnect.

Deliberately not in this PR: a way to force the "did not make it" state
in the real host (covered by unit tests and the offline fixture), and
the CLI tier labels (`minutes` / `hours`), which measurement has since
put at tens of minutes and many hours respectively.

## Type

- [ ] Fix
- [x] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

Backend:

uv run pytest tests/test_rpc_schema_match.py
tests/test_rpc_import_sync.py tests/test_importer_state.py
tests/test_importer_orchestrator.py tests/test_importer_phases.py
tests/test_importer_claude_code_skills.py
tests/test_importer_hermes_skills.py
tests/test_importer_hermes_user_md.py tests/test_cli_import_commands.py
tests/test_cli_onboard_commands.py tests/integration/test_import_e2e.py
-q
    908 passed

Reverse check: with `state.py`, `orchestrator.py`,
`skills/installer.py`, `import_sync.py` and `models.py` reverted and the
tests kept, 14 tests fail (the new state, orchestrator, installer,
phases and rpc cases); restored, all pass.

Frontend:

npm test --prefix ui-web 188 files, 2570 passed (gates included)
npm run gen:check --prefix ui-web generated.ts matches the contract (189
methods)
    npm run type-check --prefix ui-web  clean
npm run lint --prefix ui-web 0 errors (5 pre-existing warnings in
unrelated files)
npm run lint:i18n --prefix ui-tui generated catalogue is up to date

Reverse check: with the importSync store and page, the onboard store and
page and the import fixture reverted, 5 tests fail and the two
importSync test files no longer import; restored byte for byte, 48 pass.

Gates: ruff check and format on every changed Python file, commitlint
and `check_commit_messages.py` over the branch,
`check_source_language.py` over the branch, `make check-large-files` --
all pass.

Acceptance in the real host, driven with playwright-cli against `raven
web --foreground` from this checkout, an isolated `RAVEN_HOME`, an empty
EverOS root on its own port with real LLM and embedding credentials, and
a synthetic Claude Code home (global CLAUDE.md, one project memory
directory holding user, feedback and project memories, two real small
conversations, one skill):

- Wizard step 4 lists Claude Code with its counts and a switch, opencode
and codex as unsupported; the tier rows default to memory files and
their counts follow the switch. Start closes the wizard and the rail row
appears at once: "Syncing data 0%" -> 50% -> "Building your profile 1/2"
-> "Memory import finished" in 30s. On disk: two entries in
`user_memory/profile/user.md` (the project-typed memory correctly
absent), `skills/claude_code/demo-skill/`.
- Dismiss hides the row; a reload keeps it hidden.
- A full import stopped 5s in shows "Sync paused 75%" 8s later with a
clickable row; the gateway log has `import cancelled inside
.../<conversation>` and the state file has no entry for it.
- Killing the gateway, restarting it, re-authenticating and reloading
shows "Sync paused 75%" again from the state file. Clicking the row runs
"Syncing data 75%" to "Memory import finished" in 31s; the conversation
is then `submitted`.
- The CLI path over the same home (`raven import run --platform
claude_code --tier memory_files --yes`) shows the two phase bars
(`Mirroring profile [2/2]`, `Installing skills [1/1]`) and reports
`Profile: 2 entries into user.md`, `Skills: 1 installed`.

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed (new copy
is in `i18n/messages.json`; no docs page describes the wizard yet)

After folding the store budget commits, on the branch head: `uv run
pytest` over the importer, EverOS backend, RPC and CLI import suites
plus `tests/integration/test_import_e2e.py`: 1095 passed; `ruff check`
clean; commitlint, `check_commit_messages`, `check_large_files`,
`check_source_language` and pre-commit green over the 8-commit range.

## Risk

The batch size takes part in the EverOS message id an import write
carries, so a run imported under the 100-message batch would not be
deduplicated against a re-import under 50; no import of real size had
completed under the old budget, so nothing on disk depends on the old
id.

User-visible: the rail gains a row while an import exists on disk; the
wizard's sync step imports memory files only where it used to start a
full import silently (conversations remain a CLI-only import);
`import.status` gains three optional fields. The CLI's skills-only path
now offers every platform's skills, and its scan line reads `Skills: N
importable` rather than `Hermes skills`.

The `import.status` additions are optional in the contract, so an older
client reading the new gateway is unaffected. A client that stores
nothing new: `localStorage` holds only the dismissed run's signature.

Rollback: revert the squash commit; no data migration is involved. The
state file's new `meta` keys are ignored by older code.

- [x] Security impact considered (no new inputs, credentials or
endpoints; the profile mirror reads the same files the importer already
reads)
- [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-fable-5-1) <noreply@anthropic.com>
2026-09-22 01:05:18 +08:00
Tchen-data
2d21c7d441
feat(*): open the deck engine route on an attached template, not on a tier (#574)
## Summary

The route from Raven-Design to the Raven-PPT template engine used to
open on the max tier alone. The same request then came back in three
unrelated styles across the tiers, and the top one was built on a
template the user never asked for. This PR moves the decision to the one
thing that actually calls for the engine: a .pptx the user handed over.

- **Route on an attached template.** `SubagentRouteConfig` gains
`needsFile` (a suffix), a third independent condition beside `needs` and
`minTier`. Raven-Design's route to Raven-PPT now declares `needsFile:
".pptx"` and drops `minTier: "max"`. Every tier designs its deck on
Raven-Design; the engine is reached only when a .pptx was handed over,
either a bundled template picked in the web UI (companion PR #573) or
one the user attached.
- **Handed over means attached in this turn.** A new `turn_attachments`
ContextVar is frozen beside `turn_tier` on the turn path. A direct
chat's media all count; a spawn or DAG node counts an attachment only
when its task text names that attachment's path or file name. Task text
alone never opens the route: a deck brief spells the deck's destination
path, the format in words, or a stray file in the directory exactly like
a template, and the first text-only scan sent a no-template run into the
engine on its destination path.
- **Tiers change effort, not product.** medium asks for low reasoning
effort, max for xhigh (the highest word a model may know; models that do
not know it fall back to their default), and the baseline inherits the
host's setting as before.
- **Design lane retries after streamed output.** `llmRetryAfterOutput:
true` on the design lane's defaults, matching the ppt lane. A max run
died at its thirtieth iteration to an upstream idle timeout after the
body had already streamed to the host; the lane now retries instead of
failing the turn.
- **Skill: use what the user handed over first.** Documents and data are
the material, pictures are the pictures, and an attached .pptx is the
engine's work, routed before the skill is read.

Docs: `CONTEXT.md` admission paragraph, `agents/README.md`, regenerated
`schemas/subagent.schema.json`.

Also removed: the engine's internal decision log
(`plugins-dist/ppt-engine/docs/ppt-raven-design.md`), a single-language
working journal for the team building the deck lanes that has no reader
in a public repository. The maintainer keeps it outside the tree; the
two code comments that cited it by path now state their reason in place.

## Type

- [ ] Fix
- [x] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

- `uv run --frozen pytest tests/test_subagent_routing_backend.py
tests/test_agents_design_launcher.py tests/test_config_schema.py
tests/test_subagent_registry.py -q` -> 130 passed (after rebase onto
main).
- `ruff check` / `ruff format --check` on the changed Python files ->
clean.
- End to end on a full gateway: a high-tier request with a picked
template logged `classified for 'Raven-PPT'; routing there` and the
engine delivered a 20-page deck on that template in about 60 minutes;
the same request without a template logged `no .pptx the user attached
was handed over; running here` and stayed on Raven-Design. A brief that
only spelled the deck's destination path stayed on Raven-Design.
- Effort labels probed against `z-ai/glm-5.3-flash` over OpenRouter:
`low`, `high`, `xhigh` all accepted; `max` spent the whole output window
on reasoning, which is why the top tier is xhigh.

- [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: medium and high tier deck requests no longer differ in
product, only in effort; a deck on a template now requires attaching
one. A bound direct-chat handle to Raven-Design stays on Raven-Design
even with a .pptx attached (the route is evaluated at dispatch), a known
boundary.
- `needsFile` is additive; routes that do not declare it are dispatched
exactly as before.
- Rollback: revert the squash commit; no schema migration or storage
change.

- [ ] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes

## Related Issues

N/A
2026-09-21 16:44:56 +08:00
Tchen-data
96be992b9d
fix(ppt-engine): deliver the deck alone, with no pdf copy beside it (#575)
## Summary

The ppt-engine plugin's outbound hook still wrote a PDF rendering next
to every published deck and announced it on a second `MEDIA:` line. A
delivery therefore carried two files where the user asked for one, and
the transcript showed a PDF tile beside the deck. The earlier change
that stopped the build stage from producing the preview (D64) did not
reach this hook.

The hook now publishes the deck and names it once. The web UI renders
its own preview from the deck on demand, so nothing is lost; the two
helpers that placed and named the copy are removed.

## Type

- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

- `uv run --frozen pytest tests/test_ppt_engine_plugin.py -q` -> 52
passed (after rebase onto main). Four tests that asserted the PDF copy
and the second MEDIA line are flipped to assert their absence.
- `ruff check` / `ruff format --check` on the two files -> clean.
- Observed on a full gateway before the fix: a template-engine delivery
arrived as `deck.pptx` plus `deck.pdf` and two transcript tiles.

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed

## Risk

- User-visible: a deck delivery has one file, not two. Anyone who relied
on the PDF beside the deck now opens the preview in the web UI or
converts the deck themselves.
- Rollback: revert the squash commit.

- [ ] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes

## Related Issues

N/A
2026-09-20 23:45:21 -07:00
ypflll
dbe259f6d7
refactor(*): close out the participant contract the five plugins now write (#495)
## 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>
2026-09-20 11:36:35 +08:00
Tchen-data
4ae4f80691
fix(*): the deck lane draws its own pages, and a dropped stream is asked again (#467)
## Summary

Two regressions in the hand-built deck lanes (medium and high on
Raven-Design), and the stream failure that made every run of them a coin
toss.

**The deck lane draws its own pages again.** PR #451 pointed the
hand-built lane at the engine's helper modules (`ppt_layout`,
`ppt_theme`, `ppt_shapes`), which were written for the max lane's script
backend. Their defaults became the deck: `heading()` put a white surface
band bled across every page, `card()` became the way anything was
placed, text frames were top-anchored with the lower third empty, and a
build script named three colours. Measured on the same request, the
accent colour appeared 8 times across 20 pages. The skill, route note
and assets reference go back to the pre-#451 text: the lane draws with
python-pptx and takes only the icon set, `add_formula` and `math_runs`
from the engine. On the reverted lane the accent appears 54 times, the
deck carries 12 real pictures and the layouts differ page to page.

**Colour is named beside the type sizes.** The skill listed sizes for
every role and said nothing about colour, so a lane with the right
palette still drew in one colour. One paragraph now says what colour is
for; the layouts note no longer reads as one accent per page, which a
lane took as a ceiling. Where `image_search` is not offered, the
fallback no longer tells the lane to give the pictures up: `web_search`
for the page, `web_fetch` it, and download where the fetch backend keeps
image links.

**A stall in a silent think is asked again.** Across two measured runs
the lane's turn failed 28 times on `Upstream idle timeout exceeded`,
every time in the one round that writes the whole build script into a
tool argument. `stream_llm_call` refuses to retry after output a watcher
has seen, and counted reasoning deltas and half-built tool-call
fragments as that output, though neither is ever shown as the reply. So
the configured retry ladder was never reached. `rendered()` now asks
what a watcher could have seen; every retry path resets the buffers
first (a slot left standing merged with the next attempt into a call the
model never made); a stall handed back as an error response carries the
usage it spent. The in-process builtin backend, whose comment claimed a
retry ladder and passed none, now receives the deployment's
`llmErrorRetryDelays` and `llmRetryAfterOutput` through the
SubagentManager. No packaged product takes that path; all five run as
ACP agents on the loop's own call site.

**Two bundled templates edited in place**, by the maintainer's word.
`beige_geometric_general_report` loses its page 20, a dark photograph
cut by a circle under pale rounded cards; 23 pages become 22 and the two
reference pages the lane borrows from it (17, 19) keep their numbers.
`black_circuit_tech_launch` loses the 27 percent circuit texture on its
master and the photograph on its Section Header layout, so its body and
section pages sit on the master's plain `#000000`; cover and closing are
unchanged. `templates.manifest.json` is repinned; `fetch_templates.py
--verify` holds all ten pins. The registry archive was not re-cut.

No configuration default changes. The only behaviour every lane sees: a
stream that fails before any reply text reached a watcher is retried on
the configured ladder instead of failing the turn.

## Type

- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

```
uv run --frozen pytest tests/test_agent_loop_llm_error_patience.py tests/test_agent_loop_stream.py \
  tests/test_subagent_manager.py tests/test_subagent_routing_backend.py -q
265 passed in 6.85s   (after rebase onto main)

uv run --frozen pytest tests/test_litellm_provider_stream.py tests/test_litellm_provider_stream_end.py \
  tests/test_provider_stream_fallback.py tests/test_providers_stream_idle_budget.py -q
102 passed

uv run --frozen ruff check raven/agent/loop/main.py raven/agent/subagent/backends/raven_loop.py \
  raven/agent/subagent/manager.py raven/providers/streaming.py
All checks passed!

grep -nP "[^\x00-\x7F]" agents/raven-design/route-raven-ppt.md   -> no matches (the note is pinned ASCII)
```

Both new tests were checked against the unfixed code:
`test_a_stall_during_a_silent_think_is_asked_again` fails with the old
`emitted` test, and
`test_what_the_failed_attempt_left_behind_is_dropped` fails with the
buffer resets removed.

The failure itself was reproduced outside the runtime: the same
37-message history, six pictures and tool table, sent through litellm
1.101.0 to the same vendor, succeeds on a short answer every time and
fails mid-stream one time in three when asked to write the full build
script; healthy long streams show a maximum inter-chunk gap of 1.9s over
234s, so the cut is a dropped connection, not a slow model.

Decks built on the changed lane, same request as the #451 acceptance run
(glm-5.3-flash via OpenRouter): medium 21 pages with 12 pictures and 7
text colours, 48 gate findings (4 `excessive_whitespace`, down from 18);
high 13 pages with 13 pictures and 9 text colours, 37 findings. The high
run's page count came from the host agent's forwarded brief, which
stated 10-14 pages the user never asked for; that is a separate issue.

Template edits: `tests/test_ppt_engine_templates.py
tests/test_ppt_engine_default_templates.py
tests/test_ppt_engine_template_bands.py
tests/test_ppt_engine_template_theme.py
tests/test_ppt_engine_measure_geometry.py` -> 152 passed, 1 skipped;
`make check-large-files` -> clean; both templates rendered and read page
by page.

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed

## Risk

- [ ] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes

User-visible: on every lane, a streamed call that fails during reasoning
or mid tool-call, with no reply text yet shown, waits out the configured
ladder (default 15/30/60s) and asks again instead of ending the turn. A
call that already streamed reply text behaves as before. Reasoning
tokens of the abandoned attempt are spent again and are now recorded in
usage. Rollback: revert the `providers` commit alone to restore the old
failure; the skill text and the builtin-backend plumbing are independent
of it.

## Related Issues

N/A
2026-09-19 05:23:48 -07:00
ypflll
6d8c36385b
refactor(*): let a sub-agent write a conduct instead of six hook phases (#469)
## 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>
2026-09-18 14:37:11 +08:00
zhanghui
0bcc7618f9
fix(everos-memory): give a recalled case the approach it was solved with (#483)
## Summary

An EverOS agent case carries three fields: `task_intent`, `approach` and
`key_insight`. Recall built `Memory.text` from the first and the last
only, so the method a case was solved with never reached the prompt. The
reader saw what was attempted and what was concluded, with the steps
between them missing.

The other two consumers of the same row already keep all three fields:
the sub-agent memory record joins intent, approach and insight, and the
memory page maps `approach` to a card's body. Only the recall path that
feeds the model dropped it.

This joins the three fields in field order. Two constraints shaped how:

- Intent stays on the first line. The skill router takes this text's
first line as a hit's display name and as its line in the search
listing, so moving intent off line one would rename every recalled case.
- Empty fields drop out, so an EverOS that answers without an `approach`
still reads as prose instead of carrying a blank paragraph.

## Type

- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

```
uv run --frozen pytest tests/test_everos_backend.py tests/test_skill_router_everos_source.py -q
182 passed in 17.69s

make lint-python lint-types
ruff check: All checks passed!
ruff format: 1960 files already formatted
ty check: All checks passed!

make check-source-language
clean, no findings
```

The case test asserts the exact joined text rather than substring
membership, and it was run against the pre-change conversion first to
confirm it fails there (AssertionError on the missing approach). A
second test covers a row that arrives without an `approach`, which is
the shape that would otherwise produce a blank paragraph.

No user-facing doc states the recall text shape. The CONTEXT.md passage
that lists all three case fields describes the sub-agent memory record,
which is a different code path and is unchanged.

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed

## Risk

Each recalled case now carries one more paragraph, so the agent track's
share of a prompt grows by roughly the length of one `approach` per case
hit. Nothing downstream parses this text: the skill router reads the
first line for a display name and passes the remainder through
untouched, and that first line does not move.

Rollback is a revert of the single commit.

- [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-opus-5) <noreply@anthropic.com>
2026-09-18 13:17:28 +08:00
ypflll
869ad78abd
refactor(agent): read the charter and the window's shrinking through the roles (#468)
## 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>
2026-09-18 10:52:48 +08:00
xfng-sd
b58cda36a2
fix(*): pin line endings to lf so windows checkouts pass the byte gates (#457)
## Summary

A Windows checkout of this repo with the default `core.autocrlf=true`
rewrites every
text file to CRLF, and two byte-exact gates in `ui-web` then fail on a
tree that is
byte-identical to the one CI passes on Linux:

- the boot-order and open-conversation node tests slice their source on
`"\n}\n"`,
which never matches a CRLF file, so the sliced function comes out empty
and 9 tests
  fail with `ReferenceError`;
- `gen-rpc-client --check` compares its own LF output against the file
on disk and
  reports permanent drift in `src/rpc/generated.ts`.

`.gitattributes` pins the checkout filter so the working tree matches
what the
repository already stores. The repository stores LF today, so this adds
no
renormalization diff: `git add --renormalize .` over the whole tree
stages nothing
beyond the two files in this PR. Only the checkout filter changes.

`ui-web/build.py` is the other half of the same defect. It assembled the
page under
Python's default newline translation, so `dist/index.html` came out CRLF
on Windows
even from an LF source tree, and `check-page.mjs` could no longer
extract the script
payloads (its `<script>\n` anchor needs the LF to be the next byte).
That artifact
ships inside the wheel, so it must not depend on which platform
assembled it.

## Type

- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

Run on Windows 11 with `core.autocrlf=true`, in a clean worktree cut
from `main`:

- `git add --renormalize .` after the change stages nothing (confirms no
  renormalization diff);
- `file ui-web/src/rpc/generated.ts` reports CRLF on `main` and LF after
a forced
  re-checkout on this branch;
- `npm run gen:check` (ui-web): `generated.ts matches the contract (178
methods)`;
- `npx vitest run` (ui-web): 108 files, 1836 tests passed;
- `npm run --prefix ui-web build && python ui-web/build.py`:
`dist/index.html` is LF;
- `node ui-web/scripts/check-page.mjs`: `OK (1,482,975 bytes, 3 scripts
parse)`;
- `node ui-web/scripts/count-shared-globals.mjs`, `check-css.mjs`,
  `check-class-namespace.mjs`: all OK.

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed

## Risk

No runtime behaviour changes for users on Linux or macOS, where the
checkout already
produced LF. On Windows the working tree stops being rewritten to CRLF,
so a
contributor with existing local checkouts may see one large
renormalization touch on
the next checkout; the committed bytes do not move. The built
`dist/index.html` is now
LF on every platform, which is what the Linux-built wheel already
shipped.

Rollback is deleting `.gitattributes` and dropping the `newline=""`
argument in
`ui-web/build.py`.

- [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-opus-5) <noreply@anthropic.com>
2026-09-17 17:01:40 +08:00
Tchen-data
5a29ea225d
fix(raven-design): deck lane on the engine's modules, defaults first, one .pptx delivered (#451)
## Summary

The hand-built deck lane (Raven-Design at medium and high) and the deck
engine lane (Raven-PPT at max) as one product, measured on live runs.

- image_search for the deck lanes sits behind tools.web.search.images,
off by default and switched on by the design launcher; the readiness
probe for the deck route reads the target lane's own picture vendor; the
build-interpreter shim has a .cmd twin for native Windows.
- Deck route on Raven-Design: page furniture comes from the engine's
helper modules (ppt_layout, ppt_theme, ppt_icons, ppt_shapes,
ppt_charts) written beside the build script; diagrams, picture treatment
and cover/section compositions are drawn by hand. Five recorded runs had
each rewritten the same 48 helpers.
- Deck route keeps no anti-pattern ledger, contract or task state: nine
audited runs wrote the ledger 18 times and read it back never, and every
real fix came from reading a render. The editorial skill is read
alongside the deck skill; every page is read back from a render at 90
dpi or more before delivery.
- Defaults before questions: language of the request, general audience,
about 20 pages, light ground, memory first; ask at most once. Two of
three ask_user calls in the audit timed out unanswered.
- Formulas as pictures (matplotlib mathtext, dfrac promotion, serif
scale) and inline sub/superscript runs, shared by both lanes;
image_search for both lanes keyed by the selected search vendor; the
raven-python interpreter shim (sh wrapper, not a symlink); all three
tiers at 400 iterations.
- layouts.md gains nine compositions measured off the packaged
templates' reference pages; three rules ask for full components, a
hierarchy among them, and the whole page used.
- The max lane delivers the .pptx alone (D64); the PDF render stays the
engine's own preview.
- ppt-engine: template gates silenced on template pages, borrowed
template files kept apart from borrowed page numbers, the icon pen
follows the icon's side.

## Type

- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

```
uv run --frozen pytest -q -x tests/test_agents_design_launcher.py tests/test_subagent_routing_backend.py tests/test_ppt_engine_build_tool.py tests/test_ppt_engine_build_stage.py tests/test_ppt_engine_assets_formulas.py tests/test_ppt_engine_gates_registry.py
# 299 passed
```

Live runs on a test stack (medium tier, glm-5.3-flash, the
eight-character request "make a deck introducing computer vision"): with
the editorial skill read, 20 pages, 18 of them carrying a searched
picture or a paper figure, delivered in 26 minutes with no question
asked, no task-state call, no ledger, no hand-written helper, renders at
90 dpi.

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed

## Risk

User-visible: the max lane no longer delivers a PDF beside the deck; the
design lane asks fewer questions; the host loop offers image_search only
where tools.web.search.images is on. Rollback: revert the commits
touching agents/raven-design, raven/agent and
plugins-dist/ppt-engine/raven_ppt/stages/build.py; no data migration is
involved.

- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes

## Related Issues

N/A
2026-09-16 08:02:01 -07:00
zhanghui
a018351f95
chore(*): gate call correctness with a pinned type checker (#416)
## Summary

Nothing in this repo could see a signature change reach its callers.
Ruff reads one file at a time, the import contracts read edges rather
than calls, and the suite only covers lines it executes. The consequence
was concrete: a required `sandbox_home` argument added to
`BoxliteExecutor` reached `plugins-dist/design-engine`'s render path
with CI green, and a reviewer -- not a gate -- found it.

`ty` answers that question. This adds it as a pinned dev dependency, a
`make lint-types` target and a CI step, with **110 of its 133 rules
live**: nine switched off with their measured backlog recorded beside
each, fourteen shipped disabled upstream and untouched.

Getting there meant clearing 81 diagnostics. This PR folds what were
three stacked PRs (#422 and #423, now closed); each rule's story is a
commit of its own.

### 1. The gate, at 108 rules (`chore(*): gate call correctness...`)

21 diagnostics to clear, five of them real:

| Where | What |
|---|---|
| `evolver/orchestrator/production.py` | `design_of` annotated as taking
two parameters while its docstring, its only implementation and its one
call site all use three |
| `raven/cli/provider_commands.py` | `dict[str, callable]` -- the
builtin function, not a type, so the annotation asserted nothing |
| `raven/config/schema.py` | `Config` is a `BaseSettings` but declared
`env_prefix` / `env_nested_delimiter` through pydantic's `ConfigDict`,
which does not carry those keys |
| `raven/spine/delivery.py` | `StreamDelta.conversation_id` is optional
and was used as a `dict[str, str]` key; a delta without one stored a
`None` entry the close path then read as "no open stream", losing that
stream's done marker |
| `research_flow/support/harness_text.py` | a predicate table typed its
matchers as `object`, so nothing checked they are callable |

The rest were unproven invariants and annotations wider than the code:
three late-bound callables asserted where a comment used to carry the
claim, one closure binding the callable it guarded instead of re-reading
it, four `hasattr` probes that now check what the call actually needs,
and a contextmanager yielding the value it just set.

### 2. `unresolved-import` (`fix(*): resolve the imports the type gate
could not`)

21 diagnostics; three were stale module paths nothing had run into:

- `HarnessNode.current_core_version()` read `raven.__core_version__`, a
module that exists neither here nor in the wheel
`scripts/build_core_wheel.py` produces. The read sat inside `try/except
ImportError`, so the except branch was the only branch and **every node
`store.py` saved recorded `core_version="unknown"`**. It reads
`raven.__version__` now and returns `0.1.13`.
- `raven/agent/loop/wiring.py` imported `SkillForgeRouterConfig` from
`raven.config.schema`; it lives in `raven.config.raven`. Under
`TYPE_CHECKING`, so the annotation simply meant nothing.
- three scripts imported `raven.context_engine.base` and
`raven.memory_engine.base`, neither of which exists. **Two failed at
module import** -- running them was not possible.

The other eighteen were the environment: the three agent products keep
their plugin package beside them, so their roots are declared in
`[tool.ty.environment]`; `lxml` ships a compiled `etree` with no type
information, so `lxml-stubs` is a dev dependency (real types rather than
five silenced lines); `uno` and `com.sun.star.*` are suppressed per
line, since that worker runs inside LibreOffice's own interpreter.

### 3. `invalid-return-type` (`fix(*): make the declared return types
true`)

39 diagnostics, and **one stale annotation held eight of them**:
`run_turn` and the `_run_turn` behind it were declared `-> LoopOutcome`
while all three of their returns build a `TurnOutcome` -- a different
dataclass with no field in common. Nothing broke, because the spine
worker reads what it actually gets and `LoopOutcome` never leaves
`_run_agent_loop`. The annotation was the only thing wrong.

The other 31: nine annotations narrower than the code (five `return
tuple(<genexpr>)` typed as fixed-arity tuples, an inner `one()` still
declaring the two-tuple it returned before a third element was added,
`image_block`'s TypedDict), five declarations refusing a value the
function returns (four tool `execute` overrides saying `-> str` while
returning `ToolResult`), seven invariants that lived in a `# type:
ignore` comment, and ten honest widenings.

### 4. What the gates then caught in this PR's own work

- The qq factory guard passed locally only because an earlier test had
left an event loop behind. Reproduced the CI state
(`asyncio.set_event_loop(None)`), then made the test async so the loop
is its own.
- `invalid-return-type`, while still disabled, hid a regression
introduced here: the qq factory returning the class instead of an
instance. Found by diffing the rule histogram, which is why that rule is
on now.
- The diff-coverage gate named four lines in `raven/routing/cache.py` --
the asserts this work had just added, sitting inside a `try` whose
`except Exception` would have swallowed the `AssertionError` and served
the stale cache. `_do_refresh` returns its data now; the asserts, their
noqa and the swallowing all go with it.

`child_scope`, `QQChannel.start()` and `BenchmarkCache` had no tests at
all and have them now. Every one was mutation-checked.

## Type

- [ ] Fix
- [ ] Feature
- [ ] Docs
- [x] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

- `make lint-types` -> All checks passed; 81 diagnostics cleared across
the three rule sets
- Gate proven live three times, once per rule: a missing argument, an
import of a module that does not exist, and a function returning a str
under `-> int` each turn it red, and removing the probe turns it green
- `uv run ruff check` + `ruff format --check` over all six trees ->
clean
- `uv run lint-imports` -> 10 kept, 0 broken; `deptry raven` (all
extras) -> no issues; `uv lock --check` -> resolved
- `make check-source-language` -> exit 0; `commitlint` -> exit 0
- `make coverage` locally: **22050 passed, 45 skipped, 4 failed**; diff
coverage 92.59%
- All four failures are **pre-existing on `main`**, checked by a real
checkout in the same environment where they fail identically: two
`test_the_products_tool_face_*` launcher tests,
`test_a_ceiling_as_large_as_the_window_still_leaves_room_for_history`
(`reserved_tools = 6044 > 6_000`), and
`test_a_missing_key_is_said_once_rather_than_per_query`
(environment-dependent: it asserts `SERPER_API_KEY` is absent)
- Rule counts measured with both `--extra dev` and `--all-extras` --
identical, so this gate's verdict does not depend on which optional
packages are installed

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed

## Risk

Behaviour changes are confined to the fixes listed above, and each
replaces an error path with a correct one: nodes are stamped with the
real raven version instead of `"unknown"`, two scripts that could not
start now start, the stream bookkeeping no longer stores a `None` key,
and a cache refresh returns what it fetched. Everything else is a
declaration moved to match what the function already returned.

`tests/` is out of the gate's scope (113 diagnostics under the same
rules). Tests are executed, so a broken call there is already loud; this
gate is for code CI does not run. Bringing them in is sized, separate
work.

Rollback: revert the whole PR to drop the gate and its fixes together,
or delete the `[tool.ty]` block, the `lint-types` target and its CI step
to keep the fixes and drop only the gate.

- [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-opus-5) <noreply@anthropic.com>
2026-09-16 07:33:14 -07:00
zhanghui
e70a868e9c
refactor(*): seal the memory backend seam so a memory plugin needs no host edits (#414)
## 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>
2026-09-16 22:19:50 +08:00
KT
a7f0502be0
ci(*): make the idle ceiling a gate and take the last waits out (#428)
## Summary

Follow-up to #413, from a measured look at what was left: a CI shard now
spends 72 s on fixed cost (22 s environment, 48 s collection and worker
start) against 82 s of tests, the four shards are within 15 s of each
other, and 70 unmarked tests were still over the 2 s wall-clock ceiling
on CI against 42 on a laptop because CPU-bound work runs three to four
times slower there. This PR makes the ceiling a gate that is portable
across machines, takes the remaining waits out, precompiles bytecode so
the workers stop doing it four times, and fixes two product waits the
same investigation surfaced.

- `test(*)`: the ceiling judges idle time instead of wall clock, where
idle is the wall clock minus every CPU second spent on the test's
behalf, the reaped children's included (`os.times`). A test waiting on a
production sleep or a process that answers nothing waits the same
seconds on every machine; a test that computes for 2 s here and 7 s on
CI, or drives a browser or eight spawned workers, is not the problem.
The numbers ride on the teardown report so the xdist controller can
judge them; options are `--idle-ceiling` / `--idle-ceiling-strict`. The
fixture that shortens production ladders takes in the ACP cancel settle
(5 s) and the gateway delivery grace (2 s); the CLI agent tests stub the
one-shot command's unconditional 2 s hand-off grace; the rpc subagent
tests no longer spawn a login shell or probe a real endpoint over the
network; three literal timeouts shrink where the stub never answers
anyway. What is left over the ceiling carries a marker: seven real
LibreOffice renders and two tests that wait on a process answering
nothing carry `slow`, two whose assertion is the wait itself carry
`production_timing`.
- `ci(*)`: every shard runs with `--idle-ceiling-strict` (on the make
line, not in `addopts`: the Windows job runs `--noconftest`). Bytecode
precompilation was tried and dropped, the numbers are below; the
workflow is otherwise unchanged from #413.
- `test(agent)`: a heartbeat test asked for five beats of the fifteen
its intervals should produce in a 0.6 s window, and a loaded runner
delivered three. It reads the two gaps instead, which the load cannot
invert: the wait before the first beat is one interval, the wait after
it is the other. Older than the gate that surfaced it; nothing here
touches the registry.
- `perf(ppt-engine)`: `MeasuredWidth.width` remembers measured widths
(bounded, oldest key out); a 15-slide template's QA gates made 1848
freetype calls over 162 distinct keys. Importing `text_metrics` first
raised on a circular import through `template.capacity`; capacity now
imports the module and resolves the name at call time.
- `perf(*)`: `raven gateway` and `raven web` start the litellm import on
a daemon thread at boot, so saving a key from the settings page no
longer waits three to five seconds on it.
- `fix(providers)`: one thread at a time initialises litellm. It raises
three logger levels for the duration of the import and puts the captured
values back after, which holds only while one thread is doing it; a
second caller arriving inside that window captures WARNING as the level
to restore, and litellm's DEBUG and INFO stop reaching the file sink
until a restart. The window was narrow while every import sat on a
startup path and is ordinary now that a server warms it in the
background, so the two callers share a module lock. The strict-mode
warm-up also runs before the fixtures that redirect the home, and
publishing the OAuth token directories created them, so it warms under a
temporary home.

## Type

- [ ] Fix
- [ ] Feature
- [ ] Docs
- [x] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

Whole suite, `uv run --frozen --all-extras pytest -q` (macOS, 4
workers), before and after the waits came out and with the ceiling
strict:

| run | result | idle list |
|---|---|---|
| main after #413 | 22052 passed, 43 skipped in 219.41 s | 39 over 2 s
wall clock |
| this branch, `--idle-ceiling` warning | 22057 passed, 43 skipped in
210.20 s | 14 over 2 s idle, all real render or subprocess, now marked |
| this branch, `--idle-ceiling-strict` | 22058 passed, 43 skipped in
204.89 s, exit 0 | none |

The ceiling is three seconds, placed from the suite's own distribution
rather than guessed. Unmarked tests over one second of idle, measured
across the whole suite:

| idle | tests | what they are |
|---|---|---|
| 1.00-1.19 s | 19 | a test that sets a one second timeout and lets it
expire |
| 1.2-1.3 s | 3 | a subprocess handshake |
| 1.5-1.6 s | 3 | an ACP turn interrupted after 0.8 s, and two like it |
| above 1.6 s | 0 | the renders above this line all carry a marker |

A runner stretches that 1.6 s to about 2.2 s, which is how a two second
line failed two shards over tests waiting exactly as long as they meant
to. Three seconds sits in the gap the population leaves, and stays under
every ladder this guards against: the shortest constant the audit found
was a three second grace, the rest run 5, 15, 30 and 60 seconds.

What the metric separates, measured on this suite: a test that sleeps 5
s reports `4.96s idle of 5.02s`; a test that drives a headless browser
for 13 s reports under 0.8 s; six `raven doctor` subprocesses report 1.2
s where wall clock said 4.2 s; eight spawned processes contending for a
lock report under 0.8 s where wall clock said 3.6 s.

Files touched by the product changes and the new markers (`uv run
--frozen --all-extras pytest -q tests/test_litellm_setup.py
tests/test_cli_gateway_commands.py tests/test_cli_serve_commands.py
tests/test_ppt_engine_assets_fonts.py
tests/test_ppt_engine_template_capacity.py
tests/test_cli_doctor_commands.py tests/test_ppt_engine_end_to_end.py
tests/test_ppt_engine_render_service.py tests/test_rpc_model.py`): `434
passed, 2 skipped in 33.39s`, none over 1 s idle. `python -c "import
raven_ppt.services.assets.text_metrics"` in a fresh interpreter:
ImportError before, imports after.

Test-side speedups, measured per test: the ten CLI agent tests 2.0-4.4 s
to 0.05-0.36 s; the three rpc subagent tests 1.4-2.6 s to 0.01-0.02 s;
the rpc save-key test 2.2-2.8 s to 0.03 s; the two ACP probe tests 2.1 s
to 0.2 s.

Bytecode precompilation, seconds from the start of the pytest step to
the first test, per shard, over three runs of this workflow:

| what was compiled | shard 1 | shard 2 | shard 3 | shard 4 | mean |
install step |
|---|---|---|---|---|---|---|
| nothing (#413) | 52.7 | 46.5 | 45.9 | 46.0 | 47.8 | 3-4 s |
| site-packages and checkout | 39.8 | 39.3 | 35.6 | 45.5 | 40.1 | 12-17
s |
| checkout only | 55.5 | 50.1 | 44.4 | 53.8 | 51.0 | 3-4 s |

Compiling site-packages is the half that moved the number and it cost
more in the install step than it returned. Compiling the checkout alone
is inside the noise of doing nothing: the four workers share one `.pyc`
cache, so the first to import a module writes it for the rest, and most
of what a laptop measures as cold compilation is pytest rewriting test
files through a cache `compileall` cannot fill. Both are gone; the
comment in the workflow records it.

The reworked heartbeat assertion was checked against the bug it guards
by making the registry keep its first interval for every beat: one beat
arrives in the window and the assertion fails on it.

The diff gate is reproduced locally against `origin/main` after a full
`make coverage`: `Diff coverage: 100.00% (12/12 executable changed
lines)`. The two warm-up calls in the serving boot coroutines carry a
no-cover pragma naming the test that pins them, because those coroutines
bind a port and serve until they are killed.

The lock is checked against the race it closes: with it taken away, a
test that holds the first caller inside the import and starts a second
fails on `[30, 30, 30] == [20, 20, 20]`. A strict session under a clean
HOME now leaves no `.raven` behind.

`make lint-python` clean.

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed (none)

## Risk

- The ceiling is now a gate on CI. A new test that waits more than 2 s
without `slow` or `production_timing` turns its shard red; the summary
names the test and the marker to use. A local run stays warning-only.
- A subprocess that does real work is charged to the test that reaped
it, so only a real wait trips the gate. A strict session imports litellm
up front, because its 1.7 s of file opens would otherwise land on
whichever test in the shard imports it first.
- The litellm warm-up runs on a daemon thread at server boot only; unit
tests never reach either boot path (their source is pinned instead), and
a failed import is logged, not raised.
- The width memo returns the same floats; the cap evicts the oldest key.
The capacity import change resolves the same name one step later.
- Rollback: revert the PR; every change is additive or a marker.

- [x] Security impact considered (no security surface touched)
- [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>
2026-09-16 14:51:50 +08:00
GAO XINGZE
dd5d1666c6
fix: isolate design artifacts and task state by session (#431)
Give each design session its own working directory under designs using a
slug and a hash of the full session key. Restore the same directory when
the session resumes, including turns that skip the user inbound hook.

Keep review ledgers and auxiliary files in the session directory and
provide workdirPerSession=false for the existing shared-directory
behavior. Preserve existing shared files and task state without guessing
ownership.

Verify concurrent sessions, resumed turns, directory name collisions,
and completion isolation with regression tests and a live ACP rendering
run.

## Summary

Design sessions using the same working directory previously shared Task
State and output files. Give each session its own directory under
`designs/`, named with a session slug and a hash of the full session
key. Reuse that directory on resume and keep review ledgers and
auxiliary files there.


## Type

- [x] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

```bash
uv run --no-sync pytest -q tests/test_design_engine_*.py tests/test_agents_design_launcher.py tests/test_ppt_engine_plugin.py tests/test_agent_workdir.py -x
```

Result: 265 passed. One existing PPT test produced a non-failing timing
warning.

```bash
make check-large-files check-source-language COMMIT_RANGE=origin/main...HEAD
git diff --check
```

Result: passed. Pre-commit checks also passed for all seven changed
files.

A live ACP scenario exercised two concurrent sessions, actual model
calls, Chrome rendering, process restart, and session recovery. Both
sessions generated independent HTML, PDF, PNG, review ledgers, and Task
State. Revising session A left all nine session B artifact and state
file hashes unchanged. PDF image pixels matched the corresponding
previews.

The final verification command rechecked completed concurrent outputs
and ran the two recovery turns:

```bash
DESIGN_E2E_OUTPUT=/tmp/raven-design-live-e2e-hx9Ohs/run3 DESIGN_E2E_RESUME=1 uv run --no-sync pytest -q -s /tmp/raven-design-live-e2e-hx9Ohs/test_design_session_e2e.py
```

Result: 1 passed. This was a local live test harness outside the
repository. EverOS memory was disabled; Web UI interaction was not
covered.

- [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

## Related Issues

N/A

---------

Co-authored-by: Codex <noreply@openai.com>
2026-09-16 14:14:49 +08:00
zhanghui
56c79edf5a
fix(everos-memory): one refused write must not take the rest of the run with it (#415)
## Summary

An import of five memory-file sources lost four of them to a single bad
record. Diagnosing it turned up three separate faults; two are ours and
are fixed here.

**One answered-but-failed request must not kill the backend.** The
demotion classifier read any exception that was not a timeout or a
connection refusal as a dead service. EverOS returned a 500 for one
unprocessable payload -- a status line, which is proof the service is up
and answering -- and the backend went UNRESPONSIVE. Every later write
then short-circuited on the state guard and returned "not landed"
without reaching the wire, so the two sources queued behind the bad one
failed in milliseconds with no network activity at all. An
`httpx.HTTPStatusError` now leaves the state exactly as it was. A
service that does go away still demotes, through the timeout and
connection-refused paths that already existed.

**The short write budget was sized for the wrong caller.** A non-final
append got a flat ten seconds, which is a turn's patience for a handful
of messages. An append is not free work -- EverOS may carve a boundary
out of one, which runs a model -- and the importer hands over up to a
hundred messages at a time. That call overran a server that was still
working on it, which the classifier above then filed as a hung service.
The budget now follows the slice's size, floored at the turn-sized
value, so a turn is unaffected and a bulk batch gets proportionate
patience.

**A config key nobody declared.** The onboarding wizard records a `port`
in the plugin's config slice, but the manifest's `config_schema` never
listed it, so admission logged a passthrough warning on every backend
build. Declared.

The third fault is upstream and not fixed here: EverOS's episode
extraction retries malformed model output twice, then makes the final
attempt outside the try block, so a third bad response escapes as an
unhandled `JSONDecodeError` and the whole `/memory/add` request becomes
a 500. Reporting the failure is right; a 500 with a traceback is not the
way to report "this content could not be processed", and EverOS already
has a shape for "content accepted, nothing extracted". With the first
fix above, that upstream behaviour costs one source instead of the rest
of the run.

## Type

- [x] Fix

## Verification

- Reproduced on a real isolated install (temporary RAVEN_HOME, isolated
EverOS root and port) with the everos server log captured:
`EverosBackend.store timed out after 10.0s` on the 100-message batch,
and `unhandled_exception exception_type=JSONDecodeError
path=/api/v2/memory/add` for the 500, followed by two sources failing
with no request logged at all.
- A billing hypothesis was ruled out by rerunning against a key with
headroom: the server log holds only `200` x6 and `500` x1, no
401/403/429.
- Each fix was mutated away and the new test confirmed red, then
restored and confirmed green.
- `uv run pytest tests/test_everos_backend.py
tests/test_plugin_manifest.py tests/test_plugin_config_admission.py
tests/test_core_plugin_stack.py tests/test_plugin_registry.py
tests/test_everos_discover.py tests/test_everos_server.py`: 294 passed,
1 skipped (inotify is Linux-only).
- `uv run ruff check plugins-dist/ tests/` and `ruff format --check` on
the changed files: clean.
- `scripts/check_commit_messages.py`, `scripts/check_large_files.py`,
`scripts/check_source_language.py` over the branch range: clean.

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally

## Risk

User-visible changes:

1. A backend that answers with an error status stays usable. Previously
one such response silenced memory for the rest of the process,
recoverable only through an out-of-band probe; now each request stands
on its own.
2. A bulk append waits longer before giving up. A turn's append is
unchanged in practice -- the floor is the old value -- and the ceiling
only grows with the number of messages handed over in one call.

Both are local to the EverOS plugin's write path. Rollback is a revert;
neither touches stored data or the wire protocol.

- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes

## Related Issues

N/A

Co-authored-by: Claude (claude-opus-5) <noreply@anthropic.com>
2026-09-15 07:39:09 -07:00
KT
a5f84b7164
ci(*): run unit tests as four shards and speed up the suite (#413)
## Summary

The unit job takes twelve minutes on one runner. The first cut of this
PR took the production waits out of the tests, which made the suite a
quarter faster on a laptop and moved CI by 14 s (pytest 720.95 s on
main, 706.57 s here): the runner is three to four times slower than a
laptop on CPU-bound tests, and two of the twelve minutes are the four
xdist workers importing every test module. So the PR now attacks the
wall clock from every side that CI's own numbers pointed at.

- `ci(*)`: the unit job runs as four shards. pytest gains `--shard K/N`
in `tests/conftest.py`, decided in `pytest_ignore_collect` so a shard
never imports the other shards' files; test files are dealt round-robin
over their sorted list so the slow families that sort together (the ppt
engine's) are spread out. Each shard writes coverage data and no report;
a `coverage` job downloads the four data files, combines them, writes
`coverage.json` and `coverage.xml`, and runs the gates that used to
follow the tests.
- `perf(ppt-engine)`: `menu()` caches its reading of a template, capped
at eight entries. One bind reads the bound template and then every other
bundled template for the borrow offer; with ten templates bundled, every
bind evicted what the next one needed and re-measured all of them with
freetype. The cap is 32 and a hit moves its entry to the back. On this
PR's first CI run the template-tool file alone was 257 s of the
over-ceiling list, its tests 10 to 26 s each.
- `test(*)`: an autouse fixture collapses the provider chat retry
ladder, the loop's LLM-error ladder and the memory store backoff to a
millisecond per step, and the steer hook grace to one poll. It keeps
each tuple's length because both ladders count attempts with `len()`;
the steps are a millisecond rather than zero because the store pipeline
waits with `wait_for(stopping.wait(), timeout=delay)`, and a zero
timeout cancels that wait before it runs. A test that proves a timing
property opts out with the new `production_timing` marker. Ten tests
spent 257 s of the suite's worker time in those waits; none asserted on
the time.
- `test(*)`: a wall-clock ceiling. Setup plus call over 2 s on a test
marked neither `slow` nor `production_timing` is listed at the end of
the run; `--wall-clock-ceiling-strict` fails an otherwise green session
on it. Warning only here; CI flips to strict once the remaining tail is
marked.
- `test(*)`: every test created two numbered temp directories, and
pytest picks each number by scanning the base temp dir; the fake home is
now a sibling of `tmp_path`. `MPLCONFIGDIR` points at a git-ignored dir
in the checkout, because the fake home changed per test and matplotlib
rebuilt its font list from the system fonts on every run.
- `refactor(agent)`: the outer LLM-error retry ladder default `(15, 30,
60)` lived in three places; it is one constant in
`raven/config/schema.py` now, read by both `RecoveryLimits` and
`_ladder`. Behaviour unchanged.
- `test(updates)`: the first sharded run turned up an order dependency.
`beta_channel` binds `ReleaseInfo` from `raven.updates.upgrade` at
import, the update-notice tests stand a fake in for that module through
`sys.modules`, and `_refresh` imports `beta_channel` lazily; a worker
that imported `beta_channel` for the first time inside that test got an
`ImportError` swallowed as a failed refresh. The test module now imports
`beta_channel` at the top.
- `ci(*)`: the PR diff gate named every `.py` under `plugins-dist` as
production code while coverage measures only `raven` and `raven_everos`,
so a change to the ppt or design engine could never appear in the report
and the gate refused every such PR on sight; the first sharded run hit
it on `menu.py`. The pathspec now names `plugins-dist/everos-memory`,
and a test holds every production pathspec to a package some `--cov`
flag in the Makefile measures.
- Two slow tests were not waits: the sandbox second-cancel test
cancelled one tick too early (two pending cancels coalesce into one
`CancelledError`) and now waits, under a one second timeout, for the
kill to land; the two thousand-session dispatch tests wrote a span per
refused enqueue through a store that opens its file per span, so tracing
is off for them. Follow-up on the product side: `raven/tracing/store.py`
should reuse its handle.

The suite has 30 upper-bound assertions of the form `assert elapsed <
X`; shortened delays can only make those looser.

## Type

- [ ] Fix
- [ ] Feature
- [ ] Docs
- [x] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

Whole suite, `uv run --frozen --all-extras pytest -q` (macOS, 4
workers), 22051 passed / 43 skipped each time:

| tree | wall clock | unmarked tests over 2 s |
|---|---|---|
| main before this branch | 372.82 s | (no ceiling yet) |
| after the waits were taken out | 279.65 s | 63 |
| this branch | 224.25 s | 39 |

The shards partition the suite exactly (`uv run --frozen --all-extras
pytest --collect-only -q -n 0 --shard K/4`, K = 1..4):

| whole | shard 1 | shard 2 | shard 3 | shard 4 | union | ids in two
shards |
|---|---|---|---|---|---|---|
| 22095 | 5058 | 5555 | 5955 | 5527 | 22095 | 0 |

196 / 195 / 194 / 194 test files per shard. A shard collects in 7 s
where the whole suite takes 23 s on the same machine. `--ignore` still
works under `--shard`: with four `--ignore` flags on shard 1, the
ignored file that shard owns is gone from its collection (5034 ids
against 5058).

Combining loses nothing. Two small runs with `--cov=raven
--cov=raven_everos --cov-branch --cov-report=` and `COVERAGE_FILE` set,
then `make coverage-combine COVERAGE_DATA_DIR=<dir>`, against one `make
coverage` of the whole suite on main:

| report | files | statements | branches |
|---|---|---|---|
| one run of the whole suite | 704 | 82634 | 25548 |
| two shards combined | 704 | 82636 | 25548 |

Same file set; the two extra statements are the new constant and its
import. A source package's never-imported files reach the combined
report through the shard that imported it, as they reached the single
run.

The menu cache, the three files that bind templates (`uv run --frozen
--all-extras pytest -q tests/test_ppt_engine_template_tool.py
tests/test_ppt_engine_outline_checks.py
tests/test_ppt_engine_default_templates.py`): 101 s of worker time in
the last profile, now `196 passed in 11.84s` with no test over 2.9 s.
The files that call `menu()` directly: `219 passed in 8.06s`.

The font cache, the formula render test at `-n 0`: 8.91 s cold, 0.69 s
on the next run. Seven home-sensitive files: `484 passed in 5.30s`.

Ceiling guard, both modes, with the ceiling forced low so it has
something to list:

```
uv run --frozen --all-extras pytest -q -n 0 --wall-clock-ceiling=0.01 tests/test_import_cycle_budget.py tests/test_updates_install_guard.py
uv run --frozen --all-extras pytest -q -n 2 --wall-clock-ceiling=0.01 --wall-clock-ceiling-strict tests/test_updates_install_guard.py
```

First: 28 passed, five listed, exit 0. Second: 24 passed, four listed,
exit 1 (the controller flips the status; workers do not).

`make lint-python` clean, `make lint-imports` passes. The CI run on this
PR is the measurement that matters: four `unit` shards and one `coverage
gates` job.

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed (none: CI
plumbing, a cache cap, test setup)

## Risk

- The coverage gates now run in a job after the four shards. A red shard
skips the gates, a deliberate trade: combining three of four data files
would report a coverage drop that is not one, and the PR is red either
way. The gate scripts and their thresholds are unchanged.
- The diff gate no longer sees `plugins-dist/ppt-engine` or
`plugins-dist/design-engine` at all, as it could never judge them;
measuring them (`--cov=raven_ppt --cov=raven_design`, a new ratchet
baseline) is the follow-up that would bring them under the gate.
- `--shard` is opt-in; a plain `pytest` run collects everything as
before. Shard data artifacts are kept one day, the combined reports 30
days as before.
- No product behaviour change: the ladder default is the same tuple read
from one place; the menu cap only changes how long the cache keeps
entries.
- Test-only risk: a test that implicitly relied on a production-length
retry delay would see different timing. The full suite passed with the
fixture on, and a single test can opt out with `production_timing`.
- Rollback: revert the PR. The unit job goes back to one runner with the
gates inline; both markers are additive.

- [x] Security impact considered (no security surface touched)
- [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>
2026-09-15 16:00:49 +08:00
0xKT
a27559e331 fix(*): the final audit closes consent, tty truth, and the cache lies
An adversarial last pass over the whole branch found what the review
rounds had not. Consent first: the sh decline arm matched only bare n/N,
so a typed "no" installed LibreOffice through sudo; the arm now takes
the word too, and a tripwire pins the default-yes prompt in both
installers so the review-round decision cannot silently flip back. The
tty gate probed existence where openability is the truth -- the node
exists in CI, cron and docker -t without -i -- so the gate now opens it,
and a consoleless run skips instead of defaulting yes or hanging.
install.ps1 finally carries the everos memory wheel through both of its
paths with sh's own rung discipline, so the Windows summary's memory row
can be green at all. The two cache resolvers follow playwright's real
lookups (XDG_CACHE_HOME, LOCALAPPDATA, chrome-win64 layouts), a
non-object registry degrades instead of raising, and the four mouths
that name a fix now say the same runnable thing on every platform.

Co-authored-by: Claude (claude-fable-5) <noreply@anthropic.com>
2026-09-12 00:50:35 +08:00
0xKT
1d37a81a0f fix(*): the review round closes the linux64 layout, wrap-proof tests, office default
Three findings from review, one wave. The per-user cache patterns learn
chromium-*/chrome-linux64/chrome -- the layout playwright 1.62 actually
installs on Linux and the one the VM group already knew -- so doctor and
the design renderer stop disagreeing about a machine the new installer
just set up. The two doctor assertions that read a literal path fragment
out of rendered output now inject a wide console first, because xdist's
longer tmp paths cross Rich's 80-column default and split the token
mid-word. And the Linux LibreOffice offer defaults to yes with the
consequence spelled out in the prompt, matching what macOS already does
silently: for the deck lane this is the one dependency that matters, and
sudo's own password prompt still stands between Enter and any change;
install.ps1 mirrors the same default and wording.

Co-authored-by: Claude (claude-fable-5) <noreply@anthropic.com>
2026-09-11 23:48:28 +08:00
0xKT
1150aaae37 fix(plugins): design chromium discovery reaches the playwright caches
The design engine's renderer found chromium only on PATH or under the
boxlite VM's /ms-playwright root, with Linux-only executable layouts, so
a browser installed the way playwright installs one -- into the per-user
cache -- was never found on a developer machine, and the refusal named
no remedy. Discovery now walks the roots in a fixed order: PATH names,
the VM root exactly as before, a PLAYWRIGHT_BROWSERS_PATH override ("0"
resolves to the package-local browsers the way doctor resolves it, so
the two detectors cannot disagree about one environment), then the macOS
and Linux user caches. The cache globs end at the executables playwright
actually ships, Chrome for Testing naming included, and the
missing-browser refusal now names both fixes: playwright install
chromium, or the render config's chromePath.

Co-authored-by: Claude (claude-fable-5) <noreply@anthropic.com>
2026-09-11 23:48:28 +08:00
gloryfromca
58dffbf13c chore(*): merge the github trunk into the gitlab main
## Summary

Merges the GitHub trunk into this fork's main, as a merge rather than a rebase:
the resolutions below live in the merge commit, and rebasing would drop them.

Eleven upstream commits since 377a1da14 (2026-08-25), fifteen files
conflicting. The conflicts worth a reviewer's attention:

- **tracing**: upstream retired the runtime attempt id. `attempt.id` is now a
  reserved span attribute and `attempts.json` owns the grouping, so
  `begin_attempt` / `end_attempt` / `current_attempt` and every `attempt_id`
  parameter go with it. Nothing on this side called them outside tests. This
  fork's `surface` field and its `use()` helper share those hunks and stay.
- **appLayout.tsx**: took upstream's copy-notice line only. Its
  `FloatingOverlays` hunk would render that component twice, because this side
  had already moved it into its own anchor box.
- **onboard_everos.py**: upstream only refreshed three model ids, which this
  side already carries. Kept the English-only role table (AGENTS.md 1.3).
- **test_everos_server.py**: took upstream's inotify-gate tests and pointed
  them at `raven_everos.server`, where this side moved the module.
- **README.zh-CN.md**: the benchmark table had to be rebuilt by hand. Its
  separator row auto-merged with the prerequisites table's and silently
  dropped the three data rows.

Three follow-up commits fit upstream's new tests to this fork's environment.
Each is a fork/upstream difference, not a defect upstream:

- The listing tests widen the console with `env={"COLUMNS": "200"}`. That
  cannot work here: this suite runs under xdist (`addopts` carries `-n 4`) and
  its workers export `COLUMNS=80`, which rich freezes into `Console._width` at
  import time, before any invoke sets the variable. An autouse fixture gives
  the module console a real width, the way upstream's own browse test does.
- One test patched `raven.config.loader._current_config_path`; this fork keeps
  that name in `raven.home`.
- Three CJK fixtures are written as `\uXXXX` escapes so the language gate
  passes. `test_table_cjk_cells_stay_within_budget` measures what an
  east-asian glyph costs in a table cell, so an ASCII replacement would void
  the test; the escape keeps the runtime value upstream's.

**Reviewer attention, one deliberate rule break**: `MODULES_IN_CYCLES_CEILING`
in `tests/test_import_cycle_budget.py` goes 42 -> 46, and that file's comment
says the ceilings may only go down. Upstream's four new modules import each
other in pairs (`cli.trajectory_browse` with `cli.trajectory_commands`,
`trajectory.bugreport` with `trajectory.review`). Neither pair can be unpicked
by deferring an import, because that graph counts a function-local import like
a top-level one, so unpicking either means moving code that has just arrived
from upstream. The package and pair ceilings did not move. Raising the number
here is the call a reviewer may want to reverse; doing so means a refactor of
upstream's new modules, roughly 110 lines moved.

Project settings changed alongside this: `squash_option` `always` ->
`default_off`. A squash would flatten the merge commit and lose the manual
resolutions above, after which the next sync would have to redo all of them.
`merge_method` was already `merge` and is untouched.


A manual smoke run on the real hosts found one bug the suites did not, now
fixed on this branch: the sync took upstream's copy-on-select wiring into
`useMainApp` but not the two import lines it needs. Both sides had edited that
import block, so git resolved it to this fork's version and the added lines
went with it -- a semantic conflict, no marker. `raven tui --dev` died on entry
with `createCopyOnSelectReporter is not defined`. The 2072 vitest tests did not
catch it (none imports and renders the whole hook) and neither did eslint
(undefined names are left to the type checker here); `npm run type-check` does,
and is clean after the fix.


**Known red gate, recorded rather than bypassed.** Five of the eleven imported
commits fail `scripts/check_commit_messages.py` over this MR's range
(`1aef9f50`, `a83a3565`, `5ab90aa5`, `9c55d545`, `dcedd1c4`). The only
non-ASCII in them is three characters: the display name in a colleague's
`Co-authored-by` trailer (U+6C5F U+56FD U+5E86, address `guoqingjiang@`
unchanged and ASCII). Subjects and bodies are English. The job that runs this
checker fires on GitHub `pull_request` events, so a merge performed on GitLab
never runs it -- which is why this pipeline is green while the gate is red over
the same range.

The disposition, settled between the maintainer and the reviewer: a single
deliberate pass over the imported history will rewrite committer and author
information wholesale, and these five trailers belong to that pass. Rewriting
them here would be redone by it. So this is assigned to the change that can do
it once across all imported history, rather than five commits at a time inside
a sync -- not waved through as unimportant. This paragraph exists so the next
reader sees the gate was weighed, not missed.

One cleaner route remains open and is deliberately not taken here: teaching
`commit_lint.py` that a trailer's display name may be non-ASCII while its
address stays ASCII, which is arguably what AGENTS.md 3.1.1 already means when
its table calls the trailer "ASCII by format".

## Type

- [ ] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [x] Other (upstream sync)

## Verification

- `uv run --all-extras pytest -q` -> 21814 passed, 4 failed, 45 skipped.
  The four are pre-existing on main, verified by running them on a clean
  `origin/main` worktree in the same environment:
  `test_agents_oncall_launcher.py::test_the_products_tool_face_equals_the_forks_config_intent`,
  `test_agents_code_launcher.py::test_the_products_tool_face_is_the_forks_config_intent_minus_the_ledger`,
  `test_agent_loop_token_budget.py::test_a_ceiling_as_large_as_the_window_still_leaves_room_for_history`,
  `test_ppt_engine_image_search.py::test_a_missing_key_is_said_once_rather_than_per_query`.
- `npm test` in `ui-tui/` -> 143 files, 2072 tests, all passing.
- `make lint-python` -> 1930 files already formatted.
- `make lint-imports` -> 10 contracts kept, 0 broken.
- `make lint-deps` -> no dependency issues.
- `make check-source-language` -> clean.
- `make check-large-files` -> clean.

Manual smoke on the real hosts (isolated `RAVEN_HOME`, own tmux session, the
running instance on this machine left untouched):

- `raven trajectory list` -> three attempts, matching the span log on disk.
- Interactive browser (bare `raven trajectory`, driven under tmux): session
  list, attempt list, and the `turn.input_preview` values all render from the
  real log. `[M]` merged two attempts; `attempts.json` gained the definition
  with exactly those two member trace ids, and the span log stayed append-only.
- `raven trajectory split` put it back: `attempts.json` empty, listing back to
  three rows.
- `raven trajectory report-bug` produced `br-20260911-b19368.tar.gz` with the
  envelope and the nested trajectory inside; it correctly reported the fixture
  as unreplayable and pinned the attempt.
- `raven tui --dev` reaches the main layout, and the completion overlay anchors
  correctly (the `FloatingOverlays` hunk this merge resolved by hand).
- Copy-on-select driven end to end by sending SGR mouse press/drag/release
  through tmux, against a sentinel value placed on the clipboard first. The
  first drag put the selected span on the clipboard (`pbpaste` returned
  exactly the 76 characters under the drag) and reported `copied 76
  characters` into the transcript; a second drag reported `copied 10
  characters` as the transient notice above the composer, which is the line
  this merge resolved by hand. One drag, one clipboard write, one notice:
  the duplicate subscription is gone from the observable behaviour too, not
  only from the source. The host clipboard was restored byte-for-byte after.

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed

## Risk

User-visible changes all come from upstream: the interactive trajectory
browser, the tester-facing bug report flow, the feishu websocket backoff, the
EverOS inotify spawn gate, and the TUI copy-on-select notice. The fork's own
behaviour is unchanged; the only fork-side edits are in tests.

The one runtime removal is the tracing attempt API. No caller outside tests
used it on this side, and upstream replaced what it did with `attempts.json`.

Rollback: revert the merge commit. Because this lands as a merge rather than a
squash, the branch history stays intact and a revert leaves main exactly where
it was.

- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes

## Related Issues

N/A
2026-09-11 15:43:23 +00:00
gloryfromca
46029007ce chore(*): merge upstream main into the gitlab trunk
Eleven commits from the GitHub trunk since 377a1da14, fifteen files
conflicting. How each was resolved:

- raven/tracing/context.py, trace.py, spans.py and tests/test_tracing_api.py:
  upstream retired the runtime attempt id. attempt.id is now a reserved span
  attribute and attempts.json owns the grouping, so begin_attempt,
  end_attempt, current_attempt and every attempt_id parameter go with it.
  Nothing on this side called them outside tests. The fork's surface field
  and its use() helper share those hunks and stay.
- raven/trajectory/store.py: upstream's module docstring documents
  attempts.json and is a superset of ours.
- raven/cli/onboard_everos.py and tests/test_cli_onboard_commands.py:
  upstream only refreshed three model ids, which this side already carries.
  Kept our English-only role table (AGENTS.md 1.3).
- tests/test_everos_server.py: took upstream's inotify-gate tests and pointed
  them at raven_everos.server, where this side moved the module.
- ui-tui/src/app/useMainApp.ts: copy-on-select was never wired up here;
  upstream wires it.
- ui-tui/src/components/appLayout.tsx: took upstream's copy notice line only.
  Its FloatingOverlays hunk would render that component twice, because this
  side had already moved it into its own anchor box.
- README.md and README.zh-CN.md: upstream's wording under this side's emoji
  headings. The zh benchmark table had to be rebuilt: its separator row
  auto-merged with the prerequisites table's and dropped the data rows.
- tests/test_provider_rates.py and tests/test_trajectory_bundle.py: both
  sides appended independent tests at the end of the file; kept both.

Co-authored-by: Claude (claude-opus-5) <noreply@anthropic.com>
2026-09-11 17:52:06 +08:00
Tchen
e5bf6f8aed build(ppt-engine): carry playwright so an install that renders has it
The design lane imports playwright and declares it in an optional extra, so a
release install arrived without it and the browser half of rendering was off --
visible only when a render came back unavailable.

An extra is one more thing every installer has to know to ask for. The deck
engine's distribution is already fetched unconditionally by the same install, so
the pin rides along with it and every packaging route gets the library for free.
2026-09-11 12:53:39 +00:00
Tchen
f78560b5d1 feat(subagent): route a deck by tier and credentials, and give the lane its own skill
## Summary

Two lanes can produce a deck: the design lane draws its own pages, and the
template lane fills a prepared template. This combines two branches that
together decide which lane runs and equip the one that keeps the work.

Routing. A route entry is no longer only a target name. It declares what the
work owes and what to tell the row's own implementation when the route is closed
to a dispatch, either inline or in a file beside the manifest - prose inside a
JSON string is one line, unreviewable as a diff and unformattable. Both are the
row's words, not the gate's: the gate that closes a route is one piece of code
serving every row that declares one. The route to the template lane is closed
when the deployment cannot spend what that lane is built to spend. It gathers
pictures two ways, by generating them and by searching for them, and holds
neither without a key. The keys are read through the same live readers the tools
are registered from, and re-read per dispatch, so a key pasted into settings
opens the route without a restart and the answer cannot disagree with whether
the model is actually offered those tools.

Skills. The design lane gets a Skill corpus of its own, mounted alongside the
engine wheel's. The engine's corpus is the shared visual domain; this one
carries what is true of the deployment the product runs on - which tools answer
here, what the gates refuse, the page shapes and the numbers, and how to key a
cut-out out of a green screen. It sits beside the manifest that declares it, so
a checkout that has the manifest has it too.

Tiers. Medium is the one mode that names a reasoning effort of its own. Below
the top tier this agent designs the deck itself rather than handing it to the
template lane, and the cheapest tier also asking for the host's full thinking
budget is the combination nobody chose. The other modes say nothing, which is
the same as inheriting the host's.

## Type

- [ ] Fix
- [x] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

Run in a clean worktree cut from the current main tip, after
`uv sync --frozen --all-extras`.

- `uv run pytest` over the affected files: 1312 passed, exit 0. Files:
  test_subagent_routing_backend, test_subagent_vendored_agents,
  test_agents_design_launcher, test_agents_ppt_launcher,
  test_subagent_registry, test_subagent_builtin_agents, test_config_schema,
  test_agent_schemas, test_acp_schema, test_subagent_manager,
  test_subagent_direct_chat, test_subagent_mode_resolution,
  test_subagent_mode_wiring, test_subagent_third_party,
  test_cli_agent_loop_wiring, test_cli_subagent_setup, test_rpc_subagents,
  test_rpc_schema_match, test_update_subagents, test_agent_loop_web_tools.
- `make lint-python`: exit 0. ruff check reported "All checks passed" and ruff
  format reported "1921 files already formatted".
- Import check over every module this touches, exit 0: the routing backend,
  the subagent registry, manager and vendored agents, the loop entry and its
  wiring, and the config schema.

The second mounted corpus changes the render's mount list, which three launcher
tests pinned as exactly one row. They now pin the pair in append order.

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed

## Risk

Behaviour a deployment can see change:

- A deck request can stay on the design lane where it previously went to the
  template lane. That happens only where the web-search key or the image key is
  missing, and where it happens the template lane could not have gathered its
  pictures anyway.
- The render mounts a second always-on Skill directory, and mode entries gained
  a row. An entry that already names a reasoning effort now keeps it, so an
  operator's pinned effort is no longer overwritten by the host's.
- A route declaring both an inline note and a note file is refused at config
  load. No route in the tree declares either today, so no current config is
  affected.

Rollback: revert this merge. The new route fields default to empty and the
closed-route gate is inert wherever both keys are present, so reverting the
routing change alone is also safe.

- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes

## Related Issues

N/A
2026-09-11 10:57:36 +00:00
KevinHuSh
bb3f67ee9c fix(docker): run the container from the published image instead of building it
## Summary

`docker compose up --build` rebuilt the whole image on every start. For a reader
who only wants to try raven that is several minutes of Python and Node build to
arrive at what the registry already holds, so the quickstarts now say
`docker compose up`. Changed in README.md, README.zh-CN.md and docker/README.md.

`RAVEN_IMAGE` points at `evermindshanda/raven:latest`. The compose fallback is
corrected to the same account: it read `everminbd/raven:dev`, a transposition
that named nothing and would only have surfaced for someone running without a
.env file.

Two things a reviewer should decide rather than take from me:

- The fallback in docker-compose.yml is `:dev` while .env pins `:latest`. That
  is only reachable with no .env present, so it may be deliberate; it is worth
  a look either way.
- The service still carries a `build:` section and no `pull_policy`. Dropping
  `--build` stops forcing a rebuild, but with a build section present Compose
  builds a missing image rather than pulling it. If the intent is that a reader
  never builds, that likely wants `pull_policy: always` or the build section
  moved behind a profile. I have not changed it, because which of those is right
  depends on whether contributors are still expected to build from this file.

## Type

- [x] Fix
- [ ] Feature
- [x] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

- `uv run pytest tests -q -k "docker or readme"` -- 34 passed, 8 skipped
- `make check-source-language`, `make check-large-files` -- clean
- `npx commitlint` and `scripts/check_commit_messages.py` over the branch range -- clean

Not verified: no Docker daemon was available, so the published image was not
pulled and `docker compose up` was not run end to end. The claim that the image
exists at that name is the author's, not something this branch proves.

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed

## Risk

If `evermindshanda/raven:latest` is absent, private, or stale, `docker compose up`
now builds from source instead (the build section is still there), so the failure
mode is a slow start rather than a broken one. Rollback is by revert; nothing
here changes runtime behaviour, only which image Compose reaches for.

- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes

## Related Issues

N/A
2026-09-11 07:44:46 +00:00
KevinHuSh
f60bab3183 fix(docker): run the container from the published image instead of building it
## Summary

`docker compose up --build` rebuilt the whole image on every start. For a reader
who only wants to try raven that is several minutes of Python and Node build to
arrive at what the registry already holds, so the quickstarts now say
`docker compose up`. Changed in README.md, README.zh-CN.md and docker/README.md.

`RAVEN_IMAGE` points at `evermindshanda/raven:latest`. The compose fallback is
corrected to the same account: it read `everminbd/raven:dev`, a transposition
that named nothing and would only have surfaced for someone running without a
.env file.

Two things a reviewer should decide rather than take from me:

- The fallback in docker-compose.yml is `:dev` while .env pins `:latest`. That
  is only reachable with no .env present, so it may be deliberate; it is worth
  a look either way.
- The service still carries a `build:` section and no `pull_policy`. Dropping
  `--build` stops forcing a rebuild, but with a build section present Compose
  builds a missing image rather than pulling it. If the intent is that a reader
  never builds, that likely wants `pull_policy: always` or the build section
  moved behind a profile. I have not changed it, because which of those is right
  depends on whether contributors are still expected to build from this file.

## Type

- [x] Fix
- [ ] Feature
- [x] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

- `uv run pytest tests -q -k "docker or readme"` -- 34 passed, 8 skipped
- `make check-source-language`, `make check-large-files` -- clean
- `npx commitlint` and `scripts/check_commit_messages.py` over the branch range -- clean

Not verified: no Docker daemon was available, so the published image was not
pulled and `docker compose up` was not run end to end. The claim that the image
exists at that name is the author's, not something this branch proves.

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed

## Risk

If `evermindshanda/raven:latest` is absent, private, or stale, `docker compose up`
now builds from source instead (the build section is still there), so the failure
mode is a slow start rather than a broken one. Rollback is by revert; nothing
here changes runtime behaviour, only which image Compose reaches for.

- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes

## Related Issues

N/A
2026-09-11 07:44:46 +00:00
0xKT
ab8eb7d498 fix(ppt-engine): give a page box the names it promises and rasterise one at a time
## Summary

Three defects a live twenty-page run surfaced, each of which cost whole pages.

`PageBox` said in its own docstring that it reads the same as `ppt_layout.Box`, and `Box`
answers to `.x` and `.y` as well as `.w` and `.h`. `PageBox` answered to two of the four.
A build helper read `round(b.y, 3)` once, in the one place it used for every page, and all
twenty pages failed to draw with `'PageBox' object has no attribute 'y'`. `Box` was given
the same pair after the same crash; the promise was the part that did not travel.

`_check_cut_out` asked its argument for `.name`, and the spelling the skill documents is
`replace_picture(shape_at(slide, n), str(FIGURES / image), fit)`. Every other branch takes
that string -- the ones that open the file hand it to PIL, which does -- so the only thing
that refused it was the warning that exists to explain a mistake. It raised
`'str' object has no attribute 'name'` over the top of the explanation and took the page
with it.

Rasterising now has a gate of its own, and it is one. `pdf()` spends its time in a
LibreOffice subprocess with a profile of its own, so width there costs nothing and buys
wall clock; `pages_of` spends its time in pypdfium2, in a worker thread of this process,
against a library that keeps state per process rather than per document. One gate for both
put them under the same number and let the second run concurrently with itself: over a
nine-template reference set, six of the nine PDFs failed to open with
`PDFium: Data format error` while every one of the nine opened when read one at a time, and
an earlier run on the same path took SIGSEGV. `pages_of` answers a failed read with an
empty dict, so the cost was a reference sheet quietly short of two thirds of its pages
rather than anything that looked like an error.

## 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

Commands run on this branch, rebased onto main:

```
uv run --frozen pytest tests/ -k ppt -q
uv run --frozen pytest tests/test_ppt_engine_template.py -q \
  -k "page_box_answers or cut_out_warning_survives or rasterising_runs_one_at_a_time"
uv run --frozen ruff check plugins-dist/ppt-engine/raven_ppt/services/template/compose.py \
  plugins-dist/ppt-engine/raven_ppt/stages/_views.py
```

The three added tests were each confirmed to fail without the source change. The
concurrency one asserts on how many rasterisations are in flight -- the property -- rather
than on the width of a semaphore, which is one way to get it, and its stub renderer carries
the real signatures on purpose: a stub that shapes itself to the caller agrees with a call
the engine cannot make.

## Risk

- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes

Two added properties and one widened type annotation are additive. The third change
narrows rasterising to one at a time while leaving conversion as wide as it was, so a deck
whose pages are read after conversion takes slightly longer in exchange for reading all of
them; reverting the commit restores the shared gate.

## Related Issues

N/A
2026-09-11 07:22:24 +00:00
Tchen
94ed54b78d fix(ppt-engine): give a page box the names it promises and rasterise one at a time
## Summary

Three defects a live twenty-page run surfaced, each of which cost whole pages.

`PageBox` said in its own docstring that it reads the same as `ppt_layout.Box`, and `Box`
answers to `.x` and `.y` as well as `.w` and `.h`. `PageBox` answered to two of the four.
A build helper read `round(b.y, 3)` once, in the one place it used for every page, and all
twenty pages failed to draw with `'PageBox' object has no attribute 'y'`. `Box` was given
the same pair after the same crash; the promise was the part that did not travel.

`_check_cut_out` asked its argument for `.name`, and the spelling the skill documents is
`replace_picture(shape_at(slide, n), str(FIGURES / image), fit)`. Every other branch takes
that string -- the ones that open the file hand it to PIL, which does -- so the only thing
that refused it was the warning that exists to explain a mistake. It raised
`'str' object has no attribute 'name'` over the top of the explanation and took the page
with it.

Rasterising now has a gate of its own, and it is one. `pdf()` spends its time in a
LibreOffice subprocess with a profile of its own, so width there costs nothing and buys
wall clock; `pages_of` spends its time in pypdfium2, in a worker thread of this process,
against a library that keeps state per process rather than per document. One gate for both
put them under the same number and let the second run concurrently with itself: over a
nine-template reference set, six of the nine PDFs failed to open with
`PDFium: Data format error` while every one of the nine opened when read one at a time, and
an earlier run on the same path took SIGSEGV. `pages_of` answers a failed read with an
empty dict, so the cost was a reference sheet quietly short of two thirds of its pages
rather than anything that looked like an error.

## 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

Commands run on this branch, rebased onto main:

```
uv run --frozen pytest tests/ -k ppt -q
uv run --frozen pytest tests/test_ppt_engine_template.py -q \
  -k "page_box_answers or cut_out_warning_survives or rasterising_runs_one_at_a_time"
uv run --frozen ruff check plugins-dist/ppt-engine/raven_ppt/services/template/compose.py \
  plugins-dist/ppt-engine/raven_ppt/stages/_views.py
```

The three added tests were each confirmed to fail without the source change. The
concurrency one asserts on how many rasterisations are in flight -- the property -- rather
than on the width of a semaphore, which is one way to get it, and its stub renderer carries
the real signatures on purpose: a stub that shapes itself to the caller agrees with a call
the engine cannot make.

## Risk

- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes

Two added properties and one widened type annotation are additive. The third change
narrows rasterising to one at a time while leaving conversion as wide as it was, so a deck
whose pages are read after conversion takes slightly longer in exchange for reading all of
them; reverting the commit restores the shared gate.

## Related Issues

N/A
2026-09-11 07:22:24 +00:00
gloryfromca
201293cf1c refactor(sandbox): the sandbox is told where its state lives
## Summary

`raven/sandbox/_runtime.py` read `raven.config.paths.get_sandbox_dir` to find the boxlite home, while `raven/config/schema.py` imports `raven.sandbox.config` for `SandboxConfig` -- a two-edge cycle between the two packages. An executor asking the configuration layer where its own data lives is the inverted half of that pair: it can be told instead.

`get_boxlite_runtime` now takes the home. `BoxliteExecutor` and `SandboxDebugServer` take a `sandbox_home` and pass it down. `build_executor` takes `sandbox_dir` -- the resolver, normally `get_sandbox_dir` -- and calls it only inside the boxlite branch.

The resolver rather than an already-resolved path, because resolving one creates the directory and `none` is the default backend: an eager path would leave every install a boxlite home it never uses. That laziness has a test, and the test goes red if the resolve moves above the branch.

`SandboxConfig` gains no field. Its model carries an alias generator, so a field there would become a user-writable knob in `config.json`, and a resolved runtime path is not a declaration. Five production call sites pass the resolver, all in packages that already import `raven.config`, so no new edge appears.

Measured on `origin/main` in the same environment, before -> after: packages in cycles 18 -> 17, mutual pairs 13 -> 12 (`config <-> sandbox` is gone), modules in cycles 42 -> 42. The ratchet ceilings in `tests/test_import_cycle_budget.py` are deliberately left where they are.

## Type

- [ ] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [x] Refactor
- [ ] Other

## Verification

- `uv run pytest tests/test_sandbox_unit.py tests/test_sandbox_debug_server.py tests/test_agent_loop_workdir.py tests/test_cli_sandbox_commands.py tests/test_playbook_mcp.py tests/test_subagent_manager.py tests/test_import_cycle_budget.py -q` -> 336 passed
- `uv run lint-imports` -> 9 kept, 0 broken
- `uv run ruff check raven/ tests/` -> All checks passed
- `uv run ruff format --check` on the touched files -> already formatted
- `make check-source-language` -> exit 0
- The laziness guard was mutation-checked: moving `sandbox_dir("boxlite")` above the backend branch turns `test_the_sandbox_home_stays_unresolved_for_a_backend_that_has_none` red; reverting turns it green
- The integration suites under `tests/integration/` are updated to pass the real `get_sandbox_dir("boxlite")`, but were not executed here (they need a real VM)

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed

## Risk

No behaviour change on the boxlite path: the same directory reaches the same runtime, and the memo cache is still keyed on it. On the `none` path the directory is no longer created, which is the intended difference. Any caller that constructs an executor without the new argument fails at call time with a `TypeError`, not silently. Rollback is a revert of the single commit.

- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes

## Related Issues

N/A
2026-09-11 07:19:34 +00:00
Tchen
5b4cce3f43 feat(ppt-engine): deliver where the user named, one route onto a page, and the ten templates
## Summary

This branch folds four merge requests and one unpushed commit into one, so that `main`
takes one review, one approval and one merge instead of four, and so the eight-file
overlap between them is resolved once. It carries, in this order:

- **!602** `feat/ppt_deliver_to_named_path` -- `ppt_build` takes `deliver_to`; every
  publish writes the deck under `out/` and copies the same measured bytes to the path
  the user named, recording it with `role: "delivery"`. The PDF preview rides along only
  where its own `.pdf` name is free: a file already at that stem is the user's and is
  left alone, and the reply says the preview stayed under `out/`.
- **!628** `feat/ppt_copy_route_and_page_isolation` -- `adapt` is removed, so cloning a
  template page and writing into it with `replace_text` is the only route; a page whose
  block raises loses only itself and the pages after it still build; a draft counts
  against the tier's build cap and one is released at it.
- **!632** `feat/ship_templates_and_soffice_dep` -- the ten bundled deck templates are
  tracked in git with per-file sha256 pins, so a fresh clone can build a deck; the
  LibreOffice dependency is declared and resolved through one resolver.
- **!642** `fix/ppt_copy_route_and_clone_typography` -- a copy-route lookup that finds
  nothing names the near miss before the inventory; a text frame with no paragraph at
  all can be written into; a cloned page's title size is said; `row_type_drift` compares
  the same structural slot across a run's units.
- **D57's other-page clause, rewired.** D57 gave five refusals a "did you mean" hint,
  and one of them also answered "the string you named is on page N of this template".
  That clause needs the file a page was cloned out of, and the only refusal holding it
  was `adapt`'s, which !628 removed. It is restored by reading `PPT_TEMPLATE_SOURCE`,
  which the runner already sets in the author's own process and which this module
  already reads for `bundled()`; the two helpers behind the clause are unchanged.
- **D60** `read the ground under each word, not across the whole box` -- the `unreadable`
  contrast gate also measures the render's own word boxes, as extra regions through the
  same guards, so a two-line block crossed by a narrow bright ridge can no longer elect
  the dark ground and read as legible.

Decisions the union forced, none of which drops a behaviour:

- The publish record is built !602's way, with its delivery `role`, and written the way
  D49 requires -- read back off the file, atomic, and refused rather than silent when
  the record cannot be written.
- `clear_region`, `shapes_in`, `page_box` and the refusal of a bare four-number region
  survive `adapt`'s removal; so do `_heading_rows` and its helpers, which the row
  reading loads even though the call they were written for is gone.
- The author-facing guidance names !628's single route and keeps D59's rule that a
  region must declare which reading it is.
**The decision log carries a numbering collision, on purpose.** It is a set union with
no wording changed, and the numbers are left exactly as each branch wrote them, so a
reviewer meets this rather than discovers it:

- !602 and !628 each wrote a **D37** and a **D38**, about different decisions.
- !628's **D45** is not `main`'s D45; they are unrelated entries under one number.
- !628's **D42** is `main`'s **D45** word for word, so the merged log carries one
  decision under two numbers.

Renumbering touches every cross-reference in the log, and doing that inside a
seventy-commit fold immediately before a merge is how a silent break gets in. The
numbering is being fixed on a separate branch, which carries a script and a test that
fails when a citation points at nothing.

## Type

- [x] Feature
- [x] Fix
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

Run on an interpreter carrying `python-pptx`, with `PYTHONPATH` at this worktree and its
`plugins-dist/ppt-engine`, confirmed from a neutral working directory that `raven` and
`raven_ppt` resolve out of the worktree and not the host repo.

- `make test-python` (the whole suite, as CI runs it) -- 20826 passed, 49 skipped, and
  26 failures this machine produces on any branch: it has no `/usr/share/zoneinfo`, so
  every cron timezone case raises `ValueError: unknown timezone 'Asia/Shanghai'`. Checked
  out plain `origin/main` in a clean worktree and ran the same two files: the same 6
  failed and 20 errors, the ids identical character for character. Nothing on this branch
  touches cron or timezones. The stale `test_trunks_executor_would_have_dropped_that_output`
  that failed on the previous revision is retired on the new base and its replacement,
  `test_trunks_executor_preserves_output_on_timeout`, was run on its own and passes.
  The 6 failures and 20 errors are all cron timezone tests failing identically on plain
  `main` in a clean worktree, on a host with no `/usr/share/zoneinfo`.
- `make check-commits` -- exit 0.
- `make check-source-language` -- exit 0.
- `make check-large-files` -- exit 0.
- `make lint-imports` -- exit 0, 9 contracts kept, 0 broken.
- `ruff check` and `ruff format --check` over the 80 changed Python files -- exit 0.
- `pytest tests/test_ppt_engine_templates.py tests/test_utils_office.py
  tests/test_cli_doctor_commands.py` -- 97 passed; the ten templates are tracked and
  satisfy their pins, and the soffice resolver finds the local binary.
- The delivery contract, the record read-back, the page isolation and the near miss were
  each run as a measurement rather than asserted; the `unreadable` gate was run through
  the real LibreOffice render chain on a delivered 12-page deck and reports BLOCKING on
  page 12 under one word at 1.6:1.

- [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: `ppt_build` gains `deliver_to` and delivers outside `out/`;
`adapt` is gone from the author-facing template module, so a program calling it fails to
import -- `title=` and `subtitle=` have no replacement and the heading is named by the
words the template put there; a draft now counts against the tier's build cap; three
gates that nothing measured against being wrong no longer refuse; and the ten templates
are now bytes in the repository rather than a private registry fetch.

Two pieces here are about not destroying something the user has. The delivery
refuses to write its `.pdf` where a file the user already owns sits at the same
stem, rather than replacing it; and the large-file roster moved out of the manifest
inside the tree being checked and into the gate's own source, so a change can no
longer grant itself the exception the gate exists to withhold.

Rollback is per piece: each of the five sources is a contiguous run of commits on this
branch, in the order listed above, so any one of them can be reverted as a range without
touching the others.

- [x] Backward compatibility considered
- [x] Security impact considered
- [x] Rollback path is clear for risky changes

## Related Issues

N/A
2026-09-11 05:52:36 +00:00
0xKT
8716ec525c feat(docker): run raven in a docker container and make a first run configurable from the page
## 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
2026-09-11 03:27:52 +00:00
KevinHuSh
4a4a3fe15b feat(docker): run raven in a docker container and make a first run configurable from the page
## 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
2026-09-11 03:27:52 +00:00
0xKT
9c965e2470 fix(rpc): anchor the file viewer's state-dir fence on agent home, not the session workdir
## 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
2026-09-11 03:26:58 +00:00