Raven-1/docs/memory-plugin-architecture.md
zhanghui 16784d3a1e
build(*): upgrade everos and the memory plugin to 1.4.2 (#950)
## Summary

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

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

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

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

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

## Type

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

## Verification

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

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

make lint-types                           -> all checks passed

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

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

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

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

## Risk

User-visible change: memory searches stop queueing behind background
writes,
and a long-lived server stops leaking file descriptors. An existing
index pays
one read pass on the first start after the upgrade.

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

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

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

## Related Issues

N/A

---------

Co-authored-by: gloryfromca <23442919+gloryfromca@users.noreply.github.com>
Co-authored-by: Claude (claude-opus-5) <noreply@anthropic.com>
2026-10-15 11:01:45 +08:00

34 KiB

Memory Plugin Architecture & EverOS as a Bundled Backend

Design record (2026-06, pre-v0.2.0). The bundled-in-tree layout described here was superseded: EverOS now ships as its own distribution under plugins-dist/everos-memory/ -- see the Plugins entries in CONTEXT.md for current terms.

Status legend: [DONE] implemented on feature/integrate-everos · [PLAN] proposed.

This document consolidates the memory subsystem design: the refactored MemoryBackend contract, the plugin discovery model, EverOS shipped as a built-in (bundled) plugin, how third-party backends integrate, and the EverOS version-pinning / upgrade procedure.


1. Goals

  1. EverOS works out of the box with no extra install step.
  2. Adding a memory backend (first- or third-party) requires no host code change — drop a manifest + factory, or uv add a package.
  3. Heavy backend dependencies never slow or break startup: discovery reads manifests only and never imports backend code until selected.
  4. Behaviour is typed and predictable, with graceful degradation.

Key judgement: the plugin framework under raven/plugin/ already provided the machinery (four-source discovery + manifest contract + typed Protocol). The work was to (a) wire the dormant directory sources into the live boot and (b) move EverOS in-tree under raven/plugin/memory/everos/ — no new mechanism.


2. The MemoryBackend contract [DONE]

raven/contracts/memory.py defines the single Protocol every memory plugin implements. The recall surface was refactored from a single prefixed opaque owner_id to explicit XOR track ids:

class MemoryBackend(Protocol):
    async def recall(self, query: str, *,
                     user_id: str | None = None,
                     agent_id: str | None = None,
                     top_k: int) -> list[Memory]: ...
    async def store(self, session_id: str, messages: list[dict]) -> bool: ...
    async def feedback(self, signals: dict) -> None: ...   # may be no-op
    async def start(self) -> None: ...
    async def stop(self) -> None: ...
    async def health(self) -> BackendHealth | None: ...   # doctor + import

Contract rules:

  • recall takes exactly one of user_id / agent_id (XOR). The caller knows the track statically: the # Memory segment always passes user_id; BackendSkillSource always passes agent_id. Neither/both set → return [].
  • Ids are bare, backend-native strings — no user: / agent: prefix parsing. Dual-track backends (EverOS) route the set field to the matching store; flat backends (mem0, MemOS) use user_id and return [] for the agent_id call.
  • Rationale for naming the track explicitly: the prefix convention smuggled the host's dual-track concept through an intentionally generic field. Each caller already knows its track at construction, so the prefix was redundant indirection.

Identity consistency

recall is the read side and store is the write side, and they must agree on identity or stored memory is unretrievable. That is enforced structurally rather than asked of the user: memory.userId and memory.agentId are the only place either id lives, and the host hands both to the backend through ctx.services.

Host config Reaches the backend as
memory.userId ctx.services.user_id
memory.agentId ctx.services.agent_id

A backend must not read an id from its own plugins.config[<id>] slice. Two places holding the same value is what allowed a user to edit one of them and split writes from reads, and nothing warned: recall simply returned nothing forever. The everos backend logs a warning if those obsolete keys are still present and disagree.


3. Plugin discovery model [DONE]

raven/plugins/discover.py scans four sources and deduplicates by plugin id. Discovery reads manifests only — it never imports backend code. build_plugin_registry (raven/core/plugin_stack.py) wires all four via the shared plugin_discovery_sources() helper, which the raven plugins CLI command reuses so both see the same set.

Sources & priority

Source doubles as conflict priority (higher wins):

Priority Source Location Audience
4 BUNDLED raven/plugin/memory/<id>/ first-party, ships with raven
3 USER ~/.raven/plugins/<id>/ local drop-in
2 PROJECT ./.raven/plugins/<id>/, and every root in plugins.dirs per-project
1 ENTRY_POINTS pip pkg, group raven.plugins third-party distribution

bundled > user > project > entry_points enforces the "builtin shadow rule": a bundled backend can never be silently shadowed by a same-id local or pip copy. Different ids never conflict — they coexist as available contributions; the active one is chosen by memory.backend.

Manifest

Each plugin dir/package ships raven-plugin.toml:

[plugin]
id           = "everos-memory"
version      = "1.0.0"
bundled      = true

[[plugin.contributes.memory_backends]]
name    = "everos"
factory = "raven.plugin.memory.everos.backend:make_backend"

Why manifest-only discovery matters

Discovery parses TOML; it does not import the backend. A backend with a missing heavy dependency (lancedb, mem0ai) therefore cannot break discovery for every other backend. The factory module is imported only when memory.backend selects that backend — so "ships by default" never means "pays the import/startup cost by default".

Caveat: _scan_entry_points resolves a package's manifest via importlib.resources.files(pkg), which executes that package's __init__.py. Plugin packages (and the bundled everos/__init__.py) must stay empty/cheap and must not import their heavy substrate there.


4. EverOS as a bundled plugin [DONE]

The EverOS adapter lives in-tree at raven/plugin/memory/everos/, discovered via the bundled source — no separate package to install.

4.1 Layout

raven/
  plugin/                         # plugin framework + bundled implementations
    discover.py registry.py …     # framework (unchanged)
    memory/
      __init__.py                 # cheap
      everos/
        __init__.py               # cheap (touched by resource resolution; no heavy import)
        backend.py                # EverosBackend + make_backend
        tools.py                  # understand_media tool
        multimodal.py
        raven-plugin.toml      # manifest (ships as package-data)

The bundled memory implementations live under the existing raven/plugin/ package (not a separate top-level plugins/), so there is a single, unambiguous home for both the framework and the backends it loads.

4.2 What moved, what stays

Item Disposition Why
raven_everos adapter code moved into raven/plugin/memory/everos/ thin adapter; no heavy logic enters the host
everos[multimodal] substrate stays a direct raven dependency heavy deps stay isolated in the pip package; adapter only delegates
httpx stays (already a dep) http-mode client reuses it
raven_everos package / uv workspace member / its entry_points removed code is now built-in; no separate distribution

Manifest factory path changed from raven_everos.backend:make_backend to raven.plugin.memory.everos.backend:make_backend.

4.3 Dependency & packaging changes (pyproject.toml)

Removed: raven-everos>=1.0.0,<2.0.0; [tool.uv.workspace]; [tool.uv.sources] raven-everos.

Added to the hatchling wheel include allowlist so bundled manifests ship in the wheel (hatchling include is an explicit allowlist; the .toml is not matched by raven/**/*.py):

[tool.hatch.build]
include = [
    "raven/**/*.py",
    "raven/plugin/**/raven-plugin.toml",
    ...
]

Kept: everos[multimodal]==1.0.0, httpx — the relocated adapter reuses them, so no new runtime dependency was introduced.

4.4 Host wiring

plugin_discovery_sources() resolves the four source locations; both build_plugin_registry and the raven plugins CLI use it:

import raven
return {
    "bundled_dir": Path(raven.__path__[0]) / "plugin" / "memory",
    "user_dir": Path.home() / ".raven" / "plugins",
    "project_dir": Path.cwd() / ".raven" / "plugins",
    "entry_points_group": "raven.plugins",
}

Wheel resource path: a normal pip/uv install extracts raven to real directories, so raven.__path__[0] is a usable Path. Only zipimport (running from a .pyz) would need importlib.resources.as_file materialization.

4.5 User-facing impact

None. Selection stays memory.backend = "everos"; config stays under plugins.config["everos-memory"]. EverOS moving from "external plugin" to "built-in plugin" is transparent.


5. Adding a new backend (drop-in contract)

A backend is integrated through any of three channels; the contract is identical: ship raven-plugin.toml declaring a memory_backends contribution (name + factory) + a factory returning a MemoryBackend.

Two more surfaces are optional. A [[plugin.contributes.onboard]] entry (name + factory returning an OnboardStep) gives the backend a screen in raven onboard: the host lends the wizard shell as one OnboardUI and records memory.backend from the StepOutcome the step returns. Implementing MemoryBackend.health() lets raven doctor and raven import diagnose the backend through the contract alone, without the host importing it ahead of selection.

Channel Where "Install" Dependencies
pip + entry_points (recommended) standalone package uv add <pkg> package declares its own (e.g. mem0ai)
user drop-in ~/.raven/plugins/<id>/ copy the dir user must provide deps
project drop-in ./.raven/plugins/<id>/ checked into project user must provide deps

Example: a mem0 backend via pip + entry_points

raven-mem0/
  pyproject.toml          # [project.entry-points."raven.plugins"] mem0 = "raven_mem0"
  src/raven_mem0/
    __init__.py           # empty/cheap
    backend.py            # make_backend + Mem0Backend(MemoryBackend)
    raven-plugin.toml  # id="mem0-memory", contributes memory_backends name="mem0"
class Mem0Backend:  # structurally a MemoryBackend
    async def recall(self, query, *, user_id=None, agent_id=None, top_k):
        if user_id is None:        # flat backend: no agent track
            return []
        hits = self._m.search(query, user_id=user_id, limit=top_k)
        return [Memory(text=h["memory"], score=h.get("score", 0.0),
                       metadata={"id": h.get("id")}) for h in hits["results"]]
    # store / feedback / start / stop ...

def make_backend(ctx) -> MemoryBackend:
    return Mem0Backend(ctx)

Install + activate:

uv add raven-mem0          # mem0ai pulled transitively; entry_points auto-discovered
"memory":  { "backend": "mem0", "userId": "user-raven", "memoryTopK": 5 },
"plugins": { "config": { "mem0-memory": { "mem0_config": { "...": "..." } } } }

Multiple backends coexist; memory.backend picks one; plugins.disabled turns one off. An installed-but-unselected backend's code is never imported.


6. Lifecycle & failure semantics

  • Discovery: cheap, manifest-only.
  • Construction: lazy — make_backend(ctx) runs only for the selected backend. ctx carries config (the plugins.config slice), services, logger.
  • Lifecycle: host calls start() once at boot but may not await it before the first turn -- recall and store must tolerate being called while start is still running -- and calls stop() at shutdown.
  • Failure contract (raven/contracts/memory.py): a session host -- the agent loop, the TUI, the gateway, raven serve -- wraps every call into a backend and treats a raise as the loss of that one call: recall counts as no hits, store as not landed, start as no long-term memory for this session, feedback and stop as logged and ignored. raven import is the deliberate exception: nothing wraps start or stop there, so a raise in either ends the command, and a store that raises or returns False fails that one source and leaves it unsubmitted for a retry rather than passing as not landed. A backend that can classify its own failures (a timeout is not a refused connection) should catch and act on them, because the host cannot.
  • Factory raises: maybe_build_memory_backend catches and falls back to no backend (core MemoryStore still works).
  • Drop-in dep missing: that backend's construction fails and is skipped; other backends are unaffected.

7. EverOS version pinning & upgrade SOP

7.1 Exact pin is mandatory [DONE: everos[multimodal]==1.4.2]

The adapter is written against EverOS internal APIs, not a stable public surface:

  • everos.service.search.search, everos.service.memorize.memorize
  • everos.memory.search.dto.SearchRequest
  • everos.entrypoints.api.app.create_app (embedded lifespan)
  • everos.memory.extract.parser, everos.component.llm.client
  • everos.config.load_settings; and for drain in tests/scripts: everos.service.memorize._get_engine, everos.infra.persistence.sqlite.md_change_state_repo

Any release — even a patch — can move these symbols. Therefore EverOS is pinned to an exact version (==X.Y.Z), not a range: upgrades are deliberate, re-validated events, never something uv lock --upgrade can do silently.

Single pin: EverOS is pinned in one place, the plugin's own plugins-dist/everos-memory/pyproject.toml. The upgrade surface is one line.

7.2 Upgrade procedure

  1. Assess: read the EverOS changelog; check whether the internal symbols above moved, and whether the on-disk schema (~/.everos/.index/ sqlite + lancedb) changed.

  2. Bump the pin (uv only — never hand-edit pyproject/lock):

    uv add --package everos-memory 'everos[multimodal]==1.4.2' && uv sync
    

    Always keep the [multimodal] extra. Skip 1.2.0: it shipped a path-traversal regression fixed in 1.2.1.

  3. Adapt the adapter if symbols/signatures changed — only raven/plugin/memory/everos/. Re-check version assumptions written in adapter comments.

  4. Test (all three layers):

    uv run pytest tests/test_everos_plugin_discovery.py tests/test_everos_backend.py \
      tests/test_everos_http_adapter.py tests/test_memory_backend_protocol.py \
      tests/test_memory_backend_contract.py -q          # unit (mock adapter)
    uv run pytest tests/integration/test_everos_backend_e2e.py -m real_llm  # real
    
  5. Data migration (major bumps only): if the schema changed, real ~/.everos/.index/ may need rebuild/migration per the changelog. Tests use per-test tmp roots and are unaffected.

    Migrations can be one-way, and reverting Raven does not undo them. 1.2.1 is the standing example: on its first start it migrates the LanceDB schema and prunes older manifest versions, so a machine that has run 1.2.1 keeps that on-disk shape after a git revert of the pin. Rolling back the data means restoring ~/.everos/ from a copy taken before the upgrade — so take one, and say so in the release notes for any bump whose migration behaves this way. An upgrade whose only record is a pull-request description is known to whoever read that description.

  6. Finalize: set the plugin's own version to the EverOS version it pins — the two are read together, and a plugin 1.4.0 that ships EverOS 1.4.1 only invites the question which of them a given install has. Three files carry it: pyproject.toml, raven_everos/raven-plugin.toml, raven_everos/__init__.py. Two tests assert it as a literal and must be updated with it — test_everos_plugin_discovery.py::TestPackageSurface::test_imports_clean and test_cli_plugin_commands.py::TestActiveBackend::test_lists_everos_memory. Then commit pyproject.toml + uv.lock + adapter changes. Rollback = git revert (plus data restore if the schema changed — see step 4).

7.3 Record: 1.2.1 -> 1.2.3

Four packages moved: everos, everalgo-agent-memory 0.3.1 -> 0.4.0, everalgo-user-memory 0.3.2 -> 0.4.0, and lancedb 0.33.0 -> 0.34.0.

No data migration. No LanceDB table schema changed: user_profile and knowledge_topic are byte-identical between the two releases, and the five files that differ at all (episode, atomic_fact, agent_case, agent_skill, foresight) differ only in docstrings. So the startup schema check that 1.2.2 extended to column types does not fire on an index this upgrade produced. 0.33 and 0.34 were verified compatible in both directions — each writes Lance file format v2.1, and a table written by either opens, searches (over the other's IVF and FTS indexes), upserts and prunes under the other — so reverting the pin can still read the index. Step 4's backup is cheap insurance, not a precondition.

The Linux floor moved to glibc 2.28. lancedb 0.34.0 ships no manylinux_2_17 wheel and no sdist, so CentOS/RHEL 7, Ubuntu 18.04 and Amazon Linux 2 can no longer install. install.sh hands the exported lockfile to the user's uv as constraints, which makes this an install-time hard failure rather than a slow source build.

Two behaviour changes. extract_foresight now ships disabled, and because the default moved in code rather than in default_ome.toml an existing ~/.everos/ome.toml does not opt out of the change; re-enable it per install. Agent-skill extraction works for the first time — before 1.2.3 a cascade race meant it produced zero SKILL.md files — so BackendSkillSource starts contributing real skills to the prompt instead of nothing.

Two known gaps, not addressed here. On exhausting a supervised loop's restart budget the server now SIGTERMs itself, expecting a process supervisor; raven spawns it once per session and _SPAWNABLE_STATES deliberately excludes FAILED, so memory stays off until the session restarts. And everos cascade rebuild, now the supported index recovery, refuses to run while a server holds the OME lock — while raven exposes no way to stop the server it started.

7.4 Record: 1.2.3 -> 1.4.1

Five packages moved: everos 1.2.3 -> 1.4.1, pyarrow 24.0.0 -> 25.0.1 (EverOS's new floor), everalgo-boundary 0.2.0 -> 0.2.1 and everalgo-core 0.4.0 -> 0.3.0 (EverOS now pins its everalgo transitive layer with ==, so the resolver follows it down), and msvc-runtime joins on win32 only. lancedb stays at 0.34.0.

No adapter change. Every internal symbol the adapter reaches (MemoryRoot, episode_repo / agent_skill_repo, EpisodeWriter / AgentSkillWriter, the init_cmd templates, the multimodal parser and client, the two error classes) is present in 1.4.1 with the same signature.

No data migration. A copy of a 46 MB store written by 1.2.x (568 episodes, 5528 atomic facts, seven LanceDB tables at table schema version 2) started under 1.4.1 with no schema complaint and a healthy cascade. The same keyword searches returned the same ids in the same order on both versions; BM25 scores drift in the third decimal place. First start builds an IVF_FLAT index on any vector column past 2000 rows (atomic_fact here) -- seconds, and searches keep working meanwhile. A real turn through raven then wrote a new episode into that store and a fresh session recalled it, alongside episodes written months earlier under 1.2.x. Rollback was not exercised this time; lancedb did not move, so the file format is the one 1.2.3 already reads.

A running server from before the upgrade is replaced. raven used to reuse whatever answered on the configured port, so an EverOS 1.2.3 left running kept serving after the pin moved, with every surface green. ensure_everos_server now reads the running server's /health version and, for a root raven owns, sends a mismatch through the same precheck / stop / spawn chain a rotated credential takes (stale_reason). A root the user manages is theirs to restart. everos cascade sync, cascade fix --apply and cascade rebuild refuse to run beside a running server (exit code 3).

Windows. 1.4.0 runs natively on Windows, so the platform gate raven carried (everos_platform_note, ServiceState.UNSUPPORTED, the wizard's WSL notice) is gone and _everos_executable looks for everos.exe there. Spawning, probing and reusing the server were already portable. Identifying and stopping a stale server was not: _cmdline_of asked ps, and the marker everos server start never matched a Windows command line, which prints the executable as ...\Scripts\everos.exe server start. The command line now comes from WMI through PowerShell on win32 and the marker accepts both shapes; the pidfile raven writes at spawn already named the pid. Verified on a Windows 11 box: a changed memory role sent the running server through "holds credentials raven has since changed; restarting", the old pid exited and the new one answered /health. _listening_port asks the TCP table through PowerShell there (no lsof, no /proc), walking the launcher's descendants because the socket belongs to the base interpreter two launchers below everos.exe. The stop is Ctrl-Break: the child is spawned in a process group of its own (CREATE_NEW_PROCESS_GROUP, the Windows counterpart of start_new_session, and what keeps a Ctrl-C at the gateway off the server), uvicorn takes the event as a shutdown, and a server that has not acted on it in ten seconds -- one another console started, which the event cannot reach -- gets TerminateProcess, the stop every server there had before. Verified on the same box: a stop from the spawning console runs the full uvicorn shutdown (Shutting down ... Finished server process) in three seconds; a stop from another console falls back and the process is gone in two.

The upgrade helper sweeps the environment on Windows. Windows cannot replace an executable that is running, and the server outlives the gateway by design, on the environment's own python: with it up, uv failed to replace Scripts\everos.exe (os error 32). After waiting for the parent, the helper now stops every process whose executable lives under the tool environment -- that directory and nothing wider -- and only then installs. Verified on the box: the same reinstall that failed with the server up succeeds after the sweep, and the relaunched gateway spawns a fresh server.

What a six-angle review of the branch then changed. Each item is a scenario a real install can reach; the rule behind them is that memory degrades with a notice and never blocks a turn, a start or an upgrade.

  • A gateway starts the server again when it finds nothing listening (EverosBackend._may_respawn / _respawn): only for a root raven owns, only when no child of its own still runs, only when nothing holds the OME lock, at most once per thirty seconds. Before, the only spawn was in start(), which a running gateway never passes through again, so a server that went away -- an upgrade's sweep, a crash, a stop another process sent -- left the gateway without memory until it was restarted by hand.
  • A stop that was sent and did not finish (STILL_DRAINING: uvicorn closes the port at once and finishes the requests it had, an extraction included) is no longer adopted by ensure_everos_server; it raises, the backend keeps probing, and the probe above starts a replacement once the lock is free. Adopting it reported memory over a process that no longer answered.
  • A command-line lookup that failed (_cmdline_of -> None: no ps, PowerShell blocked, WMI wedged, the timeout hit) is distinct from a process that is gone. A stop keeps waiting on it; lock_holder identifies nothing; restart_for_config_change reports "could not be identified" instead of applied when something still answers on the address.
  • A spawn that loses the boot race no longer overwrites the pidfile of the live server (_start_server_if_unlocked): on Windows the pidfile is the only way back to it.
  • stop_pid counts wall time (each Windows poll launches PowerShell) and takes a grace; on Windows a backend drains the server it started itself at stop() (Ctrl-Break, sixty seconds), so an upgrade finds nothing to terminate mid-write and a settings change restarts it cleanly.
  • The helper's sweep asks again after Stop-Process and refuses to run uv while anything from the environment survives (elevated or another user's process): uv tool install --force removes the environment before it writes, and would have left every file but the one that could not go.
  • An embedding pin narrower than the index is measured at backend start (configured_embedding_width, once per pin per process) and withheld from the spawn (withhold_role): EverOS runs keyword recall and keeps storing, and the notice names the model and the width. The write-time check covers a pin written through raven; this covers one written around it. The probe no longer raises on an odd response, times out at ten seconds, and an install with the plugin on plugins.disabled is not gated. migrate_roles runs off the event loop, which the probe had put a provider round-trip onto.
  • The memory page calls the /api/v2 routes (v1 is EverOS's legacy alias), asks /health before a search the way the chat adapter does (keyword without embedding, the LLM rerank on the agent track without a cross-encoder, the profile opted in), and shows the server's own sentence on a refusal instead of "unreachable".
  • The recalled profile is rendered as lines again: the search response arrives as namespaces, and the renderer, handed one, had put namespace(explicit_info=[namespace(...)]) -- evidence fields included -- into every prompt. A tool-call-only assistant row is stored with empty content, not "None"; top_k is clamped to the server's 1..100; an empty query asks nothing; a /health probe that failed is not cached as "no capabilities" for the life of the adapter.
  • The wizard accepts a model wider than 1024 (EverOS keeps the first 1024, the settings page already accepted it) and turns the host's refusal into a re-prompt rather than a traceback.

One guard added alongside. The live install was found pinned to a 768-dimension embedding model against this 1024-wide index, with every store and search answering 500. set_embedding_endpoint now measures the model's width before writing the pin and refuses anything narrower than REQUIRED_EMBEDDING_DIMENSIONS, but only where the config names EverOS as the memory backend: a knowledge base sizes itself to whatever width the model returns, so an install with memory off or on another backend keeps any width. The wizard's own check reads the same constant and probe.

7.5 Record: 1.4.1 -> 1.4.2

One package moved: everos 1.4.1 -> 1.4.2. EverOS declares the same 36 requirements in both releases, so nothing else in the lock follows it. The plugin's own version goes 1.4.0 -> 1.4.2 rather than 1.4.1: step 5 now holds it equal to the EverOS it pins, and the number this upgrade skips is the gap that rule closes.

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

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

Three faults fixed that a long-lived server hits. A LanceDB index reader leaked file descriptors for the life of the process (capped now by [lancedb] metadata_cache_size_bytes, default 1 MB), an interactive search queued behind the cascade's background embedding (queries draw on [embedding] query_max_concurrent, default 4), and a cascade pass embedded one request per entry instead of one per file. The settings are EverOS's own; raven writes only [api] into everos.toml and copies the shipped template for a root that has none, so an existing root keeps max_concurrent as its own file spells it and picks up query_max_concurrent from the class default behind the file.


8. Validation (this change)

Layer Result
Unit (everos plugin discovery / backend / http adapter, protocol, contract, plugin command/tools, cli plugin stack, context, config, agent-loop backend dispatch + feedback, agent-loop pipeline) 240 passed
raven plugins everos-memory · Source=bundled · Status=activated
real_llm e2e (test_everos_backend_e2e.py) 2 passed, 1 xfailed (best-effort skill-cluster check) — store→extract→recall + dual-track isolation
roundtrip script (new import path) OK; users/user-raven/user.md generated

Known unrelated: the full unit suite cannot run to completion in-process because agent -m calls an unconditional os._exit(0) (agent_commands.py, commit 33b4b0d9, to dodge a torch teardown segfault), which kills the in-process pytest CliRunner. Pre-existing, independent of this refactor.


9. Design decisions & trade-offs

Decision Chosen Rejected Why
Recall track explicit user_id XOR agent_id prefixed opaque owner_id caller knows track statically; prefix was redundant indirection
EverOS code home bundled in-tree (raven/plugin/memory/everos/) external raven_everos package default-available, single upgrade surface; substrate stays an isolated pip dep
Bundled dir location under existing raven/plugin/ separate top-level raven/plugins/ one home for framework + backends; avoids singular/plural ambiguity
Discovery manifest-only (TOML) import-on-scan (Hermes-style) missing deps can't break discovery; no startup cost for unselected backends
EverOS pin exact ==X.Y.Z range >=,< adapter binds internal (non-public) APIs; upgrades must be deliberate
Conflict priority bundled > user > project > entry_points user-overrides-bundled builtin can't be silently shadowed

10. EverOS Cloud as a second backend

plugins-dist/everos-cloud-memory/ (package raven_everos_cloud, backend name everos-cloud) keeps a Raven's memory on the hosted EverOS at https://api.evermind.ai instead of a local server. It speaks the same four routes as the local plugin (/api/v2/memory/{search,add,flush,get}) with a Bearer key, depends on raven and httpx only, and never imports the everos package. Design record: docs/specs/2026-10-08-everos-cloud-memory-design.md.

Topic How it works
Key plugins.config["everos-cloud-memory"].api_key first, EVEROS_CLOUD_API_KEY second; a key that came from the environment is never written to the file. The wizard's screen and the settings page's card both write the slice through set_plugin_config_fields.
Identity memory.userId / memory.agentId, through ServiceLocator, as for every backend. Two machines on one key with the default ids share one memory; the wizard says so.
Extraction every add carries mode: "agent" (the local server runs both pipelines on every add; the cloud defaults to chat). /flush is sent only when the caller says the conversation is over -- metadata["flush"] (the sub-agent handoff) and metadata["is_final"] (the importer's last batch) -- and once per touched session at stop(), within a 5 s budget. Ordinary turns rely on the cloud's own extraction.
Limits adds are split at 500 messages / 250 KB; a single message over the ceiling is not stored and is named in the log.
Health POST /memory/get with page_size: 1; 401, 403, 429, unreachable and "no key" each have their own sentence for raven doctor, the wizard and the card.
Host surfaces the wizard asks "Which memory backend?" when more than one memory plugin is installed; the memory page reads whichever backend memory.backend names (with the Bearer header, without the OSS /health probe); settings.everos answers reason: "other_backend" for any backend that is not EverOS, which hides the llm / rerank / multimodal slots (embedding stays: knowledge bases embed with that pin); settings.everosCloud feeds the card; settings.set admits plugins.config.<id>.<field> only for a field the plugin's manifest marks settable = true (the cloud key; never an endpoint, which decides where that key is sent); a provider save no longer restarts a local EverOS unless EverOS is the backend.
Not shipped by default the release builds the wheel but raven-plugins.txt keeps three distributions until the plugin has run against the live service (tests/integration/test_everos_cloud_real_cloud.py, key-gated).
Not done delete answers False (the cloud deletes by scope, not by id); no understand_media tool (cloud multimodal needs a presigned upload); app_id / project_id stay at the cloud's defaults.

Tests: tests/test_everos_cloud_*.py over tests/_everos_cloud_fake.py, a fake cloud that honours or refuses every field the backend sends and records every request; tests/test_plugin_boundary.py scans both plugin packages.