Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

docs: add README files for schema, doctor, and python_server modules

Steven Enamakel578c21974572
diff --git a/crates/openhuman-core/src/config/schema/README.md b/crates/openhuman-core/src/config/schema/README.md
index 01216287ba..dcb96bf709 100644
--- a/crates/openhuman-core/src/config/schema/README.md
+++ b/crates/openhuman-core/src/config/schema/README.md
@@ -43,7 +43,7 @@ is mounted as a submodule of `load/dirs.rs` via `#[path]`.
| `[runtime_pool]` | `runtime_pool.rs` | `RuntimePoolConfig`, `RuntimePoolLangConfig` |
| `[runtime_python]` | `runtime_python.rs` | `RuntimePythonConfig` |
| `[scheduler_gate]` | `scheduler_gate.rs` | `SchedulerGateConfig`, `SchedulerGateMode` |
-| `[memory]`, `[memory_tree]`, `[storage]` | `storage_memory.rs` | `MemoryConfig`, `MemoryTreeConfig`, `StorageConfig`, `StorageProviderConfig`, `LlmBackend` |
+| `[memory]` (engine, `engines.<id>`, `conversations`, `context`, `sources`, embedding settings) | `memory.rs` | `MemoryConfig`, `MemoryEngineSettings`, `MemoryConversationsConfig`, `MemoryContextConfig`, `MemorySourceConfig` (see `docs/specs/memory-v2.md`) |
| `[subsystems]` | `subsystems.rs` | `SubsystemsConfig`, `MemorySubsystemConfig` |
| `[task_sources]` | `task_sources.rs` | `TaskSourcesConfig` |
| `[tokenjuice]` | `tokenjuice.rs` | `TokenjuiceConfig` |
diff --git a/crates/openhuman-core/src/config/schema/types_model_pin_tests.rs b/crates/openhuman-core/src/config/schema/types_model_pin_tests.rs
index 806d03b8e9..66ee089fee 100644
--- a/crates/openhuman-core/src/config/schema/types_model_pin_tests.rs
+++ b/crates/openhuman-core/src/config/schema/types_model_pin_tests.rs
@@ -177,3 +177,27 @@ fn default_temperature_unsupported_models_suppress_reasoning_families_only() {
);
}
}
+
+/// The v1 learning workload is gone, but configs written by older builds still
+/// carry its keys. They must keep loading (unknown keys are ignored, never an
+/// error) and the surviving workload routes must be unaffected.
+#[test]
+fn config_with_retired_learning_keys_still_parses() {
+ let config: Config = toml::from_str(
+ r#"
+learning_provider = "cloud"
+memory_provider = "ollama:summary-local"
+
+[local_ai]
+runtime_enabled = true
+
+[local_ai.usage]
+embeddings = true
+learning_reflection = true
+"#,
+ )
+ .expect("config with retired learning keys must still load");
+ assert_eq!(config.workload_local_model("memory").as_deref(), Some("summary-local"));
+ assert_eq!(config.workload_local_model("learning"), None);
+ assert!(config.local_ai.usage.embeddings);
+}
diff --git a/crates/openhuman-core/src/platform/doctor/README.md b/crates/openhuman-core/src/platform/doctor/README.md
index c9d6824d4b..f1b31dd585 100644
--- a/crates/openhuman-core/src/platform/doctor/README.md
+++ b/crates/openhuman-core/src/platform/doctor/README.md
@@ -8,7 +8,7 @@ Diagnostic / self-check domain for OpenHuman. Runs a synchronous battery of prob
- Check workspace integrity: directory existence, write probe (create/write/delete a temp probe file), `memory/` dir, `SYSTEM.md` prompt, and best-effort free disk space (warns under 512 MB; uses `df -m` on Unix, PowerShell `Get-PSDrive` on Windows).
- Inspect daemon state file: presence, JSON validity, heartbeat freshness (stale > 30s = error), scheduler component health (stale > 120s), and per-channel component freshness (stale > 300s).
- Probe environment commands: `git --version`, `curl --version`, `$SHELL`, and `$HOME`/`$USERPROFILE`.
-- Probe memory-tree DB: warn on stale `-shm`/`-wal` SQLite side-files or not-yet-created DB; otherwise report the chunk count the bound memory driver answered with (`MemoryMaintenance::store_stats`), taken by `ops::memory_chunk_count` before the blocking hop.
+- Probe the memory engine (`memory_agent_checks::check_memory_engine`): report `ok`, `degraded`, `down` or `off` (memory is off with no usable engine) from the `MemoryEngineCheck` the async caller takes from the memory domain's status before the blocking hop.
- Probe embedding-model health: if provider is `ollama`, do a 3s blocking HTTP GET to `<base_url>/api/tags` and verify the configured model is installed; non-ollama providers report OK without a local probe.
- Probe the Claude Agent SDK: if enabled, run `<binary> --version`.
- Probe provider model availability via `run_models` (currently a stub: see Notes).
@@ -59,7 +59,7 @@ None. No `bus.rs` / event-bus subscribers or publishers.
## Persistence
-None of its own (no `store.rs`). It only **reads** existing state owned by other domains: the daemon state file (`service::daemon::state_file_path`), the memory-tree SQLite DB (`<workspace>/memory_tree/chunks.db`), config files, and `<workspace>/SYSTEM.md` / `<workspace>/memory/`. Its only writes are an ephemeral workspace probe file that is immediately deleted.
+None of its own (no `store.rs`). It only **reads** existing state owned by other domains: the daemon state file (`service::daemon::state_file_path`), the memory engine's status (passed in as `MemoryEngineCheck`), config files, and `<workspace>/SYSTEM.md` / `<workspace>/memory/`. Its only writes are an ephemeral workspace probe file that is immediately deleted.
## Dependencies
@@ -80,8 +80,8 @@ None of its own (no `store.rs`). It only **reads** existing state owned by other
## Notes / gotchas
- `run()` is **strictly blocking** by contract (file system, sqlite, blocking HTTP). `reqwest::blocking::Client` panics inside a tokio runtime, so `ops::doctor_report` runs the whole thing in `tokio::task::spawn_blocking`. Do not add `.await` inside `core::run`.
-- An async probe therefore arrives as an **argument**, resolved in `ops` before the blocking hop: `MemoryChunkCount` is the first of them. Do not reach for `Handle::block_on` inside `core`: it panics on a current-thread runtime and deadlocks the multi-thread one whose worker it is already occupying.
-- The chunk count comes from the bound driver, and a driver that does not serve `Maintenance` is reported as a **failed probe** rather than as zero. That is the opposite of what the `memory_tree` status RPCs do with a missing family, and deliberately so: a status panel is better off showing an empty store than an error, while the doctor exists to name what is wrong: and "0 chunks" from a driver that cannot count is indistinguishable from a store the user has just watched themselves fill.
+- An async probe therefore arrives as an **argument**, resolved in `ops` before the blocking hop: `MemoryEngineCheck` is the first of them. Do not reach for `Handle::block_on` inside `core`: it panics on a current-thread runtime and deadlocks the multi-thread one whose worker it is already occupying.
+- An engine that is down is reported as an error and memory being off as a warning, so the doctor names what is wrong instead of showing an empty store.
- `run_models` / `doctor.models` is effectively a **stub**: it enumerates providers from `inference::provider::list_providers` but marks every entry `Skipped` with message "model catalog refresh removed" (catalog refresh was removed). It never actually probes auth/availability despite the schema description.
- The embedding probe is capped at a 3s timeout to avoid stalling on a slow Ollama daemon; non-ollama providers short-circuit to OK.
- `model_matches` treats `name` vs `name:tag` as a match only when at most one side is tagged; two differently-tagged names are not considered equal.
diff --git a/crates/openhuman-core/src/runtime/python_server/README.md b/crates/openhuman-core/src/runtime/python_server/README.md
index 7313f3ccbe..3839aebb62 100644
--- a/crates/openhuman-core/src/runtime/python_server/README.md
+++ b/crates/openhuman-core/src/runtime/python_server/README.md
@@ -6,15 +6,13 @@ module owns the process lifecycle and wire protocol; interpreter resolution
[`runtime/python`](../python/README.md) client, which this module calls into
to pick the interpreter it launches.
-Two backends currently run inside the one worker process:
+One backend currently runs inside the worker process:
-- **spaCy** (`spacy.rs`): NER extraction for the memory tree's query
- extractor, gated by `config.memory_tree.spacy_enabled`.
- **Kompress** (`kompress.rs`): TokenJuice's ModernBERT/torch plain-text
compressor, gated by `config.tokenjuice.ml_compression_enabled`.
-Both are gated behind `config.runtime_python.enabled`; `registry::enabled_backends`
-computes the active set from all three flags together.
+It is gated behind `config.runtime_python.enabled`; `registry::enabled_backends`
+computes the active set from that flag and `config.tokenjuice.ml_compression_enabled`.
## Key files
@@ -22,9 +20,8 @@ computes the active set from all three flags together.
| --- | --- |
| `mod.rs` | Submodule decls and `pub use` re-exports. |
| `server.rs` | Host side: maps `Config` and the managed interpreter onto a `ServerLaunch`, holds the process-wide `ServerSlot` (`ensure_started`, `status`). The process lifecycle itself (spawn, handshake, request/response, restart-on-failure, idle expiry, start back-off) is `tinyruntime_pyserver::{PythonServer, ServerSlot}`. |
-| `registry.rs` | `RuntimePythonBackend` enum (`Spacy`, `Kompress`) and `enabled_backends(config)`. |
+| `registry.rs` | `RuntimePythonBackend` enum (`Kompress`) and `enabled_backends(config)`. |
| `kompress.rs` | Kompress venv provisioning (`ensure_kompress`, `install_into`, `kompress_provisioned`) and the compress request (`request_kompress`). |
-| `spacy.rs` | spaCy venv provisioning (`ensure_spacy`, `spacy_provisioned`), the extract request (`extract`, re-exported as `extract_spacy`), and `python_server_cache_root`. |
| (`tinyruntime-pyserver`) | Owns the JSONL wire types (`PROTOCOL_VERSION`, request/response/ready-line), the status types (`BackendStatus`, `ServerStatus`, re-exported here as `RuntimePythonServerStatus`) and the worker script itself (`SERVER_SCRIPT`), written to the cache root as `runtime_python_server.py` each time a server is prepared. Library crate in `vendor/tinyruntime`. |
## Lifecycle
@@ -34,9 +31,8 @@ computes the active set from all three flags together.
(`Empty` / `Ready` / `Failed { message, retry_after }`):
- If the enabled backend set has changed since the cached server launched
- (e.g. Kompress toggled on after a spaCy-only start), the cache is discarded
- and a new server is started: the running process was never provisioned for
- the new backend.
+ (e.g. Kompress toggled on or off), the cache is discarded and a new server
+ is started: the running process was never provisioned for the new set.
- If the Kompress backend has been idle longer than
`config.tokenjuice.ml_sidecar_idle_timeout_secs`, the server is torn down and
restarted on the next request, freeing the torch process's memory.
@@ -45,12 +41,7 @@ computes the active set from all three flags together.
- `RuntimePythonServer::request` sends one request, and on failure resets the
child and retries once before giving up.
-`prepare_launch` picks **one** interpreter for the whole worker: if spaCy is
-enabled it owns the venv and Kompress (if also enabled) installs torch +
-transformers into it via `kompress::install_into`; if only Kompress is enabled
-it gets its own dedicated venv via `kompress::ensure_kompress`; if neither
-backend needs a venv the worker still runs under the base interpreter from
-`runtime::python::PythonBootstrap`.
+`prepare_launch` picks the interpreter for the worker: when Kompress is enabled it gets its own dedicated venv via `kompress::ensure_kompress`; otherwise the worker runs under the base interpreter from `runtime::python::PythonBootstrap`.
## Wire protocol
@@ -61,11 +52,66 @@ JSONL over the child's stdin/stdout (`tinyruntime_pyserver::protocol`), one line
mismatch against `PROTOCOL_VERSION`, `ready: false`, or no line within
`HANDSHAKE_TIMEOUT` (30s) fails the launch.
- Requests: `PythonServerRequest { id, method, params }`, methods namespaced by
- backend (`spacy.extract`, `kompress.compress`).
+ backend (`kompress.compress`).
- Responses: `PythonServerResponse { id, ok, result, error }`, matched back to
the request by `id`; the read loop skips lines with a stale/unparseable `id`
and enforces a 60s per-request timeout (`REQUEST_TIMEOUT`, sized for the
- slower Kompress backend, not added latency for spaCy).
+ slower Kompress backend).
+
+stderr is drained continuously by a background task and only logged at
+`debug`/`trace`, never surfaced to callers.
+
+## Backends
+
+**Kompress** (`kompress.rs`): TokenJuice's ModernBERT/torch plain-text
+ compressor, gated by `config.tokenjuice.ml_compression_enabled`.
+
+It is gated behind `config.runtime_python.enabled`; `registry::enabled_backends`
+computes the active set from that flag and `config.tokenjuice.ml_compression_enabled`.
+
+## Key files
+
+| File | Role |
+| --- | --- |
+| `mod.rs` | Submodule decls and `pub use` re-exports. |
+| `server.rs` | Host side: maps `Config` and the managed interpreter onto a `ServerLaunch`, holds the process-wide `ServerSlot` (`ensure_started`, `status`). The process lifecycle itself (spawn, handshake, request/response, restart-on-failure, idle expiry, start back-off) is `tinyruntime_pyserver::{PythonServer, ServerSlot}`. |
+| `registry.rs` | `RuntimePythonBackend` enum (`Kompress`) and `enabled_backends(config)`. |
+| `kompress.rs` | Kompress venv provisioning (`ensure_kompress`, `install_into`, `kompress_provisioned`) and the compress request (`request_kompress`). |
+| (`tinyruntime-pyserver`) | Owns the JSONL wire types (`PROTOCOL_VERSION`, request/response/ready-line), the status types (`BackendStatus`, `ServerStatus`, re-exported here as `RuntimePythonServerStatus`) and the worker script itself (`SERVER_SCRIPT`), written to the cache root as `runtime_python_server.py` each time a server is prepared. Library crate in `vendor/tinyruntime`. |
+
+## Lifecycle
+
+`ensure_started(config)` is the single entry point. It caches one
+`Arc<RuntimePythonServer>` behind a process-wide `OnceLock<Mutex<ServerCache>>`
+(`Empty` / `Ready` / `Failed { message, retry_after }`):
+
+- If the enabled backend set has changed since the cached server launched
+ (e.g. Kompress toggled on or off), the cache is discarded and a new server
+ is started: the running process was never provisioned for the new set.
+- If the Kompress backend has been idle longer than
+ `config.tokenjuice.ml_sidecar_idle_timeout_secs`, the server is torn down and
+ restarted on the next request, freeing the torch process's memory.
+- A startup failure caches `Failed` with a five-minute (`START_FAILURE_BACKOFF`)
+ retry window so a broken venv does not retry on every call.
+- `RuntimePythonServer::request` sends one request, and on failure resets the
+ child and retries once before giving up.
+
+`prepare_launch` picks the interpreter for the worker: when Kompress is enabled it gets its own dedicated venv via `kompress::ensure_kompress`; otherwise the worker runs under the base interpreter from `runtime::python::PythonBootstrap`.
+
+## Wire protocol
+
+JSONL over the child's stdin/stdout (`tinyruntime_pyserver::protocol`), one line per message:
+
+- Startup handshake: the worker writes a `ReadyLine` (`ready`, `protocol`,
+ `backends`, optional `error`) before any request is sent; a `protocol`
+ mismatch against `PROTOCOL_VERSION`, `ready: false`, or no line within
+ `HANDSHAKE_TIMEOUT` (30s) fails the launch.
+- Requests: `PythonServerRequest { id, method, params }`, methods namespaced by
+ backend (`kompress.compress`).
+- Responses: `PythonServerResponse { id, ok, result, error }`, matched back to
+ the request by `id`; the read loop skips lines with a stale/unparseable `id`
+ and enforces a 60s per-request timeout (`REQUEST_TIMEOUT`, sized for the
+ slower Kompress backend).
stderr is drained continuously by a background task and only logged at
`debug`/`trace`, never surfaced to callers.
@@ -82,17 +128,15 @@ returns the shared `tinymemory_api::host::SpacyResponse` type. Called from
**Kompress** (`kompress.rs`): `ensure_kompress` provisions a CPU-only torch +
transformers venv and pre-downloads `config.tokenjuice.ml_model_id`;
-`install_into` does the same into an existing (spaCy) venv when both backends
-share one interpreter. The worker loads the model fully offline
+The worker loads the model fully offline
(`HF_HUB_OFFLINE=1`, `TRANSFORMERS_OFFLINE=1`) so startup never depends on the
network once provisioned. `kompress_provisioned` is the network-free marker check the `kompress` init
step uses. `request_kompress` sends `kompress.compress` with
`target_ratio` / `max_input_chars` from `config.tokenjuice`. Called from
`inference::tokenjuice::ml`.
-Both provisioning paths are serialized behind their own `tokio::sync::Mutex`
-(`provision_lock` / `spacy_provision_lock`) so concurrent callers don't race
-the same venv build.
+Provisioning is serialized behind a `tokio::sync::Mutex` so concurrent callers
+don't race the same venv build.
## Status
@@ -106,11 +150,10 @@ step is done.
## Persistence
-No domain store. `spacy::python_server_cache_root` picks the root:
+No domain store. `server::python_server_cache_root` picks the root:
`<runtime_python.cache_dir>/runtime-python-server` when configured, else
`<OS cache dir>/openhuman/runtime-python-server`, else
-`<workspace_dir>/runtime_python_server`. Under it live `spacy-venv/`,
-`kompress-venv/`, the Kompress HF cache `kompress-hf/`, and the written
+`<workspace_dir>/runtime_python_server`. Under it live `kompress-venv/`, the Kompress HF cache `kompress-hf/`, and the written
`runtime_python_server.py`.
## Security
@@ -124,30 +167,18 @@ adds `OPENHUMAN_RPS_BACKENDS` (the enabled backend list) and, for Kompress,
`HF_HOME`, `HF_HUB_OFFLINE=1`, `TRANSFORMERS_OFFLINE=1`, and
`HF_HUB_DISABLE_TELEMETRY=1`. `process_util::apply_no_window` is applied to
the worker spawn and to every provisioning command so Windows shows no
-console flash. Sandbox/approval policy for what reaches this worker (e.g. text
-passed to `spacy.extract`) is decided by the caller before the request is
+console flash. Sandbox/approval policy for what reaches this worker is decided by the caller before the request is
sent, not here.
## Used by
-- `crates/openhuman-core/src/agent/harness_init/registry.rs`: the `runtime_python_server`,
- `spacy`, and `kompress` init steps.
-- `crates/openhuman-core/src/modules/memory_host.rs`: `extract_spacy` for the memory
- tree's query extractor.
+- `crates/openhuman-core/src/agent/harness_init/registry.rs`: the `runtime_python_server`
+ and `kompress` init steps.
- `crates/openhuman-core/src/inference/tokenjuice/ml/mod.rs`: `request_kompress` for
plain-text compression.
## Notes / gotchas
-- The server always runs a **single** interpreter: enabling Kompress after
- spaCy is already running installs torch into the spaCy venv rather than
- starting a second process.
- Restart-on-failure in `RuntimePythonServer::request` means a transient
worker crash is invisible to callers except for added latency on the retried
call.
-- `ensure_spacy` also looks for a legacy spaCy venv at
- `<cache_dir>/memory-nlp/spacy-venv` (or `<OS cache dir>/openhuman/memory-nlp/spacy-venv`)
- and `<workspace_dir>/memory_tree/nlp/spacy-venv`; a ready one is renamed into
- `runtime-python-server/spacy-venv`, or reused in place if the rename fails,
- so upgrades don't force re-provisioning. `spacy_provisioned` accepts either
- location.