# 09 — Runtime lifecycle, CLI, paths & data layout, setup/updates, diagnostics, privacy logs, migration, test inventory Source of truth: CapriCore 1.0.4 tree `~/Capri` (read-only; code wins over docs). Target: one Rust binary `capri` for Arch Linux, KDE Plasma 6.8 Wayland (companion windows via XWayland) and i3 4.25 (X11). Ollama stays an external process (host has `ollama 0.40.15` + `ollama-cuda` from pacman; Capri pins a minimum of `0.40.10`). Feature prefix: **RT**. Paths in tables are relative to the Capri folder ("legacy root") unless prefixed by a Rust root (`CONFIG`, `DATA`, `STATE`, `CACHE`, `RUN`, `SHARE`, see RT-25). --- ## 1. Purpose and scope This spec defines how Capri is launched, supervised, stopped, located on disk, configured on first run, repaired, purged, told about new versions, diagnosed and migrated, plus the privacy-preserving logging every other subsystem must use, and the inventory of Capri's tests. | Capri file(s) | Role in Capri | Rust disposition | |---|---|---| | `package.json` `scripts` (63 entries), 15 root `*.cmd` | Command surface | `capri` subcommands; dev-only scripts → `cargo xtask` (table in RT-13) | | `packages/runtime/bin/core.mjs` | `init/ollama/start/stop/restart/status/chat/image/cli` | RT-02..RT-07, RT-11 | | `packages/runtime/bin/capri.mjs` | `doctor/profiles/setup/desktop/models/setup-spotify/spotify/help`, delegates to core.mjs | RT-01, RT-06, RT-08..RT-10 | | `packages/runtime/bin/models.mjs` (followed) | Model download command | RT-10 | | `packages/runtime/bin/gateway-host.mjs` (followed) | OpenClaw stdin-lifeline host | Dropped (no OpenClaw); lifeline semantics kept for external services (RT-18) | | `packages/runtime/bin/prepare-desktop.mjs`, `src/host/desktop-identity.mjs`, `src/host/electron-bundle.mjs` | Windows branded `Capri.exe` copy of Electron, Electron completeness | Dropped; Linux identity = app_id/WM_CLASS `capri` (§8) | | `packages/runtime/bin/response-timing-preload.mjs` | `--import` preload into OpenClaw to time provider calls | In-process timing (RT-31) | | `packages/runtime/bin/run-node.ps1`, `patch-openclaw.mjs` | Node selection, npm postinstall patcher | Dropped | | `packages/runtime/src/desktop-launcher.mjs` | Desktop preconditions, single-instance show, detached launch | RT-06, RT-20 | | `packages/runtime/src/host/{paths,executables,environment,processes,readiness,launch-receipt,ollama-bundle,registry-network}.mjs`, `stop-windows-process.ps1` | Paths, executable discovery, child env, markers, launch/stop, readiness, receipts, Ollama runtime checks, registry TLS compat | RT-14..RT-20, RT-24..RT-26 | | `packages/runtime/src/{privacy-log,atomic-json,safe-file}.mjs` (+ followed `response-timing*.mjs`, `technical-model-id.mjs`, `http.mjs`) | Allowlist log records, atomic/private writes, bounded HTTP | RT-16, RT-27, RT-29..RT-33 | | followed: `src/providers/{core,services,model-plan,pull-model,pull-service-recovery,registry-tls-recovery,embedding-model,native-model}.mjs`, `src/context.mjs` (`runtime`,`initialize`), `src/config/settings.mjs`, `src/hardware/{profiles,model-catalog,model-profile,memory-budget,responsiveness}.mjs` | Core start/stop order, model presence, settings validation, profiles | RT-08..RT-11, RT-19, RT-23, RT-24 (semantics of inference/hardware owned by other specs) | | `packages/installer/**` (bin, src, windows: 65 files) | Windows Setup.exe bootstrap, PowerShell/WinForms wizard, Node install engine, uninstaller | RT-39..RT-45 (first-run setup, component engine, purge, PKGBUILD) | | `packages/updater/**`, `apps/desktop/update-service.mjs` (+ `renderer/update-notification.mjs`, IPC in `main.mjs:5266-5332`) | GitHub release check, download, staged transactional apply | RT-46 (passive notice), RT-47 (apply not ported) | | `apps/desktop/diagnostics/{report,redact,archive,state,resources,developer,response-timeline}.mjs` (+ `main/companion-ipc.mjs:159-205`) | Bug-report ZIP, redaction, developer log viewer/timelines | RT-34..RT-38 | | `config/installer*.json`, `uninstaller-text.json`, `release.json`, `community.json`, `hall-of-fame.json` | Wizard/uninstall catalogs (50 locales), release identity, links, credits | RT-39, RT-44, RT-46, RT-49 | | `scripts/*` (89 files) | Compatibility shims (2–13 lines) re-exporting `tools/*` and `packages/*` | None (dev aliases in xtask) | | `data/**`, `logs/**` | Private state (schemas only were inspected) | §3 inventory, RT-48 migration | | `tests/**` (274 files), `tools/**` (≈220 files) | Qualification | §11 | Out of scope (other specs; consumed through interfaces in §9): agent/LLM turns and tools, memory content, voice/ASR engines, desktop actions (`capri_linux`), avatar/UI rendering, filesystem-permission semantics, Spotify, request router internals. The local Linux bridge (tag `FWS-LINUX-BRIDGE`) touches this subsystem in three places: `desktop-launcher.mjs:53-56` adds `--ozone-platform=x11` on Linux; `apps/desktop/main.mjs` installs a Linux cursor and enables the native escape/action helpers on `linux`; the out-of-tree launcher `~/.local/bin/capri` runs Electron directly with `--ozone-platform=x11` and appends raw main-process output to `logs/electron-main.log` (0644). That last behavior violates Capri's own log policy and must not be reproduced (§7). --- ## 2. Feature catalog Priorities: **P0** companion broken without it, **P1** expected by a Capri user, **P2** optional/niche. "Rust/Linux" lines are normative for the rewrite. ### A. Command-line surface #### RT-01 `capri` dispatcher — P0 - Source: `packages/runtime/bin/capri.mjs:22-116`, `core.mjs:23-119`. - Capri: `capri.mjs ` defaults to `help`; `core.mjs` defaults to `status`. Commands `start stop status init chat image cli restart ollama` are forwarded to core.mjs (`capri.mjs:95-100`). `capri.mjs` errors print `Capri: ` to stderr, exit 1; core.mjs errors print ``, exit 1. Unknown command → `Unknown command: `. Help text (verbatim): `Capri commands: doctor, profiles, setup [--profile=balanced], models, desktop, start, stop, status, chat. See docs/installation.md.` - Rust/Linux: single binary with clap. `capri` without arguments runs the GUI in the foreground (the `.desktop` `Exec=capri`). Every error prints `Capri: ` to stderr. Exit codes: 0 success, 1 runtime error, 2 usage error. Global environment only (no global flags): `CAPRI_HOME`, `CAPRI_SHARE_DIR`, `CAPRI_OLLAMA_PATH` (RT-25/26). #### RT-02 `capri status` — P0 - Source: `core.mjs:46-87`. - Capri: never starts anything. Probes (in this order): 1. `GET /api/version`, timeout 3 s → `ollama: ` or `"stopped"`. 2. Gateway only if marker `capri` is alive **and** the token file exists: `GET /v1/models` with bearer, 3 s → `openclaw: "ready" | "stopped"`. 3. If Ollama answered: `GET /api/ps` (default 10 s) → `loadedModels: [{name, vramGiB: round2(size_vram / 2^30)}]`. 4. Voice: `GET http://127.0.0.1:/health` with `authorization: Bearer `, 3 s → the health JSON or `"stopped"` (errors swallowed: voice is optional). Prints `JSON.stringify(obj, null, 2)` with keys `desktop` (`running|stopped` from the `desktop` marker), `ollama`, `openclaw`, `naturalVoice`, `ui` (`"Capri desktop companion (capri.cmd)"`), `agent` (agentId), `model`, `session` (sessionKey), `loadedModels`. - Rust/Linux: same object, keys in the same order, with `openclaw` replaced by `core` (`"ready"` when the running GUI/headless core answers `status` on the control socket with `core: ready`, else `"stopped"`) and `ui` = `"Capri desktop companion (capri)"`. Voice probe sends the bearer only after an unauthenticated probe proves the port belongs to the managed voice marker (RT-17). Synthetic example: ```json { "desktop": "running", "ollama": "0.40.15", "core": "ready", "naturalVoice": { "ready": true, "protocolVersion": 2, "engine": "chatterbox-turbo", "activeEngine": "turbo" }, "ui": "Capri desktop companion (capri)", "agent": "capri", "model": "capri-qwen3.5:4b", "session": "agent:capri:main", "loadedModels": [{ "name": "capri-qwen3.5:4b", "vramGiB": 3.21 }] } ``` #### RT-03 `capri start` (headless core) — P1 - Source: `core.mjs:32-38` → `providers/core.mjs:17-83` (`startCore`, `preload = settings.preloadModels`). - Capri prints (verbatim): `Capri is ready. OpenClaw ; Ollama .` / `Control UI: /` / `Chat API: /v1/chat/completions` / `Run capri.cmd to open the desktop companion.` / `API token is stored privately in data/openclaw/gateway-token.` - Rust/Linux: runs the core start sequence RT-23 without a window (start/adopt managed Ollama, ensure model aliases and presence, prewarm when `preloadModels`), then prints `Capri is ready. Ollama .` and `Run capri to open the desktop companion.` and exits; the managed Ollama keeps running (marker) and is adopted by the GUI later. No Gateway lines. #### RT-04 `capri stop` — P0 - Source: `core.mjs:39-41`, `providers/core.mjs:216-232` (`stopCore`), `providers/services.mjs:18-35` (`stopManaged`). - Capri order: `desktop` (graceful) → `companion-voice` ∥ gateway (`Promise.allSettled`, first rejection rethrown after both settle) → `ollama` (models unloaded first, RT-19). Each stop logs `Capri service shutdown: ms`. Success message: `Capri and its Ollama instance stopped.` - Rust/Linux: `desktop` (control socket `stop`, fallback SIGTERM — RT-18) → every other registered external service (voice, optional ASR/router workers) concurrently → `ollama` last. Exit 1 if any stop fails; failed services keep their markers. Same success message. #### RT-05 `capri restart` — P2 - Source: `core.mjs:42-45` (stops and restarts only the Gateway: `Capri restarted with its saved state.`). - Rust/Linux: if the GUI runs, send control `restart` (RT-22 restart path); otherwise `stop` then `start` of the headless core. Same message. #### RT-06 Desktop launch (`capri`, `capri desktop`) — P0 - Source: `desktop-launcher.mjs:10-66`, `capri.mjs:85-91`. - Capri preconditions, in order (no file is written before step 4 succeeds or fails — `tests/desktop-launcher.test.mjs`): 1. `.runtime/updates/active.json` exists → `An update is in progress or was interrupted. Wait for it to finish, or repair this folder with the full installer.` 2. `process.arch !== 'x64'` → `This desktop preview currently targets x64.` 3. `config/core.local.json` missing → `Run npm run setup first to choose a hardware profile.` 4. Live `desktop` marker → write `data/run/desktop.show` = `{"show":true,"launchNonce":}`, return `{...marker, alreadyRunning:true}` without initializing config, memory or credentials. 5. Electron bundle incomplete → `The Capri desktop download is incomplete. Open Capri Setup again, select this installation folder and choose Retry or Repair. Keep Setup open until it finishes; microphone and voice are optional.` 6. `initialize(rt)`; Windows identity copy; delete stale `data/run/desktop.{stop,show}`; unset `ELECTRON_RUN_AS_NODE`; `launch('desktop', electron, ['--ozone-platform=x11' (Linux only), 'apps/desktop/main.mjs'])` detached. `--wait` blocks until the child exits. Output: `Showing the running Capri.` or `Capri companion started (process ).` - Rust/Linux: - `capri` (no args) and `capri desktop --wait`: run the GUI in this process. Steps: migration guard (an unfinished migration journal, RT-48, blocks with `A data import is incomplete. Run "capri migrate --resume" or "capri migrate --rollback".`) → single instance (RT-20; duplicate sends `show` and prints `Showing the running Capri.`, exit 0, touching no file) → if no `CONFIG/core.local.json`, open first-run setup (RT-39) instead of erroring → create dirs → write `RUN/run/desktop.json` marker for this process → GUI. - `capri desktop` (P2 convenience): spawns a detached `capri desktop --wait` (setsid, null stdio), waits ≤25 s for `window-ready` on the control socket, prints `Capri companion started (process ).`. - Windowing backend: on a KDE Wayland session force the X11 backend (XWayland) for all companion windows; if `WAYLAND_DISPLAY` is set and `DISPLAY` is not, fail with `Capri needs XWayland on Wayland sessions; DISPLAY is not set.` On i3 use X11 natively. #### RT-07 `capri chat` / `capri image` — P1 - Source: `core.mjs:88-109`, `src/client.mjs:10-45`. - Capri: `chat ` joins argv with spaces and prints one reply; without text it runs a REPL: banner `Capri — общий локальный диалог. Для выхода: /exit`, prompt `\nВы: `, reply printed as `\nCapri: `, empty input ignored, `/exit` ends. Request: `POST /v1/chat/completions`, timeout 240 s, headers bearer + `x-openclaw-session-key: ` + `x-openclaw-message-channel: webchat`, body `{model:"openclaw/", stream:false, messages:[{role:"system",content:personaPrompt()},{role:"user",content}]}`; reply passed through `plainDialogueText(...).trim()`. `image [prompt…]`: reads the file, MIME `image/jpeg` if bytes start `FF D8` else `image/png`, content = `[{type:"text",text},{type:"image_url",image_url:{url:"data:;base64,…"}}]`, default prompt `Опиши это изображение.` - Rust/Linux: if the GUI runs, send control `chat` (§5.2) so the same session/history is used; otherwise run the agent headless in-process (agent spec API) while holding the instance lock (refuse with `Capri is running but not responding.` if the lock is held and the socket is dead). Keep the REPL strings verbatim (they are Capri's only CLI-localized strings; see open question Q9). #### RT-08 `capri doctor` / `capri profiles` — P1 - Source: `capri.mjs:25-44`; `hardware/probe.mjs:205-310`; `hardware/profiles.mjs:53-120`; `hardware/model-catalog.mjs`. - Capri: JSON `{hardware, recommendation, software:{node,ollama,openclaw}, current:{model, contextTokens}}`, plus `profiles: MODEL_CHOICES` for `profiles`. `hardware` = `{platform, arch, osRelease, cpu, cpuThreads, ramBytes, availableRamBytes, gpus:[{name, vendor, vramMiB, memoryKind:"dedicated"|"shared"|"unknown", freeVramMiB, cudaCandidate, driver?}], warnings:[]}`; NVIDIA via `nvidia-smi --query-gpu=name,memory.total,driver_version --format=csv,noheader,nounits`. Recommendation rules (exact): RAM check `ram ≥ required − max(0.5, min(2, required/16))`; unsupported below the 8 GiB rule (`The first supported profile requires at least 8 GiB RAM.`); largest *dedicated* GPU only (never summed, shared memory never counted); `quality` if RAM ok and VRAM ≥ 11.875 GiB, else `desktop` if ≥ 7.875, else `balanced` if RAM ok, else `minimal`; `cpuThreads = max(1, min(profile.cpuThreads, floor(threads/2) || 1))`; reasons: `Detected GiB RAM.`, `Largest confirmed dedicated GPU: GiB.` or `Dedicated VRAM is unknown; a conservative text profile is selected.`, `Ollama decides actual text acceleration. CUDA speech must be installed and checked separately.` (Required RAM per profile comes from `profileRamRequirement`: `gpuSystemRamGiB` of `config/memory-estimates.json` when a dedicated GPU ≥ threshold−0.125 GiB exists, else `profile.ramGiB`.) - Rust/Linux: same JSON. `software` becomes `{ollama: bool, ollamaPath, ollamaVersion|null, session: "kde-wayland"|"i3-x11"|"other", xwayland: bool, python: bool, uv: bool}`. Linux GPU probe = `nvidia-smi` (if on PATH) + `/sys/class/drm/card*/device/{vendor,device,mem_info_vram_total,mem_info_vram_used}` (AMD dedicated), Intel/AMD APUs `memoryKind:"shared"`; RAM from `/proc/meminfo` (`MemTotal`, `MemAvailable`). Remove the warning `The desktop is currently qualified for Windows x64 only.` #### RT-09 `capri setup` (CLI profile selection) — P1 - Source: `capri.mjs:45-84`, `hardware/model-profile.mjs:12-103`. - Capri: - Refuses if markers `desktop`, `capri` or `ollama` are alive: `Stop Capri with npm stop before changing model profiles. Existing settings were preserved.` - Unsupported hardware → reasons joined by spaces. - Selected = `--profile=` else recommended. Interactive (stdin is a TTY and no `--yes`): prints `Model profiles change quality, memory use and latency. Speech packs are optional and are installed separately.`, then for each choice `: , + GiB RAM, ~ GiB VRAM for acceleration[ (BETA)]. `; asks `Profile []: `; if `core.local.json` exists asks `Replace existing local model settings? Type yes: ` (must be exactly `yes`, else `Setup cancelled; existing settings were preserved.`). Non-interactive with existing local settings requires `--replace` (`Local settings already exist. Use --replace only to deliberately change this installation.`). - Writes overrides transactionally (restores previous `core.local.json` and gateway config on failure): `model`=alias, `modelSetupRequired:false`, `upstreamModel`, `contextTokens` = largest allowed choice ≤ min(current, model limit) (fallback 8192), `cpuThreads`, `preloadModels` (`true` only for `quality`), `keepAlive:300`, `resourceProfile`, `modelCapabilities`, `modelContextLimit`, `thinkingDefault` (`off` if capabilities lack `thinking`, else `low`). - Message: `Saved locally. Next: npm run models:pull, then npm run desktop. No models were downloaded by setup.` Never downloads. - Rust/Linux: identical semantics; `npm stop` → `capri stop`; message `Saved locally. Next: capri models pull, then capri. No models were downloaded by setup.` No gateway config to patch (the agent spec reads settings directly). #### RT-10 `capri models pull` — P0 - Source: `bin/models.mjs:1-52`, `providers/model-plan.mjs:3-25`, `providers/pull-model.mjs:1-203`, `providers/{embedding-model,native-model,pull-service-recovery,registry-tls-recovery}.mjs`. - Plan (side-effect free): `models = unique([...(embeddingOnly ? [] : args || [upstreamModel ?? model]), "bge-m3:latest"])`. `--embedding-only` with explicit names → `Choose models or embeddings only`. Name regex `^[a-z0-9][a-z0-9._/-]*(?::[a-zA-Z0-9._-]+)?$` else `Invalid model name` (CLI flags can never become model names). `--plan` prints `{"models":[...],"preview":true[,"embeddingOnly":true]}` and exits. - Execution: start managed Ollama (RT-24); for each model print `Downloading ...` then pull (§5.1 `/api/pull`): print `: [ %]` when status changes or a new 10 % step is reached; stream line `{"error":…}` → fail with URL-redacted message (`https?://…` → `origin+path` + `?[redacted]` if a query existed; ≤1800 chars); success requires a `status:"success"` line, else retryable `Model pull ended before verification completed`. HTTP non-2xx → error, retryable for 408/429/500/502/503/504. - Retry: transient = error codes `ECONNRESET ETIMEDOUT EAI_AGAIN ENOTFOUND UND_ERR_SOCKET UND_ERR_CONNECT_TIMEOUT ECONNREFUSED ENETUNREACH EHOSTUNREACH` (walking `cause`/`errors` ≤4 deep) or message regex (`lookup … i/o timeout|no such host`, `connection reset`, `unexpected EOF`, `TLS handshake timeout`, `temporary failure in name resolution`, `dial|read|write tcp … (connectex|wsarecv|wsasend|i/o timeout|connection timed out|network is unreachable)`, `tls handshake eof`). At most 4 attempts; backoff `2000·2^n` ms (2, 4, 8 s); message `Model download connection interrupted: [codes]. Retrying /4 in s; Ollama retains verified layers and partial downloads.` After the 4th failure with codes: `The local model download connection failed (). Downloaded layers are retained. Retry setup and include the Ollama logs from Save report (ZIP) if it continues.` (`code: CAPRI_MODEL_PULL_CONNECTION_FAILED`). One registry-TLS recovery on `TLS handshake timeout` (RT-24); connection refused/reset → restart the managed Ollama only if it is dead and owned (`pull-service-recovery.mjs:7-25`). Pause file (installer only): abort the stream, print `Model download paused. Progress is retained.` / `Resuming model download.`; whole request deadline 2 h. - Then (unless `--embedding-only`) ensure the native chat alias (LLM spec: `/api/show` + `/api/create`, must expose `tools`+`thinking`, `vision` when the upstream has a projector), then create the CPU embedding alias `capri-embed:latest` (Capri runs `ollama create -f config/Embedding.Modelfile`, file = `FROM bge-m3:latest` / `PARAMETER num_gpu 0`), then write `data/model-inventory.json` = pretty `/api/tags` response, print `Models ready. Memory embeddings are configured for CPU.` - Rust/Linux: same; create the alias through `POST /api/create {"model":"capri-embed:latest","from":"bge-m3:latest","parameters":{"num_gpu":0},"stream":false}` (already used by `embedding-model.mjs:21-31`) so no `ollama` CLI subprocess is needed. Subcommand spelled `capri models pull [NAME…] [--plan] [--embedding-only]`. #### RT-11 `capri init` — P1 - Source: `core.mjs:27-29`, `context.mjs:254-333`. - Capri: creates `data/openclaw`, `data/workspace`, `data/workspace/memory`, `data/models`, `data/run`, `logs`, `.runtime/tmp`; creates the gateway token (`O_EXCL`, 0600, 32 random bytes hex); initializes personality and owner memory (repairing only shipped defaults in managed installs); creates/reconciles the OpenClaw config (logging silent, diagnostics off). Message `Capri configuration and private workspace initialized.` - Rust/Linux: create every Rust root with mode 0700 (RT-25), call the memory spec's `initialize_workspace()` (persona templates from `SHARE/workspace-templates`), no token, no gateway config; idempotent; same message. #### RT-12 `capri maintenance clean-cache` — P2 - Source: `tools/maintenance/clean-cache.mjs:7-145`, `tests/cleanup.test.mjs`. - Capri: preview by default; `--apply` deletes; `--package-caches` adds `.downloads`, `.runtime/uv-cache`, `.runtime/npm-cache`; fixed candidate list (27 verification folders, `.ruff_cache`, `.pytest_cache`, `__pycache__` under maintained source); any symlink in a candidate's ancestry aborts the whole plan before the first deletion; links inside a cache are unlinked, never traversed; never touches `data/`. Output JSON `{applied, logicalBytes, files, paths:[{path,bytes,files,links}]}`, then (preview) `Preview only. Add --apply to remove these caches. Stop verification/install jobs first.` Unknown args → `Usage: node scripts/clean-cache.mjs [--apply] [--package-caches]`. - Rust/Linux: same contract over `CACHE/` (`tmp/`, `downloads/` (verified archives), `verification/`) and, with `--package-caches`, `CACHE/uv/`. `DATA` is never a candidate. #### RT-13 Legacy command mapping — P1 | Capri command (npm script / .cmd) | Rust equivalent | |---|---| | `npm start`, `start.cmd` | `capri start` | | `npm stop`, `stop.cmd` | `capri stop` | | `npm run status`, `status.cmd` | `capri status` | | `npm run chat`, `chat.cmd` | `capri chat [text]` (+ `capri image FILE [prompt]`) | | `npm run desktop`, `capri.cmd` (`run-node.ps1 desktop`) | `capri` / `capri desktop [--wait]` | | `npm run doctor` / `capri.mjs profiles` | `capri doctor` / `capri profiles` | | `npm run setup`, `setup.cmd` | `capri setup [--profile=ID] [--yes] [--replace]` (CLI) — GUI first-run is RT-39 | | `npm run models:pull` | `capri models pull [NAME…] [--plan] [--embedding-only]` | | `core.mjs init|ollama|restart` | `capri init`, `capri ollama` (start/adopt managed Ollama, print version JSON), `capri restart` | | `core.mjs cli …` (OpenClaw CLI passthrough) | Not ported (no OpenClaw) | | `npm run setup:spotify`, `setup-spotify.cmd`, `spotify.cmd` | `capri spotify setup`, `capri spotify …` (Spotify spec) | | `setup-streaming-asr.cmd`, `setup-multilingual.cmd`, `setup-request-router.cmd` / `npm run setup:routing`, `setup-voice-training.cmd` | `capri components install recognition|voice|router [--language L]` (RT-40; engines owned by speech/router specs) | | `voice.cmd` (`.runtime/voice-training-venv/Scripts/python.exe -m integrations.voice_training`) | `capri voice-training …` → external Python (voice spec) | | `Install Capri.cmd` (wizard) | pacman/AUR package + in-app first-run setup (RT-39/RT-45) | | `Save setup report.cmd` | `capri diagnostics export` (RT-38) | | `npm run clean:cache` | `capri maintenance clean-cache` | | `npm run configure:{perception,files,applications,dialogue,performance,context}` | Obsolete: they patch OpenClaw `openclaw.json` (plugins/tools allowlists, sampling, context policy, native alias) after backing it up to `data/config-backups/`. Rust registers tools statically; permissions decide availability. | | `npm test`, `test:runtime`, `test:assets`, `check`, `format`, `format:check` | `cargo test`, `cargo test -p capri-runtime`, `cargo test --features assets`, `cargo clippy`, `cargo fmt` | | `npm run verify`, `verify:*` (34 scripts), `benchmark:latency`, `build:sprites`, `build:locales`, `verify:locales` | `cargo xtask verify ` / `bench` / `assets` (dev only, never shipped) | | `release:source`, `release:check`, `release:installer`, `verify:installer`, `postinstall` | `makepkg` + PKGBUILD checks (RT-45); `postinstall` (OpenClaw patcher) dropped | ### B. Process supervision Managed service names in Capri: `desktop` (Electron), `capri` (Gateway host = `rt.logPrefix`), `ollama`, `companion-voice` (Python TTS server), plus test prefixes `verification`, `desktop-verification`. ASR and router workers are children of the desktop process, not marker-managed. In Rust: `desktop` (the GUI process itself), `ollama`, `companion-voice` (if the voice spec keeps the Python server), and any worker another spec chooses to run detached. #### RT-14 Process markers and identity — P0 - Source: `host/processes.mjs:23-85`. - Marker path `data/run/.json`; name must match `^[a-z0-9-]{1,64}$` (case-insensitive) else `Invalid managed process name`. - Marker JSON: `{"pid":int,"startedAt":"","executable":"","args":[...],"projectRoot":"","privateLogSchema":1,"deviceKey"?:"<≤128 chars>"}`. - Read rules: file ≤ 65 536 bytes, valid JSON, "belongs here" (`projectRoot` absolute and equal to this root — case-insensitive on Windows; legacy markers without `projectRoot` only if `executable` or `args[0]` lies inside the root), `pid` positive integer, `startedAt` all digits; otherwise the marker is ignored (treated as absent). - `managedProcess(name)` = marker valid **and** current start time of `pid` equals `startedAt`. Linux start time: `/proc//stat`, take text after the last `)` + 2 chars, split on spaces, element 19 (= stat field 22 `starttime`, clock ticks since boot) — same as `capri_linux/common.py:80-87 started_ticks`. - `requiresPrivacyRestart(marker)` = `marker.privateLogSchema !== 1`: such a service is stopped and relaunched before adoption (it may hold raw stdout descriptors from an older build). - Rust/Linux: keep the schema, rename `projectRoot` → `dataRoot` (canonical DATA path) and keep `privateLogSchema:1`. Markers live in `RUN/run/.json` (tmpfs; vanishes at reboot/logout together with the processes). After validating identity, open a pidfd (`pidfd_open`) and use it for waiting and signalling, pinning the identity like the Windows handle in `stop-windows-process.ps1:12-25`. #### RT-15 Launching a managed service — P0 - Source: `host/processes.mjs:86-195`, `host/environment.mjs:8-48`. - If the service is already managed: call `onExit` immediately and return the existing marker (adoption). - Executable must exist: `Executable for is missing. Run npm run doctor.` - Create `logs/` and `data/run/`; delete `data/run/.stop` (only the launcher may clear a stop request; a slow child must never erase a fresh one). - Log files `logs/.stdout.log` / `.stderr.log`: private-path check; if present must be a regular file with `nlink == 1` (`Service log storage is unavailable.`); truncate to empty, mode 0600. Child output is **never** written: `stdio: 'ignore'`. Only lifecycle records are appended (RT-30). - Spawn: `cwd = root`, env = `environment(rt)` (+ registry-TLS adjustment for Ollama, + per-service extras such as `OLLAMA_GPU_OVERHEAD`, device variables), `detached: true` on non-Windows (new session), hidden window on Windows. - Events: `spawn` → record stdout `{event:"started"}`, read start time; if unreadable → ` exited during startup; see logs.`; write marker atomically (failure → kill child, reject). `error` → stderr `{event:"spawn-failed", code}`. `exit` → `{event:"exited", exitCode?}` to stderr when code ≠ 0, else stdout (signal exits have no `exitCode`). - Rust/Linux: `std::process::Command` with `process_group(0)` + `setsid` in `pre_exec`, `stdin/stdout/stderr = Stdio::null()`, `current_dir(DATA)`. Children survive GUI exit (no `PR_SET_PDEATHSIG`); the GUI reaps children it spawned (`tokio::process::Child::wait`) and uses pidfd polling for adopted ones. Env: inherit the parent environment minus `*TOKEN*`, `*SECRET*`, `*PASSWORD*`, `*API_KEY*` variables (defense in depth; Capri leaked `OPENCLAW_GATEWAY_TOKEN` into every child), then add the service env. #### RT-16 Readiness waiting and bounded local HTTP — P0 - Source: `http.mjs:2-62`, `host/readiness.mjs:6-55`. - `request(url, {timeout=10 s, maxBytes=16 MiB})`: redirects are errors; non-2xx → body discarded, error `HTTP from ` (never the body); body > limit → `Service response exceeds limit`; empty body → `null`; else JSON. - `waitFor(check, {timeout=90 s, interval=1 s, label})`: returns first truthy result; errors remembered; timeout → `