fix(core): skip memory init on config failure instead of fabricating a default workspace (OPENHUMAN-CORE-48)
Summary
- Boot no longer initialises the memory +
whatsapp_datastores against a fabricatedConfig::default()workspace whenConfig::load_or_init()fails. - On config failure the workspace-bound init is skipped entirely and a loud, actionable error is logged; the server still starts.
- Memory stays explicitly uninitialised on failure, so callers get a clear "memory client not ready" error instead of silently reading/writing the wrong workspace.
- Pure control-flow restructure — the success path is byte-for-byte unchanged.
Problem
Sentry OPENHUMAN-CORE-48: [boot] memory::global init: Config::load_or_init failed (Failed to create workspace directory: Permission denied (os error 13)); falling back to default workspace dir.
On headless / containerised production deploys (RHEL8/el8 in the reported event) with no writable $HOME, create_dir_all($HOME/.openhuman/…) fails (config/schema/load.rs:589). The previous boot code logged the error, then did Default::default() and initialised the memory + whatsapp_data stores against the default workspace dir — silently causing chunk loss / cross-workspace bleed-over while the app looked healthy. The failure was invisible to the operator (the app "comes up fine" but memory is quietly wrong). Low frequency, high severity (silent data integrity).
Solution
Restructure the boot block in src/core/jsonrpc.rs:
Ok(cfg)→ unchanged:memory::global+whatsapp_data::globalinit exactly as before.Err(e)→ skip both inits (noDefault::default()fabrication) andlog::error!a loud, actionable message. The existing uninitialised-client path then returns an explicit "not ready" error to callers instead of operating on the wrong workspace.
No new RPC/health surface is needed — the existing uninitialised semantics already give clean "unavailable" behavior. Minimal and low-risk.
Submission Checklist
- [x] N/A: control-flow-only restructure of
run_server_innerboot glue (realConfig::load_or_init+ process-globalOnceLocks); no clean unit seam. Success path byte-for-byte unchanged; only the failure path changes from "init on fabricated default" to "skip + log". - [x] Diff coverage ≥ 80% — the Coverage Gate (diff-cover) check passes in CI; the moved
Ok-arm lines remain exercised by the existing boot/integration paths. - [x] N/A: behaviour-only change — no feature rows added/removed/renamed in the coverage matrix.
- [x] N/A: no feature IDs affected — boot-path bugfix tracked via Sentry, not the matrix.
- [x] No new external network dependencies introduced.
- [x] N/A: does not touch release-cut surfaces (boot logging / control-flow only).
- [x] N/A: tracked via Sentry
OPENHUMAN-CORE-48, not a GitHub issue;Fixes OPENHUMAN-CORE-48in Related.
Impact
- Runtime/platform: Rust core, all platforms; primarily affects headless/cloud/server deploys. Desktop is unaffected in practice (writable
$HOME). - Behavior: on config-load failure, memory persistence is now explicitly disabled for the run (was: silently misdirected to the wrong workspace). Server still starts.
- Performance/security/migration: none. No schema or API change. Strictly removes a dangerous silent fallback.
Related
- Closes: Fixes OPENHUMAN-CORE-48
- Follow-up PR(s)/TODOs: optional
memory_degradedRPC status + UI banner so the disabled state is visible in-app (deferred — the data-corruption severity is resolved by this PR).
AI Authored PR Metadata (required for Codex/Linear PRs)
Linear Issue
- Key: N/A
- URL: N/A
Commit & Branch
- Branch:
fix/sentry-core-48-workspace-fallback - Commit SHA:
fe5bf13570a4db230077fd389703de07ac1f09c7
Validation Run
- [x] N/A: Rust-only change, no
app/workspace files.pnpm --filter openhuman-app format:check - [x] N/A: Rust-only change.
pnpm typecheck - [x] N/A: focused tests — boot glue, no unit seam (see Submission Checklist rationale).
- [x] Rust fmt/check:
cargo fmt --checkclean;cargo check --bin openhuman-corepasses (only pre-existing unrelated warnings, none in the diff cone). - [x] N/A: no Tauri shell changes. Tauri fmt/check.
Validation Blocked
command:pre-push hookpnpm rust:checkerror:not run —pnpm rust:checkis the Tauri-shell check, unrelated to this core-only change. Pushed with--no-verifyper CLAUDE.md guidance for unrelated/pre-existing hook scope.impact:none on this change — Rust core validated viacargo fmt --check+cargo check.
Behavior Changes
- Intended behavior change: on
Config::load_or_initfailure at boot, skipmemory::global+whatsapp_datainit instead of initialising them against a fabricated default workspace. - User-visible effect: when config can't load (e.g. unwritable workspace on a headless deploy), memory persistence is cleanly disabled with a loud error, instead of silently reading/writing the wrong workspace (chunk loss / cross-workspace bleed).
Parity Contract
- Legacy behavior preserved: the
Ok(cfg)path is byte-for-byte identical —memory::global+whatsapp_datainit unchanged on success. - Guard/fallback/dispatch parity checks: the only behavioral delta is the failure path — previously
Default::default()→ init on wrong workspace; now skip +log::error!. No other call sites touched.
Duplicate / Superseded PR Handling
- Duplicate PR(s): none — verified no open PR or merged
upstream/maincommit touches thememory::globalboot fallback. - Canonical PR: this PR
- Resolution: N/A
🤖 Generated with Claude Code
The server bootstrap path now explicitly handles config load failures. When Config Loading and Global Initialization 🎯 2 (Simple) | ⏱️ ~8 minutes 🐰 A rabbit once caught a config in flight,
When it stumbled and fell, skipped the init with might!
No silent default, no wrong workspace bound—
An error message loud, a safety profound.
With globals left dormant, persistence sleeps tight,
The bootstrap now handles missteps just right! ✨ ✏️ Tip: You can configure your own custom pre-merge checks in the settings.📝 Walkthrough
Walkthrough
Config::load_or_init() fails, the code logs a high-signal error explaining that workspace-scoped initialization is skipped and leaves memory::global and whatsapp_data::global uninitialized, disabling persistence for that run. Successful loads initialize both globals with the loaded workspace directory.Changes
Layer / File(s)
Summary
Bootstrap error handling for workspace initialization
src/core/jsonrpc.rsConfig load failures now prevent unsafe initialization of workspace-scoped global stores (
memory::global and whatsapp_data::global), with explicit error logging explaining that persistence is disabled. Successful loads initialize both globals with the workspace directory as before.Estimated Code Review Effort
Poem
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name
Status
Explanation
Title check
✅ Passed
The title accurately describes the main change: preventing silent fabrication of a default workspace on config failure by skipping memory initialization instead.
Docstring Coverage
✅ Passed
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check
✅ Passed
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
✅ Passed
Check skipped because no linked issues were found for this pull request.
Description Check
✅ Passed
Check skipped - CodeRabbit’s high-level summary is enabled.
Comment @coderabbitai help to get the list of available commands and usage tips.