The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
docs(library): add benchmarking environment and minimal feature recipe
Steven Enamakelc346eb5f8f88
diff --git a/docs/library-benchmarking.md b/docs/library-benchmarking.mdnew file mode 100644index 0000000000..3abb950306--- /dev/null+++ b/docs/library-benchmarking.md@@ -0,0 +1,378 @@+# Library benchmarking environment++## Purpose++"opencompany" wants to embed the OpenHuman Rust core as a library: no always-on+RPC server, no Tauri shell, just the core linked in-process and driven+directly. That changes what "resource usage" means. There is no single steady+process to profile; there are per-use-case workloads (a long-running agent+loop, a delegated multi-agent turn, a saved workflow run, a background+subconscious pass, a memory ingest, a bare embed) that each have their own+startup cost, steady-state footprint, and growth curve.++This document describes the benchmark environment built to measure that: a+pinned `library-profile` binary with eight scenarios, four driver scripts+under `scripts/profile/`, and the comparison point the team cares about+(ZeroClaw). It builds on the manual investigation in+[`docs/resource-profiling-session-2026-07-21.md`](resource-profiling-session-2026-07-21.md);+read that document for the deep memory/CPU attribution work. This document is+about running repeatable benchmarks, not re-deriving those findings.++## The eight scenarios++All scenarios run in `target/release/library-profile <scenario>`, replace+network inference with a deterministic provider (`rss-bench` feature), and+print one pretty-printed JSON result object to stdout (diagnostics go to+stderr). Each models a distinct embedding use case:++| Scenario | Models |+| --- | --- |+| `memory-ingest` | Canonicalizing and ingesting a batch of chat messages through the real extraction/admission/tree-queue pipeline. |+| `subagents` | A delegation turn: an orchestrator session spawns real subagents via `spawn_parallel_agents` and merges their findings. |+| `agent-turn` | The minimal embed case: one agent, one turn, no delegation, no workflow. The smallest useful "hello world" for a host that just wants a single reply. |+| `long-agent` | A long-running agent loop (`OPENHUMAN_PROFILE_TURNS`, default 25) in one process, to see whether RSS plateaus or grows per turn. |+| `workflow` | A saved automation run (`flows_create` + `flows_run`), representing the flows/automation embedding path rather than ad hoc chat. |+| `subconscious` | A background subconscious turn (the always-on reflective pass), distinct from an interactive chat turn. |+| `cold-phases` | Bootstrap attribution: per-phase checkpoints (config load, registry init, agent build, memory construction, first turn) so cold-start cost can be attributed to a phase instead of one lump sum. |+| `fleet` | N concurrent live agents with latency-realistic mock inference — the "100-1000 agents in a 2 GB / 2 vCPU server" question. See [below](#the-2-gb--2-vcpu-server-budget). |++## How to run++Six scripts under `scripts/profile/` (each has `-h`/`--help`):++- **`library-bench.sh`** — the primary RSS/duration benchmark. Builds the+ binaries, runs each scenario N fresh-process repeats (default 5), and+ aggregates median/min/max into `summary.json` + `summary.md`.++ ```bash+ ./scripts/profile/library-bench.sh # default build, all scenarios+ ./scripts/profile/library-bench.sh --slim # --no-default-features recipe+ ./scripts/profile/library-bench.sh --scenarios "long-agent,subagents" --turns 50 --warm+ ```++- **`library-cpu.sh`** — a `samply` wrapper for one scenario's CPU profile,+ isolated from persistence/timezone noise by default.++ ```bash+ ./scripts/profile/library-cpu.sh subagents+ samply load target/profile/rust-library/subagents-cpu.json.gz+ ```++- **`library-heap.sh`** — builds the `rss-bench-dhat` variant and runs a+ scenario under dhat for live-heap attribution (allocation sites, retained+ bytes). RSS/timing under dhat are perturbed; don't compare those numbers to+ `library-bench.sh` output.++ ```bash+ ./scripts/profile/library-heap.sh memory-ingest+ # load target/profile/rust-library/dhat-memory-ingest.json at+ # https://nnethercote.github.io/dh_view/dh_view.html+ ```++- **`library-fleet.sh`** — sweeps the `fleet` scenario across a list of agent+ counts and gates the result against the 2 GB / 2 vCPU server budget (see+ below).++ ```bash+ ./scripts/profile/library-fleet.sh --agents 100 --latency-ms 200+ ./scripts/profile/library-fleet.sh --agents "50,100,500" --target 1000 --budget-mib 2048+ ```++- **`library-instances.sh`** — sweeps N independent *processes* (not agents+ in one process) of a scenario, held alive via `OPENHUMAN_PROFILE_HOLD_SECS`,+ and measures per-instance/aggregate cost — the many-processes counterpart+ to `library-fleet.sh`'s one-process model (see+ [below](#fleet-one-process-vs-instances-many-processes)).++ ```bash+ ./scripts/profile/library-instances.sh --instances "10,25,50" --hold-secs 30+ ```++- **`library-pool-gate.sh`** — the runtime-pool regression gate (#5106). Runs+ `skill-run` with K parallel skill runs and asserts the process tree grows by+ ~one pooled worker, not K interpreters; reports pooled vs unpooled.++ ```bash+ ./scripts/profile/library-pool-gate.sh --concurrency 8 --workers 1+ ```++### Default vs slim builds++Default-feature builds link every compile-time domain gate (`voice`, `web3`,+`media`, `meet`, `skills`, `flows`, `mcp`, `tui`) — the byte-identical desktop+recipe. The slim recipe drops everything not required by the harness:++```bash+cargo build --release \+ --no-default-features --features rss-bench \+ --bin library-profile --bin rss-bench+```++`--slim` on `library-bench.sh` builds this recipe. Per the prior session,+compile-time gates shrink the binary substantially but only move settled RSS+by a few MiB — most of the RSS story is initialization and allocator+behavior, not linked code size.++### Useful env knobs++| Variable | Effect |+| --- | --- |+| `OPENHUMAN_PROFILE_TURNS` | Turn count for `long-agent` (default 25). |+| `OPENHUMAN_PROFILE_PREWARM_SUBAGENTS=1` | Run one warm-up turn before measuring (`subagents`/`subconscious`), isolating first-use cost from steady state. |+| `OPENHUMAN_PROFILE_DISABLE_MEMORY_WRITES=1` | Disable `memory.auto_save` and episodic capture, isolating orchestration from persistence. |+| `OPENHUMAN_PROFILE_FORCE_UTC=1` | Skip `iana_time_zone`/CoreFoundation timezone resolution. |+| `OPENHUMAN_PROFILE_HOLD_SECS` / `HOLD_BEFORE_SECS` | Pause the process at settled/baseline state for external inspection (`vmmap`, `heap`, `malloc_history`, Instruments). |+| `OPENHUMAN_PROFILE_DHAT_OUT` | Output path for dhat JSON (set by `library-heap.sh`). |+| `OPENHUMAN_PROFILE_SKILL_RUN_CONCURRENCY` | `skill-run`: number of parallel `code_executor` turns (K), each spawning a `node_exec` job (default 1). |+| `OPENHUMAN_PROFILE_SKILL_RUN_POOL` | `skill-run`: `off` disables the shared runtime pool (legacy per-call spawn; tree then shows ~K resident `node` children). Default on. |+| `OPENHUMAN_PROFILE_SKILL_RUN_POOL_WORKERS` | `skill-run`: pool size W when pooling is on (default 1). The scenario asserts `child_count <= W` for K > 1 — the #5106 regression gate. |++## Metrics and interpretation++Every run reports `baseline`/`settled`/`peak_rss_kib` (macOS: `proc_pid_rusage`+RSS, `getrusage` peak, `proc_pidinfo` thread count), `retained_delta_kib`+(settled minus baseline), `peak_delta_kib`, and `duration_ms`. `long-agent`+additionally reports `checkpoints[]` so first-turn vs. last-turn growth is+visible directly.++**RSS is not private heap.** The prior session's deep attribution found a+~42 MiB slim-build snapshot broken down as roughly 15.2 MiB private physical+footprint, 3.18 MiB live heap, 18.7 MiB resident executable text, and ~9.4 MiB+of resident-but-mostly-inactive malloc pages (allocator high-water+retention). See+[`docs/resource-profiling-session-2026-07-21.md`](resource-profiling-session-2026-07-21.md#deep-memory-attribution)+for the full breakdown, the executable-paging finding (a cold turn faults in+~15 MiB of previously nonresident OpenHuman code), and the warmed-process+control showing steady-state turns cost ~0.5-1.9 MiB once warm rather than+the ~26-31 MiB a cold turn costs. Use `library-bench.sh` for the RSS/duration+headline numbers, `library-cpu.sh` when CPU attribution is the question, and+`library-heap.sh` only when RSS numbers need live-allocation attribution+(accepting the dhat perturbation).++## The ZeroClaw comparison++ZeroClaw self-reports idling under 5 MiB RAM; the "7.8-12 MiB under load"+figure sometimes quoted alongside it has no locatable primary source, and even+the idle figure is vendor marketing with no third-party verification (see+[`docs/harness-comparison-2026-07-22.md`](harness-comparison-2026-07-22.md)).+OpenHuman's Rust core currently settles around 35-50 MiB depending on+scenario and feature set (see the baseline table below).++Treat this as a **north star, not an apples-to-apples benchmark**. ZeroClaw's+scope and feature set differ substantially from the OpenHuman core: OpenHuman+links a full agent/memory/tool/orchestration stack (SQLite-backed unified+memory, TinyCortex PII detection, prompt-injection detection, a builtin-agent+registry, tool catalogs, provider routing) that a narrower harness may not+carry at all. A closer gap is a meaningful signal that the initialization+graph is leaner; it is not evidence of feature parity, and a wider gap is not+automatically a regression if it comes from carrying more capability. Every+`library-bench.sh` summary includes a labeled comparison row/note for exactly+this reason: visible, but explicitly called out as external.++## The 2 GB / 2 vCPU server budget++"opencompany" wants a single server to host 100-1000 live agents inside a 2 GB+RAM / 2 vCPU box. That is a budget question, not a per-scenario RSS question:+2048 MiB / 1000 agents is roughly 2 MiB per agent all-in, but the fixed+per-process base (allocator high water, code paging, registries, detectors —+the same ~30 MiB every scenario above pays once) amortizes across however many+agents share the process. What actually determines whether 1000 agents fit is+the **marginal** cost per additional agent once that base is paid, not the+per-agent average. `library-fleet.sh` runs the `fleet` scenario (N concurrent+live agents, latency-realistic mock inference so idle time looks like real+network waits rather than a busy loop) across a sweep of N and reports that+marginal cost directly (`marginal_rss_kib_per_agent`), alongside idle CPU over+a parked 10s window, thread count, and open FD count — all of which should+stay roughly flat as N grows if per-agent state is cheap and idle agents cost+~zero CPU.++Working targets: marginal cost ≤ 1.5 MiB/agent, threads and FDs flat (not+linear) in N, and idle CPU low regardless of N — an agent that isn't mid-turn+should not be spending cycles. `OPENHUMAN_PROFILE_WORKER_THREADS=2` pins the+scenario's tokio runtime to 2 worker threads to simulate the 2 vCPU box rather+than scaling with the host's actual core count. The `budget` block in each+run's JSON (`target_agents`, `ram_budget_mib`, `projected_rss_mib_at_target`,+`fits`) projects the swept marginal cost out to the real target (default 1000+agents / 2048 MiB); `library-fleet.sh` aggregates medians per N into+`summary.md` and exits nonzero if any swept N projects `fits: false`, making+it usable as a CI-style regression gate (`--no-gate` to disable).++**Caveats, stated plainly:** these numbers are gathered on macOS, which has no+cgroup memory limit to enforce or observe locally — the budget check is a+projection from measured marginal cost, not a live "did it actually get+OOM-killed at N agents" test. macOS also lacks Linux's `/proc/<pid>/smaps_rollup`,+which would give true PSS (proportional shared memory) instead of RSS; RSS+overcounts shared pages (executable text, shared library mappings) in a way+that matters more as agent count grows and more of the process footprint is+genuinely shared. Treat the macOS numbers as an approximation of the target+Linux server, not a substitute for it. The JSON schema already has a Linux+path — `proc_metrics` reads `/proc/<pid>/status` and `/proc/<pid>/stat` on+Linux — so true validation should eventually mean running the same+`library-profile fleet` binary on a cgroup-limited Linux box (matching the 2+vCPU / 2 GB target) rather than trusting the macOS projection alone.++### Fleet (one process) vs instances (many processes)++The budget section above measures one deployment shape: N agents sharing a+single process. But "opencompany" may instead run OpenHuman as **N+independent processes or containers** — one per tenant — rather than N+agents inside one process. Those are different cost models and the fleet+number does not answer the second one.++- **Fleet (`library-fleet.sh`)** pays the ~30-50 MiB fixed base (allocator+ high water, code paging, registries, detectors) **once**, and amortizes it+ across however many agents share that process. Marginal cost per agent is+ what matters, and it can be well under 1 MiB once the base is paid.+- **Instances (`library-instances.sh`)** pays that same fixed base **N+ times**, once per process — minus whatever the OS actually shares across+ processes (resident executable text, shared library mappings). Summed RSS+ across instances therefore **double-counts** those shared pages; it is an+ upper bound, not the true footprint. True per-instance marginal cost is+ better read from summed PSS (Linux only — macOS has no PSS-equivalent+ metric), which divides shared pages across the processes that share them.++`library-instances.sh` spawns N held `library-profile` processes staggered+on startup, samples aggregate sum-RSS every 2s while they hold at settled+state, and reports median settled RSS/instance, mean and peak aggregate+sum-RSS, and summed PSS when available, plus a labeled 2 GB-box+extrapolation estimate:++```bash+./scripts/profile/library-instances.sh --instances "10,25,50" --hold-secs 30+```++**This is still a macOS proxy, not container validation.** True validation+means running the same binary under real `cgroup` memory limits (e.g.+`docker run --memory=2g`) on a Linux host and observing whether it survives+or gets OOM-killed at the target instance count — not projecting from local+sum-RSS. That is follow-up work, and it belongs on a Linux box: this repo's+own `openhuman-core` Docker build is currently blocked on Apple Silicon (the+`whisper-rs-sys`/whisper.cpp NEON fp16 intrinsics fail to compile under+arm64-Linux emulation with GCC 12 — see the umbrella repo's root `CLAUDE.md`+gotchas and `docs/resource-profiling-session-2026-07-21.md`). The path+around that blocker is either building for `linux/amd64` under emulation (the+whisper AVX path has no NEON bug) or running the validation on a native Linux+host rather than macOS Docker Desktop.++## Profiling escalation path++Start cheap, escalate only as needed:++1. **`library-bench.sh`** — RSS/duration medians across fresh processes. Answers "did this change move the needle" for most changes.+2. **`library-cpu.sh` (samply)** — symbolized CPU profile when a scenario is slower than expected, or to attribute cold-path CPU to a specific phase (registry init, agent build, memory construction, SQLite init, TinyAgents turn runner were the top contributors in the prior session).+3. **`library-heap.sh` (dhat)** — live-heap allocation sites and retained bytes when RSS is high but the cause isn't obvious from CPU alone (e.g. the TinyCortex PII `RegexSet` finding came from stack-logged allocation attribution, not CPU sampling).+4. **Instruments / `vmmap` / `heap` / `malloc_history`** — deepest macOS-native attribution, using the `OPENHUMAN_PROFILE_HOLD_SECS` / `HOLD_BEFORE_SECS` hooks to pause the process at baseline or settled state:++ ```bash+ OPENHUMAN_PROFILE_HOLD_SECS=120 target/release/library-profile subagents &+ vmmap -summary <pid>+ heap -sH <pid>++ MallocStackLogging=1 OPENHUMAN_PROFILE_HOLD_SECS=120 \+ target/release/library-profile subagents &+ malloc_history <pid> -allBySize+ ```++ This is what surfaced the PII-sanitizer regex cache and the first-turn+ executable-paging finding in the prior session; reach for it only once+ `library-bench.sh`/`library-cpu.sh`/`library-heap.sh` have narrowed the+ question to a specific scenario and metric.++## Current baseline numbers++From the 2026-07-21 profiling session (medians over five fresh processes+unless noted; see that document for methodology and caveats):++| Scenario | Build | Median settled RSS | Median retained Δ |+| --- | --- | ---: | ---: |+| 1-agent roster | default | 38.7 MiB | - |+| 8-agent roster | default | 41.5 MiB | +2.8 MiB total (~0.40 MiB/agent) |+| 1-agent roster | slim | 35.5 MiB | - |+| 8-agent roster | slim | 38.7 MiB | +3.2 MiB total |+| `memory-ingest` (100 msgs) | default | 25.5 MiB | 9.31 MiB |+| `memory-ingest` (100 msgs) | slim | 23.8 MiB | 8.58 MiB |+| `subagents` (cold, 2 children) | default | 48.5 MiB | 30.8 MiB |+| `subagents` (cold, 2 children) | slim | 42.4 MiB | 25.7 MiB |+| `subagents` (warmed repeat, persistence off) | default | - | 0.52 MiB |+| `subagents` (warmed repeat, normal capture) | default | - | 1.84 MiB |+| ZeroClaw (external, idle, self-reported/unverified) | - | < 5 MiB | - |++First full `library-bench.sh` run of the new scenarios (default build, 5+fresh-process repeats, 2026-07-21, Apple Silicon macOS):++| Scenario | Build | Median settled RSS | Median retained Δ | Median duration |+| --- | --- | ---: | ---: | ---: |+| `agent-turn` (cold, 1 turn) | default | 47.6 MiB | 29.5 MiB | 102 ms |+| `subconscious` (cold, no delegation) | default | 47.9 MiB | 29.8 MiB | 138 ms |+| `subagents` (cold, 2 children) | default | 48.0 MiB | 29.9 MiB | 142 ms |+| `workflow` (`flows_create` + `flows_run`) | default | 50.9 MiB | 29.9 MiB | 110 ms |+| `long-agent` (25 warmed turns) | default | 65.8 MiB | 18.5 MiB | 1,361 ms |+| `cold-phases` (9 bootstrap phases) | default | 51.2 MiB | 36.5 MiB | 476 ms |+| `memory-ingest` (100 msgs) | default | 25.8 MiB | 9.3 MiB | 2,099 ms |++Notable structure behind these medians:++- The `long-agent` per-turn series plateaus: typical turns add 30-150 KiB,+ and the 25-turn total (~16.8 MiB first-to-last) is dominated by two async+ persistence/compaction bursts of 6-8 MiB each, matching the prior session's+ warmed-repeat outlier observation. Steady-state growth is not linear.+- Cold `agent-turn`, `subconscious`, `subagents`, and `workflow` all retain+ approximately the same ~29-30 MiB, confirming the cost is shared bootstrap+ (code paging, registries, detectors, allocator high water), not the+ specific workload on top of it.+- A dhat run of `agent-turn` measured 33.4 MB total allocated across 135,756+ blocks, but only 5.0 MB peak live heap and 3.1 MB live at exit, again+ showing RSS is mostly not live heap data.++### Fleet, instances, and runtime baselines (2026-07-22, post-PII-prefilter)++`library-fleet.sh` sweep (default build, 3 repeats, 3 turns/agent, 200 ms+mock latency, 2 worker threads, target 1000 agents / 2048 MiB):++| N agents | Marginal KiB/agent | Settled MiB | Idle CPU ms/10s | Threads | fds | p95 turn ms | Projected MiB @1000 | Fits |+| ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | :---: |+| 50 | 1,985 | 223 | 3 | 71 | 420 | 2,848 | 1,956 | yes |+| 100 | 1,866 | 356 | 3 | 123 | 820 | 5,402 | 1,840 | yes |+| 500 | 1,770 | 1,393 | 3 | 211 | 3,220 | 25,484 | 1,747 | yes |++`library-instances.sh` (many-processes model, `agent-turn` held 20 s):+~47.8-48.2 MiB per instance flat at N=10/25/50 → roughly 42 instances per+2 GiB by sum-RSS (upper bound; macOS has no PSS). The one-process fleet+model is ~25x denser than the per-process model.++Runtime/subagent scenarios: `skill-run` measures a real `node` child at+~72-75 MB RSS (~121 MB process tree vs ~51 MB self) — the basis of the+runtime-pooling issue (tinyhumansai/openhuman#5106); `subagent-storm` shows+~0.78 MiB marginal per additional parallel subagent (K=8→32 cross-width).++Runtime pool (#5106): with the shared pool on (the default), a batch of K+concurrent `skill-run` turns shares a bounded set of warm `node` workers, so+the process tree grows by ~one pooled worker instead of K interpreters.+Measured at **K=8** (`max_workers=1`, system node v24): pooled tree+`child_count=1` at **~202 MiB**, vs unpooled `child_count=8` at **~690 MiB**+(eight `node` children of ~73–75 MB each) — a ~490 MiB / 3.4× reduction that+grows with K. Compare the two regimes directly:++```bash+# Legacy: K interpreters resident at peak.+OPENHUMAN_PROFILE_SKILL_RUN_CONCURRENCY=8 OPENHUMAN_PROFILE_SKILL_RUN_POOL=off \+ target/release/library-profile skill-run+# Pooled: child_count stays at the pool size (asserted), not K.+OPENHUMAN_PROFILE_SKILL_RUN_CONCURRENCY=8 OPENHUMAN_PROFILE_SKILL_RUN_POOL_WORKERS=1 \+ target/release/library-profile skill-run+```++The pool is configured in `[runtime_pool]` (master switch + per-language+`node`/`python` `max_workers`, `idle_ttl_secs`, `recycle_after_jobs`,+`max_queue_depth`); `enabled = false` reverts every caller to the legacy+per-call spawn.++Watch-items from the sweep: thread count grows ~0.35/agent (needs+attribution + cap before real 1000-agent runs), and p95 latency at N=500 on+2 workers shows CPU saturation is the load constraint, not memory.++## See also++- [`docs/resource-profiling-session-2026-07-21.md`](resource-profiling-session-2026-07-21.md) — the full manual investigation (deep attribution, cold-path CPU, library-design implications, recommended optimization order).+- [`scripts/profile/README.md`](../scripts/profile/README.md) — script quick reference.+- `src/bin/library_profile/main.rs` — the scenario implementations.diff --git a/docs/library-minimal-recipe.md b/docs/library-minimal-recipe.mdnew file mode 100644index 0000000000..92f19a3d76--- /dev/null+++ b/docs/library-minimal-recipe.md@@ -0,0 +1,238 @@+# Library-minimal feature recipe++A **supported, measured** compile-time feature recipe for embedding the OpenHuman+Rust core as a library in "opencompany" — headless, no RPC server, no Tauri+shell, targeting 100-1000 live agents in a 2 GB RAM / 2 vCPU box.++It follows the repo's existing slim convention (`cargo build --no-default-features+--features "<explicit list>"`, see AGENTS.md "Compile-time domain gates") and keeps+only the domains the opencompany use cases actually exercise: **agent turns,+subagent delegation, memory ingest, workflow (flows) runs, and python/js skill+execution.**++## The build command++Opencompany recipe (production embed — no benchmark/harness code):++```bash+cargo build --release \+ --no-default-features --features "skills,flows"+```++- To build the profiling harness against the same recipe, add the dev-only+ `rss-bench` feature and the two bench bins:++ ```bash+ cargo build --release \+ --no-default-features --features "rss-bench,skills,flows" \+ --bin library-profile --bin rss-bench+ ```++There is **no** `library-minimal` meta-feature in `Cargo.toml`, on purpose — see+[Why no alias](#why-no-cargotoml-alias) below.++## Keep / drop table++The single `default` list this session was written against no longer exists.+There are two sets now (AGENTS.md, "Compile-time domain gates"): **Contrib** is+`[features] default`, what a bare `cargo check` compiles; **Product** is+`scripts/ci/product-features.txt`, what the desktop app ships. Both columns+below are current. `desktop-automation` has since been removed from the tree+altogether, hence the dashes; `tui` is in neither set.++Note how much of this recipe the contributor set already gives you for free —+`voice`, `web3`, `meet` and `tui` are default-OFF today. The Decision column+still records what a **library host** wants, which is the thing this document+is actually for.++| Gate | Contrib | Product | Decision | Why | Deps shed |+| --- | :---: | :---: | :---: | --- | --- |+| `skills` | ON | ON | **KEEP** | python/js `SKILL.md` execution is a stated opencompany use case | none (surface/prompt/startup only) |+| `flows` | ON | ON | **KEEP** | saved-workflow (`flows_create`+`flows_run`) runs are a stated use case | — (adds `tinyflows`, `jaq-*`, `rhai`; see cost note) |+| `voice` | OFF | ON | **DROP** | STT/TTS/dictation/podcast — a headless host does no audio I/O | `hound`, `lettre` |+| `web3` | OFF | ON | **DROP** | crypto wallet / swap / x402 machine payments — not an opencompany path | `bitcoin`, `curve25519-dalek` |+| `media` | ON | ON | **DROP** | `media_generate_*` image/video tools — surface-only | none (backend-proxied) |+| `meet` | OFF | ON | **DROP** | Google-Meet join/live-STT/TTS bot — no headless use | none |+| `mcp` | ON | ON | **DROP** | MCP stdio/HTTP server + Smithery registry (~20k LOC, ~19 tools) — a library host is not an MCP host | none (hand-rolled over tokio/reqwest/axum) |+| `desktop-automation` | — | — | **DROP** | AX / `computer` tool family drives a **local desktop UI** — meaningless headless | `uiautomation` |+| `tui` | OFF | — | **DROP** | `openhuman tui`/`chat` terminal UI — no terminal in a library host | `ratatui`, `crossterm`, `unicode-width` |++**Non-default optional features** (`sandbox-landlock`, `sandbox-bubblewrap`,+`peripheral-rpi`, `browser-native`/`fantoccini`, `landlock`, `whatsapp-web`,+`e2e-test-support`, `rss-bench`, `rss-bench-dhat`) are all default-OFF, so a+`--no-default-features` build never links them unless explicitly added. None are+needed for opencompany; `rss-bench`/`rss-bench-dhat` are dev/benchmark-only.++## Measured results++All numbers gathered on this branch, Apple-Silicon macOS, `--release` profile+(`optimized + debuginfo`). "default" = the prior 2026-07-21 session baselines in+[`docs/library-benchmarking.md`](library-benchmarking.md); "pure slim" =+`--no-default-features --features rss-bench` (drops everything). Both slim numbers+were reproduced on this machine and match the prior doc exactly (68.4 MiB).++### Binary size++| Build | Features | Unstripped | Stripped |+| --- | --- | ---: | ---: |+| default | (all gates) | 115.9 MiB¹ | — |+| **library-minimal** | `skills,flows` | **~81.1 MiB** | **~60.4 MiB** |+| pure slim | (none) | 68.4 MiB | 51.0 MiB |++¹ from the prior session (unstripped, same profile). library-minimal bins measured+directly: `rss-bench` 81.1 MiB, `library-profile` 83.0 MiB unstripped (the extra+~2 MiB is the harness itself). The domain recipe (`skills,flows`, no `rss-bench`)+matches the `rss-bench` figure — the bench feature adds negligible code.++- **library-minimal vs default: -34.8 MiB (~30% smaller)**, and a correspondingly+ narrower code-paging surface (the dominant cold-turn RSS factor per the prior+ session's executable-paging finding).+- **library-minimal vs pure slim: +12.7 MiB unstripped / +9.4 MiB stripped — all+ of it `flows`.** `cargo tree` confirms the delta is `rhai 1.25` + `rhai_codegen`+ + `jaq-core/std/json` + `tinyflows`; `skills` sheds **zero** deps (its value is+ tool-surface/prompt/startup, not size). `flows` is by far the most expensive+ domain we *keep* — see follow-up #2.++### Per-scenario RSS (5 fresh-process repeats, median, `OPENHUMAN_PROFILE_FORCE_UTC=1`)++| Scenario | minimal settled | minimal retained Δ | default settled² | default retained² | Δ settled |+| --- | ---: | ---: | ---: | ---: | ---: |+| `agent-turn` (cold, 1 turn) | 44.0 MiB | 26.6 MiB | 47.6 MiB | 29.5 MiB | **-3.6 MiB** |+| `subagents` (cold, 2 children) | 44.5 MiB | 27.1 MiB | 48.0 MiB | 29.9 MiB | **-3.5 MiB** |+| `workflow` (`flows_create`+`flows_run`) | 46.2 MiB | 26.0 MiB | 50.9 MiB | 29.9 MiB | **-4.7 MiB** |+| `memory-ingest` (100 msgs) | 24.7 MiB | 8.8 MiB | 25.8 MiB | 9.3 MiB | **-1.1 MiB** |+| `long-agent` (10 turns) | 46.4 MiB | 2.9 MiB | — (25-turn: 65.8 MiB) | — | n/a³ |++² default column from `docs/library-benchmarking.md` (2026-07-21). Those medians+may not have used `OPENHUMAN_PROFILE_FORCE_UTC=1`, so treat the Δ as approximate+(±~1 MiB). The direction and magnitude match the prior session's "slim saves+~3.2 MiB settled RSS" finding.++³ `long-agent` was run at 10 turns here vs 25 in the default baseline, so the+absolute settled figures aren't comparable. The low 2.9 MiB retained Δ confirms+per-turn growth plateaus (matches the prior "not linear" observation).++**Takeaway (consistent with the prior session):** compile-time gates shrink the+*binary* substantially (-30%) but move *settled RSS* by only ~3-5 MiB per+scenario. Most of the RSS story is initialization + allocator high-water, not+linked code size. The binary/code-paging win is the primary reason to prefer this+recipe; the RSS win is real but secondary.++## What is functionally absent in this build++Summarized from the per-gate behavior notes in AGENTS.md. Dropped domains fail+*closed and cleanly* — controllers become unknown-method, tools are simply absent+from the tool list (not degraded to runtime errors), CLI subcommands report a+build-fact error:++- **voice/audio:** voice + audio controllers unregistered (unknown-method over+ RPC, absent from `/schema`); `audio_generate_podcast` tools absent; `openhuman+ voice` returns "voice disabled".+- **web3:** wallet / web3 / x402 controllers unregistered; swap/bridge/dapp agent+ tools absent; the x402 402-retry path returns unpaid; tinyplace on-chain+ payments degrade to graceful "wallet disabled" errors (tinyplace comms ++ ed25519 signing are unaffected).+- **media:** `media_generate_*` agent tools absent.+- **meet:** meet controllers unregistered; live Meet bot / STT-LLM-TTS loop absent.+- **mcp:** `mcp_server` / `mcp_registry` (`mcp_clients` namespace) / `mcp_audit`+ controllers unknown-method; ~19 MCP agent tools absent; `openhuman mcp` CLI+ returns a "rebuild with --features mcp" build-fact error. (`McpHttpClient` ++ `sanitize` stay compiled — the gitbooks docs tool and the orchestrator prompt+ sanitizer still work.)+- **desktop-automation:** `accessibility` / `autocomplete`+ / `desktop_companion` domains + the `computer` tool family (`ax_interact`,+ `automate`, mouse/keyboard) absent.+- **tui:** `openhuman tui` / `chat` returns "tui feature disabled at compile time".++Everything the opencompany use cases need remains: the agent harness + turn+runner, subagent delegation (`spawn_parallel_agents`), the full memory stack+(TinyCortex store/tree/queue/ingest + PII/injection detectors), threads, config,+security policy, provider routing/inference, `skills` (SKILL.md discovery/install++ node/python execution + `run_workflow`/`await_workflow`), and `flows` (saved+graph create/run/schedule + `workflow_builder`/`flow_discovery` agents).++## Test verification++The disabled-build test gotcha (AGENTS.md: CI's smoke lane runs `cargo check`+only and never compiles `--no-default-features` test code) was checked directly:++```bash+cargo test --lib --no-default-features --features "skills,flows" core::+# result: ok. 660 passed; 0 failed; 1 ignored; 10513 filtered out+```++The both-ways gate tests in `src/core/all_tests.rs` (which assert dropped domains+become unknown-method) pass under this recipe. No pre-existing failures.++## CI note++Nothing is added to the `default` feature list — this is a **subtractive**+`--no-default-features` recipe, not a new default-ON gate. The **Feature+Forwarding Gate** (`scripts/ci/check-feature-forwarding.mjs`) only inspects the+`default` list and its forwarding into the desktop shell's `Cargo.toml`, so it+**does not apply** here: there is nothing to forward. This recipe carries no CI+risk and needs no `INTENTIONALLY_NOT_FORWARDED` entry.++## Why no `Cargo.toml` alias++The repo convention (AGENTS.md "Slim-profile convention") is deliberate: **no+`full` meta-feature; build slim variants with an explicit feature list.** A+`library-minimal = ["skills","flows"]` alias would be convenient, but it:++- duplicates the `default` list's maintenance burden — a new default-ON gate that+ opencompany *should* pick up would silently be missing from a frozen alias+ (the exact failure mode the "no meta-feature" rule exists to avoid), and+- hides the subtractive intent behind a name, making the drop set invisible at+ the call site.++**Recommendation: document the explicit list (this file), do not add the alias.**+If maintainers later decide an alias is worth it, the minimal-drift option is to+express it *subtractively* in tooling rather than as a frozen additive list —+but that is a follow-up decision, not part of this recipe.++## Follow-up shed list (ranked)++Largest remaining always-on costs a headless library host does not need. These+are **not implemented here** — they require new gates/refactors — listed for+prioritization.++1. ~~**`inference` gate → shed `whisper-rs` + `whisper-rs-sys` (+ `cpal`/`coreaudio`).**~~+ **DONE, and better than proposed.** The bundled whisper.cpp STT engine was not+ gated — it was **deleted**. `whisper-rs` / `whisper-rs-sys` (and the+ `[patch.crates-io] whisper-rs-sys` fork entries in both Cargo worlds) are gone+ from every build, not just the slim one, and with them the whisper.cpp + GGML+ C++ static link that previously required a platform-specific build workaround.+ Speech-to-text is a hosted call now, with the engine chosen by+ `voice_server.stt_engine` (see the AGENTS.md scope note). The `inference`+ feature survives with a narrower job: it gates `cpal` alone, which is what a+ headless library host wanted shed anyway.++2. **Split `rhai` out of the `flows` gate.** `flows` is the most expensive domain+ we *keep* (+12.7 MiB, dominated by `rhai 1.25` — a full scripting engine).+ `rhai` arrives only via `tinyagents/repl`, which powers the `.ragsh`+ language-workflow tool (`rhai_workflows`). If opencompany needs `tinyflows`+ saved-graph runs but **not** the `.ragsh` rhai tool, splitting `rhai_workflows`+ into its own sub-gate would reclaim most of that 12.7 MiB while keeping the+ flows graph engine. Currently all-or-nothing.++3. **`git2` (vendored libgit2).** Always-on native dependency of the `memory_diff`+ change-ledger (git-backed snapshots/checkpoints/diffs). A large vendored C lib.+ If a library host does not need git-backed memory diffs, this is a candidate for+ a future gate.++4. **`reqwest` dual TLS backends.** The root `reqwest` enables both `rustls-tls`+ **and** `native-tls` — two full TLS stacks linked simultaneously. A headless+ host on a known target could pick one, shedding the other.++5. **Node/Python runtime bootstrap deps** (`tar`, `xz2`+liblzma, `zip`, `flate2`).+ Only needed if `skills`/`flows` actually execute node/python workloads; kept+ here because `skills` is on. If a deployment runs only pure-LLM skills, these+ archive/decompression deps become sheddable.++## See also++- [`docs/library-benchmarking.md`](library-benchmarking.md) — the benchmark+ environment, scenario definitions, and default/slim baselines.+- [`docs/resource-profiling-session-2026-07-21.md`](resource-profiling-session-2026-07-21.md)+ — deep memory/CPU attribution (why RSS is mostly not live heap).+- AGENTS.md "Compile-time domain gates" — the per-gate behavior and dependency notes.