Raven-1/tests/test_core_plugin_stack.py

786 lines
29 KiB
Python
Raw Permalink Normal View History

2026-06-28 18:17:27 +08:00
"""CLI plugin-stack helper.
Exercises :func:`build_plugin_registry` and
fix(tools): an array sent as its own JSON is still an array ## Summary Reported as "deliver_files is broken". It is not: **the tool never ran.** Every `deliver_files` call on one install was refused before dispatch -- five in a row in a single session -- and nothing was ever delivered: ``` Error: Invalid parameters for tool 'deliver_files': files should be array ``` What the model sent was the array, spelled as a string: ```json {"files": "[{\"path\": \"...poster.png\", \"title\": \"...\"}]", "message": "..."} ``` `cast_params` already forgives that spelling for every scalar type -- `"3"` for an integer, `"true"` for a boolean -- and did not for arrays or objects, which are exactly the types a model is most likely to stringify. ## Type - [x] Fix - [ ] Feature ## The edge of the forgiving is the design When the value is a string, try `json.loads`, and take the result **only if it is the type the schema asked for**. A string that is not JSON, or is JSON of the wrong shape, is returned unchanged so the validator still names the real problem -- the point is to widen what is accepted, not to swallow a type error. **Nothing here can raise.** Turning "your argument has the wrong type" into a traceback would be worse than the refusal it replaces, so the parse is wrapped and failure falls through. **A `type: "string"` field is never parsed.** JSON is ordinary text in a message body or a file's content, and replacing it would hand the tool something it never asked for. Two independent things prevent it today (the string branch returns before the parse is reached, and the parse only wins on a type match), which is why the case pinning it is a tripwire rather than a load-bearing assertion -- said so in its own docstring rather than left to look like coverage. ## Not just deliver_files Six built-in tools declare an array or object parameter and were all exposed: | tool | parameter | |---|---| | `deliver_files` | `files` | | `ask_user` | `questions` | | `image_generate` | `images` | | `message` | `media` | | `create_playbook` | `skills` | | `video_generate` | `params` | The same failure was already seen from the other side: `acp_client/acp_agent.py` records `update_task_state` and `operations should be array` from a real dispatch. ## Verification ``` make lint-python ruff check + ruff format --check, 1850 files make lint-imports 9 contracts kept, 0 broken pytest tests/ 19,699 passed, 7 failed (all pre-existing, see below) ``` - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [ ] User-facing docs or screenshots -- no user-facing string **End to end, through the real tool**, with the exact payload that failed five times in production: ``` files sent as: str -> [{"path": ".../poster.png", "title": "..."}] returned: Delivered 1 file(s): poster.png (72 B). still "should be array": False registered in the store: True ``` Twelve cases, five mutations, each killing at least one: | mutation | red | |---|---| | drop the whole branch (the old behaviour) | 3 | | raise instead of falling through on a parse failure | 5 | | accept the parse whatever type it yielded | 1 | | do not re-cast the parsed value, so items are not cast | 1 | | widen the tuple to include `string` | **survived -- unreachable** | The last is worth stating rather than hiding: that mutation cannot change behaviour, because the `type == "string"` branch returns earlier and the type check would refuse the result anyway. I also tried moving the new block above that branch, alone and combined with widening the tuple, and neither reddens anything either. The invariant holds by construction; the case that documents it says so. **Pre-existing failures, checked against the base.** 7 failed in the full run, all in `tests/test_security_network.py` (`test_a_redirect_to_a_dangerous_address_is_refused` and siblings). Running that file alone on this same tree gives 4 -- the count is order-dependent -- and the change touches only `raven/agent/tools/params.py` plus a new test file, neither of which `raven/security/network.py` imports. The failures are the box's resolver: it returns poisoned answers roughly half the time, which I measured separately (`en.wikipedia.org` came back as `2001::1` on 3 of 6 lookups). Not introduced here, and worth someone's attention on its own. ## Risk - [x] Security impact considered -- widens what reaches a tool's own validation, not what bypasses it. A parsed value is still validated against the same schema, and a parse that yields the wrong type is refused exactly as before - [x] Backward compatibility considered -- a call that worked before takes the identical path; the new branch is reached only by a `str` where an array or object is declared, which previously always failed - [x] Rollback path is clear -- single-commit revert ## Related Issues N/A ## Swept `mr-review-patterns` pre-submit sweep, over `git diff origin/main...HEAD`. - **1 (a write location moved)** -- nothing moved; a branch was added to an existing dispatch on `target_type`. Grepped every caller of `cast_params`: the registry is the only one, and it runs `validate_params` right after, which is the reader this affects. - **2 (a value with several entry points)** -- the cast is the single funnel every tool argument passes through, which is why the fix belongs here and not in `deliver_files`. - **3 (a guard)** -- checked both directions: what it wrongly lets through (JSON of the wrong type, non-JSON text -- both refused, with cases) and what it wrongly refuses (a real list, unaffected, with a case). - **4 (tests)** -- five mutations above, one honestly reported as unreachable. Failing-ID sets diffed against the base rather than counts. - **6 (stale text)** -- the module docstring enumerated what is coerced ("a string that should be an integer"); it now names arrays and objects too. Grepped the tracked tree for other statements of the rule: none. - **9 (error handling)** -- the new path adds one way to end and it is caught: `json.loads` raises `ValueError` on bad text and `TypeError` on a non-string, and both fall through to the untouched value. - **11** -- `git ls-files | grep -c node_modules` is 0; the commit-message gate was run, not eyeballed. Not applicable, with reasons: **3b, 3c, 3d, 3e** (no tool schema produced, no state moved, one lane, no assertion lost its symbol); **4b, 4c, 4d** (no platform branch, no shell, no rendered number); **5, 5b** (no dependency; `json` is stdlib and already imported across this package); **6b, 6c** (no backup, no generated artifact); **7, 7b** (nothing on disk); **8** (no asset, no secret); **10** (no prompt text). ## Deliberately not fixed The error text still ends with `[Analyze the error above and try a different approach.]`, and the model plainly did not -- it sent the same shape five times. A message naming the expected spelling (`files must be a JSON array, not a string containing one`) would give it something to act on. That is a change to the registry's error surface, affects every tool, and deserves its own argument. ## Moved from !594 Opened on a compliant source branch. AGENTS.md 2.1 asks for a 3-5 word snake_case description and the previous branch had seven; GitLab cannot change an existing merge request's source branch, so the change moves rather than the name. Same commits, rebased onto `c2a9768f`. Both code findings from the review on !594 are already in them -- `RecursionError` caught with its regression case, and the implementation comment reduced to the two non-obvious reasons. Nothing else changed, so that review carries.
2026-09-09 15:42:36 +00:00
:func:`maybe_build_memory_backend` against the ``raven_everos`` plugin,
which the dev environment installs from ``plugins-dist/everos-memory`` and
which discovery finds through the ``raven.plugins`` entry-point group.
2026-06-28 18:17:27 +08:00
"""
from __future__ import annotations
fix(tools): an array sent as its own JSON is still an array ## Summary Reported as "deliver_files is broken". It is not: **the tool never ran.** Every `deliver_files` call on one install was refused before dispatch -- five in a row in a single session -- and nothing was ever delivered: ``` Error: Invalid parameters for tool 'deliver_files': files should be array ``` What the model sent was the array, spelled as a string: ```json {"files": "[{\"path\": \"...poster.png\", \"title\": \"...\"}]", "message": "..."} ``` `cast_params` already forgives that spelling for every scalar type -- `"3"` for an integer, `"true"` for a boolean -- and did not for arrays or objects, which are exactly the types a model is most likely to stringify. ## Type - [x] Fix - [ ] Feature ## The edge of the forgiving is the design When the value is a string, try `json.loads`, and take the result **only if it is the type the schema asked for**. A string that is not JSON, or is JSON of the wrong shape, is returned unchanged so the validator still names the real problem -- the point is to widen what is accepted, not to swallow a type error. **Nothing here can raise.** Turning "your argument has the wrong type" into a traceback would be worse than the refusal it replaces, so the parse is wrapped and failure falls through. **A `type: "string"` field is never parsed.** JSON is ordinary text in a message body or a file's content, and replacing it would hand the tool something it never asked for. Two independent things prevent it today (the string branch returns before the parse is reached, and the parse only wins on a type match), which is why the case pinning it is a tripwire rather than a load-bearing assertion -- said so in its own docstring rather than left to look like coverage. ## Not just deliver_files Six built-in tools declare an array or object parameter and were all exposed: | tool | parameter | |---|---| | `deliver_files` | `files` | | `ask_user` | `questions` | | `image_generate` | `images` | | `message` | `media` | | `create_playbook` | `skills` | | `video_generate` | `params` | The same failure was already seen from the other side: `acp_client/acp_agent.py` records `update_task_state` and `operations should be array` from a real dispatch. ## Verification ``` make lint-python ruff check + ruff format --check, 1850 files make lint-imports 9 contracts kept, 0 broken pytest tests/ 19,699 passed, 7 failed (all pre-existing, see below) ``` - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [ ] User-facing docs or screenshots -- no user-facing string **End to end, through the real tool**, with the exact payload that failed five times in production: ``` files sent as: str -> [{"path": ".../poster.png", "title": "..."}] returned: Delivered 1 file(s): poster.png (72 B). still "should be array": False registered in the store: True ``` Twelve cases, five mutations, each killing at least one: | mutation | red | |---|---| | drop the whole branch (the old behaviour) | 3 | | raise instead of falling through on a parse failure | 5 | | accept the parse whatever type it yielded | 1 | | do not re-cast the parsed value, so items are not cast | 1 | | widen the tuple to include `string` | **survived -- unreachable** | The last is worth stating rather than hiding: that mutation cannot change behaviour, because the `type == "string"` branch returns earlier and the type check would refuse the result anyway. I also tried moving the new block above that branch, alone and combined with widening the tuple, and neither reddens anything either. The invariant holds by construction; the case that documents it says so. **Pre-existing failures, checked against the base.** 7 failed in the full run, all in `tests/test_security_network.py` (`test_a_redirect_to_a_dangerous_address_is_refused` and siblings). Running that file alone on this same tree gives 4 -- the count is order-dependent -- and the change touches only `raven/agent/tools/params.py` plus a new test file, neither of which `raven/security/network.py` imports. The failures are the box's resolver: it returns poisoned answers roughly half the time, which I measured separately (`en.wikipedia.org` came back as `2001::1` on 3 of 6 lookups). Not introduced here, and worth someone's attention on its own. ## Risk - [x] Security impact considered -- widens what reaches a tool's own validation, not what bypasses it. A parsed value is still validated against the same schema, and a parse that yields the wrong type is refused exactly as before - [x] Backward compatibility considered -- a call that worked before takes the identical path; the new branch is reached only by a `str` where an array or object is declared, which previously always failed - [x] Rollback path is clear -- single-commit revert ## Related Issues N/A ## Swept `mr-review-patterns` pre-submit sweep, over `git diff origin/main...HEAD`. - **1 (a write location moved)** -- nothing moved; a branch was added to an existing dispatch on `target_type`. Grepped every caller of `cast_params`: the registry is the only one, and it runs `validate_params` right after, which is the reader this affects. - **2 (a value with several entry points)** -- the cast is the single funnel every tool argument passes through, which is why the fix belongs here and not in `deliver_files`. - **3 (a guard)** -- checked both directions: what it wrongly lets through (JSON of the wrong type, non-JSON text -- both refused, with cases) and what it wrongly refuses (a real list, unaffected, with a case). - **4 (tests)** -- five mutations above, one honestly reported as unreachable. Failing-ID sets diffed against the base rather than counts. - **6 (stale text)** -- the module docstring enumerated what is coerced ("a string that should be an integer"); it now names arrays and objects too. Grepped the tracked tree for other statements of the rule: none. - **9 (error handling)** -- the new path adds one way to end and it is caught: `json.loads` raises `ValueError` on bad text and `TypeError` on a non-string, and both fall through to the untouched value. - **11** -- `git ls-files | grep -c node_modules` is 0; the commit-message gate was run, not eyeballed. Not applicable, with reasons: **3b, 3c, 3d, 3e** (no tool schema produced, no state moved, one lane, no assertion lost its symbol); **4b, 4c, 4d** (no platform branch, no shell, no rendered number); **5, 5b** (no dependency; `json` is stdlib and already imported across this package); **6b, 6c** (no backup, no generated artifact); **7, 7b** (nothing on disk); **8** (no asset, no secret); **10** (no prompt text). ## Deliberately not fixed The error text still ends with `[Analyze the error above and try a different approach.]`, and the model plainly did not -- it sent the same shape five times. A message naming the expected spelling (`files must be a JSON array, not a string containing one`) would give it something to act on. That is a change to the registry's error surface, affects every tool, and deserves its own argument. ## Moved from !594 Opened on a compliant source branch. AGENTS.md 2.1 asks for a 3-5 word snake_case description and the previous branch had seven; GitLab cannot change an existing merge request's source branch, so the change moves rather than the name. Same commits, rebased onto `c2a9768f`. Both code findings from the review on !594 are already in them -- `RecursionError` caught with its regression case, and the implementation comment reduced to the two non-obvious reasons. Nothing else changed, so that review carries.
2026-09-09 15:42:36 +00:00
import ast
fix(core): the memory service stops holding up the first session (#630) ## Summary Two changes against the same symptom: the first session after an install waits on the memory service and then runs without long-term memory anyway. **The wait is unnecessary.** A resident host awaited `backend.start()` at boot, so it held for the readiness budget -- 10s -- before serving anything. The backend already has a state machine for exactly that window: `store` answers False so the loop retries the record, and `recall` returns no hits for that turn and schedules a probe. Waiting for the service before serving the first turn is what the state machine replaced everywhere else. `plugin_stack.start_backend_detached` is the same shape as `warm_up_in_background` for litellm: a resident process starts the slow thing once and goes on serving, and the on-demand path reports a failure to whoever needs it. Three callers take it -- the gateway at boot and at a generation swap, and `raven a2a serve`. The other three keep awaiting, because for them there is no later turn to recover into: an import checks readiness immediately, a sub-agent writes one record, and a one-shot turn exits. It is retired in `Runtime.dispose`, the single point both resident hosts go through. **The wait was also far longer than its budget.** uv does not compile bytecode by default, so the first process to import a module compiles it, and for raven that process is the EverOS service the first session starts. Measured on a fresh isolated install: 22s from spawn to ready, of which 18s elapses before the service writes its first log line. `UV_COMPILE_BYTECODE=1` in the installer moves that into the install, where the user is already watching a progress line. ## Type - [x] Fix - [ ] Feature - [ ] Docs - [ ] CI / tooling - [ ] Refactor - [ ] Other ## Verification Measured on a throwaway install in an isolated `RAVEN_HOME` / `UV_TOOL_DIR` / `UV_TOOL_BIN_DIR`, built from this checkout: - cold first start, as shipped today: 22s spawn to ready (readiness budget 10s) - second start against the same tree: 2.2s - freshly scaffolded root, bytecode already compiled: 2.1s - byte-compiling the rest of that tree: 13.9s for 16756 files, single threaded, so the cost is compilation and it is paid once per machine The detached start was read at the layer that owns the ordering, the gateway's own log. Before this change `Page:` cannot appear until after `everos server ready`; after it: ``` 17 EverosBackend.start 20 Page: http://127.0.0.1:18894 28 started everos server 31 everos server ready ``` The page is serving at line 20 and the child is only spawned at line 28. The interval this removes from the boot measured 5.5s on a machine whose bytecode is already compiled. Commands: - `uv run --frozen --python 3.12 --all-extras pytest tests/test_core_plugin_stack.py tests/test_core_runtime_swap.py tests/test_cli_gateway_commands.py tests/test_cli_a2a_commands.py tests/test_cli_import_commands.py tests/test_memory_backend_protocol.py -q` -- 191 passed after the rebase onto main - the same set plus `tests/test_everos_backend.py` and `tests/test_core_runtime_eval_hooks.py` -- 364 passed - `ruff check raven/ tests/` -- all checks passed - `ruff format --check raven/ tests/` -- 1654 files already formatted - `sh -n install.sh` -- clean Each of the six new cases was mutated to confirm it can fail: dropping the task reference, dropping the done-callback, making the cancel a no-op, and removing the cancel from `dispose`. Every mutation turned the case that names that behaviour red, and the source was restored and hash-compared afterwards. - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [ ] User-facing docs or screenshots are updated when needed ## Risk User-visible change: a resident host now serves its first turn before the memory service has answered. A turn that arrives in that window gets no recall, and its record is retried rather than lost. Previously the host waited and, when the wait overran, that session had no memory at all -- so the window is narrower than what it replaces, not wider. The installer now compiles bytecode, which makes an install slower by roughly the compile time and larger by the `.pyc` tree. Rollback: both commits are independent and revert cleanly. Reverting the first restores the awaited start; reverting the second restores the uncompiled install. - [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:46:12 +08:00
import logging
2026-06-28 18:17:27 +08:00
from pathlib import Path
fix(tools): an array sent as its own JSON is still an array ## Summary Reported as "deliver_files is broken". It is not: **the tool never ran.** Every `deliver_files` call on one install was refused before dispatch -- five in a row in a single session -- and nothing was ever delivered: ``` Error: Invalid parameters for tool 'deliver_files': files should be array ``` What the model sent was the array, spelled as a string: ```json {"files": "[{\"path\": \"...poster.png\", \"title\": \"...\"}]", "message": "..."} ``` `cast_params` already forgives that spelling for every scalar type -- `"3"` for an integer, `"true"` for a boolean -- and did not for arrays or objects, which are exactly the types a model is most likely to stringify. ## Type - [x] Fix - [ ] Feature ## The edge of the forgiving is the design When the value is a string, try `json.loads`, and take the result **only if it is the type the schema asked for**. A string that is not JSON, or is JSON of the wrong shape, is returned unchanged so the validator still names the real problem -- the point is to widen what is accepted, not to swallow a type error. **Nothing here can raise.** Turning "your argument has the wrong type" into a traceback would be worse than the refusal it replaces, so the parse is wrapped and failure falls through. **A `type: "string"` field is never parsed.** JSON is ordinary text in a message body or a file's content, and replacing it would hand the tool something it never asked for. Two independent things prevent it today (the string branch returns before the parse is reached, and the parse only wins on a type match), which is why the case pinning it is a tripwire rather than a load-bearing assertion -- said so in its own docstring rather than left to look like coverage. ## Not just deliver_files Six built-in tools declare an array or object parameter and were all exposed: | tool | parameter | |---|---| | `deliver_files` | `files` | | `ask_user` | `questions` | | `image_generate` | `images` | | `message` | `media` | | `create_playbook` | `skills` | | `video_generate` | `params` | The same failure was already seen from the other side: `acp_client/acp_agent.py` records `update_task_state` and `operations should be array` from a real dispatch. ## Verification ``` make lint-python ruff check + ruff format --check, 1850 files make lint-imports 9 contracts kept, 0 broken pytest tests/ 19,699 passed, 7 failed (all pre-existing, see below) ``` - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [ ] User-facing docs or screenshots -- no user-facing string **End to end, through the real tool**, with the exact payload that failed five times in production: ``` files sent as: str -> [{"path": ".../poster.png", "title": "..."}] returned: Delivered 1 file(s): poster.png (72 B). still "should be array": False registered in the store: True ``` Twelve cases, five mutations, each killing at least one: | mutation | red | |---|---| | drop the whole branch (the old behaviour) | 3 | | raise instead of falling through on a parse failure | 5 | | accept the parse whatever type it yielded | 1 | | do not re-cast the parsed value, so items are not cast | 1 | | widen the tuple to include `string` | **survived -- unreachable** | The last is worth stating rather than hiding: that mutation cannot change behaviour, because the `type == "string"` branch returns earlier and the type check would refuse the result anyway. I also tried moving the new block above that branch, alone and combined with widening the tuple, and neither reddens anything either. The invariant holds by construction; the case that documents it says so. **Pre-existing failures, checked against the base.** 7 failed in the full run, all in `tests/test_security_network.py` (`test_a_redirect_to_a_dangerous_address_is_refused` and siblings). Running that file alone on this same tree gives 4 -- the count is order-dependent -- and the change touches only `raven/agent/tools/params.py` plus a new test file, neither of which `raven/security/network.py` imports. The failures are the box's resolver: it returns poisoned answers roughly half the time, which I measured separately (`en.wikipedia.org` came back as `2001::1` on 3 of 6 lookups). Not introduced here, and worth someone's attention on its own. ## Risk - [x] Security impact considered -- widens what reaches a tool's own validation, not what bypasses it. A parsed value is still validated against the same schema, and a parse that yields the wrong type is refused exactly as before - [x] Backward compatibility considered -- a call that worked before takes the identical path; the new branch is reached only by a `str` where an array or object is declared, which previously always failed - [x] Rollback path is clear -- single-commit revert ## Related Issues N/A ## Swept `mr-review-patterns` pre-submit sweep, over `git diff origin/main...HEAD`. - **1 (a write location moved)** -- nothing moved; a branch was added to an existing dispatch on `target_type`. Grepped every caller of `cast_params`: the registry is the only one, and it runs `validate_params` right after, which is the reader this affects. - **2 (a value with several entry points)** -- the cast is the single funnel every tool argument passes through, which is why the fix belongs here and not in `deliver_files`. - **3 (a guard)** -- checked both directions: what it wrongly lets through (JSON of the wrong type, non-JSON text -- both refused, with cases) and what it wrongly refuses (a real list, unaffected, with a case). - **4 (tests)** -- five mutations above, one honestly reported as unreachable. Failing-ID sets diffed against the base rather than counts. - **6 (stale text)** -- the module docstring enumerated what is coerced ("a string that should be an integer"); it now names arrays and objects too. Grepped the tracked tree for other statements of the rule: none. - **9 (error handling)** -- the new path adds one way to end and it is caught: `json.loads` raises `ValueError` on bad text and `TypeError` on a non-string, and both fall through to the untouched value. - **11** -- `git ls-files | grep -c node_modules` is 0; the commit-message gate was run, not eyeballed. Not applicable, with reasons: **3b, 3c, 3d, 3e** (no tool schema produced, no state moved, one lane, no assertion lost its symbol); **4b, 4c, 4d** (no platform branch, no shell, no rendered number); **5, 5b** (no dependency; `json` is stdlib and already imported across this package); **6b, 6c** (no backup, no generated artifact); **7, 7b** (nothing on disk); **8** (no asset, no secret); **10** (no prompt text). ## Deliberately not fixed The error text still ends with `[Analyze the error above and try a different approach.]`, and the model plainly did not -- it sent the same shape five times. A message naming the expected spelling (`files must be a JSON array, not a string containing one`) would give it something to act on. That is a change to the registry's error surface, affects every tool, and deserves its own argument. ## Moved from !594 Opened on a compliant source branch. AGENTS.md 2.1 asks for a 3-5 word snake_case description and the previous branch had seven; GitLab cannot change an existing merge request's source branch, so the change moves rather than the name. Same commits, rebased onto `c2a9768f`. Both code findings from the review on !594 are already in them -- `RecursionError` caught with its regression case, and the implementation comment reduced to the two non-obvious reasons. Nothing else changed, so that review carries.
2026-09-09 15:42:36 +00:00
import pytest
import raven
2026-06-28 18:17:27 +08:00
from raven.config.raven import (
MemoryConfig,
PluginsConfig,
build: whole-repo lint + pre-commit convention (config only) (#59) ## Change description > Whole-repo lint + pre-commit convention, CONFIG ONLY (no source reformat in this PR). Python (ruff) and TypeScript (eslint + prettier) share a 120-col margin via the committed pre-commit gate. This upgrades main's existing basic ruff setup and adds the TS lint stack (none existed on main). > > What this PR adds: > - ruff: line-length 120; security rules S101/S105/S106/S107/S506/S605/S607; policy per-file-ignores (tests + accepted CLI deferred-imports + product asserts + N818, each commented); ruff pinned <0.16. > - eslint/prettier: shared base (`eslint.base.mjs` + `prettier.config.mjs`); ui-tui extends it with React rules, bridge with a Node-only config; hermes-ink vendor and generated RPC types excluded. > - pre-commit: keeps main's hooks (conventional-commit, detect-private-key, etc.), adds a top-level exclude and 4 local eslint/prettier hooks; bumps the pre-commit dev dep. > - 2 lint-surfaced fixes: PlannerContext import (F821) in the sentinel runner; lower-cased file-local cron-heartbeat constants (N806). (raven/config/raven.py's F821 was already fixed on main.) > > Sequencing: config only. `ruff check` is intentionally red on ~307 auto-fixables (I001/F401/F541/E701/E702); a SEPARATE reformat branch runs `ruff --fix` + `ruff format` + eslint/prettier --fix to clear them (100% auto-resolvable, zero manual). Enforcement (pre-commit install / CI) turns on only after the reformat lands, so do not expect a green tree from this PR alone. > > CLI-owned files (the reformat and several per-file-ignores touch `raven/cli/*`) are under review by the CLI team. Judgment items (TS no-explicit-any, no-unused-expressions, S101 convert-vs-keep, N818 rename, C90, mypy) are deferred to v2. ## Type of change - [ ] Bug fix - [x] New feature - [ ] Document - [x] Others ## Related issues (if there is) > none ## Checklists ### Development - [ ] Lint rules pass locally - [ ] Application changes have been tested thoroughly - [ ] Automated tests covering modified code pass > config-only: `ruff check` is red on auto-fixables by design (the reformat branch clears them); eslint/prettier configs load in both ui-tui and bridge. ### Security - [x] Security impact of change has been considered - [ ] Code follows company security practices and guidelines > Only dependency change is the dev-only pre-commit tool plus the ruff pin; the detect-private-key hook from main is retained. ### Code review - [x] Pull request has a descriptive title and context useful to a reviewer - [ ] Pull request linked to JIRA ticket when applicable --------- Co-authored-by: Sheng Zhao <sheng.zhao@evermind.ai> Co-authored-by: Claude (claude-opus-4-8) <noreply@anthropic.com>
2026-07-01 12:09:42 +08:00
RavenConfig,
2026-06-28 18:17:27 +08:00
)
feat(ui-tui): tool cards open themselves, the strip marks here, ticker words split ## Summary Three reader-facing changes to the TUI transcript and the instance strip. **A settled tool call opens itself.** A tool card had two states, shut and full, and neither is what a reader wants by default: shut hides the result that was the point of the call, full spends a thousand rows on a result five rows would have answered. There are now three levels - shut, a preview capped at `TOOL_PREVIEW_ROWS` result rows with a `+N` row standing for the remainder, and full at `TOOL_FULL_ROWS`. The cap is what bounds the cost, so a call that came back opens unasked and only a call that returned nothing stays shut, its block being the argument the row above already shows. A reader's own decision always wins over that default. The `+N` row becomes its own two-way control: it reveals the rest, then folds back to the cap, where the block's own click shuts the card outright. It used to ride inside the output array, which made the one row announcing there was more to see the row that collapsed the card. Fold state moves out of the component that draws it into a store keyed by tool call id. Held in the row's component state, a row that changed - a step landing in a turn still running - unmounted and took the reader's decision with it, so a card opened seconds ago closed itself. `useMainApp` now reads that store when it measures: a resize drops every measured height because the cache buckets on columns, so without the folds there, rows below the fold came back at their default height and the transcript scrolled to the wrong place. **The strip marks the row whose conversation is on screen.** The composer's top border names the instance being typed to, and the strip listed every instance without saying which of them that was. The active row now carries a gutter bar in the strip's own leftmost column, where nothing else draws, so the bar reads as a position and the bullet beside it goes on saying status alone. The active row is exempt from every cap, and a line no click can switch to - a graph line, a loose spawn - never carries it. An interrupted turn also refreshes the instance registry now: `message.complete` already did, but the manager moves the row on this path too, writing `cancelled` or `failed`, so without the re-read an interrupted instance went on showing a filled bullet while its view went on polling a turn that had ended. **The censored ticker vocabulary splits from Raven's own.** Wrapped agents render their status as a kaomoji plus a verb, some of it on the channel the reasoning arrives on, and `cleanThinkingText` strips exactly that pair - but it was reading its strip list off Raven's own `FACES` and `VERBS`. That made the two one list, so a branding change silently changed what gets censored out of a model's reasoning: rename a verb and the old word stops being stripped, adopt a word another agent uses and Raven's own ticker starts eating itself. `tickerNoise.ts` now holds that vocabulary, frozen and deliberately separate; it describes other agents' output and changes only when one of them does. `FACES` and `VERBS` are then free to move, and they move here: the kaomoji become one bird wearing different expressions, and the verbs are ordered as one round of work rather than by how close the words are in meaning, because at one word every 2.5s a reader sees most of the list in a single turn. Each emoji frame is a single code point on purpose - a ZWJ sequence or a variation selector renders as two glyphs on terminals that do not compose it, which shifts everything right of the ticker. ## Type - [ ] Fix - [x] Feature - [ ] Docs - [ ] CI / tooling - [ ] Refactor - [ ] Other ## Verification Run on a worktree at this branch's tip, against the current main tip: - `npx vitest run` (ui-tui): 141 files, 2052 tests passed - `npx tsc --noEmit -p tsconfig.json` (ui-tui): exit 0, no output - `make check-source-language COMMIT_RANGE=origin/main..HEAD`: exit 0 - `make check-large-files COMMIT_RANGE=origin/main..HEAD`: exit 0 No Python source is touched, so no pytest selection applies. `ui-tui/CONTEXT.md` is updated for the fold levels and the gutter bar; the tool-card work carries its design note under `docs/plans/`. - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [x] User-facing docs or screenshots are updated when needed ## Risk Three user-visible changes, all inside the terminal UI: - a tool call that returned something now opens to a capped preview instead of staying shut. A reader who prefers it shut clicks once, and that decision holds for the life of the call. - the instance strip spends one leading column on the gutter bar, so every row has one column less for its name. - the status ticker shows a different set of glyphs and words. No RPC schema, config or on-disk format changes. Fold state lives in memory and per transcript view, so nothing persists across a restart and there is nothing to migrate. The split strip list only widens what is removed from displayed reasoning text; it reads no new input and grants no new capability. Rollback is a revert of the squash commit. - [x] Security impact considered - [x] Backward compatibility considered - [x] Rollback path is clear for risky changes ## Related Issues N/A
2026-09-10 12:42:09 +00:00
from raven.config.schema import Config, MediaGenConfig, ToolsConfig, WebToolsConfig
fix(tools): an array sent as its own JSON is still an array ## Summary Reported as "deliver_files is broken". It is not: **the tool never ran.** Every `deliver_files` call on one install was refused before dispatch -- five in a row in a single session -- and nothing was ever delivered: ``` Error: Invalid parameters for tool 'deliver_files': files should be array ``` What the model sent was the array, spelled as a string: ```json {"files": "[{\"path\": \"...poster.png\", \"title\": \"...\"}]", "message": "..."} ``` `cast_params` already forgives that spelling for every scalar type -- `"3"` for an integer, `"true"` for a boolean -- and did not for arrays or objects, which are exactly the types a model is most likely to stringify. ## Type - [x] Fix - [ ] Feature ## The edge of the forgiving is the design When the value is a string, try `json.loads`, and take the result **only if it is the type the schema asked for**. A string that is not JSON, or is JSON of the wrong shape, is returned unchanged so the validator still names the real problem -- the point is to widen what is accepted, not to swallow a type error. **Nothing here can raise.** Turning "your argument has the wrong type" into a traceback would be worse than the refusal it replaces, so the parse is wrapped and failure falls through. **A `type: "string"` field is never parsed.** JSON is ordinary text in a message body or a file's content, and replacing it would hand the tool something it never asked for. Two independent things prevent it today (the string branch returns before the parse is reached, and the parse only wins on a type match), which is why the case pinning it is a tripwire rather than a load-bearing assertion -- said so in its own docstring rather than left to look like coverage. ## Not just deliver_files Six built-in tools declare an array or object parameter and were all exposed: | tool | parameter | |---|---| | `deliver_files` | `files` | | `ask_user` | `questions` | | `image_generate` | `images` | | `message` | `media` | | `create_playbook` | `skills` | | `video_generate` | `params` | The same failure was already seen from the other side: `acp_client/acp_agent.py` records `update_task_state` and `operations should be array` from a real dispatch. ## Verification ``` make lint-python ruff check + ruff format --check, 1850 files make lint-imports 9 contracts kept, 0 broken pytest tests/ 19,699 passed, 7 failed (all pre-existing, see below) ``` - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [ ] User-facing docs or screenshots -- no user-facing string **End to end, through the real tool**, with the exact payload that failed five times in production: ``` files sent as: str -> [{"path": ".../poster.png", "title": "..."}] returned: Delivered 1 file(s): poster.png (72 B). still "should be array": False registered in the store: True ``` Twelve cases, five mutations, each killing at least one: | mutation | red | |---|---| | drop the whole branch (the old behaviour) | 3 | | raise instead of falling through on a parse failure | 5 | | accept the parse whatever type it yielded | 1 | | do not re-cast the parsed value, so items are not cast | 1 | | widen the tuple to include `string` | **survived -- unreachable** | The last is worth stating rather than hiding: that mutation cannot change behaviour, because the `type == "string"` branch returns earlier and the type check would refuse the result anyway. I also tried moving the new block above that branch, alone and combined with widening the tuple, and neither reddens anything either. The invariant holds by construction; the case that documents it says so. **Pre-existing failures, checked against the base.** 7 failed in the full run, all in `tests/test_security_network.py` (`test_a_redirect_to_a_dangerous_address_is_refused` and siblings). Running that file alone on this same tree gives 4 -- the count is order-dependent -- and the change touches only `raven/agent/tools/params.py` plus a new test file, neither of which `raven/security/network.py` imports. The failures are the box's resolver: it returns poisoned answers roughly half the time, which I measured separately (`en.wikipedia.org` came back as `2001::1` on 3 of 6 lookups). Not introduced here, and worth someone's attention on its own. ## Risk - [x] Security impact considered -- widens what reaches a tool's own validation, not what bypasses it. A parsed value is still validated against the same schema, and a parse that yields the wrong type is refused exactly as before - [x] Backward compatibility considered -- a call that worked before takes the identical path; the new branch is reached only by a `str` where an array or object is declared, which previously always failed - [x] Rollback path is clear -- single-commit revert ## Related Issues N/A ## Swept `mr-review-patterns` pre-submit sweep, over `git diff origin/main...HEAD`. - **1 (a write location moved)** -- nothing moved; a branch was added to an existing dispatch on `target_type`. Grepped every caller of `cast_params`: the registry is the only one, and it runs `validate_params` right after, which is the reader this affects. - **2 (a value with several entry points)** -- the cast is the single funnel every tool argument passes through, which is why the fix belongs here and not in `deliver_files`. - **3 (a guard)** -- checked both directions: what it wrongly lets through (JSON of the wrong type, non-JSON text -- both refused, with cases) and what it wrongly refuses (a real list, unaffected, with a case). - **4 (tests)** -- five mutations above, one honestly reported as unreachable. Failing-ID sets diffed against the base rather than counts. - **6 (stale text)** -- the module docstring enumerated what is coerced ("a string that should be an integer"); it now names arrays and objects too. Grepped the tracked tree for other statements of the rule: none. - **9 (error handling)** -- the new path adds one way to end and it is caught: `json.loads` raises `ValueError` on bad text and `TypeError` on a non-string, and both fall through to the untouched value. - **11** -- `git ls-files | grep -c node_modules` is 0; the commit-message gate was run, not eyeballed. Not applicable, with reasons: **3b, 3c, 3d, 3e** (no tool schema produced, no state moved, one lane, no assertion lost its symbol); **4b, 4c, 4d** (no platform branch, no shell, no rendered number); **5, 5b** (no dependency; `json` is stdlib and already imported across this package); **6b, 6c** (no backup, no generated artifact); **7, 7b** (nothing on disk); **8** (no asset, no secret); **10** (no prompt text). ## Deliberately not fixed The error text still ends with `[Analyze the error above and try a different approach.]`, and the model plainly did not -- it sent the same shape five times. A message naming the expected spelling (`files must be a JSON array, not a string containing one`) would give it something to act on. That is a change to the registry's error surface, affects every tool, and deserves its own argument. ## Moved from !594 Opened on a compliant source branch. AGENTS.md 2.1 asks for a 3-5 word snake_case description and the previous branch had seven; GitLab cannot change an existing merge request's source branch, so the change moves rather than the name. Same commits, rebased onto `c2a9768f`. Both code findings from the review on !594 are already in them -- `RecursionError` caught with its regression case, and the implementation comment reduced to the two non-obvious reasons. Nothing else changed, so that review carries.
2026-09-09 15:42:36 +00:00
from raven.contracts.memory import MemoryBackend
from raven.core.plugin_stack import (
build_plugin_hooks,
build_plugin_registry,
build_plugin_tools,
everos_plugin_installed,
everos_plugin_missing_note,
maybe_build_memory_backend,
named_plugin_roots,
)
from raven.plugins import PluginRegistry
from tests._everos_presence import everos_plugin_absent, everos_plugin_broken
2026-06-28 18:17:27 +08:00
# ---------------------------------------------------------------------------
# Helpers
# ---------------------------------------------------------------------------
def _config(
*,
memory_backend: str | None = "everos",
disabled: list[str] | None = None,
plugin_config: dict | None = None,
fix(tools): an array sent as its own JSON is still an array ## Summary Reported as "deliver_files is broken". It is not: **the tool never ran.** Every `deliver_files` call on one install was refused before dispatch -- five in a row in a single session -- and nothing was ever delivered: ``` Error: Invalid parameters for tool 'deliver_files': files should be array ``` What the model sent was the array, spelled as a string: ```json {"files": "[{\"path\": \"...poster.png\", \"title\": \"...\"}]", "message": "..."} ``` `cast_params` already forgives that spelling for every scalar type -- `"3"` for an integer, `"true"` for a boolean -- and did not for arrays or objects, which are exactly the types a model is most likely to stringify. ## Type - [x] Fix - [ ] Feature ## The edge of the forgiving is the design When the value is a string, try `json.loads`, and take the result **only if it is the type the schema asked for**. A string that is not JSON, or is JSON of the wrong shape, is returned unchanged so the validator still names the real problem -- the point is to widen what is accepted, not to swallow a type error. **Nothing here can raise.** Turning "your argument has the wrong type" into a traceback would be worse than the refusal it replaces, so the parse is wrapped and failure falls through. **A `type: "string"` field is never parsed.** JSON is ordinary text in a message body or a file's content, and replacing it would hand the tool something it never asked for. Two independent things prevent it today (the string branch returns before the parse is reached, and the parse only wins on a type match), which is why the case pinning it is a tripwire rather than a load-bearing assertion -- said so in its own docstring rather than left to look like coverage. ## Not just deliver_files Six built-in tools declare an array or object parameter and were all exposed: | tool | parameter | |---|---| | `deliver_files` | `files` | | `ask_user` | `questions` | | `image_generate` | `images` | | `message` | `media` | | `create_playbook` | `skills` | | `video_generate` | `params` | The same failure was already seen from the other side: `acp_client/acp_agent.py` records `update_task_state` and `operations should be array` from a real dispatch. ## Verification ``` make lint-python ruff check + ruff format --check, 1850 files make lint-imports 9 contracts kept, 0 broken pytest tests/ 19,699 passed, 7 failed (all pre-existing, see below) ``` - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [ ] User-facing docs or screenshots -- no user-facing string **End to end, through the real tool**, with the exact payload that failed five times in production: ``` files sent as: str -> [{"path": ".../poster.png", "title": "..."}] returned: Delivered 1 file(s): poster.png (72 B). still "should be array": False registered in the store: True ``` Twelve cases, five mutations, each killing at least one: | mutation | red | |---|---| | drop the whole branch (the old behaviour) | 3 | | raise instead of falling through on a parse failure | 5 | | accept the parse whatever type it yielded | 1 | | do not re-cast the parsed value, so items are not cast | 1 | | widen the tuple to include `string` | **survived -- unreachable** | The last is worth stating rather than hiding: that mutation cannot change behaviour, because the `type == "string"` branch returns earlier and the type check would refuse the result anyway. I also tried moving the new block above that branch, alone and combined with widening the tuple, and neither reddens anything either. The invariant holds by construction; the case that documents it says so. **Pre-existing failures, checked against the base.** 7 failed in the full run, all in `tests/test_security_network.py` (`test_a_redirect_to_a_dangerous_address_is_refused` and siblings). Running that file alone on this same tree gives 4 -- the count is order-dependent -- and the change touches only `raven/agent/tools/params.py` plus a new test file, neither of which `raven/security/network.py` imports. The failures are the box's resolver: it returns poisoned answers roughly half the time, which I measured separately (`en.wikipedia.org` came back as `2001::1` on 3 of 6 lookups). Not introduced here, and worth someone's attention on its own. ## Risk - [x] Security impact considered -- widens what reaches a tool's own validation, not what bypasses it. A parsed value is still validated against the same schema, and a parse that yields the wrong type is refused exactly as before - [x] Backward compatibility considered -- a call that worked before takes the identical path; the new branch is reached only by a `str` where an array or object is declared, which previously always failed - [x] Rollback path is clear -- single-commit revert ## Related Issues N/A ## Swept `mr-review-patterns` pre-submit sweep, over `git diff origin/main...HEAD`. - **1 (a write location moved)** -- nothing moved; a branch was added to an existing dispatch on `target_type`. Grepped every caller of `cast_params`: the registry is the only one, and it runs `validate_params` right after, which is the reader this affects. - **2 (a value with several entry points)** -- the cast is the single funnel every tool argument passes through, which is why the fix belongs here and not in `deliver_files`. - **3 (a guard)** -- checked both directions: what it wrongly lets through (JSON of the wrong type, non-JSON text -- both refused, with cases) and what it wrongly refuses (a real list, unaffected, with a case). - **4 (tests)** -- five mutations above, one honestly reported as unreachable. Failing-ID sets diffed against the base rather than counts. - **6 (stale text)** -- the module docstring enumerated what is coerced ("a string that should be an integer"); it now names arrays and objects too. Grepped the tracked tree for other statements of the rule: none. - **9 (error handling)** -- the new path adds one way to end and it is caught: `json.loads` raises `ValueError` on bad text and `TypeError` on a non-string, and both fall through to the untouched value. - **11** -- `git ls-files | grep -c node_modules` is 0; the commit-message gate was run, not eyeballed. Not applicable, with reasons: **3b, 3c, 3d, 3e** (no tool schema produced, no state moved, one lane, no assertion lost its symbol); **4b, 4c, 4d** (no platform branch, no shell, no rendered number); **5, 5b** (no dependency; `json` is stdlib and already imported across this package); **6b, 6c** (no backup, no generated artifact); **7, 7b** (nothing on disk); **8** (no asset, no secret); **10** (no prompt text). ## Deliberately not fixed The error text still ends with `[Analyze the error above and try a different approach.]`, and the model plainly did not -- it sent the same shape five times. A message naming the expected spelling (`files must be a JSON array, not a string containing one`) would give it something to act on. That is a change to the registry's error surface, affects every tool, and deserves its own argument. ## Moved from !594 Opened on a compliant source branch. AGENTS.md 2.1 asks for a 3-5 word snake_case description and the previous branch had seven; GitLab cannot change an existing merge request's source branch, so the change moves rather than the name. Same commits, rebased onto `c2a9768f`. Both code findings from the review on !594 are already in them -- `RecursionError` caught with its regression case, and the implementation comment reduced to the two non-obvious reasons. Nothing else changed, so that review carries.
2026-09-09 15:42:36 +00:00
dirs: list[str] | None = None,
feat(ui-tui): tool cards open themselves, the strip marks here, ticker words split ## Summary Three reader-facing changes to the TUI transcript and the instance strip. **A settled tool call opens itself.** A tool card had two states, shut and full, and neither is what a reader wants by default: shut hides the result that was the point of the call, full spends a thousand rows on a result five rows would have answered. There are now three levels - shut, a preview capped at `TOOL_PREVIEW_ROWS` result rows with a `+N` row standing for the remainder, and full at `TOOL_FULL_ROWS`. The cap is what bounds the cost, so a call that came back opens unasked and only a call that returned nothing stays shut, its block being the argument the row above already shows. A reader's own decision always wins over that default. The `+N` row becomes its own two-way control: it reveals the rest, then folds back to the cap, where the block's own click shuts the card outright. It used to ride inside the output array, which made the one row announcing there was more to see the row that collapsed the card. Fold state moves out of the component that draws it into a store keyed by tool call id. Held in the row's component state, a row that changed - a step landing in a turn still running - unmounted and took the reader's decision with it, so a card opened seconds ago closed itself. `useMainApp` now reads that store when it measures: a resize drops every measured height because the cache buckets on columns, so without the folds there, rows below the fold came back at their default height and the transcript scrolled to the wrong place. **The strip marks the row whose conversation is on screen.** The composer's top border names the instance being typed to, and the strip listed every instance without saying which of them that was. The active row now carries a gutter bar in the strip's own leftmost column, where nothing else draws, so the bar reads as a position and the bullet beside it goes on saying status alone. The active row is exempt from every cap, and a line no click can switch to - a graph line, a loose spawn - never carries it. An interrupted turn also refreshes the instance registry now: `message.complete` already did, but the manager moves the row on this path too, writing `cancelled` or `failed`, so without the re-read an interrupted instance went on showing a filled bullet while its view went on polling a turn that had ended. **The censored ticker vocabulary splits from Raven's own.** Wrapped agents render their status as a kaomoji plus a verb, some of it on the channel the reasoning arrives on, and `cleanThinkingText` strips exactly that pair - but it was reading its strip list off Raven's own `FACES` and `VERBS`. That made the two one list, so a branding change silently changed what gets censored out of a model's reasoning: rename a verb and the old word stops being stripped, adopt a word another agent uses and Raven's own ticker starts eating itself. `tickerNoise.ts` now holds that vocabulary, frozen and deliberately separate; it describes other agents' output and changes only when one of them does. `FACES` and `VERBS` are then free to move, and they move here: the kaomoji become one bird wearing different expressions, and the verbs are ordered as one round of work rather than by how close the words are in meaning, because at one word every 2.5s a reader sees most of the list in a single turn. Each emoji frame is a single code point on purpose - a ZWJ sequence or a variation selector renders as two glyphs on terminals that do not compose it, which shifts everything right of the ticker. ## Type - [ ] Fix - [x] Feature - [ ] Docs - [ ] CI / tooling - [ ] Refactor - [ ] Other ## Verification Run on a worktree at this branch's tip, against the current main tip: - `npx vitest run` (ui-tui): 141 files, 2052 tests passed - `npx tsc --noEmit -p tsconfig.json` (ui-tui): exit 0, no output - `make check-source-language COMMIT_RANGE=origin/main..HEAD`: exit 0 - `make check-large-files COMMIT_RANGE=origin/main..HEAD`: exit 0 No Python source is touched, so no pytest selection applies. `ui-tui/CONTEXT.md` is updated for the fold levels and the gutter bar; the tool-card work carries its design note under `docs/plans/`. - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [x] User-facing docs or screenshots are updated when needed ## Risk Three user-visible changes, all inside the terminal UI: - a tool call that returned something now opens to a capped preview instead of staying shut. A reader who prefers it shut clicks once, and that decision holds for the life of the call. - the instance strip spends one leading column on the gutter bar, so every row has one column less for its name. - the status ticker shows a different set of glyphs and words. No RPC schema, config or on-disk format changes. Fold state lives in memory and per transcript view, so nothing persists across a restart and there is nothing to migrate. The split strip list only widens what is removed from displayed reasoning text; it reads no new input and grants no new capability. Rollback is a revert of the squash commit. - [x] Security impact considered - [x] Backward compatibility considered - [x] Rollback path is clear for risky changes ## Related Issues N/A
2026-09-10 12:42:09 +00:00
tools: ToolsConfig | None = None,
2026-06-28 18:17:27 +08:00
) -> RavenConfig:
return RavenConfig(
memory=MemoryConfig(backend=memory_backend),
plugins=PluginsConfig(
disabled=list(disabled or []),
config=dict(plugin_config or {}),
fix(tools): an array sent as its own JSON is still an array ## Summary Reported as "deliver_files is broken". It is not: **the tool never ran.** Every `deliver_files` call on one install was refused before dispatch -- five in a row in a single session -- and nothing was ever delivered: ``` Error: Invalid parameters for tool 'deliver_files': files should be array ``` What the model sent was the array, spelled as a string: ```json {"files": "[{\"path\": \"...poster.png\", \"title\": \"...\"}]", "message": "..."} ``` `cast_params` already forgives that spelling for every scalar type -- `"3"` for an integer, `"true"` for a boolean -- and did not for arrays or objects, which are exactly the types a model is most likely to stringify. ## Type - [x] Fix - [ ] Feature ## The edge of the forgiving is the design When the value is a string, try `json.loads`, and take the result **only if it is the type the schema asked for**. A string that is not JSON, or is JSON of the wrong shape, is returned unchanged so the validator still names the real problem -- the point is to widen what is accepted, not to swallow a type error. **Nothing here can raise.** Turning "your argument has the wrong type" into a traceback would be worse than the refusal it replaces, so the parse is wrapped and failure falls through. **A `type: "string"` field is never parsed.** JSON is ordinary text in a message body or a file's content, and replacing it would hand the tool something it never asked for. Two independent things prevent it today (the string branch returns before the parse is reached, and the parse only wins on a type match), which is why the case pinning it is a tripwire rather than a load-bearing assertion -- said so in its own docstring rather than left to look like coverage. ## Not just deliver_files Six built-in tools declare an array or object parameter and were all exposed: | tool | parameter | |---|---| | `deliver_files` | `files` | | `ask_user` | `questions` | | `image_generate` | `images` | | `message` | `media` | | `create_playbook` | `skills` | | `video_generate` | `params` | The same failure was already seen from the other side: `acp_client/acp_agent.py` records `update_task_state` and `operations should be array` from a real dispatch. ## Verification ``` make lint-python ruff check + ruff format --check, 1850 files make lint-imports 9 contracts kept, 0 broken pytest tests/ 19,699 passed, 7 failed (all pre-existing, see below) ``` - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [ ] User-facing docs or screenshots -- no user-facing string **End to end, through the real tool**, with the exact payload that failed five times in production: ``` files sent as: str -> [{"path": ".../poster.png", "title": "..."}] returned: Delivered 1 file(s): poster.png (72 B). still "should be array": False registered in the store: True ``` Twelve cases, five mutations, each killing at least one: | mutation | red | |---|---| | drop the whole branch (the old behaviour) | 3 | | raise instead of falling through on a parse failure | 5 | | accept the parse whatever type it yielded | 1 | | do not re-cast the parsed value, so items are not cast | 1 | | widen the tuple to include `string` | **survived -- unreachable** | The last is worth stating rather than hiding: that mutation cannot change behaviour, because the `type == "string"` branch returns earlier and the type check would refuse the result anyway. I also tried moving the new block above that branch, alone and combined with widening the tuple, and neither reddens anything either. The invariant holds by construction; the case that documents it says so. **Pre-existing failures, checked against the base.** 7 failed in the full run, all in `tests/test_security_network.py` (`test_a_redirect_to_a_dangerous_address_is_refused` and siblings). Running that file alone on this same tree gives 4 -- the count is order-dependent -- and the change touches only `raven/agent/tools/params.py` plus a new test file, neither of which `raven/security/network.py` imports. The failures are the box's resolver: it returns poisoned answers roughly half the time, which I measured separately (`en.wikipedia.org` came back as `2001::1` on 3 of 6 lookups). Not introduced here, and worth someone's attention on its own. ## Risk - [x] Security impact considered -- widens what reaches a tool's own validation, not what bypasses it. A parsed value is still validated against the same schema, and a parse that yields the wrong type is refused exactly as before - [x] Backward compatibility considered -- a call that worked before takes the identical path; the new branch is reached only by a `str` where an array or object is declared, which previously always failed - [x] Rollback path is clear -- single-commit revert ## Related Issues N/A ## Swept `mr-review-patterns` pre-submit sweep, over `git diff origin/main...HEAD`. - **1 (a write location moved)** -- nothing moved; a branch was added to an existing dispatch on `target_type`. Grepped every caller of `cast_params`: the registry is the only one, and it runs `validate_params` right after, which is the reader this affects. - **2 (a value with several entry points)** -- the cast is the single funnel every tool argument passes through, which is why the fix belongs here and not in `deliver_files`. - **3 (a guard)** -- checked both directions: what it wrongly lets through (JSON of the wrong type, non-JSON text -- both refused, with cases) and what it wrongly refuses (a real list, unaffected, with a case). - **4 (tests)** -- five mutations above, one honestly reported as unreachable. Failing-ID sets diffed against the base rather than counts. - **6 (stale text)** -- the module docstring enumerated what is coerced ("a string that should be an integer"); it now names arrays and objects too. Grepped the tracked tree for other statements of the rule: none. - **9 (error handling)** -- the new path adds one way to end and it is caught: `json.loads` raises `ValueError` on bad text and `TypeError` on a non-string, and both fall through to the untouched value. - **11** -- `git ls-files | grep -c node_modules` is 0; the commit-message gate was run, not eyeballed. Not applicable, with reasons: **3b, 3c, 3d, 3e** (no tool schema produced, no state moved, one lane, no assertion lost its symbol); **4b, 4c, 4d** (no platform branch, no shell, no rendered number); **5, 5b** (no dependency; `json` is stdlib and already imported across this package); **6b, 6c** (no backup, no generated artifact); **7, 7b** (nothing on disk); **8** (no asset, no secret); **10** (no prompt text). ## Deliberately not fixed The error text still ends with `[Analyze the error above and try a different approach.]`, and the model plainly did not -- it sent the same shape five times. A message naming the expected spelling (`files must be a JSON array, not a string containing one`) would give it something to act on. That is a change to the registry's error surface, affects every tool, and deserves its own argument. ## Moved from !594 Opened on a compliant source branch. AGENTS.md 2.1 asks for a 3-5 word snake_case description and the previous branch had seven; GitLab cannot change an existing merge request's source branch, so the change moves rather than the name. Same commits, rebased onto `c2a9768f`. Both code findings from the review on !594 are already in them -- `RecursionError` caught with its regression case, and the implementation comment reduced to the two non-obvious reasons. Nothing else changed, so that review carries.
2026-09-09 15:42:36 +00:00
dirs=list(dirs or []),
2026-06-28 18:17:27 +08:00
),
feat(ui-tui): tool cards open themselves, the strip marks here, ticker words split ## Summary Three reader-facing changes to the TUI transcript and the instance strip. **A settled tool call opens itself.** A tool card had two states, shut and full, and neither is what a reader wants by default: shut hides the result that was the point of the call, full spends a thousand rows on a result five rows would have answered. There are now three levels - shut, a preview capped at `TOOL_PREVIEW_ROWS` result rows with a `+N` row standing for the remainder, and full at `TOOL_FULL_ROWS`. The cap is what bounds the cost, so a call that came back opens unasked and only a call that returned nothing stays shut, its block being the argument the row above already shows. A reader's own decision always wins over that default. The `+N` row becomes its own two-way control: it reveals the rest, then folds back to the cap, where the block's own click shuts the card outright. It used to ride inside the output array, which made the one row announcing there was more to see the row that collapsed the card. Fold state moves out of the component that draws it into a store keyed by tool call id. Held in the row's component state, a row that changed - a step landing in a turn still running - unmounted and took the reader's decision with it, so a card opened seconds ago closed itself. `useMainApp` now reads that store when it measures: a resize drops every measured height because the cache buckets on columns, so without the folds there, rows below the fold came back at their default height and the transcript scrolled to the wrong place. **The strip marks the row whose conversation is on screen.** The composer's top border names the instance being typed to, and the strip listed every instance without saying which of them that was. The active row now carries a gutter bar in the strip's own leftmost column, where nothing else draws, so the bar reads as a position and the bullet beside it goes on saying status alone. The active row is exempt from every cap, and a line no click can switch to - a graph line, a loose spawn - never carries it. An interrupted turn also refreshes the instance registry now: `message.complete` already did, but the manager moves the row on this path too, writing `cancelled` or `failed`, so without the re-read an interrupted instance went on showing a filled bullet while its view went on polling a turn that had ended. **The censored ticker vocabulary splits from Raven's own.** Wrapped agents render their status as a kaomoji plus a verb, some of it on the channel the reasoning arrives on, and `cleanThinkingText` strips exactly that pair - but it was reading its strip list off Raven's own `FACES` and `VERBS`. That made the two one list, so a branding change silently changed what gets censored out of a model's reasoning: rename a verb and the old word stops being stripped, adopt a word another agent uses and Raven's own ticker starts eating itself. `tickerNoise.ts` now holds that vocabulary, frozen and deliberately separate; it describes other agents' output and changes only when one of them does. `FACES` and `VERBS` are then free to move, and they move here: the kaomoji become one bird wearing different expressions, and the verbs are ordered as one round of work rather than by how close the words are in meaning, because at one word every 2.5s a reader sees most of the list in a single turn. Each emoji frame is a single code point on purpose - a ZWJ sequence or a variation selector renders as two glyphs on terminals that do not compose it, which shifts everything right of the ticker. ## Type - [ ] Fix - [x] Feature - [ ] Docs - [ ] CI / tooling - [ ] Refactor - [ ] Other ## Verification Run on a worktree at this branch's tip, against the current main tip: - `npx vitest run` (ui-tui): 141 files, 2052 tests passed - `npx tsc --noEmit -p tsconfig.json` (ui-tui): exit 0, no output - `make check-source-language COMMIT_RANGE=origin/main..HEAD`: exit 0 - `make check-large-files COMMIT_RANGE=origin/main..HEAD`: exit 0 No Python source is touched, so no pytest selection applies. `ui-tui/CONTEXT.md` is updated for the fold levels and the gutter bar; the tool-card work carries its design note under `docs/plans/`. - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [x] User-facing docs or screenshots are updated when needed ## Risk Three user-visible changes, all inside the terminal UI: - a tool call that returned something now opens to a capped preview instead of staying shut. A reader who prefers it shut clicks once, and that decision holds for the life of the call. - the instance strip spends one leading column on the gutter bar, so every row has one column less for its name. - the status ticker shows a different set of glyphs and words. No RPC schema, config or on-disk format changes. Fold state lives in memory and per transcript view, so nothing persists across a restart and there is nothing to migrate. The split strip list only widens what is removed from displayed reasoning text; it reads no new input and grants no new capability. Rollback is a revert of the squash commit. - [x] Security impact considered - [x] Backward compatibility considered - [x] Rollback path is clear for risky changes ## Related Issues N/A
2026-09-10 12:42:09 +00:00
base=Config(tools=tools) if tools is not None else Config(),
2026-06-28 18:17:27 +08:00
)
# ---------------------------------------------------------------------------
# build_plugin_registry
# ---------------------------------------------------------------------------
class TestBuildRegistry:
def test_returns_registry_with_everos_activated(self) -> None:
reg = build_plugin_registry(_config())
assert isinstance(reg, PluginRegistry)
assert "everos-memory" in reg.activated_ids()
assert "everos" in reg.memory_backend_names()
def test_disabled_plugin_id_skipped(self) -> None:
reg = build_plugin_registry(
_config(disabled=["everos-memory"]),
)
assert "everos-memory" not in reg.activated_ids()
assert "everos" not in reg.memory_backend_names()
# ---------------------------------------------------------------------------
# maybe_build_memory_backend
# ---------------------------------------------------------------------------
class TestMaybeBuildBackend:
def test_default_config_builds_everos(self, tmp_path: Path) -> None:
backend = maybe_build_memory_backend(tmp_path, _config())
assert backend is not None
assert isinstance(backend, MemoryBackend)
def test_memory_backend_none_returns_none(
build: whole-repo lint + pre-commit convention (config only) (#59) ## Change description > Whole-repo lint + pre-commit convention, CONFIG ONLY (no source reformat in this PR). Python (ruff) and TypeScript (eslint + prettier) share a 120-col margin via the committed pre-commit gate. This upgrades main's existing basic ruff setup and adds the TS lint stack (none existed on main). > > What this PR adds: > - ruff: line-length 120; security rules S101/S105/S106/S107/S506/S605/S607; policy per-file-ignores (tests + accepted CLI deferred-imports + product asserts + N818, each commented); ruff pinned <0.16. > - eslint/prettier: shared base (`eslint.base.mjs` + `prettier.config.mjs`); ui-tui extends it with React rules, bridge with a Node-only config; hermes-ink vendor and generated RPC types excluded. > - pre-commit: keeps main's hooks (conventional-commit, detect-private-key, etc.), adds a top-level exclude and 4 local eslint/prettier hooks; bumps the pre-commit dev dep. > - 2 lint-surfaced fixes: PlannerContext import (F821) in the sentinel runner; lower-cased file-local cron-heartbeat constants (N806). (raven/config/raven.py's F821 was already fixed on main.) > > Sequencing: config only. `ruff check` is intentionally red on ~307 auto-fixables (I001/F401/F541/E701/E702); a SEPARATE reformat branch runs `ruff --fix` + `ruff format` + eslint/prettier --fix to clear them (100% auto-resolvable, zero manual). Enforcement (pre-commit install / CI) turns on only after the reformat lands, so do not expect a green tree from this PR alone. > > CLI-owned files (the reformat and several per-file-ignores touch `raven/cli/*`) are under review by the CLI team. Judgment items (TS no-explicit-any, no-unused-expressions, S101 convert-vs-keep, N818 rename, C90, mypy) are deferred to v2. ## Type of change - [ ] Bug fix - [x] New feature - [ ] Document - [x] Others ## Related issues (if there is) > none ## Checklists ### Development - [ ] Lint rules pass locally - [ ] Application changes have been tested thoroughly - [ ] Automated tests covering modified code pass > config-only: `ruff check` is red on auto-fixables by design (the reformat branch clears them); eslint/prettier configs load in both ui-tui and bridge. ### Security - [x] Security impact of change has been considered - [ ] Code follows company security practices and guidelines > Only dependency change is the dev-only pre-commit tool plus the ruff pin; the detect-private-key hook from main is retained. ### Code review - [x] Pull request has a descriptive title and context useful to a reviewer - [ ] Pull request linked to JIRA ticket when applicable --------- Co-authored-by: Sheng Zhao <sheng.zhao@evermind.ai> Co-authored-by: Claude (claude-opus-4-8) <noreply@anthropic.com>
2026-07-01 12:09:42 +08:00
self,
tmp_path: Path,
2026-06-28 18:17:27 +08:00
) -> None:
backend = maybe_build_memory_backend(
build: whole-repo lint + pre-commit convention (config only) (#59) ## Change description > Whole-repo lint + pre-commit convention, CONFIG ONLY (no source reformat in this PR). Python (ruff) and TypeScript (eslint + prettier) share a 120-col margin via the committed pre-commit gate. This upgrades main's existing basic ruff setup and adds the TS lint stack (none existed on main). > > What this PR adds: > - ruff: line-length 120; security rules S101/S105/S106/S107/S506/S605/S607; policy per-file-ignores (tests + accepted CLI deferred-imports + product asserts + N818, each commented); ruff pinned <0.16. > - eslint/prettier: shared base (`eslint.base.mjs` + `prettier.config.mjs`); ui-tui extends it with React rules, bridge with a Node-only config; hermes-ink vendor and generated RPC types excluded. > - pre-commit: keeps main's hooks (conventional-commit, detect-private-key, etc.), adds a top-level exclude and 4 local eslint/prettier hooks; bumps the pre-commit dev dep. > - 2 lint-surfaced fixes: PlannerContext import (F821) in the sentinel runner; lower-cased file-local cron-heartbeat constants (N806). (raven/config/raven.py's F821 was already fixed on main.) > > Sequencing: config only. `ruff check` is intentionally red on ~307 auto-fixables (I001/F401/F541/E701/E702); a SEPARATE reformat branch runs `ruff --fix` + `ruff format` + eslint/prettier --fix to clear them (100% auto-resolvable, zero manual). Enforcement (pre-commit install / CI) turns on only after the reformat lands, so do not expect a green tree from this PR alone. > > CLI-owned files (the reformat and several per-file-ignores touch `raven/cli/*`) are under review by the CLI team. Judgment items (TS no-explicit-any, no-unused-expressions, S101 convert-vs-keep, N818 rename, C90, mypy) are deferred to v2. ## Type of change - [ ] Bug fix - [x] New feature - [ ] Document - [x] Others ## Related issues (if there is) > none ## Checklists ### Development - [ ] Lint rules pass locally - [ ] Application changes have been tested thoroughly - [ ] Automated tests covering modified code pass > config-only: `ruff check` is red on auto-fixables by design (the reformat branch clears them); eslint/prettier configs load in both ui-tui and bridge. ### Security - [x] Security impact of change has been considered - [ ] Code follows company security practices and guidelines > Only dependency change is the dev-only pre-commit tool plus the ruff pin; the detect-private-key hook from main is retained. ### Code review - [x] Pull request has a descriptive title and context useful to a reviewer - [ ] Pull request linked to JIRA ticket when applicable --------- Co-authored-by: Sheng Zhao <sheng.zhao@evermind.ai> Co-authored-by: Claude (claude-opus-4-8) <noreply@anthropic.com>
2026-07-01 12:09:42 +08:00
tmp_path,
_config(memory_backend=None),
2026-06-28 18:17:27 +08:00
)
assert backend is None
def test_unknown_backend_returns_none_no_raise(
build: whole-repo lint + pre-commit convention (config only) (#59) ## Change description > Whole-repo lint + pre-commit convention, CONFIG ONLY (no source reformat in this PR). Python (ruff) and TypeScript (eslint + prettier) share a 120-col margin via the committed pre-commit gate. This upgrades main's existing basic ruff setup and adds the TS lint stack (none existed on main). > > What this PR adds: > - ruff: line-length 120; security rules S101/S105/S106/S107/S506/S605/S607; policy per-file-ignores (tests + accepted CLI deferred-imports + product asserts + N818, each commented); ruff pinned <0.16. > - eslint/prettier: shared base (`eslint.base.mjs` + `prettier.config.mjs`); ui-tui extends it with React rules, bridge with a Node-only config; hermes-ink vendor and generated RPC types excluded. > - pre-commit: keeps main's hooks (conventional-commit, detect-private-key, etc.), adds a top-level exclude and 4 local eslint/prettier hooks; bumps the pre-commit dev dep. > - 2 lint-surfaced fixes: PlannerContext import (F821) in the sentinel runner; lower-cased file-local cron-heartbeat constants (N806). (raven/config/raven.py's F821 was already fixed on main.) > > Sequencing: config only. `ruff check` is intentionally red on ~307 auto-fixables (I001/F401/F541/E701/E702); a SEPARATE reformat branch runs `ruff --fix` + `ruff format` + eslint/prettier --fix to clear them (100% auto-resolvable, zero manual). Enforcement (pre-commit install / CI) turns on only after the reformat lands, so do not expect a green tree from this PR alone. > > CLI-owned files (the reformat and several per-file-ignores touch `raven/cli/*`) are under review by the CLI team. Judgment items (TS no-explicit-any, no-unused-expressions, S101 convert-vs-keep, N818 rename, C90, mypy) are deferred to v2. ## Type of change - [ ] Bug fix - [x] New feature - [ ] Document - [x] Others ## Related issues (if there is) > none ## Checklists ### Development - [ ] Lint rules pass locally - [ ] Application changes have been tested thoroughly - [ ] Automated tests covering modified code pass > config-only: `ruff check` is red on auto-fixables by design (the reformat branch clears them); eslint/prettier configs load in both ui-tui and bridge. ### Security - [x] Security impact of change has been considered - [ ] Code follows company security practices and guidelines > Only dependency change is the dev-only pre-commit tool plus the ruff pin; the detect-private-key hook from main is retained. ### Code review - [x] Pull request has a descriptive title and context useful to a reviewer - [ ] Pull request linked to JIRA ticket when applicable --------- Co-authored-by: Sheng Zhao <sheng.zhao@evermind.ai> Co-authored-by: Claude (claude-opus-4-8) <noreply@anthropic.com>
2026-07-01 12:09:42 +08:00
self,
tmp_path: Path,
2026-06-28 18:17:27 +08:00
) -> None:
"""A user-config typo / missing plugin must NOT crash boot —
the helper logs + degrades, AgentLoop falls back to legacy."""
backend = maybe_build_memory_backend(
build: whole-repo lint + pre-commit convention (config only) (#59) ## Change description > Whole-repo lint + pre-commit convention, CONFIG ONLY (no source reformat in this PR). Python (ruff) and TypeScript (eslint + prettier) share a 120-col margin via the committed pre-commit gate. This upgrades main's existing basic ruff setup and adds the TS lint stack (none existed on main). > > What this PR adds: > - ruff: line-length 120; security rules S101/S105/S106/S107/S506/S605/S607; policy per-file-ignores (tests + accepted CLI deferred-imports + product asserts + N818, each commented); ruff pinned <0.16. > - eslint/prettier: shared base (`eslint.base.mjs` + `prettier.config.mjs`); ui-tui extends it with React rules, bridge with a Node-only config; hermes-ink vendor and generated RPC types excluded. > - pre-commit: keeps main's hooks (conventional-commit, detect-private-key, etc.), adds a top-level exclude and 4 local eslint/prettier hooks; bumps the pre-commit dev dep. > - 2 lint-surfaced fixes: PlannerContext import (F821) in the sentinel runner; lower-cased file-local cron-heartbeat constants (N806). (raven/config/raven.py's F821 was already fixed on main.) > > Sequencing: config only. `ruff check` is intentionally red on ~307 auto-fixables (I001/F401/F541/E701/E702); a SEPARATE reformat branch runs `ruff --fix` + `ruff format` + eslint/prettier --fix to clear them (100% auto-resolvable, zero manual). Enforcement (pre-commit install / CI) turns on only after the reformat lands, so do not expect a green tree from this PR alone. > > CLI-owned files (the reformat and several per-file-ignores touch `raven/cli/*`) are under review by the CLI team. Judgment items (TS no-explicit-any, no-unused-expressions, S101 convert-vs-keep, N818 rename, C90, mypy) are deferred to v2. ## Type of change - [ ] Bug fix - [x] New feature - [ ] Document - [x] Others ## Related issues (if there is) > none ## Checklists ### Development - [ ] Lint rules pass locally - [ ] Application changes have been tested thoroughly - [ ] Automated tests covering modified code pass > config-only: `ruff check` is red on auto-fixables by design (the reformat branch clears them); eslint/prettier configs load in both ui-tui and bridge. ### Security - [x] Security impact of change has been considered - [ ] Code follows company security practices and guidelines > Only dependency change is the dev-only pre-commit tool plus the ruff pin; the detect-private-key hook from main is retained. ### Code review - [x] Pull request has a descriptive title and context useful to a reviewer - [ ] Pull request linked to JIRA ticket when applicable --------- Co-authored-by: Sheng Zhao <sheng.zhao@evermind.ai> Co-authored-by: Claude (claude-opus-4-8) <noreply@anthropic.com>
2026-07-01 12:09:42 +08:00
tmp_path,
_config(memory_backend="nonexistent"),
2026-06-28 18:17:27 +08:00
)
assert backend is None
def test_disabled_backend_returns_none(self, tmp_path: Path) -> None:
backend = maybe_build_memory_backend(
tmp_path,
_config(
memory_backend="everos",
disabled=["everos-memory"],
),
)
assert backend is None
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
def test_a_missing_backend_is_said_out_loud(self, tmp_path: Path, capsys) -> None:
cfg = _config(memory_backend="ghost")
backend = maybe_build_memory_backend(tmp_path, cfg, registry=PluginRegistry())
assert backend is None
err = capsys.readouterr().err
assert "memory.backend" in err and "ghost" in err
def test_the_shipped_default_missing_names_what_to_install(self, tmp_path: Path, capsys) -> None:
"""The commonest way to reach that line is an install without the plugin.
Naming only the backends that ARE installed leaves such a reader with
nothing to do; doctor and the wizard both answer it in one sentence, and
a turn is the surface that actually reaches this code.
"""
from tests._everos_presence import everos_plugin_absent
with everos_plugin_absent():
backend = maybe_build_memory_backend(tmp_path, _config(memory_backend="everos"), registry=PluginRegistry())
assert backend is None
assert "everos-memory" in capsys.readouterr().err
2026-06-28 18:17:27 +08:00
# ---------------------------------------------------------------------------
# Per-plugin config slice resolution
# ---------------------------------------------------------------------------
class TestConfigSliceResolution:
def test_config_by_plugin_id(self, tmp_path: Path) -> None:
backend = maybe_build_memory_backend(
tmp_path,
build: whole-repo lint + pre-commit convention (config only) (#59) ## Change description > Whole-repo lint + pre-commit convention, CONFIG ONLY (no source reformat in this PR). Python (ruff) and TypeScript (eslint + prettier) share a 120-col margin via the committed pre-commit gate. This upgrades main's existing basic ruff setup and adds the TS lint stack (none existed on main). > > What this PR adds: > - ruff: line-length 120; security rules S101/S105/S106/S107/S506/S605/S607; policy per-file-ignores (tests + accepted CLI deferred-imports + product asserts + N818, each commented); ruff pinned <0.16. > - eslint/prettier: shared base (`eslint.base.mjs` + `prettier.config.mjs`); ui-tui extends it with React rules, bridge with a Node-only config; hermes-ink vendor and generated RPC types excluded. > - pre-commit: keeps main's hooks (conventional-commit, detect-private-key, etc.), adds a top-level exclude and 4 local eslint/prettier hooks; bumps the pre-commit dev dep. > - 2 lint-surfaced fixes: PlannerContext import (F821) in the sentinel runner; lower-cased file-local cron-heartbeat constants (N806). (raven/config/raven.py's F821 was already fixed on main.) > > Sequencing: config only. `ruff check` is intentionally red on ~307 auto-fixables (I001/F401/F541/E701/E702); a SEPARATE reformat branch runs `ruff --fix` + `ruff format` + eslint/prettier --fix to clear them (100% auto-resolvable, zero manual). Enforcement (pre-commit install / CI) turns on only after the reformat lands, so do not expect a green tree from this PR alone. > > CLI-owned files (the reformat and several per-file-ignores touch `raven/cli/*`) are under review by the CLI team. Judgment items (TS no-explicit-any, no-unused-expressions, S101 convert-vs-keep, N818 rename, C90, mypy) are deferred to v2. ## Type of change - [ ] Bug fix - [x] New feature - [ ] Document - [x] Others ## Related issues (if there is) > none ## Checklists ### Development - [ ] Lint rules pass locally - [ ] Application changes have been tested thoroughly - [ ] Automated tests covering modified code pass > config-only: `ruff check` is red on auto-fixables by design (the reformat branch clears them); eslint/prettier configs load in both ui-tui and bridge. ### Security - [x] Security impact of change has been considered - [ ] Code follows company security practices and guidelines > Only dependency change is the dev-only pre-commit tool plus the ruff pin; the detect-private-key hook from main is retained. ### Code review - [x] Pull request has a descriptive title and context useful to a reviewer - [ ] Pull request linked to JIRA ticket when applicable --------- Co-authored-by: Sheng Zhao <sheng.zhao@evermind.ai> Co-authored-by: Claude (claude-opus-4-8) <noreply@anthropic.com>
2026-07-01 12:09:42 +08:00
_config(
plugin_config={
"everos-memory": {"mode": "embedded", "base_url": "http://x"},
}
),
2026-06-28 18:17:27 +08:00
)
# Backend received the config slice keyed by plugin id.
assert backend._config["mode"] == "embedded"
assert backend._config["base_url"] == "http://x"
def test_config_by_backend_name_fallback(
build: whole-repo lint + pre-commit convention (config only) (#59) ## Change description > Whole-repo lint + pre-commit convention, CONFIG ONLY (no source reformat in this PR). Python (ruff) and TypeScript (eslint + prettier) share a 120-col margin via the committed pre-commit gate. This upgrades main's existing basic ruff setup and adds the TS lint stack (none existed on main). > > What this PR adds: > - ruff: line-length 120; security rules S101/S105/S106/S107/S506/S605/S607; policy per-file-ignores (tests + accepted CLI deferred-imports + product asserts + N818, each commented); ruff pinned <0.16. > - eslint/prettier: shared base (`eslint.base.mjs` + `prettier.config.mjs`); ui-tui extends it with React rules, bridge with a Node-only config; hermes-ink vendor and generated RPC types excluded. > - pre-commit: keeps main's hooks (conventional-commit, detect-private-key, etc.), adds a top-level exclude and 4 local eslint/prettier hooks; bumps the pre-commit dev dep. > - 2 lint-surfaced fixes: PlannerContext import (F821) in the sentinel runner; lower-cased file-local cron-heartbeat constants (N806). (raven/config/raven.py's F821 was already fixed on main.) > > Sequencing: config only. `ruff check` is intentionally red on ~307 auto-fixables (I001/F401/F541/E701/E702); a SEPARATE reformat branch runs `ruff --fix` + `ruff format` + eslint/prettier --fix to clear them (100% auto-resolvable, zero manual). Enforcement (pre-commit install / CI) turns on only after the reformat lands, so do not expect a green tree from this PR alone. > > CLI-owned files (the reformat and several per-file-ignores touch `raven/cli/*`) are under review by the CLI team. Judgment items (TS no-explicit-any, no-unused-expressions, S101 convert-vs-keep, N818 rename, C90, mypy) are deferred to v2. ## Type of change - [ ] Bug fix - [x] New feature - [ ] Document - [x] Others ## Related issues (if there is) > none ## Checklists ### Development - [ ] Lint rules pass locally - [ ] Application changes have been tested thoroughly - [ ] Automated tests covering modified code pass > config-only: `ruff check` is red on auto-fixables by design (the reformat branch clears them); eslint/prettier configs load in both ui-tui and bridge. ### Security - [x] Security impact of change has been considered - [ ] Code follows company security practices and guidelines > Only dependency change is the dev-only pre-commit tool plus the ruff pin; the detect-private-key hook from main is retained. ### Code review - [x] Pull request has a descriptive title and context useful to a reviewer - [ ] Pull request linked to JIRA ticket when applicable --------- Co-authored-by: Sheng Zhao <sheng.zhao@evermind.ai> Co-authored-by: Claude (claude-opus-4-8) <noreply@anthropic.com>
2026-07-01 12:09:42 +08:00
self,
tmp_path: Path,
2026-06-28 18:17:27 +08:00
) -> None:
"""When the user uses the shorter key (backend name), the
helper still finds it. Useful for handwritten configs."""
backend = maybe_build_memory_backend(
tmp_path,
build: whole-repo lint + pre-commit convention (config only) (#59) ## Change description > Whole-repo lint + pre-commit convention, CONFIG ONLY (no source reformat in this PR). Python (ruff) and TypeScript (eslint + prettier) share a 120-col margin via the committed pre-commit gate. This upgrades main's existing basic ruff setup and adds the TS lint stack (none existed on main). > > What this PR adds: > - ruff: line-length 120; security rules S101/S105/S106/S107/S506/S605/S607; policy per-file-ignores (tests + accepted CLI deferred-imports + product asserts + N818, each commented); ruff pinned <0.16. > - eslint/prettier: shared base (`eslint.base.mjs` + `prettier.config.mjs`); ui-tui extends it with React rules, bridge with a Node-only config; hermes-ink vendor and generated RPC types excluded. > - pre-commit: keeps main's hooks (conventional-commit, detect-private-key, etc.), adds a top-level exclude and 4 local eslint/prettier hooks; bumps the pre-commit dev dep. > - 2 lint-surfaced fixes: PlannerContext import (F821) in the sentinel runner; lower-cased file-local cron-heartbeat constants (N806). (raven/config/raven.py's F821 was already fixed on main.) > > Sequencing: config only. `ruff check` is intentionally red on ~307 auto-fixables (I001/F401/F541/E701/E702); a SEPARATE reformat branch runs `ruff --fix` + `ruff format` + eslint/prettier --fix to clear them (100% auto-resolvable, zero manual). Enforcement (pre-commit install / CI) turns on only after the reformat lands, so do not expect a green tree from this PR alone. > > CLI-owned files (the reformat and several per-file-ignores touch `raven/cli/*`) are under review by the CLI team. Judgment items (TS no-explicit-any, no-unused-expressions, S101 convert-vs-keep, N818 rename, C90, mypy) are deferred to v2. ## Type of change - [ ] Bug fix - [x] New feature - [ ] Document - [x] Others ## Related issues (if there is) > none ## Checklists ### Development - [ ] Lint rules pass locally - [ ] Application changes have been tested thoroughly - [ ] Automated tests covering modified code pass > config-only: `ruff check` is red on auto-fixables by design (the reformat branch clears them); eslint/prettier configs load in both ui-tui and bridge. ### Security - [x] Security impact of change has been considered - [ ] Code follows company security practices and guidelines > Only dependency change is the dev-only pre-commit tool plus the ruff pin; the detect-private-key hook from main is retained. ### Code review - [x] Pull request has a descriptive title and context useful to a reviewer - [ ] Pull request linked to JIRA ticket when applicable --------- Co-authored-by: Sheng Zhao <sheng.zhao@evermind.ai> Co-authored-by: Claude (claude-opus-4-8) <noreply@anthropic.com>
2026-07-01 12:09:42 +08:00
_config(
plugin_config={
"everos": {"mode": "http", "base_url": "http://y"},
}
),
2026-06-28 18:17:27 +08:00
)
assert backend._config["mode"] == "http"
assert backend._config["base_url"] == "http://y"
def test_plugin_id_takes_precedence_over_backend_name(
build: whole-repo lint + pre-commit convention (config only) (#59) ## Change description > Whole-repo lint + pre-commit convention, CONFIG ONLY (no source reformat in this PR). Python (ruff) and TypeScript (eslint + prettier) share a 120-col margin via the committed pre-commit gate. This upgrades main's existing basic ruff setup and adds the TS lint stack (none existed on main). > > What this PR adds: > - ruff: line-length 120; security rules S101/S105/S106/S107/S506/S605/S607; policy per-file-ignores (tests + accepted CLI deferred-imports + product asserts + N818, each commented); ruff pinned <0.16. > - eslint/prettier: shared base (`eslint.base.mjs` + `prettier.config.mjs`); ui-tui extends it with React rules, bridge with a Node-only config; hermes-ink vendor and generated RPC types excluded. > - pre-commit: keeps main's hooks (conventional-commit, detect-private-key, etc.), adds a top-level exclude and 4 local eslint/prettier hooks; bumps the pre-commit dev dep. > - 2 lint-surfaced fixes: PlannerContext import (F821) in the sentinel runner; lower-cased file-local cron-heartbeat constants (N806). (raven/config/raven.py's F821 was already fixed on main.) > > Sequencing: config only. `ruff check` is intentionally red on ~307 auto-fixables (I001/F401/F541/E701/E702); a SEPARATE reformat branch runs `ruff --fix` + `ruff format` + eslint/prettier --fix to clear them (100% auto-resolvable, zero manual). Enforcement (pre-commit install / CI) turns on only after the reformat lands, so do not expect a green tree from this PR alone. > > CLI-owned files (the reformat and several per-file-ignores touch `raven/cli/*`) are under review by the CLI team. Judgment items (TS no-explicit-any, no-unused-expressions, S101 convert-vs-keep, N818 rename, C90, mypy) are deferred to v2. ## Type of change - [ ] Bug fix - [x] New feature - [ ] Document - [x] Others ## Related issues (if there is) > none ## Checklists ### Development - [ ] Lint rules pass locally - [ ] Application changes have been tested thoroughly - [ ] Automated tests covering modified code pass > config-only: `ruff check` is red on auto-fixables by design (the reformat branch clears them); eslint/prettier configs load in both ui-tui and bridge. ### Security - [x] Security impact of change has been considered - [ ] Code follows company security practices and guidelines > Only dependency change is the dev-only pre-commit tool plus the ruff pin; the detect-private-key hook from main is retained. ### Code review - [x] Pull request has a descriptive title and context useful to a reviewer - [ ] Pull request linked to JIRA ticket when applicable --------- Co-authored-by: Sheng Zhao <sheng.zhao@evermind.ai> Co-authored-by: Claude (claude-opus-4-8) <noreply@anthropic.com>
2026-07-01 12:09:42 +08:00
self,
tmp_path: Path,
2026-06-28 18:17:27 +08:00
) -> None:
"""If both keys are present, the canonical (plugin id) wins."""
backend = maybe_build_memory_backend(
tmp_path,
build: whole-repo lint + pre-commit convention (config only) (#59) ## Change description > Whole-repo lint + pre-commit convention, CONFIG ONLY (no source reformat in this PR). Python (ruff) and TypeScript (eslint + prettier) share a 120-col margin via the committed pre-commit gate. This upgrades main's existing basic ruff setup and adds the TS lint stack (none existed on main). > > What this PR adds: > - ruff: line-length 120; security rules S101/S105/S106/S107/S506/S605/S607; policy per-file-ignores (tests + accepted CLI deferred-imports + product asserts + N818, each commented); ruff pinned <0.16. > - eslint/prettier: shared base (`eslint.base.mjs` + `prettier.config.mjs`); ui-tui extends it with React rules, bridge with a Node-only config; hermes-ink vendor and generated RPC types excluded. > - pre-commit: keeps main's hooks (conventional-commit, detect-private-key, etc.), adds a top-level exclude and 4 local eslint/prettier hooks; bumps the pre-commit dev dep. > - 2 lint-surfaced fixes: PlannerContext import (F821) in the sentinel runner; lower-cased file-local cron-heartbeat constants (N806). (raven/config/raven.py's F821 was already fixed on main.) > > Sequencing: config only. `ruff check` is intentionally red on ~307 auto-fixables (I001/F401/F541/E701/E702); a SEPARATE reformat branch runs `ruff --fix` + `ruff format` + eslint/prettier --fix to clear them (100% auto-resolvable, zero manual). Enforcement (pre-commit install / CI) turns on only after the reformat lands, so do not expect a green tree from this PR alone. > > CLI-owned files (the reformat and several per-file-ignores touch `raven/cli/*`) are under review by the CLI team. Judgment items (TS no-explicit-any, no-unused-expressions, S101 convert-vs-keep, N818 rename, C90, mypy) are deferred to v2. ## Type of change - [ ] Bug fix - [x] New feature - [ ] Document - [x] Others ## Related issues (if there is) > none ## Checklists ### Development - [ ] Lint rules pass locally - [ ] Application changes have been tested thoroughly - [ ] Automated tests covering modified code pass > config-only: `ruff check` is red on auto-fixables by design (the reformat branch clears them); eslint/prettier configs load in both ui-tui and bridge. ### Security - [x] Security impact of change has been considered - [ ] Code follows company security practices and guidelines > Only dependency change is the dev-only pre-commit tool plus the ruff pin; the detect-private-key hook from main is retained. ### Code review - [x] Pull request has a descriptive title and context useful to a reviewer - [ ] Pull request linked to JIRA ticket when applicable --------- Co-authored-by: Sheng Zhao <sheng.zhao@evermind.ai> Co-authored-by: Claude (claude-opus-4-8) <noreply@anthropic.com>
2026-07-01 12:09:42 +08:00
_config(
plugin_config={
"everos-memory": {"marker": "canonical"},
"everos": {"marker": "fallback"},
}
),
2026-06-28 18:17:27 +08:00
)
assert backend._config["marker"] == "canonical"
def test_no_config_slice_yields_empty_dict(
build: whole-repo lint + pre-commit convention (config only) (#59) ## Change description > Whole-repo lint + pre-commit convention, CONFIG ONLY (no source reformat in this PR). Python (ruff) and TypeScript (eslint + prettier) share a 120-col margin via the committed pre-commit gate. This upgrades main's existing basic ruff setup and adds the TS lint stack (none existed on main). > > What this PR adds: > - ruff: line-length 120; security rules S101/S105/S106/S107/S506/S605/S607; policy per-file-ignores (tests + accepted CLI deferred-imports + product asserts + N818, each commented); ruff pinned <0.16. > - eslint/prettier: shared base (`eslint.base.mjs` + `prettier.config.mjs`); ui-tui extends it with React rules, bridge with a Node-only config; hermes-ink vendor and generated RPC types excluded. > - pre-commit: keeps main's hooks (conventional-commit, detect-private-key, etc.), adds a top-level exclude and 4 local eslint/prettier hooks; bumps the pre-commit dev dep. > - 2 lint-surfaced fixes: PlannerContext import (F821) in the sentinel runner; lower-cased file-local cron-heartbeat constants (N806). (raven/config/raven.py's F821 was already fixed on main.) > > Sequencing: config only. `ruff check` is intentionally red on ~307 auto-fixables (I001/F401/F541/E701/E702); a SEPARATE reformat branch runs `ruff --fix` + `ruff format` + eslint/prettier --fix to clear them (100% auto-resolvable, zero manual). Enforcement (pre-commit install / CI) turns on only after the reformat lands, so do not expect a green tree from this PR alone. > > CLI-owned files (the reformat and several per-file-ignores touch `raven/cli/*`) are under review by the CLI team. Judgment items (TS no-explicit-any, no-unused-expressions, S101 convert-vs-keep, N818 rename, C90, mypy) are deferred to v2. ## Type of change - [ ] Bug fix - [x] New feature - [ ] Document - [x] Others ## Related issues (if there is) > none ## Checklists ### Development - [ ] Lint rules pass locally - [ ] Application changes have been tested thoroughly - [ ] Automated tests covering modified code pass > config-only: `ruff check` is red on auto-fixables by design (the reformat branch clears them); eslint/prettier configs load in both ui-tui and bridge. ### Security - [x] Security impact of change has been considered - [ ] Code follows company security practices and guidelines > Only dependency change is the dev-only pre-commit tool plus the ruff pin; the detect-private-key hook from main is retained. ### Code review - [x] Pull request has a descriptive title and context useful to a reviewer - [ ] Pull request linked to JIRA ticket when applicable --------- Co-authored-by: Sheng Zhao <sheng.zhao@evermind.ai> Co-authored-by: Claude (claude-opus-4-8) <noreply@anthropic.com>
2026-07-01 12:09:42 +08:00
self,
tmp_path: Path,
2026-06-28 18:17:27 +08:00
) -> None:
backend = maybe_build_memory_backend(tmp_path, _config())
assert backend._config == {}
# ---------------------------------------------------------------------------
# Registry injection — caller can pass a pre-built registry
# ---------------------------------------------------------------------------
class TestRegistryInjection:
def test_caller_supplied_registry_used(self, tmp_path: Path) -> None:
reg = build_plugin_registry(_config())
backend = maybe_build_memory_backend(
build: whole-repo lint + pre-commit convention (config only) (#59) ## Change description > Whole-repo lint + pre-commit convention, CONFIG ONLY (no source reformat in this PR). Python (ruff) and TypeScript (eslint + prettier) share a 120-col margin via the committed pre-commit gate. This upgrades main's existing basic ruff setup and adds the TS lint stack (none existed on main). > > What this PR adds: > - ruff: line-length 120; security rules S101/S105/S106/S107/S506/S605/S607; policy per-file-ignores (tests + accepted CLI deferred-imports + product asserts + N818, each commented); ruff pinned <0.16. > - eslint/prettier: shared base (`eslint.base.mjs` + `prettier.config.mjs`); ui-tui extends it with React rules, bridge with a Node-only config; hermes-ink vendor and generated RPC types excluded. > - pre-commit: keeps main's hooks (conventional-commit, detect-private-key, etc.), adds a top-level exclude and 4 local eslint/prettier hooks; bumps the pre-commit dev dep. > - 2 lint-surfaced fixes: PlannerContext import (F821) in the sentinel runner; lower-cased file-local cron-heartbeat constants (N806). (raven/config/raven.py's F821 was already fixed on main.) > > Sequencing: config only. `ruff check` is intentionally red on ~307 auto-fixables (I001/F401/F541/E701/E702); a SEPARATE reformat branch runs `ruff --fix` + `ruff format` + eslint/prettier --fix to clear them (100% auto-resolvable, zero manual). Enforcement (pre-commit install / CI) turns on only after the reformat lands, so do not expect a green tree from this PR alone. > > CLI-owned files (the reformat and several per-file-ignores touch `raven/cli/*`) are under review by the CLI team. Judgment items (TS no-explicit-any, no-unused-expressions, S101 convert-vs-keep, N818 rename, C90, mypy) are deferred to v2. ## Type of change - [ ] Bug fix - [x] New feature - [ ] Document - [x] Others ## Related issues (if there is) > none ## Checklists ### Development - [ ] Lint rules pass locally - [ ] Application changes have been tested thoroughly - [ ] Automated tests covering modified code pass > config-only: `ruff check` is red on auto-fixables by design (the reformat branch clears them); eslint/prettier configs load in both ui-tui and bridge. ### Security - [x] Security impact of change has been considered - [ ] Code follows company security practices and guidelines > Only dependency change is the dev-only pre-commit tool plus the ruff pin; the detect-private-key hook from main is retained. ### Code review - [x] Pull request has a descriptive title and context useful to a reviewer - [ ] Pull request linked to JIRA ticket when applicable --------- Co-authored-by: Sheng Zhao <sheng.zhao@evermind.ai> Co-authored-by: Claude (claude-opus-4-8) <noreply@anthropic.com>
2026-07-01 12:09:42 +08:00
tmp_path,
_config(),
registry=reg,
2026-06-28 18:17:27 +08:00
)
# Backend constructed via the explicit registry.
assert backend is not None
def test_default_construction_creates_internal_registry(
build: whole-repo lint + pre-commit convention (config only) (#59) ## Change description > Whole-repo lint + pre-commit convention, CONFIG ONLY (no source reformat in this PR). Python (ruff) and TypeScript (eslint + prettier) share a 120-col margin via the committed pre-commit gate. This upgrades main's existing basic ruff setup and adds the TS lint stack (none existed on main). > > What this PR adds: > - ruff: line-length 120; security rules S101/S105/S106/S107/S506/S605/S607; policy per-file-ignores (tests + accepted CLI deferred-imports + product asserts + N818, each commented); ruff pinned <0.16. > - eslint/prettier: shared base (`eslint.base.mjs` + `prettier.config.mjs`); ui-tui extends it with React rules, bridge with a Node-only config; hermes-ink vendor and generated RPC types excluded. > - pre-commit: keeps main's hooks (conventional-commit, detect-private-key, etc.), adds a top-level exclude and 4 local eslint/prettier hooks; bumps the pre-commit dev dep. > - 2 lint-surfaced fixes: PlannerContext import (F821) in the sentinel runner; lower-cased file-local cron-heartbeat constants (N806). (raven/config/raven.py's F821 was already fixed on main.) > > Sequencing: config only. `ruff check` is intentionally red on ~307 auto-fixables (I001/F401/F541/E701/E702); a SEPARATE reformat branch runs `ruff --fix` + `ruff format` + eslint/prettier --fix to clear them (100% auto-resolvable, zero manual). Enforcement (pre-commit install / CI) turns on only after the reformat lands, so do not expect a green tree from this PR alone. > > CLI-owned files (the reformat and several per-file-ignores touch `raven/cli/*`) are under review by the CLI team. Judgment items (TS no-explicit-any, no-unused-expressions, S101 convert-vs-keep, N818 rename, C90, mypy) are deferred to v2. ## Type of change - [ ] Bug fix - [x] New feature - [ ] Document - [x] Others ## Related issues (if there is) > none ## Checklists ### Development - [ ] Lint rules pass locally - [ ] Application changes have been tested thoroughly - [ ] Automated tests covering modified code pass > config-only: `ruff check` is red on auto-fixables by design (the reformat branch clears them); eslint/prettier configs load in both ui-tui and bridge. ### Security - [x] Security impact of change has been considered - [ ] Code follows company security practices and guidelines > Only dependency change is the dev-only pre-commit tool plus the ruff pin; the detect-private-key hook from main is retained. ### Code review - [x] Pull request has a descriptive title and context useful to a reviewer - [ ] Pull request linked to JIRA ticket when applicable --------- Co-authored-by: Sheng Zhao <sheng.zhao@evermind.ai> Co-authored-by: Claude (claude-opus-4-8) <noreply@anthropic.com>
2026-07-01 12:09:42 +08:00
self,
tmp_path: Path,
2026-06-28 18:17:27 +08:00
) -> None:
# Sanity: with no registry passed, the helper still works.
backend = maybe_build_memory_backend(tmp_path, _config())
assert backend is not None
# ---------------------------------------------------------------------------
# Workspace plumbing through ServiceLocator
# ---------------------------------------------------------------------------
class TestServiceLocatorPlumbing:
def test_workspace_reaches_backend(self, tmp_path: Path) -> None:
backend = maybe_build_memory_backend(tmp_path, _config())
# EverosBackend stores ctx.services on construction.
assert backend._services.workspace == tmp_path
feat(*): add hermes as a cold-start import source (#264) ## Summary Adds Hermes as a cold-start import source, alongside the existing Claude Code scanner, across three kinds of data. **Memory files.** `MEMORY.md` and `USER.md` are discovered through the same profile resolution Hermes itself uses (`HERMES_HOME`, then `active_profile` redirecting to `<root>/profiles/<name>`). `USER.md` entries are additionally mirrored into the native `user_memory/profile/user.md`: six host consumers (Curator, Personalizer, four Sentinel producers) read that file directly and never see EverOS-only content. An LLM picks each entry's H2 heading; every failure path lands the entry under `## Notes`, which injection always includes, so a misclassification costs tokens rather than visibility. **Conversations.** Sessions are enumerated by shelling out to `hermes sessions export --dry-run`, whose listing is capped at 100 rows. The scanner walks time windows until every session is covered rather than silently importing the first 100. Only ended sessions are candidates, and `reopen_session()` can clear `ended_at`, so the window reconciliation documents the resulting race in both directions instead of assuming monotonicity. **Skills.** Provenance is classified from on-disk evidence -- the `.bundled_manifest` name-to-md5 map, `.hub/lock.json`, and `.usage.json` -- with a `package_hash` byte-identical to Hermes' own `_dir_hash`, so a skill still matching its factory content is left alone and only user-authored or curator-managed skills are copied into the local skill pool. Skills never travel as ScanResults, so the menus, the confirm line and the final summary all state the skill count explicitly; without it a run that installs 12 of 82 reads as having dropped 70. Failure isolation: `scan_all` now reports a failing scanner through an `on_error` callback and keeps the other platforms' results, and a Hermes run whose conversations cannot be enumerated still returns its memory files. Two pre-existing defects found while working here are fixed in the same branch: a multi-line recall hit escaped its bullet in the context segment renderer, and a recalled EverOS profile was rendered as a Python repr and left uncapped. Also in this branch, from hands-on testing of the finished flow: - `raven import run` could never reach its interactive path. The selectors called questionary's synchronous `ask()` from inside `asyncio.run()`, and prompt_toolkit drives `Application.run()` through `asyncio.run()`, which raises inside a running loop. No test covered it: every case passed `--platform` and `--tier`, bypassing the selectors. - Import outcomes now render as one block after the progress display closes. Printing them from `_build_and_run` sent them to this module's Console while onboard's live progress belongs to its themed Console, and Rich's Live can only hold back writes on its own console, so they landed mid-bar and left the bar duplicated. - The `import run` selectors use the shared prompt style and glyphs instead of questionary's defaults; onboard's foreground import gains the phase reporter it never had, so the multi-second USER.md mirror is no longer silent behind a bar reading 100%. The EverOS backend moves with it. Agent-track recall turned out to be dead: agent-track HYBRID fuses `agent_case` and `agent_skill` through a rerank cross-encoder, and with no rerank provider the server refuses the request outright, which `recall` catches and turns into an empty list against a file-only logger. A live 1.1.3 probe returns `RuntimeError: owner_type='agent' with method='hybrid' requires a rerank provider`. The adapter now reads `capabilities.rerank` from `/health` and asks for the LLM lane only when the cross-encoder is genuinely absent -- always sending it would make every correctly configured user pay an LLM call per recall, never sending it leaves the track dead for anyone who skipped the optional rerank role in onboard. That capability is only readable from everos 1.2.1, so the pin moves 1.1.3 -> 1.2.1, skipping 1.2.0 (built from a branch missing the 1.1.4 fixes, including a knowledge-upload path traversal). Memory endpoints move to `/api/v2`, canonical since 1.2.0; `/api/v1` still resolves to the same handlers but is documented as a legacy alias. Only everos endpoints move -- the Skill Hub and OpenRouter clients have their own v1 surfaces. That upgrade also broke an assumption Raven was making. "Server running" and "server can recall" used to be the same statement; 1.2.1 boots with `[llm]` alone instead of aborting, so a misconfigured provider answers 200 and quietly serves less. Raven decided a role was configured by reading model + api_key out of `everos.toml`, which cannot see that. Capabilities are now read from `/health` at all three points where it matters: the memory step (right after the server it already starts), `raven doctor` (which had no EverOS check at all), and `backend.start()` -- the only one of the three on the path every session takes, which is where an expired key actually surfaces. It follows the precedent already set there for native Windows and prints to stderr rather than a log nobody reads, but does not drop to a no-op: writes still land, and `everos cascade backfill` gives those rows their vectors once the provider is fixed. The same reading makes the embedding role genuinely optional. It was not before: recall sends no `method`, so it took the server default of HYBRID, which everos refuses without an embedding provider -- skipping the role produced a memory that stored everything and returned nothing. The adapter now asks for KEYWORD when no embedding capability is reported, searching the same rows lexically instead of semantically, and that also rules out the rerank fallback because KEYWORD's agent path never reaches the cross-encoder. So the wizard stops requiring embedding and states what each role buys before asking for it -- llm alone gets keyword recall, embedding adds meaning, rerank sharpens ordering -- and skipping embedding is reported in colour rather than dim, because skipping rerank costs ordering while skipping embedding costs semantic recall entirely. Fault and degradation are now distinguished rather than lumped together: only a missing llm sets doctor's exit code, and `raven doctor` names what each unconfigured optional role costs, per role, since "optional" alone does not help anyone decide. The wizard also stops asking whether to enable memory at all -- everos is the only backend, so the question framed a choice that does not exist, and both of its answers were described wrongly (declining was said to use "native Markdown memory", which does not exist: `raven/plugin/memory/` holds only everos, and `ContextAssembler.owns_compaction` is a hardcoded True that stops the consolidator from ever updating user.md). Backing out is still possible and now states the real consequence in colour. The memory LLM field is pre-filled with the user's own main model rather than a recommended id, because a recommendation is only reachable if their key carries it. Two rounds of review on this branch found defects worth naming, since each was invisible for the same reason -- no test covered the path: - **Skills were copied before the run's own `Proceed?` gate.** The two early returns that install a skills-only import sit above it, so a machine whose only importable data is skills had directories copied before being asked anything. Both paths now name the count and ask; the wizard's `Start?` gate is further down still, so its two call sites ask as well. Every covering test passed `--yes`, which is what hid it. - **A cancelled run still ran both post-phases.** `run_import` returns normally once it sees the cancel file, so `raven import stop` halted the conversation loop and then started an LLM call per USER.md entry plus a full skill copy. - **Org-mirror skills were imported past a gate Hermes applies itself.** Hermes token-gates `_org/`: with no `.active_org` marker it prunes the whole mirror, and with one it descends only into the named org, so a stale mirror is content Hermes no longer loads. Discovery now mirrors that. Excluding `_org` outright would have been the opposite error -- it drops the active org's skills. - **`doctor` and the wizard probed the default address.** Both took `DEFAULT_EVEROS_BASE_URL` while the backend reads the configured `base_url`, so a user who moved everos off port 18791 was told it was not running -- by the checks added to make a degraded server visible. - **An unbuilt multimodal role was reported by nobody.** The section-to-capability mapping had an entry both consumers skipped. - **The USER.md progress line reached 100% before the last call.** Each report counted the call about to start; on a measured 9.4s run that left ~3s sitting at 100%, the exact symptom the phase reporter was added to remove. - **Registry-name collisions were only checked within one run**, so a name an earlier import or the user's own skill already claimed produced the invisible skill that `get(name)` never returns. - **"All platforms" plus "run in background" could not work.** `import run` has no all-platforms flag, so the child reached its platform picker with DEVNULL on both streams and no terminal, after the wizard reported the import as started. It now runs in the foreground and says so. The e2e tests this branch made dead are fixed too: identity moved to the host, so `config={"agent_id": ...}` is ignored, and the agent-track test wrote under the services default while querying the tag -- `hits` was empty, its per-hit assertions vacuous, and an `xfail` absorbed it. The plugin manifest moves to 1.1.0, which the upgrade SOP in this same diff asks for. Not in scope: Codex, KimiCode and OpenClaw remain placeholders; cold-start import stays an EverOS-only path with no native fallback. ## Type - [x] Feature - [ ] Fix ## Verification ``` uv run --all-extras pytest -q 5405 passed, 30 skipped, 13 deselected uv run ruff check . All checks passed! uv run ruff format --check . 873 files already formatted make check-large-files passed ``` Beyond the suite, the importer was run against a real Hermes install at `--tier full`: memory files, conversations and skills all landed, EverOS extracted agent cases from the imported conversations (`quality_score=1.0` in the server log), and a second run over the same data reported `Submitted: 0, Skipped: 4`, confirming the checkpointing is idempotent. The everos upgrade was verified against a live server holding real imported data: on 1.1.3 the agent track returns 500 and `/api/v2` returns 404; on 1.2.1 with this change the agent track returns an `agent_case` and the user track is unchanged at three episodes. Re-verified after killing the server and cold starting it, with the resolved binary printed to confirm which build answered. `raven doctor` and the wizard both report llm and embedding available with rerank absent against that server. The suite was also run with HOME pointed at an empty directory, which is how the memory-probe and import-step tests were caught reading the developer's own configuration instead of their own fixtures. That pass also found the test suite waiting out `ensure_everos_server`'s 30s readiness timeout on every machine without a running server -- always, on CI -- which cost one file 34 of its 35 seconds and is now stubbed. The interactive flow was verified under a pty, comparing the two console wirings directly, and each new assertion was mutation-tested: every behavioural change on this branch had its fix reverted and the covering test confirmed red, and only that test. Where a fix had a plausible wrong shape, that shape was mutated too -- excluding `_org` wholesale rather than token-gating it, reporting progress after the await instead of before, seeding the registry-name check from the pool without ordering it after the target resolution. Two of those mutations survived and were the more useful result: one showed a guard clause could not fire (`_target_for` only ever returns a path that does not exist, so excluding it from the pool lookup was dead code, now removed), the other showed the wizard's own confirmation sits below the returns it was supposed to cover. - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally User-facing docs are unchanged: this adds a platform to an existing documented command rather than a new surface. The developer docs move with the code -- `docs/memory-plugin-architecture.md` (the everos pin, and the upgrade SOP now stating that a one-way migration belongs in the release notes) and `scripts/README.md` (two deleted scripts). ## Risk - [x] Security impact considered - [x] Backward compatibility considered - [x] Rollback path is clear for risky changes The import writes to EverOS and to `user_memory/profile/user.md`, and copies skill directories into the local skill pool. EverOS has no delete endpoint, so an unwanted import is not undone by reverting this branch; the skill copies and the profile edits are plain files and can be removed by hand. Import state lives in `~/.raven/import_state.json` and can be deleted to start over. Behaviour changes for existing users: the onboard wizard's import step and `raven import run` both look different (shared prompt style, skill counts, one summary block). `raven import run`'s interactive path changes from "crashes immediately" to working. Rolling back restores the crash. Three more, from the review round: a skills-only import now asks before copying (one extra prompt, skippable with `--yes`), an all-platforms import chosen with "run in background" runs in the foreground instead and says so, and skills under a stale `_org/` mirror are no longer imported -- Hermes does not load them either, but anyone who had them imported by an earlier build keeps them, since nothing here deletes. Two consequences of the everos upgrade that operators need to know: - **The index migration is one-way.** everos 1.2.1 migrates the LanceDB schema on first start and prunes older manifest versions, so once a machine has run this, its memory index can no longer be read by an older everos. Reverting the branch does not undo it. - **A missing provider no longer aborts startup.** 1.2.1 boots with `[llm]` alone. A misconfigured embedding provider used to fail loudly; it now degrades to keyword search, and rows written in that state carry no vector until `everos cascade backfill` is run. everos itself only logs one warning line, which is why the wizard, `raven doctor` and `backend.start()` all surface it -- the last of those runs every session, so an expired key is reported rather than discovered. - **Behaviour change for users who skip embedding.** Recall degrades to keyword matching instead of failing, and the wizard no longer stops them from getting there. That is the point of the change, but it means a user can now end up with a working memory that is measurably worse at recall than the previous all-or-nothing setup would have allowed. ## Related Issues N/A --------- Co-authored-by: Claude (claude-opus-5) <noreply@anthropic.com>
2026-08-04 20:44:07 +08:00
def test_the_two_identities_do_not_arrive_swapped(self, tmp_path: Path) -> None:
"""The whole point of moving identity into ServiceLocator is that a
mismatch makes every written memory unrecallable with no warning. Until
this assertion existed, swapping the two arguments at the only
production wiring point left the entire suite green."""
config = _config()
config.memory.user_id = "u-distinct"
config.memory.agent_id = "a-distinct"
backend = maybe_build_memory_backend(tmp_path, config)
assert backend._services.user_id == "u-distinct"
assert backend._services.agent_id == "a-distinct"
fix(tools): an array sent as its own JSON is still an array ## Summary Reported as "deliver_files is broken". It is not: **the tool never ran.** Every `deliver_files` call on one install was refused before dispatch -- five in a row in a single session -- and nothing was ever delivered: ``` Error: Invalid parameters for tool 'deliver_files': files should be array ``` What the model sent was the array, spelled as a string: ```json {"files": "[{\"path\": \"...poster.png\", \"title\": \"...\"}]", "message": "..."} ``` `cast_params` already forgives that spelling for every scalar type -- `"3"` for an integer, `"true"` for a boolean -- and did not for arrays or objects, which are exactly the types a model is most likely to stringify. ## Type - [x] Fix - [ ] Feature ## The edge of the forgiving is the design When the value is a string, try `json.loads`, and take the result **only if it is the type the schema asked for**. A string that is not JSON, or is JSON of the wrong shape, is returned unchanged so the validator still names the real problem -- the point is to widen what is accepted, not to swallow a type error. **Nothing here can raise.** Turning "your argument has the wrong type" into a traceback would be worse than the refusal it replaces, so the parse is wrapped and failure falls through. **A `type: "string"` field is never parsed.** JSON is ordinary text in a message body or a file's content, and replacing it would hand the tool something it never asked for. Two independent things prevent it today (the string branch returns before the parse is reached, and the parse only wins on a type match), which is why the case pinning it is a tripwire rather than a load-bearing assertion -- said so in its own docstring rather than left to look like coverage. ## Not just deliver_files Six built-in tools declare an array or object parameter and were all exposed: | tool | parameter | |---|---| | `deliver_files` | `files` | | `ask_user` | `questions` | | `image_generate` | `images` | | `message` | `media` | | `create_playbook` | `skills` | | `video_generate` | `params` | The same failure was already seen from the other side: `acp_client/acp_agent.py` records `update_task_state` and `operations should be array` from a real dispatch. ## Verification ``` make lint-python ruff check + ruff format --check, 1850 files make lint-imports 9 contracts kept, 0 broken pytest tests/ 19,699 passed, 7 failed (all pre-existing, see below) ``` - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [ ] User-facing docs or screenshots -- no user-facing string **End to end, through the real tool**, with the exact payload that failed five times in production: ``` files sent as: str -> [{"path": ".../poster.png", "title": "..."}] returned: Delivered 1 file(s): poster.png (72 B). still "should be array": False registered in the store: True ``` Twelve cases, five mutations, each killing at least one: | mutation | red | |---|---| | drop the whole branch (the old behaviour) | 3 | | raise instead of falling through on a parse failure | 5 | | accept the parse whatever type it yielded | 1 | | do not re-cast the parsed value, so items are not cast | 1 | | widen the tuple to include `string` | **survived -- unreachable** | The last is worth stating rather than hiding: that mutation cannot change behaviour, because the `type == "string"` branch returns earlier and the type check would refuse the result anyway. I also tried moving the new block above that branch, alone and combined with widening the tuple, and neither reddens anything either. The invariant holds by construction; the case that documents it says so. **Pre-existing failures, checked against the base.** 7 failed in the full run, all in `tests/test_security_network.py` (`test_a_redirect_to_a_dangerous_address_is_refused` and siblings). Running that file alone on this same tree gives 4 -- the count is order-dependent -- and the change touches only `raven/agent/tools/params.py` plus a new test file, neither of which `raven/security/network.py` imports. The failures are the box's resolver: it returns poisoned answers roughly half the time, which I measured separately (`en.wikipedia.org` came back as `2001::1` on 3 of 6 lookups). Not introduced here, and worth someone's attention on its own. ## Risk - [x] Security impact considered -- widens what reaches a tool's own validation, not what bypasses it. A parsed value is still validated against the same schema, and a parse that yields the wrong type is refused exactly as before - [x] Backward compatibility considered -- a call that worked before takes the identical path; the new branch is reached only by a `str` where an array or object is declared, which previously always failed - [x] Rollback path is clear -- single-commit revert ## Related Issues N/A ## Swept `mr-review-patterns` pre-submit sweep, over `git diff origin/main...HEAD`. - **1 (a write location moved)** -- nothing moved; a branch was added to an existing dispatch on `target_type`. Grepped every caller of `cast_params`: the registry is the only one, and it runs `validate_params` right after, which is the reader this affects. - **2 (a value with several entry points)** -- the cast is the single funnel every tool argument passes through, which is why the fix belongs here and not in `deliver_files`. - **3 (a guard)** -- checked both directions: what it wrongly lets through (JSON of the wrong type, non-JSON text -- both refused, with cases) and what it wrongly refuses (a real list, unaffected, with a case). - **4 (tests)** -- five mutations above, one honestly reported as unreachable. Failing-ID sets diffed against the base rather than counts. - **6 (stale text)** -- the module docstring enumerated what is coerced ("a string that should be an integer"); it now names arrays and objects too. Grepped the tracked tree for other statements of the rule: none. - **9 (error handling)** -- the new path adds one way to end and it is caught: `json.loads` raises `ValueError` on bad text and `TypeError` on a non-string, and both fall through to the untouched value. - **11** -- `git ls-files | grep -c node_modules` is 0; the commit-message gate was run, not eyeballed. Not applicable, with reasons: **3b, 3c, 3d, 3e** (no tool schema produced, no state moved, one lane, no assertion lost its symbol); **4b, 4c, 4d** (no platform branch, no shell, no rendered number); **5, 5b** (no dependency; `json` is stdlib and already imported across this package); **6b, 6c** (no backup, no generated artifact); **7, 7b** (nothing on disk); **8** (no asset, no secret); **10** (no prompt text). ## Deliberately not fixed The error text still ends with `[Analyze the error above and try a different approach.]`, and the model plainly did not -- it sent the same shape five times. A message naming the expected spelling (`files must be a JSON array, not a string containing one`) would give it something to act on. That is a change to the registry's error surface, affects every tool, and deserves its own argument. ## Moved from !594 Opened on a compliant source branch. AGENTS.md 2.1 asks for a 3-5 word snake_case description and the previous branch had seven; GitLab cannot change an existing merge request's source branch, so the change moves rather than the name. Same commits, rebased onto `c2a9768f`. Both code findings from the review on !594 are already in them -- `RecursionError` caught with its regression case, and the implementation comment reduced to the two non-obvious reasons. Nothing else changed, so that review carries.
2026-09-09 15:42:36 +00:00
# ---------------------------------------------------------------------------
# plugins.dirs
# ---------------------------------------------------------------------------
class TestConfiguredDirs:
def test_named_roots_resolve_from_config(self, tmp_path: Path) -> None:
assert named_plugin_roots(_config(dirs=[str(tmp_path)])) == (tmp_path,)
assert named_plugin_roots(_config()) == ()
assert named_plugin_roots(None) == ()
def test_a_plugin_under_a_named_root_activates(self, tmp_path: Path) -> None:
root = tmp_path / "plugins"
(root / "shelf").mkdir(parents=True)
(root / "shelf" / "raven-plugin.toml").write_text(
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
'[plugin]\nid = "shelf"\nversion = "0.1.0"\n',
fix(tools): an array sent as its own JSON is still an array ## Summary Reported as "deliver_files is broken". It is not: **the tool never ran.** Every `deliver_files` call on one install was refused before dispatch -- five in a row in a single session -- and nothing was ever delivered: ``` Error: Invalid parameters for tool 'deliver_files': files should be array ``` What the model sent was the array, spelled as a string: ```json {"files": "[{\"path\": \"...poster.png\", \"title\": \"...\"}]", "message": "..."} ``` `cast_params` already forgives that spelling for every scalar type -- `"3"` for an integer, `"true"` for a boolean -- and did not for arrays or objects, which are exactly the types a model is most likely to stringify. ## Type - [x] Fix - [ ] Feature ## The edge of the forgiving is the design When the value is a string, try `json.loads`, and take the result **only if it is the type the schema asked for**. A string that is not JSON, or is JSON of the wrong shape, is returned unchanged so the validator still names the real problem -- the point is to widen what is accepted, not to swallow a type error. **Nothing here can raise.** Turning "your argument has the wrong type" into a traceback would be worse than the refusal it replaces, so the parse is wrapped and failure falls through. **A `type: "string"` field is never parsed.** JSON is ordinary text in a message body or a file's content, and replacing it would hand the tool something it never asked for. Two independent things prevent it today (the string branch returns before the parse is reached, and the parse only wins on a type match), which is why the case pinning it is a tripwire rather than a load-bearing assertion -- said so in its own docstring rather than left to look like coverage. ## Not just deliver_files Six built-in tools declare an array or object parameter and were all exposed: | tool | parameter | |---|---| | `deliver_files` | `files` | | `ask_user` | `questions` | | `image_generate` | `images` | | `message` | `media` | | `create_playbook` | `skills` | | `video_generate` | `params` | The same failure was already seen from the other side: `acp_client/acp_agent.py` records `update_task_state` and `operations should be array` from a real dispatch. ## Verification ``` make lint-python ruff check + ruff format --check, 1850 files make lint-imports 9 contracts kept, 0 broken pytest tests/ 19,699 passed, 7 failed (all pre-existing, see below) ``` - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [ ] User-facing docs or screenshots -- no user-facing string **End to end, through the real tool**, with the exact payload that failed five times in production: ``` files sent as: str -> [{"path": ".../poster.png", "title": "..."}] returned: Delivered 1 file(s): poster.png (72 B). still "should be array": False registered in the store: True ``` Twelve cases, five mutations, each killing at least one: | mutation | red | |---|---| | drop the whole branch (the old behaviour) | 3 | | raise instead of falling through on a parse failure | 5 | | accept the parse whatever type it yielded | 1 | | do not re-cast the parsed value, so items are not cast | 1 | | widen the tuple to include `string` | **survived -- unreachable** | The last is worth stating rather than hiding: that mutation cannot change behaviour, because the `type == "string"` branch returns earlier and the type check would refuse the result anyway. I also tried moving the new block above that branch, alone and combined with widening the tuple, and neither reddens anything either. The invariant holds by construction; the case that documents it says so. **Pre-existing failures, checked against the base.** 7 failed in the full run, all in `tests/test_security_network.py` (`test_a_redirect_to_a_dangerous_address_is_refused` and siblings). Running that file alone on this same tree gives 4 -- the count is order-dependent -- and the change touches only `raven/agent/tools/params.py` plus a new test file, neither of which `raven/security/network.py` imports. The failures are the box's resolver: it returns poisoned answers roughly half the time, which I measured separately (`en.wikipedia.org` came back as `2001::1` on 3 of 6 lookups). Not introduced here, and worth someone's attention on its own. ## Risk - [x] Security impact considered -- widens what reaches a tool's own validation, not what bypasses it. A parsed value is still validated against the same schema, and a parse that yields the wrong type is refused exactly as before - [x] Backward compatibility considered -- a call that worked before takes the identical path; the new branch is reached only by a `str` where an array or object is declared, which previously always failed - [x] Rollback path is clear -- single-commit revert ## Related Issues N/A ## Swept `mr-review-patterns` pre-submit sweep, over `git diff origin/main...HEAD`. - **1 (a write location moved)** -- nothing moved; a branch was added to an existing dispatch on `target_type`. Grepped every caller of `cast_params`: the registry is the only one, and it runs `validate_params` right after, which is the reader this affects. - **2 (a value with several entry points)** -- the cast is the single funnel every tool argument passes through, which is why the fix belongs here and not in `deliver_files`. - **3 (a guard)** -- checked both directions: what it wrongly lets through (JSON of the wrong type, non-JSON text -- both refused, with cases) and what it wrongly refuses (a real list, unaffected, with a case). - **4 (tests)** -- five mutations above, one honestly reported as unreachable. Failing-ID sets diffed against the base rather than counts. - **6 (stale text)** -- the module docstring enumerated what is coerced ("a string that should be an integer"); it now names arrays and objects too. Grepped the tracked tree for other statements of the rule: none. - **9 (error handling)** -- the new path adds one way to end and it is caught: `json.loads` raises `ValueError` on bad text and `TypeError` on a non-string, and both fall through to the untouched value. - **11** -- `git ls-files | grep -c node_modules` is 0; the commit-message gate was run, not eyeballed. Not applicable, with reasons: **3b, 3c, 3d, 3e** (no tool schema produced, no state moved, one lane, no assertion lost its symbol); **4b, 4c, 4d** (no platform branch, no shell, no rendered number); **5, 5b** (no dependency; `json` is stdlib and already imported across this package); **6b, 6c** (no backup, no generated artifact); **7, 7b** (nothing on disk); **8** (no asset, no secret); **10** (no prompt text). ## Deliberately not fixed The error text still ends with `[Analyze the error above and try a different approach.]`, and the model plainly did not -- it sent the same shape five times. A message naming the expected spelling (`files must be a JSON array, not a string containing one`) would give it something to act on. That is a change to the registry's error surface, affects every tool, and deserves its own argument. ## Moved from !594 Opened on a compliant source branch. AGENTS.md 2.1 asks for a 3-5 word snake_case description and the previous branch had seven; GitLab cannot change an existing merge request's source branch, so the change moves rather than the name. Same commits, rebased onto `c2a9768f`. Both code findings from the review on !594 are already in them -- `RecursionError` caught with its regression case, and the implementation comment reduced to the two non-obvious reasons. Nothing else changed, so that review carries.
2026-09-09 15:42:36 +00:00
encoding="utf-8",
)
assert "shelf" in build_plugin_registry(_config(dirs=[str(root)])).activated_ids()
assert "shelf" not in build_plugin_registry(_config()).activated_ids()
fix(plugins): a plugin that fails to load no longer takes every other plugin with it (#703) ## Summary One plugin that failed to activate dropped every plugin. `PluginRegistry.activate` raised on the first plugin whose factory would not import (or whose contribution name collided), and `build_plugin_registry` (`raven/core/plugin_stack.py`) answered by returning an empty registry. A single broken user plugin therefore silently removed research-flow, ppt-engine, design-engine, the memory backend and the bundled playbook tools, with one stderr warning as the only trace. Reproduced with two mock plugins under a scratch `RAVEN_HOME`: `aa-broken` (factory raises `ImportError`) beside `zz-good`; before this change the registry came back with `activated: []`, after it with `design-engine, everos-memory, playbook, ppt-engine, zz-good` activated and `aa-broken` named as failed. Changes: - **Per-plugin activation** (`raven/plugins/registry.py`). Each admitted plugin activates on its own. One that fails is rolled back whole (no partial contribution in any table, and the `sys.path` entry `_ensure_importable` appended for it is withdrawn), recorded as a `PluginActivationFailure` (`activation_failures()`), and the plugins after it still activate. In a name conflict the plugin activated first (discovery order, by id) keeps the name and the other is recorded as failed. A module `__getattr__` that raises something other than `AttributeError` is now a recorded failure rather than an uncaught crash. - **Said to the user** (`plugin_stack.build_plugin_registry`, `runtime.build_runtime`). Each failure is one notice naming the plugin, its cause and the `plugins.disabled` escape, through the host's notifier (`HostWiring.notify`), else stderr - the same channel the missing-memory-backend notice already uses. When the configured memory backend belongs to a plugin that failed, the memory notice names that plugin and its cause instead of "no installed plugin provides it". - **`raven plugins`** shows a `failed` status and the cause under the table (the command called `activate` directly and previously crashed on such a plugin). - **Agents smoke check** (`raven/cli/agents_commands.py`) matched the old log line "plugin activation failed", which no longer exists; it now reads the shared `PLUGIN_FAILURE_MARKER`, and its test prints the notice the real producer writes, so the two cannot drift. - **Sub-agents inherit the host's opt-outs** (`product_render.write_rendered`, `inherit_plugin_opt_outs`). A product engine inherits `RAVEN_HOME`, so it scans the host's `<home>/plugins` and the shared interpreter's entry points, but it read `plugins.disabled` only from its own rendered config; a plugin disabled on the host came back in every product. Every render now merges the host's list after the product's own. The product's own engine plugin never travels (`own_plugins=`, passed by all five launchers and the scaffold): the PPT agent is `ppt-engine`, and a host turning it off for its own agent is not a request to run the PPT agent without it. A contract test reads every launcher's `write_rendered` call and requires it to name its `*_PLUGIN_ID`. - `CONTEXT.md` (Plugin Registry) and `docs-site/docs/building-plugin{,.zh}.md` describe the new behaviour. Not in this PR: the Web UI plugin list (`ext.list`) is discovery-only and does not show a failed plugin; adding it is a wire change (`ExtListResult`, openrpc, generated TS, the page) and is left for a follow-up. The TUI, gateway and `raven agent` hosts show the notice through their notifiers; the rpc stack (serve/acp) prints it to stderr, which is also what the agents smoke check reads. ## Type - [x] Fix - [ ] Feature - [ ] Docs - [ ] CI / tooling - [ ] Refactor - [ ] Other ## Verification **Rebased**: head 7cd000dbc on origin/main 8ee5ae0d8, without conflicts. `git range-diff` shows every commit replayed unchanged. The branch's own test files rerun at this head: 395 passed. Numbers elsewhere in this description are from earlier heads. Head b4d51aee8, rebased onto origin/main 6551f8259 after #698 and #708 merged. #698 conflicted in `raven/config/product_render.py` and `tests/test_config_product_render.py`: both PRs added a function at the same spot (`inherit_host_denials` there, `inherit_plugin_opt_outs` here) and a call in `write_rendered`. The resolution keeps both functions and all their tests; `write_rendered` now reads `host_config()` once and passes it to both. #708 touches none of these files. At this head: ``` COLORTERM=truecolor uv run --frozen --python 3.12 --all-extras pytest -q -p no:cacheprovider 25948 passed, 109 skipped uv run --frozen --python 3.12 --all-extras pytest -q tests/test_config_product_render.py 44 passed ruff check / ruff format --check / make lint-imports lint-deps lint-types / git diff --check origin/main...HEAD check_source_language.py origin/main...HEAD / make check-commits / check-large-files all clean cd ui-tui && npm run lint:rpc && npm run type-check && npm test 144 files, 2106 passed ``` The earlier `TUI checks` failure (run 35834019105, head 5fc374035) was `newInstancePicker.test.tsx > quick-selects by the number it printed`. This PR changes nothing under `ui-tui/`; the test passed 5 of 5 runs locally at this head and in the full ui-tui run above. The numbers below are from the earlier heads and are kept for the record. ``` uv run --frozen --python 3.12 --extra dev ruff check raven evolver agents plugins-dist tests scripts All checks passed uv run --frozen --python 3.12 --extra dev ruff format --check raven evolver agents plugins-dist tests scripts 2083 files already formatted make lint-imports && make lint-deps && make lint-types Contracts: 10 kept, 0 broken / No dependency issues found / All checks passed git diff --check origin/main...HEAD clean COLORTERM=truecolor make coverage (full suite, head before rebasing onto 7fdf296f4) 25847 passed, 109 skipped COVERAGE_BASE_REF=origin/main make coverage-diff Diff coverage: 100.00% (71/71 executable changed lines) PYTHONPATH=. uv run --frozen --python 3.12 --extra dev python scripts/check_source_language.py origin/main...HEAD exit 0 make check-commits pass git merge-tree --write-tree HEAD origin/main clean ``` After rebasing onto 7fdf296f4 (its two new commits touch none of these files), the touched suites at this head: ``` COLORTERM=truecolor uv run --frozen --python 3.12 --all-extras pytest -q tests/test_plugin_*.py tests/test_core_plugin_stack.py tests/test_cli_plugin_commands.py tests/test_cli_agents_commands.py tests/test_cli_tui_commands.py tests/test_config_product_render.py tests/test_agents_*launcher*.py tests/test_everos_plugin_discovery.py tests/test_release_plugin_list.py tests/test_cli_gateway_commands.py 727 passed uv run --frozen --python 3.12 --all-extras pytest -q tests/test_subagent_vendored_agents.py tests/test_rpc_subagents.py tests/test_subagent_acp.py 452 passed ``` Revert-to-red, one production file restored to origin/main at a time with the tests kept: ``` raven/plugins/registry.py -> 2 errors (plugin_stack imports PluginActivationFailure) raven/core/plugin_stack.py -> 6 failed raven/core/runtime.py -> 1 failed (build_runtime hands the host's notifier to the registry) raven/config/product_render.py -> 42 failed raven/cli/agents_commands.py -> 1 failed (smoke reds a handshake whose plugin did not load) raven/cli/plugin_commands.py -> 1 failed (failed row and escaped cause) agents/raven-ppt/run.py -> 2 failed (engine exemption, launcher contract) ``` Ten existing tests pinned "activation raises" (`test_plugin_registry`, `test_plugin_bootstrap`, and the conflict tests for tools, hooks, tool gates and session observers). They now assert the new contract instead: the later plugin is recorded with the same reason text, the earlier one keeps the name, and nothing of the loser is registered. Two stubs in `test_cli_tui_commands.py` took `build_plugin_registry(cfg)` and now accept the `notify` keyword. - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [x] User-facing docs or screenshots are updated when needed ## Risk - A plugin conflict used to disable all plugins; it now keeps the plugin that activates first and skips the other with a notice. Two plugins contributing the same name therefore run with one of them instead of none. - A product sub-agent now starts with the host's `plugins.disabled` merged into its config (its own engine excepted). A plugin that was disabled on the host but relied on inside a product stops loading there; the remedy is to enable it on the host. - `PluginRegistry.activate` no longer raises `PluginConflictError` / `PluginFactoryImportError`; the only in-tree callers were `assemble_plugin_registry` and `raven plugins`. The exception classes stay exported. - Security: the change only narrows what loads. A failed plugin's directory leaves sys.path, and the inherited opt-outs can only remove plugins from a product, never add one. - Rollback: revert the squash 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-5) <noreply@anthropic.com>
2026-09-23 22:41:21 +08:00
# ---------------------------------------------------------------------------
# One broken plugin
# ---------------------------------------------------------------------------
def _broken_plugin_root(tmp_path: Path, *, backend: str | None = None) -> Path:
"""A named root holding plugin ``wreck``, whose factory module raises on import."""
package = f"_wreck_{tmp_path.name.replace('-', '_')}"
root = tmp_path / "plugins"
plug = root / "wreck"
(plug / package).mkdir(parents=True)
(plug / package / "__init__.py").write_text("raise ImportError('boom')\n", encoding="utf-8")
kind, name = ("memory_backends", backend) if backend else ("tools", "wreck_tool")
(plug / "raven-plugin.toml").write_text(
f'[plugin]\nid = "wreck"\nversion = "0.1.0"\n'
f'[[plugin.contributes.{kind}]]\nname = "{name}"\nfactory = "{package}:make"\n',
encoding="utf-8",
)
return root
class TestOneBrokenPlugin:
def test_the_rest_of_the_registry_survives_and_the_host_hears_it(self, tmp_path: Path) -> None:
heard: list[str] = []
reg = build_plugin_registry(_config(dirs=[str(_broken_plugin_root(tmp_path))]), notify=heard.append)
assert "wreck" not in reg.activated_ids()
assert {"everos-memory", "playbook"} <= set(reg.activated_ids())
assert [f.plugin_id for f in reg.activation_failures()] == ["wreck"]
[message] = heard
assert "'wreck' did not load" in message
assert "boom" in message
assert "plugins.disabled" in message
def test_two_broken_plugins_each_get_a_notice_that_claims_nothing_about_the_other(self, tmp_path: Path) -> None:
root = _broken_plugin_root(tmp_path)
twin = root / "wreck2"
(root / "wreck").rename(twin)
(twin / "raven-plugin.toml").write_text(
(twin / "raven-plugin.toml").read_text(encoding="utf-8").replace('"wreck"', '"wreck2"'), encoding="utf-8"
)
_broken_plugin_root(tmp_path / "second")
heard: list[str] = []
reg = build_plugin_registry(
_config(dirs=[str(root), str(tmp_path / "second" / "plugins")]), notify=heard.append
)
assert [f.plugin_id for f in reg.activation_failures()] == ["wreck", "wreck2"]
assert len(heard) == 2
for message in heard:
assert "loaded normally" not in message
assert "Other plugins continue loading" in message
def test_without_a_notifier_it_reaches_stderr(self, tmp_path: Path, capsys) -> None:
build_plugin_registry(_config(dirs=[str(_broken_plugin_root(tmp_path))]))
assert "'wreck' did not load" in capsys.readouterr().err
def test_a_disabled_broken_plugin_is_not_touched(self, tmp_path: Path) -> None:
heard: list[str] = []
reg = build_plugin_registry(
_config(dirs=[str(_broken_plugin_root(tmp_path))], disabled=["wreck"]), notify=heard.append
)
assert reg.activation_failures() == []
assert heard == []
def test_a_backend_whose_plugin_failed_is_not_called_uninstalled(self, tmp_path: Path) -> None:
cfg = _config(memory_backend="wreckmem", dirs=[str(_broken_plugin_root(tmp_path, backend="wreckmem"))])
heard: list[str] = []
reg = build_plugin_registry(cfg, notify=heard.append)
assert maybe_build_memory_backend(tmp_path, cfg, registry=reg, notify=heard.append) is None
memory_notice = heard[-1]
assert "provided by plugin 'wreck', which did not load: importing" in memory_notice
assert "boom" in memory_notice
assert "no installed plugin provides it" not in memory_notice
def test_build_runtime_hands_the_hosts_notifier_to_the_registry(self, tmp_path: Path, monkeypatch) -> None:
from raven.agent.loop.bundles import HostWiring
from raven.contracts.llm_provider import LLMResponse
from raven.core import plugin_stack, runtime
from raven.providers.base import LLMProvider
root = _broken_plugin_root(tmp_path)
monkeypatch.setattr(
plugin_stack,
"plugin_discovery_sources",
lambda: {
"bundled_dir": tmp_path / "none",
"user_dir": root,
"project_dir": tmp_path / "none",
"entry_points_group": None,
},
)
monkeypatch.setattr(runtime.token_wise_stack, "install_from_config", lambda *a, **k: None)
monkeypatch.setattr(runtime.token_wise_stack, "caching_probe", lambda *a, **k: False)
class _Provider(LLMProvider):
def __init__(self) -> None:
super().__init__(api_key="test")
async def chat(self, messages, **kwargs):
return LLMResponse(content="ok", finish_reason="stop")
def get_default_model(self) -> str:
return "fake/default"
config = Config()
config.agents.defaults.workspace = str(tmp_path / "ws")
heard: list[str] = []
rt = runtime.build_runtime(
config, _config(memory_backend=None), provider=_Provider(), host=HostWiring(notify=heard.append)
)
try:
assert any("'wreck' did not load" in m for m in heard)
finally:
rt.discard()
fix(tools): an array sent as its own JSON is still an array ## Summary Reported as "deliver_files is broken". It is not: **the tool never ran.** Every `deliver_files` call on one install was refused before dispatch -- five in a row in a single session -- and nothing was ever delivered: ``` Error: Invalid parameters for tool 'deliver_files': files should be array ``` What the model sent was the array, spelled as a string: ```json {"files": "[{\"path\": \"...poster.png\", \"title\": \"...\"}]", "message": "..."} ``` `cast_params` already forgives that spelling for every scalar type -- `"3"` for an integer, `"true"` for a boolean -- and did not for arrays or objects, which are exactly the types a model is most likely to stringify. ## Type - [x] Fix - [ ] Feature ## The edge of the forgiving is the design When the value is a string, try `json.loads`, and take the result **only if it is the type the schema asked for**. A string that is not JSON, or is JSON of the wrong shape, is returned unchanged so the validator still names the real problem -- the point is to widen what is accepted, not to swallow a type error. **Nothing here can raise.** Turning "your argument has the wrong type" into a traceback would be worse than the refusal it replaces, so the parse is wrapped and failure falls through. **A `type: "string"` field is never parsed.** JSON is ordinary text in a message body or a file's content, and replacing it would hand the tool something it never asked for. Two independent things prevent it today (the string branch returns before the parse is reached, and the parse only wins on a type match), which is why the case pinning it is a tripwire rather than a load-bearing assertion -- said so in its own docstring rather than left to look like coverage. ## Not just deliver_files Six built-in tools declare an array or object parameter and were all exposed: | tool | parameter | |---|---| | `deliver_files` | `files` | | `ask_user` | `questions` | | `image_generate` | `images` | | `message` | `media` | | `create_playbook` | `skills` | | `video_generate` | `params` | The same failure was already seen from the other side: `acp_client/acp_agent.py` records `update_task_state` and `operations should be array` from a real dispatch. ## Verification ``` make lint-python ruff check + ruff format --check, 1850 files make lint-imports 9 contracts kept, 0 broken pytest tests/ 19,699 passed, 7 failed (all pre-existing, see below) ``` - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [ ] User-facing docs or screenshots -- no user-facing string **End to end, through the real tool**, with the exact payload that failed five times in production: ``` files sent as: str -> [{"path": ".../poster.png", "title": "..."}] returned: Delivered 1 file(s): poster.png (72 B). still "should be array": False registered in the store: True ``` Twelve cases, five mutations, each killing at least one: | mutation | red | |---|---| | drop the whole branch (the old behaviour) | 3 | | raise instead of falling through on a parse failure | 5 | | accept the parse whatever type it yielded | 1 | | do not re-cast the parsed value, so items are not cast | 1 | | widen the tuple to include `string` | **survived -- unreachable** | The last is worth stating rather than hiding: that mutation cannot change behaviour, because the `type == "string"` branch returns earlier and the type check would refuse the result anyway. I also tried moving the new block above that branch, alone and combined with widening the tuple, and neither reddens anything either. The invariant holds by construction; the case that documents it says so. **Pre-existing failures, checked against the base.** 7 failed in the full run, all in `tests/test_security_network.py` (`test_a_redirect_to_a_dangerous_address_is_refused` and siblings). Running that file alone on this same tree gives 4 -- the count is order-dependent -- and the change touches only `raven/agent/tools/params.py` plus a new test file, neither of which `raven/security/network.py` imports. The failures are the box's resolver: it returns poisoned answers roughly half the time, which I measured separately (`en.wikipedia.org` came back as `2001::1` on 3 of 6 lookups). Not introduced here, and worth someone's attention on its own. ## Risk - [x] Security impact considered -- widens what reaches a tool's own validation, not what bypasses it. A parsed value is still validated against the same schema, and a parse that yields the wrong type is refused exactly as before - [x] Backward compatibility considered -- a call that worked before takes the identical path; the new branch is reached only by a `str` where an array or object is declared, which previously always failed - [x] Rollback path is clear -- single-commit revert ## Related Issues N/A ## Swept `mr-review-patterns` pre-submit sweep, over `git diff origin/main...HEAD`. - **1 (a write location moved)** -- nothing moved; a branch was added to an existing dispatch on `target_type`. Grepped every caller of `cast_params`: the registry is the only one, and it runs `validate_params` right after, which is the reader this affects. - **2 (a value with several entry points)** -- the cast is the single funnel every tool argument passes through, which is why the fix belongs here and not in `deliver_files`. - **3 (a guard)** -- checked both directions: what it wrongly lets through (JSON of the wrong type, non-JSON text -- both refused, with cases) and what it wrongly refuses (a real list, unaffected, with a case). - **4 (tests)** -- five mutations above, one honestly reported as unreachable. Failing-ID sets diffed against the base rather than counts. - **6 (stale text)** -- the module docstring enumerated what is coerced ("a string that should be an integer"); it now names arrays and objects too. Grepped the tracked tree for other statements of the rule: none. - **9 (error handling)** -- the new path adds one way to end and it is caught: `json.loads` raises `ValueError` on bad text and `TypeError` on a non-string, and both fall through to the untouched value. - **11** -- `git ls-files | grep -c node_modules` is 0; the commit-message gate was run, not eyeballed. Not applicable, with reasons: **3b, 3c, 3d, 3e** (no tool schema produced, no state moved, one lane, no assertion lost its symbol); **4b, 4c, 4d** (no platform branch, no shell, no rendered number); **5, 5b** (no dependency; `json` is stdlib and already imported across this package); **6b, 6c** (no backup, no generated artifact); **7, 7b** (nothing on disk); **8** (no asset, no secret); **10** (no prompt text). ## Deliberately not fixed The error text still ends with `[Analyze the error above and try a different approach.]`, and the model plainly did not -- it sent the same shape five times. A message naming the expected spelling (`files must be a JSON array, not a string containing one`) would give it something to act on. That is a change to the registry's error surface, affects every tool, and deserves its own argument. ## Moved from !594 Opened on a compliant source branch. AGENTS.md 2.1 asks for a 3-5 word snake_case description and the previous branch had seven; GitLab cannot change an existing merge request's source branch, so the change moves rather than the name. Same commits, rebased onto `c2a9768f`. Both code findings from the review on !594 are already in them -- `RecursionError` caught with its regression case, and the implementation comment reduced to the two non-obvious reasons. Nothing else changed, so that review carries.
2026-09-09 15:42:36 +00:00
# ---------------------------------------------------------------------------
# The provider grant
# ---------------------------------------------------------------------------
class _GrantWatch:
"""A registry stand-in that records what locator each factory was handed."""
def __init__(self, seen: list) -> None:
self._seen = seen
def hook_names(self):
return ["h"]
def tool_names(self):
return ["t"]
def hook_plugin_id(self, name):
return "p"
def tool_plugin_id(self, name):
return "p"
def build_hook(self, name, *, config, services):
feat(ui-tui): tool cards open themselves, the strip marks here, ticker words split ## Summary Three reader-facing changes to the TUI transcript and the instance strip. **A settled tool call opens itself.** A tool card had two states, shut and full, and neither is what a reader wants by default: shut hides the result that was the point of the call, full spends a thousand rows on a result five rows would have answered. There are now three levels - shut, a preview capped at `TOOL_PREVIEW_ROWS` result rows with a `+N` row standing for the remainder, and full at `TOOL_FULL_ROWS`. The cap is what bounds the cost, so a call that came back opens unasked and only a call that returned nothing stays shut, its block being the argument the row above already shows. A reader's own decision always wins over that default. The `+N` row becomes its own two-way control: it reveals the rest, then folds back to the cap, where the block's own click shuts the card outright. It used to ride inside the output array, which made the one row announcing there was more to see the row that collapsed the card. Fold state moves out of the component that draws it into a store keyed by tool call id. Held in the row's component state, a row that changed - a step landing in a turn still running - unmounted and took the reader's decision with it, so a card opened seconds ago closed itself. `useMainApp` now reads that store when it measures: a resize drops every measured height because the cache buckets on columns, so without the folds there, rows below the fold came back at their default height and the transcript scrolled to the wrong place. **The strip marks the row whose conversation is on screen.** The composer's top border names the instance being typed to, and the strip listed every instance without saying which of them that was. The active row now carries a gutter bar in the strip's own leftmost column, where nothing else draws, so the bar reads as a position and the bullet beside it goes on saying status alone. The active row is exempt from every cap, and a line no click can switch to - a graph line, a loose spawn - never carries it. An interrupted turn also refreshes the instance registry now: `message.complete` already did, but the manager moves the row on this path too, writing `cancelled` or `failed`, so without the re-read an interrupted instance went on showing a filled bullet while its view went on polling a turn that had ended. **The censored ticker vocabulary splits from Raven's own.** Wrapped agents render their status as a kaomoji plus a verb, some of it on the channel the reasoning arrives on, and `cleanThinkingText` strips exactly that pair - but it was reading its strip list off Raven's own `FACES` and `VERBS`. That made the two one list, so a branding change silently changed what gets censored out of a model's reasoning: rename a verb and the old word stops being stripped, adopt a word another agent uses and Raven's own ticker starts eating itself. `tickerNoise.ts` now holds that vocabulary, frozen and deliberately separate; it describes other agents' output and changes only when one of them does. `FACES` and `VERBS` are then free to move, and they move here: the kaomoji become one bird wearing different expressions, and the verbs are ordered as one round of work rather than by how close the words are in meaning, because at one word every 2.5s a reader sees most of the list in a single turn. Each emoji frame is a single code point on purpose - a ZWJ sequence or a variation selector renders as two glyphs on terminals that do not compose it, which shifts everything right of the ticker. ## Type - [ ] Fix - [x] Feature - [ ] Docs - [ ] CI / tooling - [ ] Refactor - [ ] Other ## Verification Run on a worktree at this branch's tip, against the current main tip: - `npx vitest run` (ui-tui): 141 files, 2052 tests passed - `npx tsc --noEmit -p tsconfig.json` (ui-tui): exit 0, no output - `make check-source-language COMMIT_RANGE=origin/main..HEAD`: exit 0 - `make check-large-files COMMIT_RANGE=origin/main..HEAD`: exit 0 No Python source is touched, so no pytest selection applies. `ui-tui/CONTEXT.md` is updated for the fold levels and the gutter bar; the tool-card work carries its design note under `docs/plans/`. - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [x] User-facing docs or screenshots are updated when needed ## Risk Three user-visible changes, all inside the terminal UI: - a tool call that returned something now opens to a capped preview instead of staying shut. A reader who prefers it shut clicks once, and that decision holds for the life of the call. - the instance strip spends one leading column on the gutter bar, so every row has one column less for its name. - the status ticker shows a different set of glyphs and words. No RPC schema, config or on-disk format changes. Fold state lives in memory and per transcript view, so nothing persists across a restart and there is nothing to migrate. The split strip list only widens what is removed from displayed reasoning text; it reads no new input and grants no new capability. Rollback is a revert of the squash commit. - [x] Security impact considered - [x] Backward compatibility considered - [x] Rollback path is clear for risky changes ## Related Issues N/A
2026-09-10 12:42:09 +00:00
self._seen.append(("hook", services))
fix(tools): an array sent as its own JSON is still an array ## Summary Reported as "deliver_files is broken". It is not: **the tool never ran.** Every `deliver_files` call on one install was refused before dispatch -- five in a row in a single session -- and nothing was ever delivered: ``` Error: Invalid parameters for tool 'deliver_files': files should be array ``` What the model sent was the array, spelled as a string: ```json {"files": "[{\"path\": \"...poster.png\", \"title\": \"...\"}]", "message": "..."} ``` `cast_params` already forgives that spelling for every scalar type -- `"3"` for an integer, `"true"` for a boolean -- and did not for arrays or objects, which are exactly the types a model is most likely to stringify. ## Type - [x] Fix - [ ] Feature ## The edge of the forgiving is the design When the value is a string, try `json.loads`, and take the result **only if it is the type the schema asked for**. A string that is not JSON, or is JSON of the wrong shape, is returned unchanged so the validator still names the real problem -- the point is to widen what is accepted, not to swallow a type error. **Nothing here can raise.** Turning "your argument has the wrong type" into a traceback would be worse than the refusal it replaces, so the parse is wrapped and failure falls through. **A `type: "string"` field is never parsed.** JSON is ordinary text in a message body or a file's content, and replacing it would hand the tool something it never asked for. Two independent things prevent it today (the string branch returns before the parse is reached, and the parse only wins on a type match), which is why the case pinning it is a tripwire rather than a load-bearing assertion -- said so in its own docstring rather than left to look like coverage. ## Not just deliver_files Six built-in tools declare an array or object parameter and were all exposed: | tool | parameter | |---|---| | `deliver_files` | `files` | | `ask_user` | `questions` | | `image_generate` | `images` | | `message` | `media` | | `create_playbook` | `skills` | | `video_generate` | `params` | The same failure was already seen from the other side: `acp_client/acp_agent.py` records `update_task_state` and `operations should be array` from a real dispatch. ## Verification ``` make lint-python ruff check + ruff format --check, 1850 files make lint-imports 9 contracts kept, 0 broken pytest tests/ 19,699 passed, 7 failed (all pre-existing, see below) ``` - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [ ] User-facing docs or screenshots -- no user-facing string **End to end, through the real tool**, with the exact payload that failed five times in production: ``` files sent as: str -> [{"path": ".../poster.png", "title": "..."}] returned: Delivered 1 file(s): poster.png (72 B). still "should be array": False registered in the store: True ``` Twelve cases, five mutations, each killing at least one: | mutation | red | |---|---| | drop the whole branch (the old behaviour) | 3 | | raise instead of falling through on a parse failure | 5 | | accept the parse whatever type it yielded | 1 | | do not re-cast the parsed value, so items are not cast | 1 | | widen the tuple to include `string` | **survived -- unreachable** | The last is worth stating rather than hiding: that mutation cannot change behaviour, because the `type == "string"` branch returns earlier and the type check would refuse the result anyway. I also tried moving the new block above that branch, alone and combined with widening the tuple, and neither reddens anything either. The invariant holds by construction; the case that documents it says so. **Pre-existing failures, checked against the base.** 7 failed in the full run, all in `tests/test_security_network.py` (`test_a_redirect_to_a_dangerous_address_is_refused` and siblings). Running that file alone on this same tree gives 4 -- the count is order-dependent -- and the change touches only `raven/agent/tools/params.py` plus a new test file, neither of which `raven/security/network.py` imports. The failures are the box's resolver: it returns poisoned answers roughly half the time, which I measured separately (`en.wikipedia.org` came back as `2001::1` on 3 of 6 lookups). Not introduced here, and worth someone's attention on its own. ## Risk - [x] Security impact considered -- widens what reaches a tool's own validation, not what bypasses it. A parsed value is still validated against the same schema, and a parse that yields the wrong type is refused exactly as before - [x] Backward compatibility considered -- a call that worked before takes the identical path; the new branch is reached only by a `str` where an array or object is declared, which previously always failed - [x] Rollback path is clear -- single-commit revert ## Related Issues N/A ## Swept `mr-review-patterns` pre-submit sweep, over `git diff origin/main...HEAD`. - **1 (a write location moved)** -- nothing moved; a branch was added to an existing dispatch on `target_type`. Grepped every caller of `cast_params`: the registry is the only one, and it runs `validate_params` right after, which is the reader this affects. - **2 (a value with several entry points)** -- the cast is the single funnel every tool argument passes through, which is why the fix belongs here and not in `deliver_files`. - **3 (a guard)** -- checked both directions: what it wrongly lets through (JSON of the wrong type, non-JSON text -- both refused, with cases) and what it wrongly refuses (a real list, unaffected, with a case). - **4 (tests)** -- five mutations above, one honestly reported as unreachable. Failing-ID sets diffed against the base rather than counts. - **6 (stale text)** -- the module docstring enumerated what is coerced ("a string that should be an integer"); it now names arrays and objects too. Grepped the tracked tree for other statements of the rule: none. - **9 (error handling)** -- the new path adds one way to end and it is caught: `json.loads` raises `ValueError` on bad text and `TypeError` on a non-string, and both fall through to the untouched value. - **11** -- `git ls-files | grep -c node_modules` is 0; the commit-message gate was run, not eyeballed. Not applicable, with reasons: **3b, 3c, 3d, 3e** (no tool schema produced, no state moved, one lane, no assertion lost its symbol); **4b, 4c, 4d** (no platform branch, no shell, no rendered number); **5, 5b** (no dependency; `json` is stdlib and already imported across this package); **6b, 6c** (no backup, no generated artifact); **7, 7b** (nothing on disk); **8** (no asset, no secret); **10** (no prompt text). ## Deliberately not fixed The error text still ends with `[Analyze the error above and try a different approach.]`, and the model plainly did not -- it sent the same shape five times. A message naming the expected spelling (`files must be a JSON array, not a string containing one`) would give it something to act on. That is a change to the registry's error surface, affects every tool, and deserves its own argument. ## Moved from !594 Opened on a compliant source branch. AGENTS.md 2.1 asks for a 3-5 word snake_case description and the previous branch had seven; GitLab cannot change an existing merge request's source branch, so the change moves rather than the name. Same commits, rebased onto `c2a9768f`. Both code findings from the review on !594 are already in them -- `RecursionError` caught with its regression case, and the implementation comment reduced to the two non-obvious reasons. Nothing else changed, so that review carries.
2026-09-09 15:42:36 +00:00
return object()
def build_tool(self, name, *, config, services):
feat(ui-tui): tool cards open themselves, the strip marks here, ticker words split ## Summary Three reader-facing changes to the TUI transcript and the instance strip. **A settled tool call opens itself.** A tool card had two states, shut and full, and neither is what a reader wants by default: shut hides the result that was the point of the call, full spends a thousand rows on a result five rows would have answered. There are now three levels - shut, a preview capped at `TOOL_PREVIEW_ROWS` result rows with a `+N` row standing for the remainder, and full at `TOOL_FULL_ROWS`. The cap is what bounds the cost, so a call that came back opens unasked and only a call that returned nothing stays shut, its block being the argument the row above already shows. A reader's own decision always wins over that default. The `+N` row becomes its own two-way control: it reveals the rest, then folds back to the cap, where the block's own click shuts the card outright. It used to ride inside the output array, which made the one row announcing there was more to see the row that collapsed the card. Fold state moves out of the component that draws it into a store keyed by tool call id. Held in the row's component state, a row that changed - a step landing in a turn still running - unmounted and took the reader's decision with it, so a card opened seconds ago closed itself. `useMainApp` now reads that store when it measures: a resize drops every measured height because the cache buckets on columns, so without the folds there, rows below the fold came back at their default height and the transcript scrolled to the wrong place. **The strip marks the row whose conversation is on screen.** The composer's top border names the instance being typed to, and the strip listed every instance without saying which of them that was. The active row now carries a gutter bar in the strip's own leftmost column, where nothing else draws, so the bar reads as a position and the bullet beside it goes on saying status alone. The active row is exempt from every cap, and a line no click can switch to - a graph line, a loose spawn - never carries it. An interrupted turn also refreshes the instance registry now: `message.complete` already did, but the manager moves the row on this path too, writing `cancelled` or `failed`, so without the re-read an interrupted instance went on showing a filled bullet while its view went on polling a turn that had ended. **The censored ticker vocabulary splits from Raven's own.** Wrapped agents render their status as a kaomoji plus a verb, some of it on the channel the reasoning arrives on, and `cleanThinkingText` strips exactly that pair - but it was reading its strip list off Raven's own `FACES` and `VERBS`. That made the two one list, so a branding change silently changed what gets censored out of a model's reasoning: rename a verb and the old word stops being stripped, adopt a word another agent uses and Raven's own ticker starts eating itself. `tickerNoise.ts` now holds that vocabulary, frozen and deliberately separate; it describes other agents' output and changes only when one of them does. `FACES` and `VERBS` are then free to move, and they move here: the kaomoji become one bird wearing different expressions, and the verbs are ordered as one round of work rather than by how close the words are in meaning, because at one word every 2.5s a reader sees most of the list in a single turn. Each emoji frame is a single code point on purpose - a ZWJ sequence or a variation selector renders as two glyphs on terminals that do not compose it, which shifts everything right of the ticker. ## Type - [ ] Fix - [x] Feature - [ ] Docs - [ ] CI / tooling - [ ] Refactor - [ ] Other ## Verification Run on a worktree at this branch's tip, against the current main tip: - `npx vitest run` (ui-tui): 141 files, 2052 tests passed - `npx tsc --noEmit -p tsconfig.json` (ui-tui): exit 0, no output - `make check-source-language COMMIT_RANGE=origin/main..HEAD`: exit 0 - `make check-large-files COMMIT_RANGE=origin/main..HEAD`: exit 0 No Python source is touched, so no pytest selection applies. `ui-tui/CONTEXT.md` is updated for the fold levels and the gutter bar; the tool-card work carries its design note under `docs/plans/`. - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [x] User-facing docs or screenshots are updated when needed ## Risk Three user-visible changes, all inside the terminal UI: - a tool call that returned something now opens to a capped preview instead of staying shut. A reader who prefers it shut clicks once, and that decision holds for the life of the call. - the instance strip spends one leading column on the gutter bar, so every row has one column less for its name. - the status ticker shows a different set of glyphs and words. No RPC schema, config or on-disk format changes. Fold state lives in memory and per transcript view, so nothing persists across a restart and there is nothing to migrate. The split strip list only widens what is removed from displayed reasoning text; it reads no new input and grants no new capability. Rollback is a revert of the squash commit. - [x] Security impact considered - [x] Backward compatibility considered - [x] Rollback path is clear for risky changes ## Related Issues N/A
2026-09-10 12:42:09 +00:00
self._seen.append(("tool", services))
fix(tools): an array sent as its own JSON is still an array ## Summary Reported as "deliver_files is broken". It is not: **the tool never ran.** Every `deliver_files` call on one install was refused before dispatch -- five in a row in a single session -- and nothing was ever delivered: ``` Error: Invalid parameters for tool 'deliver_files': files should be array ``` What the model sent was the array, spelled as a string: ```json {"files": "[{\"path\": \"...poster.png\", \"title\": \"...\"}]", "message": "..."} ``` `cast_params` already forgives that spelling for every scalar type -- `"3"` for an integer, `"true"` for a boolean -- and did not for arrays or objects, which are exactly the types a model is most likely to stringify. ## Type - [x] Fix - [ ] Feature ## The edge of the forgiving is the design When the value is a string, try `json.loads`, and take the result **only if it is the type the schema asked for**. A string that is not JSON, or is JSON of the wrong shape, is returned unchanged so the validator still names the real problem -- the point is to widen what is accepted, not to swallow a type error. **Nothing here can raise.** Turning "your argument has the wrong type" into a traceback would be worse than the refusal it replaces, so the parse is wrapped and failure falls through. **A `type: "string"` field is never parsed.** JSON is ordinary text in a message body or a file's content, and replacing it would hand the tool something it never asked for. Two independent things prevent it today (the string branch returns before the parse is reached, and the parse only wins on a type match), which is why the case pinning it is a tripwire rather than a load-bearing assertion -- said so in its own docstring rather than left to look like coverage. ## Not just deliver_files Six built-in tools declare an array or object parameter and were all exposed: | tool | parameter | |---|---| | `deliver_files` | `files` | | `ask_user` | `questions` | | `image_generate` | `images` | | `message` | `media` | | `create_playbook` | `skills` | | `video_generate` | `params` | The same failure was already seen from the other side: `acp_client/acp_agent.py` records `update_task_state` and `operations should be array` from a real dispatch. ## Verification ``` make lint-python ruff check + ruff format --check, 1850 files make lint-imports 9 contracts kept, 0 broken pytest tests/ 19,699 passed, 7 failed (all pre-existing, see below) ``` - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [ ] User-facing docs or screenshots -- no user-facing string **End to end, through the real tool**, with the exact payload that failed five times in production: ``` files sent as: str -> [{"path": ".../poster.png", "title": "..."}] returned: Delivered 1 file(s): poster.png (72 B). still "should be array": False registered in the store: True ``` Twelve cases, five mutations, each killing at least one: | mutation | red | |---|---| | drop the whole branch (the old behaviour) | 3 | | raise instead of falling through on a parse failure | 5 | | accept the parse whatever type it yielded | 1 | | do not re-cast the parsed value, so items are not cast | 1 | | widen the tuple to include `string` | **survived -- unreachable** | The last is worth stating rather than hiding: that mutation cannot change behaviour, because the `type == "string"` branch returns earlier and the type check would refuse the result anyway. I also tried moving the new block above that branch, alone and combined with widening the tuple, and neither reddens anything either. The invariant holds by construction; the case that documents it says so. **Pre-existing failures, checked against the base.** 7 failed in the full run, all in `tests/test_security_network.py` (`test_a_redirect_to_a_dangerous_address_is_refused` and siblings). Running that file alone on this same tree gives 4 -- the count is order-dependent -- and the change touches only `raven/agent/tools/params.py` plus a new test file, neither of which `raven/security/network.py` imports. The failures are the box's resolver: it returns poisoned answers roughly half the time, which I measured separately (`en.wikipedia.org` came back as `2001::1` on 3 of 6 lookups). Not introduced here, and worth someone's attention on its own. ## Risk - [x] Security impact considered -- widens what reaches a tool's own validation, not what bypasses it. A parsed value is still validated against the same schema, and a parse that yields the wrong type is refused exactly as before - [x] Backward compatibility considered -- a call that worked before takes the identical path; the new branch is reached only by a `str` where an array or object is declared, which previously always failed - [x] Rollback path is clear -- single-commit revert ## Related Issues N/A ## Swept `mr-review-patterns` pre-submit sweep, over `git diff origin/main...HEAD`. - **1 (a write location moved)** -- nothing moved; a branch was added to an existing dispatch on `target_type`. Grepped every caller of `cast_params`: the registry is the only one, and it runs `validate_params` right after, which is the reader this affects. - **2 (a value with several entry points)** -- the cast is the single funnel every tool argument passes through, which is why the fix belongs here and not in `deliver_files`. - **3 (a guard)** -- checked both directions: what it wrongly lets through (JSON of the wrong type, non-JSON text -- both refused, with cases) and what it wrongly refuses (a real list, unaffected, with a case). - **4 (tests)** -- five mutations above, one honestly reported as unreachable. Failing-ID sets diffed against the base rather than counts. - **6 (stale text)** -- the module docstring enumerated what is coerced ("a string that should be an integer"); it now names arrays and objects too. Grepped the tracked tree for other statements of the rule: none. - **9 (error handling)** -- the new path adds one way to end and it is caught: `json.loads` raises `ValueError` on bad text and `TypeError` on a non-string, and both fall through to the untouched value. - **11** -- `git ls-files | grep -c node_modules` is 0; the commit-message gate was run, not eyeballed. Not applicable, with reasons: **3b, 3c, 3d, 3e** (no tool schema produced, no state moved, one lane, no assertion lost its symbol); **4b, 4c, 4d** (no platform branch, no shell, no rendered number); **5, 5b** (no dependency; `json` is stdlib and already imported across this package); **6b, 6c** (no backup, no generated artifact); **7, 7b** (nothing on disk); **8** (no asset, no secret); **10** (no prompt text). ## Deliberately not fixed The error text still ends with `[Analyze the error above and try a different approach.]`, and the model plainly did not -- it sent the same shape five times. A message naming the expected spelling (`files must be a JSON array, not a string containing one`) would give it something to act on. That is a change to the registry's error surface, affects every tool, and deserves its own argument. ## Moved from !594 Opened on a compliant source branch. AGENTS.md 2.1 asks for a 3-5 word snake_case description and the previous branch had seven; GitLab cannot change an existing merge request's source branch, so the change moves rather than the name. Same commits, rebased onto `c2a9768f`. Both code findings from the review on !594 are already in them -- `RecursionError` caught with its regression case, and the implementation comment reduced to the two non-obvious reasons. Nothing else changed, so that review carries.
2026-09-09 15:42:36 +00:00
return object()
class TestProviderGrant:
def test_the_connections_provider_reaches_hooks_and_tools(self, tmp_path: Path) -> None:
seen: list = []
lent = object()
build_plugin_hooks(tmp_path, _config(), registry=_GrantWatch(seen), provider=lent)
build_plugin_tools(tmp_path, _config(), registry=_GrantWatch(seen), provider=lent)
feat(ui-tui): tool cards open themselves, the strip marks here, ticker words split ## Summary Three reader-facing changes to the TUI transcript and the instance strip. **A settled tool call opens itself.** A tool card had two states, shut and full, and neither is what a reader wants by default: shut hides the result that was the point of the call, full spends a thousand rows on a result five rows would have answered. There are now three levels - shut, a preview capped at `TOOL_PREVIEW_ROWS` result rows with a `+N` row standing for the remainder, and full at `TOOL_FULL_ROWS`. The cap is what bounds the cost, so a call that came back opens unasked and only a call that returned nothing stays shut, its block being the argument the row above already shows. A reader's own decision always wins over that default. The `+N` row becomes its own two-way control: it reveals the rest, then folds back to the cap, where the block's own click shuts the card outright. It used to ride inside the output array, which made the one row announcing there was more to see the row that collapsed the card. Fold state moves out of the component that draws it into a store keyed by tool call id. Held in the row's component state, a row that changed - a step landing in a turn still running - unmounted and took the reader's decision with it, so a card opened seconds ago closed itself. `useMainApp` now reads that store when it measures: a resize drops every measured height because the cache buckets on columns, so without the folds there, rows below the fold came back at their default height and the transcript scrolled to the wrong place. **The strip marks the row whose conversation is on screen.** The composer's top border names the instance being typed to, and the strip listed every instance without saying which of them that was. The active row now carries a gutter bar in the strip's own leftmost column, where nothing else draws, so the bar reads as a position and the bullet beside it goes on saying status alone. The active row is exempt from every cap, and a line no click can switch to - a graph line, a loose spawn - never carries it. An interrupted turn also refreshes the instance registry now: `message.complete` already did, but the manager moves the row on this path too, writing `cancelled` or `failed`, so without the re-read an interrupted instance went on showing a filled bullet while its view went on polling a turn that had ended. **The censored ticker vocabulary splits from Raven's own.** Wrapped agents render their status as a kaomoji plus a verb, some of it on the channel the reasoning arrives on, and `cleanThinkingText` strips exactly that pair - but it was reading its strip list off Raven's own `FACES` and `VERBS`. That made the two one list, so a branding change silently changed what gets censored out of a model's reasoning: rename a verb and the old word stops being stripped, adopt a word another agent uses and Raven's own ticker starts eating itself. `tickerNoise.ts` now holds that vocabulary, frozen and deliberately separate; it describes other agents' output and changes only when one of them does. `FACES` and `VERBS` are then free to move, and they move here: the kaomoji become one bird wearing different expressions, and the verbs are ordered as one round of work rather than by how close the words are in meaning, because at one word every 2.5s a reader sees most of the list in a single turn. Each emoji frame is a single code point on purpose - a ZWJ sequence or a variation selector renders as two glyphs on terminals that do not compose it, which shifts everything right of the ticker. ## Type - [ ] Fix - [x] Feature - [ ] Docs - [ ] CI / tooling - [ ] Refactor - [ ] Other ## Verification Run on a worktree at this branch's tip, against the current main tip: - `npx vitest run` (ui-tui): 141 files, 2052 tests passed - `npx tsc --noEmit -p tsconfig.json` (ui-tui): exit 0, no output - `make check-source-language COMMIT_RANGE=origin/main..HEAD`: exit 0 - `make check-large-files COMMIT_RANGE=origin/main..HEAD`: exit 0 No Python source is touched, so no pytest selection applies. `ui-tui/CONTEXT.md` is updated for the fold levels and the gutter bar; the tool-card work carries its design note under `docs/plans/`. - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [x] User-facing docs or screenshots are updated when needed ## Risk Three user-visible changes, all inside the terminal UI: - a tool call that returned something now opens to a capped preview instead of staying shut. A reader who prefers it shut clicks once, and that decision holds for the life of the call. - the instance strip spends one leading column on the gutter bar, so every row has one column less for its name. - the status ticker shows a different set of glyphs and words. No RPC schema, config or on-disk format changes. Fold state lives in memory and per transcript view, so nothing persists across a restart and there is nothing to migrate. The split strip list only widens what is removed from displayed reasoning text; it reads no new input and grants no new capability. Rollback is a revert of the squash commit. - [x] Security impact considered - [x] Backward compatibility considered - [x] Rollback path is clear for risky changes ## Related Issues N/A
2026-09-10 12:42:09 +00:00
assert [(kind, services.provider) for kind, services in seen] == [("hook", lent), ("tool", lent)]
fix(tools): an array sent as its own JSON is still an array ## Summary Reported as "deliver_files is broken". It is not: **the tool never ran.** Every `deliver_files` call on one install was refused before dispatch -- five in a row in a single session -- and nothing was ever delivered: ``` Error: Invalid parameters for tool 'deliver_files': files should be array ``` What the model sent was the array, spelled as a string: ```json {"files": "[{\"path\": \"...poster.png\", \"title\": \"...\"}]", "message": "..."} ``` `cast_params` already forgives that spelling for every scalar type -- `"3"` for an integer, `"true"` for a boolean -- and did not for arrays or objects, which are exactly the types a model is most likely to stringify. ## Type - [x] Fix - [ ] Feature ## The edge of the forgiving is the design When the value is a string, try `json.loads`, and take the result **only if it is the type the schema asked for**. A string that is not JSON, or is JSON of the wrong shape, is returned unchanged so the validator still names the real problem -- the point is to widen what is accepted, not to swallow a type error. **Nothing here can raise.** Turning "your argument has the wrong type" into a traceback would be worse than the refusal it replaces, so the parse is wrapped and failure falls through. **A `type: "string"` field is never parsed.** JSON is ordinary text in a message body or a file's content, and replacing it would hand the tool something it never asked for. Two independent things prevent it today (the string branch returns before the parse is reached, and the parse only wins on a type match), which is why the case pinning it is a tripwire rather than a load-bearing assertion -- said so in its own docstring rather than left to look like coverage. ## Not just deliver_files Six built-in tools declare an array or object parameter and were all exposed: | tool | parameter | |---|---| | `deliver_files` | `files` | | `ask_user` | `questions` | | `image_generate` | `images` | | `message` | `media` | | `create_playbook` | `skills` | | `video_generate` | `params` | The same failure was already seen from the other side: `acp_client/acp_agent.py` records `update_task_state` and `operations should be array` from a real dispatch. ## Verification ``` make lint-python ruff check + ruff format --check, 1850 files make lint-imports 9 contracts kept, 0 broken pytest tests/ 19,699 passed, 7 failed (all pre-existing, see below) ``` - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [ ] User-facing docs or screenshots -- no user-facing string **End to end, through the real tool**, with the exact payload that failed five times in production: ``` files sent as: str -> [{"path": ".../poster.png", "title": "..."}] returned: Delivered 1 file(s): poster.png (72 B). still "should be array": False registered in the store: True ``` Twelve cases, five mutations, each killing at least one: | mutation | red | |---|---| | drop the whole branch (the old behaviour) | 3 | | raise instead of falling through on a parse failure | 5 | | accept the parse whatever type it yielded | 1 | | do not re-cast the parsed value, so items are not cast | 1 | | widen the tuple to include `string` | **survived -- unreachable** | The last is worth stating rather than hiding: that mutation cannot change behaviour, because the `type == "string"` branch returns earlier and the type check would refuse the result anyway. I also tried moving the new block above that branch, alone and combined with widening the tuple, and neither reddens anything either. The invariant holds by construction; the case that documents it says so. **Pre-existing failures, checked against the base.** 7 failed in the full run, all in `tests/test_security_network.py` (`test_a_redirect_to_a_dangerous_address_is_refused` and siblings). Running that file alone on this same tree gives 4 -- the count is order-dependent -- and the change touches only `raven/agent/tools/params.py` plus a new test file, neither of which `raven/security/network.py` imports. The failures are the box's resolver: it returns poisoned answers roughly half the time, which I measured separately (`en.wikipedia.org` came back as `2001::1` on 3 of 6 lookups). Not introduced here, and worth someone's attention on its own. ## Risk - [x] Security impact considered -- widens what reaches a tool's own validation, not what bypasses it. A parsed value is still validated against the same schema, and a parse that yields the wrong type is refused exactly as before - [x] Backward compatibility considered -- a call that worked before takes the identical path; the new branch is reached only by a `str` where an array or object is declared, which previously always failed - [x] Rollback path is clear -- single-commit revert ## Related Issues N/A ## Swept `mr-review-patterns` pre-submit sweep, over `git diff origin/main...HEAD`. - **1 (a write location moved)** -- nothing moved; a branch was added to an existing dispatch on `target_type`. Grepped every caller of `cast_params`: the registry is the only one, and it runs `validate_params` right after, which is the reader this affects. - **2 (a value with several entry points)** -- the cast is the single funnel every tool argument passes through, which is why the fix belongs here and not in `deliver_files`. - **3 (a guard)** -- checked both directions: what it wrongly lets through (JSON of the wrong type, non-JSON text -- both refused, with cases) and what it wrongly refuses (a real list, unaffected, with a case). - **4 (tests)** -- five mutations above, one honestly reported as unreachable. Failing-ID sets diffed against the base rather than counts. - **6 (stale text)** -- the module docstring enumerated what is coerced ("a string that should be an integer"); it now names arrays and objects too. Grepped the tracked tree for other statements of the rule: none. - **9 (error handling)** -- the new path adds one way to end and it is caught: `json.loads` raises `ValueError` on bad text and `TypeError` on a non-string, and both fall through to the untouched value. - **11** -- `git ls-files | grep -c node_modules` is 0; the commit-message gate was run, not eyeballed. Not applicable, with reasons: **3b, 3c, 3d, 3e** (no tool schema produced, no state moved, one lane, no assertion lost its symbol); **4b, 4c, 4d** (no platform branch, no shell, no rendered number); **5, 5b** (no dependency; `json` is stdlib and already imported across this package); **6b, 6c** (no backup, no generated artifact); **7, 7b** (nothing on disk); **8** (no asset, no secret); **10** (no prompt text). ## Deliberately not fixed The error text still ends with `[Analyze the error above and try a different approach.]`, and the model plainly did not -- it sent the same shape five times. A message naming the expected spelling (`files must be a JSON array, not a string containing one`) would give it something to act on. That is a change to the registry's error surface, affects every tool, and deserves its own argument. ## Moved from !594 Opened on a compliant source branch. AGENTS.md 2.1 asks for a 3-5 word snake_case description and the previous branch had seven; GitLab cannot change an existing merge request's source branch, so the change moves rather than the name. Same commits, rebased onto `c2a9768f`. Both code findings from the review on !594 are already in them -- `RecursionError` caught with its regression case, and the implementation comment reduced to the two non-obvious reasons. Nothing else changed, so that review carries.
2026-09-09 15:42:36 +00:00
def test_no_provider_lends_none(self, tmp_path: Path) -> None:
seen: list = []
build_plugin_hooks(tmp_path, _config(), registry=_GrantWatch(seen))
feat(ui-tui): tool cards open themselves, the strip marks here, ticker words split ## Summary Three reader-facing changes to the TUI transcript and the instance strip. **A settled tool call opens itself.** A tool card had two states, shut and full, and neither is what a reader wants by default: shut hides the result that was the point of the call, full spends a thousand rows on a result five rows would have answered. There are now three levels - shut, a preview capped at `TOOL_PREVIEW_ROWS` result rows with a `+N` row standing for the remainder, and full at `TOOL_FULL_ROWS`. The cap is what bounds the cost, so a call that came back opens unasked and only a call that returned nothing stays shut, its block being the argument the row above already shows. A reader's own decision always wins over that default. The `+N` row becomes its own two-way control: it reveals the rest, then folds back to the cap, where the block's own click shuts the card outright. It used to ride inside the output array, which made the one row announcing there was more to see the row that collapsed the card. Fold state moves out of the component that draws it into a store keyed by tool call id. Held in the row's component state, a row that changed - a step landing in a turn still running - unmounted and took the reader's decision with it, so a card opened seconds ago closed itself. `useMainApp` now reads that store when it measures: a resize drops every measured height because the cache buckets on columns, so without the folds there, rows below the fold came back at their default height and the transcript scrolled to the wrong place. **The strip marks the row whose conversation is on screen.** The composer's top border names the instance being typed to, and the strip listed every instance without saying which of them that was. The active row now carries a gutter bar in the strip's own leftmost column, where nothing else draws, so the bar reads as a position and the bullet beside it goes on saying status alone. The active row is exempt from every cap, and a line no click can switch to - a graph line, a loose spawn - never carries it. An interrupted turn also refreshes the instance registry now: `message.complete` already did, but the manager moves the row on this path too, writing `cancelled` or `failed`, so without the re-read an interrupted instance went on showing a filled bullet while its view went on polling a turn that had ended. **The censored ticker vocabulary splits from Raven's own.** Wrapped agents render their status as a kaomoji plus a verb, some of it on the channel the reasoning arrives on, and `cleanThinkingText` strips exactly that pair - but it was reading its strip list off Raven's own `FACES` and `VERBS`. That made the two one list, so a branding change silently changed what gets censored out of a model's reasoning: rename a verb and the old word stops being stripped, adopt a word another agent uses and Raven's own ticker starts eating itself. `tickerNoise.ts` now holds that vocabulary, frozen and deliberately separate; it describes other agents' output and changes only when one of them does. `FACES` and `VERBS` are then free to move, and they move here: the kaomoji become one bird wearing different expressions, and the verbs are ordered as one round of work rather than by how close the words are in meaning, because at one word every 2.5s a reader sees most of the list in a single turn. Each emoji frame is a single code point on purpose - a ZWJ sequence or a variation selector renders as two glyphs on terminals that do not compose it, which shifts everything right of the ticker. ## Type - [ ] Fix - [x] Feature - [ ] Docs - [ ] CI / tooling - [ ] Refactor - [ ] Other ## Verification Run on a worktree at this branch's tip, against the current main tip: - `npx vitest run` (ui-tui): 141 files, 2052 tests passed - `npx tsc --noEmit -p tsconfig.json` (ui-tui): exit 0, no output - `make check-source-language COMMIT_RANGE=origin/main..HEAD`: exit 0 - `make check-large-files COMMIT_RANGE=origin/main..HEAD`: exit 0 No Python source is touched, so no pytest selection applies. `ui-tui/CONTEXT.md` is updated for the fold levels and the gutter bar; the tool-card work carries its design note under `docs/plans/`. - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [x] User-facing docs or screenshots are updated when needed ## Risk Three user-visible changes, all inside the terminal UI: - a tool call that returned something now opens to a capped preview instead of staying shut. A reader who prefers it shut clicks once, and that decision holds for the life of the call. - the instance strip spends one leading column on the gutter bar, so every row has one column less for its name. - the status ticker shows a different set of glyphs and words. No RPC schema, config or on-disk format changes. Fold state lives in memory and per transcript view, so nothing persists across a restart and there is nothing to migrate. The split strip list only widens what is removed from displayed reasoning text; it reads no new input and grants no new capability. Rollback is a revert of the squash commit. - [x] Security impact considered - [x] Backward compatibility considered - [x] Rollback path is clear for risky changes ## Related Issues N/A
2026-09-10 12:42:09 +00:00
assert [(kind, services.provider) for kind, services in seen] == [("hook", None)]
class TestHostToolsGrants:
"""The host side of ``media_proxy``, ``web_config`` and ``media_config``.
The plugin side is tested with a hand-built locator; this is the link nothing
else pins, and the one that was broken: every entrance hands the stack its
``RavenConfig``, whose ``tools`` lives under ``base``, so reading ``tools`` off
the extension object lent None to every deployment.
"""
def test_the_hosts_media_proxy_and_web_section_reach_tools(self, tmp_path: Path) -> None:
seen: list = []
tools = ToolsConfig(
media=MediaGenConfig(proxy="http://127.0.0.1:7890"),
web=WebToolsConfig(proxy="socks5://127.0.0.1:1080"),
)
config = _config(tools=tools)
build_plugin_tools(tmp_path, config, registry=_GrantWatch(seen))
[(kind, services)] = seen
assert kind == "tool"
assert services.media_proxy == "http://127.0.0.1:7890"
assert services.web_config is not None
assert services.web_config() is config.base.tools.web
assert services.web_config().proxy == "socks5://127.0.0.1:1080"
assert callable(services.media_config)
def test_a_host_without_a_proxy_lends_none_and_its_web_section(self, tmp_path: Path) -> None:
seen: list = []
config = _config()
build_plugin_tools(tmp_path, config, registry=_GrantWatch(seen))
[(_, services)] = seen
assert services.media_proxy is None
assert services.web_config is not None
assert services.web_config() is config.base.tools.web
def test_a_base_config_is_read_as_itself(self, tmp_path: Path) -> None:
"""A caller holding the base ``Config`` rather than the extension is read
directly; the two lanes name the same section."""
from raven.core.plugin_stack import _host_config
base = Config(tools=ToolsConfig(media=MediaGenConfig(proxy="http://10.0.0.1:3128")))
assert _host_config(base) is base
assert _host_config(_config(tools=base.tools)).tools.media.proxy == "http://10.0.0.1:3128"
fix(tools): an array sent as its own JSON is still an array ## Summary Reported as "deliver_files is broken". It is not: **the tool never ran.** Every `deliver_files` call on one install was refused before dispatch -- five in a row in a single session -- and nothing was ever delivered: ``` Error: Invalid parameters for tool 'deliver_files': files should be array ``` What the model sent was the array, spelled as a string: ```json {"files": "[{\"path\": \"...poster.png\", \"title\": \"...\"}]", "message": "..."} ``` `cast_params` already forgives that spelling for every scalar type -- `"3"` for an integer, `"true"` for a boolean -- and did not for arrays or objects, which are exactly the types a model is most likely to stringify. ## Type - [x] Fix - [ ] Feature ## The edge of the forgiving is the design When the value is a string, try `json.loads`, and take the result **only if it is the type the schema asked for**. A string that is not JSON, or is JSON of the wrong shape, is returned unchanged so the validator still names the real problem -- the point is to widen what is accepted, not to swallow a type error. **Nothing here can raise.** Turning "your argument has the wrong type" into a traceback would be worse than the refusal it replaces, so the parse is wrapped and failure falls through. **A `type: "string"` field is never parsed.** JSON is ordinary text in a message body or a file's content, and replacing it would hand the tool something it never asked for. Two independent things prevent it today (the string branch returns before the parse is reached, and the parse only wins on a type match), which is why the case pinning it is a tripwire rather than a load-bearing assertion -- said so in its own docstring rather than left to look like coverage. ## Not just deliver_files Six built-in tools declare an array or object parameter and were all exposed: | tool | parameter | |---|---| | `deliver_files` | `files` | | `ask_user` | `questions` | | `image_generate` | `images` | | `message` | `media` | | `create_playbook` | `skills` | | `video_generate` | `params` | The same failure was already seen from the other side: `acp_client/acp_agent.py` records `update_task_state` and `operations should be array` from a real dispatch. ## Verification ``` make lint-python ruff check + ruff format --check, 1850 files make lint-imports 9 contracts kept, 0 broken pytest tests/ 19,699 passed, 7 failed (all pre-existing, see below) ``` - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [ ] User-facing docs or screenshots -- no user-facing string **End to end, through the real tool**, with the exact payload that failed five times in production: ``` files sent as: str -> [{"path": ".../poster.png", "title": "..."}] returned: Delivered 1 file(s): poster.png (72 B). still "should be array": False registered in the store: True ``` Twelve cases, five mutations, each killing at least one: | mutation | red | |---|---| | drop the whole branch (the old behaviour) | 3 | | raise instead of falling through on a parse failure | 5 | | accept the parse whatever type it yielded | 1 | | do not re-cast the parsed value, so items are not cast | 1 | | widen the tuple to include `string` | **survived -- unreachable** | The last is worth stating rather than hiding: that mutation cannot change behaviour, because the `type == "string"` branch returns earlier and the type check would refuse the result anyway. I also tried moving the new block above that branch, alone and combined with widening the tuple, and neither reddens anything either. The invariant holds by construction; the case that documents it says so. **Pre-existing failures, checked against the base.** 7 failed in the full run, all in `tests/test_security_network.py` (`test_a_redirect_to_a_dangerous_address_is_refused` and siblings). Running that file alone on this same tree gives 4 -- the count is order-dependent -- and the change touches only `raven/agent/tools/params.py` plus a new test file, neither of which `raven/security/network.py` imports. The failures are the box's resolver: it returns poisoned answers roughly half the time, which I measured separately (`en.wikipedia.org` came back as `2001::1` on 3 of 6 lookups). Not introduced here, and worth someone's attention on its own. ## Risk - [x] Security impact considered -- widens what reaches a tool's own validation, not what bypasses it. A parsed value is still validated against the same schema, and a parse that yields the wrong type is refused exactly as before - [x] Backward compatibility considered -- a call that worked before takes the identical path; the new branch is reached only by a `str` where an array or object is declared, which previously always failed - [x] Rollback path is clear -- single-commit revert ## Related Issues N/A ## Swept `mr-review-patterns` pre-submit sweep, over `git diff origin/main...HEAD`. - **1 (a write location moved)** -- nothing moved; a branch was added to an existing dispatch on `target_type`. Grepped every caller of `cast_params`: the registry is the only one, and it runs `validate_params` right after, which is the reader this affects. - **2 (a value with several entry points)** -- the cast is the single funnel every tool argument passes through, which is why the fix belongs here and not in `deliver_files`. - **3 (a guard)** -- checked both directions: what it wrongly lets through (JSON of the wrong type, non-JSON text -- both refused, with cases) and what it wrongly refuses (a real list, unaffected, with a case). - **4 (tests)** -- five mutations above, one honestly reported as unreachable. Failing-ID sets diffed against the base rather than counts. - **6 (stale text)** -- the module docstring enumerated what is coerced ("a string that should be an integer"); it now names arrays and objects too. Grepped the tracked tree for other statements of the rule: none. - **9 (error handling)** -- the new path adds one way to end and it is caught: `json.loads` raises `ValueError` on bad text and `TypeError` on a non-string, and both fall through to the untouched value. - **11** -- `git ls-files | grep -c node_modules` is 0; the commit-message gate was run, not eyeballed. Not applicable, with reasons: **3b, 3c, 3d, 3e** (no tool schema produced, no state moved, one lane, no assertion lost its symbol); **4b, 4c, 4d** (no platform branch, no shell, no rendered number); **5, 5b** (no dependency; `json` is stdlib and already imported across this package); **6b, 6c** (no backup, no generated artifact); **7, 7b** (nothing on disk); **8** (no asset, no secret); **10** (no prompt text). ## Deliberately not fixed The error text still ends with `[Analyze the error above and try a different approach.]`, and the model plainly did not -- it sent the same shape five times. A message naming the expected spelling (`files must be a JSON array, not a string containing one`) would give it something to act on. That is a change to the registry's error surface, affects every tool, and deserves its own argument. ## Moved from !594 Opened on a compliant source branch. AGENTS.md 2.1 asks for a 3-5 word snake_case description and the previous branch had seven; GitLab cannot change an existing merge request's source branch, so the change moves rather than the name. Same commits, rebased onto `c2a9768f`. Both code findings from the review on !594 are already in them -- `RecursionError` caught with its regression case, and the implementation comment reduced to the two non-obvious reasons. Nothing else changed, so that review carries.
2026-09-09 15:42:36 +00:00
# ---------------------------------------------------------------------------
# everos plugin presence
# ---------------------------------------------------------------------------
class TestEverosPresence:
def test_the_dev_environment_carries_the_plugin(self) -> None:
assert everos_plugin_installed() is True
def test_an_uninstalled_distribution_reads_as_absent(self) -> None:
with everos_plugin_absent():
assert everos_plugin_installed() is False
def test_a_plugin_that_is_broken_inside_still_reads_as_installed(self) -> None:
"""The two failures a host must not confuse: gone, and here but broken.
A package whose own imports fail is present -- the guard says so, and the
import the caller then makes raises the plugin's own error instead of
being reported as an absence nobody can act on.
"""
with everos_plugin_broken():
assert everos_plugin_installed() is True
with pytest.raises(ImportError):
from raven_everos.health import capability_available # noqa: F401
def test_no_host_module_imports_the_plugin_at_module_level(self) -> None:
"""Every one of these imports has to stay inside a function.
A module-level one fails at ``import raven.cli``, before any guard can
run, and no amount of degrading downstream can recover from that.
"""
root = Path(raven.__file__).parent
offenders = [
f"{path.relative_to(root)}:{node.lineno}"
for path in sorted(root.rglob("*.py"))
for node in ast.parse(path.read_text(encoding="utf-8")).body
if isinstance(node, (ast.Import, ast.ImportFrom))
for name in ([node.module or ""] if isinstance(node, ast.ImportFrom) else [a.name for a in node.names])
if name.startswith("raven_everos")
]
assert offenders == []
def test_the_note_names_the_distribution_and_the_default(self) -> None:
note = everos_plugin_missing_note()
assert "everos-memory" in note
assert "memory.backend" in note
def test_build_plugin_tools_stamps_the_contributing_plugin(tmp_path):
"""[seam-1] The wake grant's namespace comes from this stamp; a plugin
that could name its own namespace could steal another's partition."""
from types import SimpleNamespace
from raven.core.plugin_stack import build_plugin_tools
class _Tool:
name = "t1"
class _Reg:
def tool_names(self):
return ["t1"]
def tool_plugin_id(self, name):
return "plug-a"
def build_tool(self, name, config, services):
return _Tool()
cfg = SimpleNamespace(
memory=SimpleNamespace(user_id="u", agent_id="a"),
plugins=SimpleNamespace(config={}),
)
tools = build_plugin_tools(tmp_path, cfg, registry=_Reg(), provider=None)
assert len(tools) == 1
assert tools[0].contributed_by == "plug-a"
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
class _OnboardReg:
"""A registry stand-in contributing one onboard step."""
def __init__(self, step) -> None:
self._step = step
def onboard_names(self):
return ["everos"]
def onboard_plugin_id(self, name):
return None
def activated_ids(self):
return []
def manifest_for(self, plugin_id):
return None
def build_onboard_step(self, name, *, config, services):
if isinstance(self._step, Exception):
raise self._step
return self._step
def test_build_onboard_steps_yields_every_activated_step(tmp_path):
from raven.core.plugin_stack import build_onboard_steps
step = object()
assert build_onboard_steps(tmp_path, _config(), registry=_OnboardReg(step)) == [("everos", step)]
def test_build_onboard_steps_skips_a_raising_factory(tmp_path, caplog):
from raven.core.plugin_stack import build_onboard_steps
with caplog.at_level("WARNING"):
assert build_onboard_steps(tmp_path, _config(), registry=_OnboardReg(RuntimeError("boom"))) == []
assert "boom" in caplog.text
def test_build_onboard_steps_hands_each_plugin_its_own_config_slice(tmp_path):
"""[mrbot] Two plugins, differently named: A owns backend 'a-backend'
(no onboard screen), B owns both backend and onboard 'b-backend'. B's
onboard step must receive plugins.config['B'], never A's slice --
exercises the fix (resolve via the onboard entry's own plugin id)
directly, independent of the cross-owner case activation now refuses."""
import sys as _sys
import types
from raven.core.plugin_stack import build_onboard_steps
from raven.plugins import (
Contributes,
DiscoveredPlugin,
ManifestOrigin,
MemoryBackendContribution,
OnboardContribution,
PluginManifest,
PluginRegistry,
)
mod = types.ModuleType("_test_onboard_slice_owner")
mod.make_backend_a = lambda ctx: "a"
mod.make_backend_b = lambda ctx: "b"
mod.make_onboard_step_b = lambda ctx: ("step-b", ctx.config)
_sys.modules["_test_onboard_slice_owner"] = mod
try:
mf_a = PluginManifest(
id="A",
version="0.1",
contributes=Contributes(
memory_backends=[
MemoryBackendContribution(name="a-backend", factory="_test_onboard_slice_owner:make_backend_a"),
],
),
)
mf_b = PluginManifest(
id="B",
version="0.1",
contributes=Contributes(
memory_backends=[
MemoryBackendContribution(name="b-backend", factory="_test_onboard_slice_owner:make_backend_b"),
],
onboard=[
OnboardContribution(name="b-backend", factory="_test_onboard_slice_owner:make_onboard_step_b"),
],
),
)
reg = PluginRegistry()
reg.activate(
[
DiscoveredPlugin(manifest=mf_a, source=ManifestOrigin.USER, location=None),
DiscoveredPlugin(manifest=mf_b, source=ManifestOrigin.USER, location=None),
]
)
cfg = _config(
plugin_config={
"A": {"marker": "a-slice"},
"B": {"marker": "b-slice"},
}
)
steps = build_onboard_steps(tmp_path, cfg, registry=reg)
assert [name for name, _ in steps] == ["b-backend"]
_step_name, received_config = steps[0][1]
assert received_config == {"marker": "b-slice"}
finally:
_sys.modules.pop("_test_onboard_slice_owner", None)
fix(core): the memory service stops holding up the first session (#630) ## Summary Two changes against the same symptom: the first session after an install waits on the memory service and then runs without long-term memory anyway. **The wait is unnecessary.** A resident host awaited `backend.start()` at boot, so it held for the readiness budget -- 10s -- before serving anything. The backend already has a state machine for exactly that window: `store` answers False so the loop retries the record, and `recall` returns no hits for that turn and schedules a probe. Waiting for the service before serving the first turn is what the state machine replaced everywhere else. `plugin_stack.start_backend_detached` is the same shape as `warm_up_in_background` for litellm: a resident process starts the slow thing once and goes on serving, and the on-demand path reports a failure to whoever needs it. Three callers take it -- the gateway at boot and at a generation swap, and `raven a2a serve`. The other three keep awaiting, because for them there is no later turn to recover into: an import checks readiness immediately, a sub-agent writes one record, and a one-shot turn exits. It is retired in `Runtime.dispose`, the single point both resident hosts go through. **The wait was also far longer than its budget.** uv does not compile bytecode by default, so the first process to import a module compiles it, and for raven that process is the EverOS service the first session starts. Measured on a fresh isolated install: 22s from spawn to ready, of which 18s elapses before the service writes its first log line. `UV_COMPILE_BYTECODE=1` in the installer moves that into the install, where the user is already watching a progress line. ## Type - [x] Fix - [ ] Feature - [ ] Docs - [ ] CI / tooling - [ ] Refactor - [ ] Other ## Verification Measured on a throwaway install in an isolated `RAVEN_HOME` / `UV_TOOL_DIR` / `UV_TOOL_BIN_DIR`, built from this checkout: - cold first start, as shipped today: 22s spawn to ready (readiness budget 10s) - second start against the same tree: 2.2s - freshly scaffolded root, bytecode already compiled: 2.1s - byte-compiling the rest of that tree: 13.9s for 16756 files, single threaded, so the cost is compilation and it is paid once per machine The detached start was read at the layer that owns the ordering, the gateway's own log. Before this change `Page:` cannot appear until after `everos server ready`; after it: ``` 17 EverosBackend.start 20 Page: http://127.0.0.1:18894 28 started everos server 31 everos server ready ``` The page is serving at line 20 and the child is only spawned at line 28. The interval this removes from the boot measured 5.5s on a machine whose bytecode is already compiled. Commands: - `uv run --frozen --python 3.12 --all-extras pytest tests/test_core_plugin_stack.py tests/test_core_runtime_swap.py tests/test_cli_gateway_commands.py tests/test_cli_a2a_commands.py tests/test_cli_import_commands.py tests/test_memory_backend_protocol.py -q` -- 191 passed after the rebase onto main - the same set plus `tests/test_everos_backend.py` and `tests/test_core_runtime_eval_hooks.py` -- 364 passed - `ruff check raven/ tests/` -- all checks passed - `ruff format --check raven/ tests/` -- 1654 files already formatted - `sh -n install.sh` -- clean Each of the six new cases was mutated to confirm it can fail: dropping the task reference, dropping the done-callback, making the cancel a no-op, and removing the cancel from `dispose`. Every mutation turned the case that names that behaviour red, and the source was restored and hash-compared afterwards. - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [ ] User-facing docs or screenshots are updated when needed ## Risk User-visible change: a resident host now serves its first turn before the memory service has answered. A turn that arrives in that window gets no recall, and its record is retried rather than lost. Previously the host waited and, when the wait overran, that session had no memory at all -- so the window is narrower than what it replaces, not wider. The installer now compiles bytecode, which makes an install slower by roughly the compile time and larger by the `.pyc` tree. Rollback: both commits are independent and revert cleanly. Reverting the first restores the awaited start; reverting the second restores the uncompiled install. - [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:46:12 +08:00
class TestStartBackendDetached:
"""The resident hosts start the memory backend without waiting on it.
Awaited, the start held every resident boot for the readiness budget --
10s on a machine whose first everos start has to compile its bytecode --
and a session that overran it reported no long-term memory while the child
was still coming up. Detached, the backend's own state machine covers that
window: ``store`` answers False so the loop retries, ``recall`` returns no
hits and schedules a probe.
"""
@pytest.mark.asyncio
async def test_the_caller_is_not_held_until_the_start_finishes(self) -> None:
"""The whole point: control comes back before ``start()`` is done."""
import asyncio
from raven.core.plugin_stack import start_backend_detached
released = asyncio.Event()
finished = asyncio.Event()
class _SlowBackend:
async def start(self) -> None:
await released.wait()
finished.set()
start_backend_detached(_SlowBackend(), logger=logging.getLogger(__name__))
# Still blocked inside start(), and we are already here.
assert not finished.is_set()
released.set()
await asyncio.wait_for(finished.wait(), timeout=2)
@pytest.mark.asyncio
async def test_the_task_is_held_so_it_cannot_be_collected_mid_flight(self) -> None:
"""asyncio keeps only a weak reference; a dropped task is a lost start."""
import asyncio
import gc
from raven.core import plugin_stack
gate = asyncio.Event()
ran = asyncio.Event()
class _Backend:
async def start(self) -> None:
await gate.wait()
ran.set()
plugin_stack.start_backend_detached(_Backend(), logger=logging.getLogger(__name__))
gc.collect()
assert any(t is not None for _b, t in plugin_stack._PENDING_BACKEND_STARTS), "the in-flight start was not held"
gate.set()
await asyncio.wait_for(ran.wait(), timeout=2)
await asyncio.sleep(0)
assert not plugin_stack._PENDING_BACKEND_STARTS, "a finished start was not released"
@pytest.mark.asyncio
async def test_a_start_that_raises_is_logged_and_not_re_raised(self) -> None:
"""The three call sites all swallowed it; the helper owes them the same."""
import asyncio
from raven.core import plugin_stack
class _Failing:
async def start(self) -> None:
raise RuntimeError("no service here")
logged: list[str] = []
class _Logger:
def exception(self, msg: str) -> None:
logged.append(msg)
plugin_stack.start_backend_detached(_Failing(), logger=_Logger())
for _ in range(20):
await asyncio.sleep(0)
if logged:
break
assert logged and "memory backend start failed" in logged[0]
@pytest.mark.asyncio
async def test_no_backend_is_nothing_to_do(self) -> None:
"""``backend`` is None when no memory plugin is wired."""
from raven.core import plugin_stack
plugin_stack.start_backend_detached(None, logger=logging.getLogger(__name__))
assert not plugin_stack._PENDING_BACKEND_STARTS
@pytest.mark.asyncio
async def test_cancel_retires_a_start_still_in_flight(self) -> None:
"""A start left running polls an address for a generation that is gone."""
import asyncio
from raven.core import plugin_stack
entered = asyncio.Event()
cancelled = asyncio.Event()
class _Hanging:
async def start(self) -> None:
entered.set()
try:
await asyncio.sleep(30)
except asyncio.CancelledError:
cancelled.set()
raise
backend = _Hanging()
plugin_stack.start_backend_detached(backend, logger=logging.getLogger(__name__))
await asyncio.wait_for(entered.wait(), timeout=2)
await plugin_stack.cancel_pending_backend_starts(backend)
assert cancelled.is_set(), "cancel returned before the start had left"