Repository navigation
Description
Goal
On macOS, running tests (pnpm test:rust, cargo test, pnpm debug web, pnpm dev:app:web) now and then raises Keychain access prompts. Each rebuild changes the ad-hoc code signature of the test binary, so macOS asks again for openhuman / app:master_key. The goal is that only a release build of the shipped hosts (desktop app, openhuman-core CLI, TUI) ever reaches the native OS credential store. Every test, e2e run, debug script and debug build uses the encrypted file store with a workspace or environment master key. The OS keystore code moves out of the openhuman-rpc library into a host-tier crate that the three host binaries install explicitly. A tripwire makes any accidental OS-keystore access in a test fail loudly, on Linux CI as well.
OpenHuman core keeps the ports (SecretBackend, MasterKeySource, install_*) and the env → host source → keyring/master.key resolution. Nothing moves to a tiny* repo: tinystoragedrivers already owns KeyringSecrets, and only its host wiring changes.
Where we are (deep dive, 2026-10-18)
#7380 moved the OS keystore out of core into openhuman-rpc. It still ships inside the library, which turns it on by default and installs it on every host boot:
crates/openhuman-rpc/src/keyring/holds 202 LOC (mod 28, backend 100, master_key 74) and 349 lines of tests.OsMasterKeySource(master_key.rs:9) readskeyring::Entry("openhuman","app:master_key").OsKeyringBackend(backend.rs:18) wrapstinystoragedrivers::secrets::KeyringSecrets.crates/openhuman-rpc/src/host/secret_storage.rsis 57 LOC. Itsinstall()(:12) callskeyring::install()(keyring/mod.rs:13), which always installsOsMasterKeySource, then installs the persistentencrypted_filebackend.host::cli(host.rs:105),host::desktop(:269) andhost::tui(:318) all call it. Any process booted through them, including theopenhuman-corebinary that tests spawn, therefore resolves the master key from the OS keychain unlessOPENHUMAN_KEYRING_MASTER_KEY(_FILE)is set (encrypted_file_backend.rs:235-253).crates/openhuman-rpc/Cargo.toml:15makesos-keyringa default feature, and:25makesserverimplyos-keyring.keyring 3(apple/windows/linux-native) andtinystoragedrivers/keyring(:82-83) therefore compile into every rpc consumer.- Three core paths ask the installed source:
try_load_master_key(encrypted_file_backend.rs:247) can do up to three keychain operations (load, mint and store, then readback).storage_master_key(:133) does the same.storage_master_key_resolvable(:186) does a keychain read before checking whetherkeyring/master.keyexists.
secret_storage::is_available()(ops.rs:210) probes the master key, andkeyring_consent::check_secret_access(policy.rs:57) calls it. Profiles, credential refs and the wallet mnemonic all go through it.
What reaches the real keychain today:
| Caller | Exposure | Leaf |
|---|---|---|
tests/cli_model_overrides_e2e.rs:10,59,68,115 |
spawns core with no key env | L1 |
tests/storage_default_import_e2e.rs:96 |
serve, HOME and workspace only |
L1 |
tests/embedded_server_shutdown_e2e.rs:85 |
in-process serve_desktop |
L1 |
tests/memory_cortexdb_live.rs:153 |
BACKEND=file only, so lazy storage secrets still reach the OS source |
L1 |
crates/openhuman-rpc/tests/host_desktop.rs:64, host_tui.rs:23 |
in-process host boot | L2 |
crates/openhuman-app/src/core_process_tests.rs:129,177,209,246 |
ensure_running → host::desktop |
L2 |
scripts/test-rust-with-mock.sh:220 (pnpm test:rust, pnpm debug rust) |
sets no key env | L1 |
scripts/debug/web-ui.mjs:163 (pnpm debug web), goals-live.mjs:371, harness-cache-audit.mjs:493, harness-subagent-rpc-audit.mjs:714, capture-first-inference.mjs:53 |
scratch workspace, no key env | L3 |
scripts/run-dev-web.sh:171 (pnpm dev:app:web) |
debug openhuman-core serve on the real workspace |
L6 |
pnpm dev:app (run-dev-macos.sh, dev signer) |
debug Tauri build | L6 |
Already safe: 15 test sites set a key. These include mcp_stdio_integration, cli_storage_url_e2e, storage_layout_migration_e2e, saas_mode/support.rs, and every app/scripts/e2e-*.sh. There is no shared spawn helper: each test builds its own Command. tests/support/env_guard.rs::init_keyring_workspace() claims that no key env is needed, which stopped being true when #7380 landed. CI never notices because no macOS job runs cargo test: test-reusable.yml runs on ubuntu and windows, and test.yml:30 (macos-15) only compiles. On Linux the keychain is linux-keyutils, which raises no prompt.
Target architecture
openhuman-core ports + resolution: SecretBackend, MasterKeySource, install slots,
env → host source → workspace keyring/master.key (unchanged)
openhuman-embed public facade adds MasterKeySource + install_master_key_source
openhuman-rpc no OS keystore: no `keyring` dep, no `os-keyring` feature;
host::{cli,desktop,tui} install only the persistent encrypted_file
backend and use whatever key source the host already installed
openhuman-keystore NEW host-tier crate (depends on openhuman-rpc only):
OsMasterKeySource, OsKeyringBackend, `install(Policy)`,
debug-build file default, test tripwire
openhuman-cli / -app / -tui call openhuman_keystore::install(...) in main before host::*,
behind their `os-keyring` feature
tests / scripts one spawn helper with a fixed test master key; tripwire on in CI
The crate chain becomes core → embed → tinyhumans → rpc → { keystore } → { app, cli, tui }. Hosts may name openhuman-rpc and openhuman-keystore, and nothing else.
Ground rules
- Service and account names stay byte-identical (
openhuman,app:master_key,{user}:{key}), so existing desktop installs read their key unchanged. - The core never mints a replacement for a key it could not read (
load_or_mint_master_keysemantics). Any change of key source for an existing workspace goes through an explicit adoption step with a regression test. - Tests move with the code (
backend_tests.rs,master_key_tests.rsmove into the new crate). Delete the rpc module in the same PR, with no re-export shim. - Feature gates stay forwarded:
node scripts/ci/check-feature-forwarding.mjs,node scripts/ci/check-crate-chain.mjsandpnpm rust:layoutstay green, and both enabled and disabled builds are checked. - Coordinate with [cloud-storage] adopt: secret key source env → KMS → local file, with per-tenant derived keys senamakel/openhuman#288 (storage key provider env → KMS → file) and feat(permissions): add new service-related permissions to allow-core-… #272 (pods minting their own
master.key). This tree changes which host source is installed. Those leaves change the storage key provider, and neither should undo the other.
Work items (one PR each, details below)
Phase 0: stop the prompts now (parallel, no design change)
- L1 tests: one core spawn helper with a fixed master key; fix root e2e sites and
test-rust-with-mock.sh - L2 tests: fixed master key for the in-crate host-boot tests (rpc
host_*, appcore_process_tests) - L3 scripts: debug scripts that spawn a scratch core set the file store and a key
Phase 1: move the keystore to the host layer
- L4 core:
storage_master_key_resolvablecheckskeyring/master.keybefore probing the host source - L5 embed + new
openhuman-keystorecrate: moverpc::keyring, hosts install it, rpc dropsos-keyring - L6 keystore policy: debug builds and tests default to the file store; OS keychain is opt-in; one-time adoption of an existing OS key
Phase 2: guard and document
- L7 CI guard: tripwire on in every test lane;
keyringonly inopenhuman-keystore; core spawns only through the helper - L8 docs: AGENTS/CLAUDE repo map, storage and security docs,
.env.example,init_keyring_workspacecomment - L9 definition of done: macOS run of the full local test and debug matrix with zero Keychain prompts
Suggested order
- L1, L2, L3 and L4 run in parallel and land first. They remove the prompts for everything that already goes through a script or helper.
- L5 is the structural move. It is one PR because the product must not lose its keychain between the rpc removal and the host install.
- L6 builds on L5. L7 builds on L1, L5 and L6.
- L8 runs in parallel with L7. L9 is last.
Related
- refactor: move the OS key store out of openhuman-core into openhuman-rpc #7380 moved the OS keystore from core into rpc. This tree finishes that move.
- Let headless deployments supply the encrypted_file keyring master key #6926 and Document headless deployment gaps: glibc floor, no-account BYOK route, container keyring, OCI recipe #6927 cover the headless master-key env, which stays the operator path.
- Prompt user consent when OS keyring is unavailable before falling back to local secret storage #3053 and
keyring_consent_statusreportsactive_mode: os_keyringfor the file backend #6076 are keyring consent. The in-app overlay stays, and it should never appear in file mode. - [cloud-storage] adopt: secret key source env → KMS → local file, with per-tenant derived keys senamakel/openhuman#288 and feat(permissions): add new service-related permissions to allow-core-… #272 are the cloud-storage key provider work under Epic: cloud-ready storage — every piece of user state behind the tinystoragedrivers ports (file-by-file audit) #7419. Coordinate with them; nothing here supersedes them.
- [test-ownership] secret_storage: put the plaintext FileBackend and file_store helpers on tsd-secrets file; delete the copies and tests senamakel/openhuman#239 moves the plaintext
FileBackendto tsd-secrets file. It is independent.
Decisions (settled 2026-10-18)
- D1: the OS keystore moves to a new host-tier crate,
crates/openhuman-keystore, which sits aboveopenhuman-rpcand is installed by app, cli and tui inmain. It does not become a non-default rpc feature. - D2: every debug build uses the file store by default. That includes
pnpm dev:app,pnpm dev:app:webandcargo run.OPENHUMAN_KEYSTORE=osopts back in. - D3: the first debug boot of a workspace that already has a
secrets.encadopts the existing OS master key intokeyring/master.key. That costs one last prompt. It never mints a replacement.
Work item details
L1 — [keystore] tests: one core spawn helper with a fixed master key; fix root e2e sites and test-rust-with-mock.sh
Context
The openhuman-core binary boots through openhuman_rpc::host::cli, which installs OsMasterKeySource (crates/openhuman-rpc/src/host/secret_storage.rs:14). A test that spawns it without OPENHUMAN_KEYRING_MASTER_KEY(_FILE) reads the macOS Keychain, and each rebuild re-prompts. Every root test builds its own Command. The exposed sites are:
tests/cli_model_overrides_e2e.rs:10,59,68,115tests/storage_default_import_e2e.rs:96tests/embedded_server_shutdown_e2e.rs:85, which runs in-processserve_desktoptests/memory_cortexdb_live.rs:153, which setsBACKEND=filebut not the key, while storage secrets still callstorage_master_key()
The main local runner, scripts/test-rust-with-mock.sh:220, sets no key, unlike scripts/test-rust-e2e.sh:184. tests/support/env_guard.rs::init_keyring_workspace() still says that no master-key env is needed.
Scope
- Add
tests/support/core_command.rs:core_command() -> std::process::CommandforCARGO_BIN_EXE_openhuman-core. It setsOPENHUMAN_KEYRING_MASTER_KEYto a fixed test key, removes_FILEandOPENHUMAN_KEYRING_BACKEND, and setsHOME/USERPROFILEto a scratch dir when the caller gives one. Addin_process_test_key_env()for in-process boots, underenv_lock. - Move the exposed sites above onto it. Also move the existing safe sites (
cli_storage_url_e2e,storage_layout_migration_e2e,cli_sigpipe,saas_mode/support.rskeeps its ownTEST_MASTER_KEYbut re-uses the helper's constant). -
scripts/test-rust-with-mock.sh: export a fixedOPENHUMAN_KEYRING_MASTER_KEYwhen unset, astest-rust-e2e.sh:184does, and log that it did (without the value). - Correct the
init_keyring_workspace()doc comment.
Acceptance criteria
- Every root test that spawns
openhuman-coreor callshost::*gets the key from the helper.rg 'CARGO_BIN_EXE_openhuman-core' testsmatches onlytests/support/core_command.rs. - Regression test: a spawned
openhuman-core inference get_client_config(thecli_model_overridescase) logsmaster key loaded from OPENHUMAN_KEYRING_MASTER_KEYand neverhost master key source.
Verification
cargo test -p openhuman-cli --test cli_model_overrides_e2e --test storage_default_import_e2e --test embedded_server_shutdown_e2e · pnpm rust:layout · bash scripts/test-rust-with-mock.sh --help · on macOS, pnpm debug rust cli_model_overrides with no Keychain dialog
Agent brief
Depends on: none · Blocks: L7 · Parallel with: L2, L3, L4
Research first
- Does any test assert behaviour without a master key on purpose?
cli_sigpipe.rs:58sets an invalid key, andcli_model_overrides_e2e.rs:165a malformed one. Keep those explicit overrides. - Which other root tests boot
host::*in-process? Runrg 'host::(cli|desktop|tui|serve_desktop)' tests.
Files to consider
- Read:
tests/support/env_guard.rs,tests/saas_mode/support.rs:15,72-85(the existing pattern),crates/openhuman-tinyhumans/src/hosted/test_support.rs:24-45 - Change: the exposed test files above,
tests/support/mod.rs(or how support is included),scripts/test-rust-with-mock.sh - Tests: the touched e2e targets (
crates/openhuman-cli/Cargo.toml[[test]]entries are unchanged)
Workflow: implementing-an-epic step · Subagents: tdd-implementer (Sonnet), then code-reviewer
Gates: cargo test -p openhuman-cli --test <each touched> · cargo clippy -p openhuman-cli --all-targets -- -D warnings · pnpm rust:layout
L2 — [keystore] tests: fixed master key for in-crate host-boot tests (rpc host_*, app core_process_tests)
Context
These in-crate tests boot a real host and install OsMasterKeySource:
crates/openhuman-rpc/tests/host_desktop.rs:64-67(serve_desktop)host_tui.rs:23(host::tui())host_cli.rs:17,19, which is--helponly and safe today, but should carry the same setupcrates/openhuman-app/src/core_process_tests.rs:129,177,209,246(ensure_running→host::desktopatcore_process.rs:320); itstest_workspace()(:63-76) sets no keyring env
They cannot use the root tests/support helper because they are separate crates.
Scope
- Set a fixed
OPENHUMAN_KEYRING_MASTER_KEYin each rpctests/host_*.rsbefore the host call. They alreadyset_varthe workspace and backend URL. - Set the same key in
core_process_tests.rs::test_workspace(), restoring it afterwards with the guard the file already uses.
Acceptance criteria
- Regression test:
host_desktopasserts that the master key resolved from the env, not the host source. Read the[keyring:encrypted_file] master key loaded fromlog line or expose the source name throughsecret_storagestatus.
Verification
cargo test -p openhuman-rpc --test host_desktop --test host_tui --test host_cli · cargo test --manifest-path crates/openhuman-app/Cargo.toml core_process
Agent brief
Depends on: none · Blocks: L7 · Parallel with: L1, L3, L4
Research first
- Is
core_process_tests.rs:297(reuse of an existing listener) a boot path? - Does
keyring_consent_statusexpose the master-key source so the assertion can avoid scraping logs? Checksecurity/keyring_consent/ops.rs.
Files to consider
- Change:
crates/openhuman-rpc/tests/host_{desktop,tui,cli}.rs,crates/openhuman-app/src/core_process_tests.rs
Workflow: implementing-an-epic step · Subagents: tdd-implementer (Sonnet), then code-reviewer
Gates: cargo test -p openhuman-rpc · cargo check --manifest-path crates/openhuman-app/Cargo.toml --tests · cargo clippy -p openhuman-rpc --all-targets -- -D warnings
L3 — [keystore] scripts: debug scripts that spawn a scratch core use the file store and a key
Context
These scripts start a debug openhuman-core serve on a scratch workspace with no key env, so they reach the Keychain:
scripts/debug/web-ui.mjs:105,163-168(pnpm debug web)scripts/debug/goals-live.mjs:371scripts/debug/harness-cache-audit.mjs:493scripts/debug/harness-subagent-rpc-audit.mjs:714scripts/debug/capture-first-inference.mjs:53with--spawn-core
The e2e session scripts already do this correctly: app/scripts/e2e-run-session.sh:80-89 and e2e-web-session.sh:30-45.
Scope
- Add a shared helper in
scripts/debug/(orscripts/lib/),scratchCoreEnv(base). It setsOPENHUMAN_KEYRING_BACKEND=encrypted_fileand a randomOPENHUMAN_KEYRING_MASTER_KEYper scratch workspace, unless the caller already set one. - Use it in the five scripts above.
Acceptance criteria
scripts/__tests__/gains a node test for the helper: it keeps an operator-supplied key, generates a 64-hex key otherwise, and never touches the user's workspace.
Verification
node --test scripts/__tests__/<new>.test.mjs · pnpm debug web --script scripts/debug/web-scripts/stop-mid-turn.mjs on macOS with no dialog
Agent brief
Depends on: none · Blocks: L9 · Parallel with: L1, L2, L4
Research first
- Does
capture-first-inference.mjsever point at the user's real workspace? If so, do not inject a key there; L6 covers it.
Files to consider
- Read:
app/scripts/e2e-web-session.sh:30-45(the pattern) - Change: the five scripts above, plus a new helper and test
Workflow: implementing-an-epic step · Subagents: tdd-implementer (Sonnet), then code-reviewer
Gates: pnpm test:scripts (or the CI scripts lane) · pnpm format:check
L4 — [keystore] core: storage_master_key_resolvable checks keyring/master.key before probing the host source
Context
crates/openhuman-core/src/security/secret_storage/encrypted_file_backend.rs:168-190 evaluates installed_master_key_source().load(), a native keychain read, before it checks dir.join("keyring/master.key").is_file(). resolvable() (:193) is a plain OR, so the order of evaluation is what costs the prompt. The callers are the layout migration (storage/layout/credentials.rs:82,115), which runs on boot.
Scope
- Evaluate the cheap answers first: the cached key, the env key, then the key file. Probe the host source only when all of them are false.
Acceptance criteria
- Regression test in
encrypted_file_backend_tests.rs: install a counting fakeMasterKeySourceand createkeyring/master.key.storage_master_key_resolvable()returns true and the fake'sloadcount is 0.
Verification
cargo test -p openhuman storage_master_key_resolvable · cargo test -p openhuman storage::layout::credentials
Agent brief
Depends on: none · Blocks: L6 · Parallel with: L1, L2, L3
Research first
- Can a workspace have both a
master.keyand an OS key that disagree? If so, is "resolvable" still the right answer, given thattry_load_master_keyprefers the host source? Document the decision in the doc comment.
Files to consider
- Change:
crates/openhuman-core/src/security/secret_storage/encrypted_file_backend.rs:168-195 - Tests:
encrypted_file_backend_tests.rs;key_source_tests.rshas the fake source
Workflow: implementing-an-epic step · Subagents: systematic-debugger → tdd-implementer (Sonnet), then code-reviewer
Gates: cargo check -p openhuman · cargo clippy -p openhuman --all-targets -- -D warnings · pnpm rust:layout
L5 — [keystore] new openhuman-keystore crate: move rpc::keyring, hosts install it, rpc drops os-keyring
Context
The OS keystore (crates/openhuman-rpc/src/keyring/, 202 LOC plus 349 test lines) is compiled into the rpc library and installed by host::{cli,desktop,tui} (host.rs:105,269,318 via host/secret_storage.rs:14). Two features force it on:
os-keyringis an rpc default (Cargo.toml:15).serverimplies it (:25).
Every library consumer and test therefore links the keychain and installs it on boot. Hosts are limited to depending on openhuman-rpc (scripts/ci/check-crate-chain.mjs:46-51). The traits it implements come in through core_host, which hosts may not use. Embed's public secret_storage facade (crates/openhuman-embed/src/secret_storage.rs) lacks MasterKeySource and install_master_key_source.
Scope
- Embed: add
MasterKeySource,install_master_key_sourceandinstalled_master_key_sourceto the publicopenhuman_embed::secret_storagefacade. rpc re-exports it asopenhuman_rpc::embed::secret_storage. - New crate
crates/openhuman-keystore, depending onopenhuman-rpc(default-features = false),keyring 3(apple/windows/linux-native),tinystoragedriverssecrets,keyring,zeroizeandhex. Movebackend.rsandmaster_key.rswith their_tests.rsunchanged. Exposepub fn install()with today's semantics. - rpc: delete
src/keyring/and theos-keyringfeature, remove it fromdefaultand fromserver, and drop thekeyringdependency and thetinystoragedrivers/keyringfeature.host/secret_storage.rs::install()keeps only the persistentencrypted_filebackend and leaves an already-installed key source alone. - Hosts install the keystore before
host::*, behind each host'sos-keyringfeature (nowdep:openhuman-keystore):crates/openhuman-cli/src/main.rs:36crates/openhuman-app/src/core_process.rs:320and the bundled CLI atlib.rs:3485crates/openhuman-tui/src/runner.rs, beforeprocess::init_master_key()at:134
- Gates:
scripts/ci/check-crate-chain.mjs: addopenhuman-keystore: ['openhuman-rpc'], and let app, cli and tui name it.scripts/lib/feature-forwarding.mjs:491,719andscripts/ci/product-features.txt:110:os-keyringbecomes a host-local gate.scripts/ci/product-features.sh:53.- Fixtures in
scripts/__tests__/feature-forwarding.test.mjs:827,903.
- Add the root workspace member, and update
crates/openhuman-app/Cargo.toml, which is outside the workspace.
Acceptance criteria
cargo tree -p openhuman-rpc -e normal -i keyringis empty, and so is the same query foropenhuman-rpc --features server.cargo tree -p openhuman-cli -i keyringshows it only throughopenhuman-keystore.- Regression test (rpc):
host::clibooted in a test with no keystore installed leavesinstalled_master_key_source()asNone, and the master key comes fromkeyring/master.key. - Regression test (keystore): the existing
master_key_tests.rsandbackend_tests.rs(keyring::mock) pass in the new crate. Service and account strings are asserted unchanged. - The desktop build with the product features still installs
OsMasterKeySource: an app test asserts that the host-install function runs beforehost::desktop.
Verification
cargo check --manifest-path Cargo.toml · cargo check --manifest-path crates/openhuman-app/Cargo.toml · cargo test -p openhuman-keystore · cargo test -p openhuman-rpc · node scripts/ci/check-crate-chain.mjs · node scripts/ci/check-feature-forwarding.mjs · pnpm rust:layout · bash scripts/ci/product-features.sh (both CORE_ONLY=1 and default)
Agent brief
Depends on: none (L2 lands first to avoid conflicts in tests/host_*.rs) · Blocks: L6, L7, L8 · Parallel with: L1, L3, L4
Research first
cargo test --workspaceunifies features. Onceopenhuman-keystoreis a workspace member,tinystoragedrivers-secrets/keyringis still compiled intotinymcpand other crates during workspace test builds. Confirm that nothing there callsKeyringSecrets; the touchpoint audit found none.- The
openhuman-appgateway andmcpsubcommands boot throughlib.rs::run_core_from_args. Every entry needs the install. - Is
openhuman-keystorethe right name and tier, or should this be a non-default rpc feature that the host calls explicitly? This is decision D1 in the epic. The default is the separate crate, so thatcargo test -p openhuman-rpccannot link it.
Files to consider
- Read:
crates/openhuman-rpc/src/keyring/*,crates/openhuman-rpc/src/host/secret_storage.rs,crates/openhuman-rpc/src/host.rs:83-110,263-330,crates/openhuman-embed/src/host_internals.rs:208-220,crates/openhuman-embed/src/secret_storage.rs - Change: the files above, the three host manifests and entry points, the CI scripts listed, and the root
Cargo.tomlmembers - Tests:
crates/openhuman-keystore/src/*_tests.rs,crates/openhuman-rpc/src/host/secret_storage_tests.rs
Workflow: implementing-an-epic step · Subagents: tdd-implementer (Opus, or Sonnet with a stronger review, because this is security-sensitive), then code-reviewer
Gates: as in Verification, plus cargo clippy --workspace --all-targets -- -D warnings
L6 — [keystore] policy: debug builds and tests default to the file store; OS keychain is opt-in; one-time adoption of an existing OS key
Context
After L5, any host binary still installs OsMasterKeySource, including debug builds:
pnpm dev:app:webruns a debugopenhuman-core serve(scripts/run-dev-web.sh:171) on the real workspace.pnpm dev:apprunscargo tauri dev.- Any
cargo run.
Debug binaries change signature on every rebuild, so macOS re-prompts. The dev signer (scripts/setup-dev-codesign.sh) only helps dev:app. The user's ask is that tests, e2e and "everything we use" run on the file store.
Scope
-
openhuman_keystore::install()takes a policy:- Release builds install
OsMasterKeySource, as today. - Debug builds (
cfg(debug_assertions)) install nothing, so core falls back to{workspace}/keyring/master.key. The exception isOPENHUMAN_KEYSTORE=os(orOPENHUMAN_KEYRING_BACKEND=os), which opts in for debugging the keychain itself.OPENHUMAN_KEYSTORE=fileforces the file store in a release build. - Log the decision once:
[keystore] source=os|file reason=<release|debug|env>.
- Release builds install
- Adoption, so that a debug build does not orphan an existing dev workspace's
secrets.enc. On the first debug boot wheresecrets.encexists andkeyring/master.keydoes not:- read the OS key once;
- write it to
keyring/master.key(mode 0600, throughfile_store::write_atomic); - log it, and never prompt again.
- If the read is denied, refuse with a clear error that names
OPENHUMAN_KEYSTORE=os. Never mint a replacement.
- Tripwire: with
OPENHUMAN_KEYSTORE_TRIPWIRE=1, everyOsMasterKeySourceandOsKeyringBackendoperation panics with the caller's backtrace. L7 turns it on in CI and in the test scripts.
Acceptance criteria
- Unit tests over the pure policy function: (debug, no env) → file; (debug,
os) → os; (release, no env) → os; (release,file) → file. - Regression test: in a debug workspace with
secrets.encand a mock OS entry holding key K, the first boot writesmaster.key= K and the existing secret decrypts. A second boot does not touch the mock entry (load count 0). - Regression test: when the OS read is denied during adoption, the result is an error, with no
master.keywritten andsecrets.encleft unchanged. - Tripwire test: with the env set,
OsMasterKeySource::loadpanics.
Verification
cargo test -p openhuman-keystore · on macOS: pnpm dev:app:web twice across a rebuild with no dialog after adoption
Agent brief
Depends on: L5, L4 · Blocks: L7, L9 · Parallel with: L8
Research first
- Decision D2: should
pnpm dev:app(signed with the dev signer) also default to the file store? This draft says yes ("everything we use filestore"). Checkscripts/run-dev-macos.shand decide whether to passOPENHUMAN_KEYSTORE=osthere. - Adoption also touches
secretstore.master_keyand auth profiles stored in the OS backend (OsKeyringBackend, only whenOPENHUMAN_KEYRING_BACKEND=os). Is any default-path data stored in the OS backend rather than insecrets.enc? Checksecurity/credentials/profiles/keychain.rsandweb3/wallet/ops/state.rs:56. - Interaction with [cloud-storage] bug: a pod with no configured key mints its own keyring/master.key, so other pods cannot decrypt senamakel/openhuman#272 and [Channels] Telegram Managed DM auth and user mapping #288 (cloud pods and the storage key provider order).
Files to consider
- Read:
crates/openhuman-core/src/security/secret_storage/encrypted_file_backend.rs:77-160,235-253,encrypted_file_backend/key_source.rs:63-125 - Change:
crates/openhuman-keystore/src/lib.rs(newpolicy.rs,adopt.rs,tripwire.rs) - Tests:
crates/openhuman-keystore/src/*_tests.rs
Workflow: implementing-an-epic step · Subagents: plan-writer (Opus) for the adoption design, then tdd-implementer, then code-reviewer
Gates: cargo test -p openhuman-keystore · cargo clippy -p openhuman-keystore --all-targets -- -D warnings · cargo check --manifest-path crates/openhuman-app/Cargo.toml
L7 — [keystore] CI guard: tripwire in every test lane; keyring only in openhuman-keystore; core spawns only through the helper
Context
Prompts only show on macOS, and no macOS CI job runs tests (test-reusable.yml uses ubuntu and windows; test.yml:30 only compiles). A regression would therefore go unnoticed. The L6 tripwire makes any OS-keystore access fail on Linux too.
Scope
- Set
OPENHUMAN_KEYSTORE_TRIPWIRE=1inscripts/test-rust-with-mock.sh,scripts/test-rust-e2e.sh,scripts/ci/rust-coverage.sh,app/scripts/e2e-run-session.sh,e2e-web-session.shand.github/workflows/test-reusable.yml. - Add a new check to
pnpm rust:layout,scripts/ci/check-keystore-boundary.mjs, which fails when:- a
keyringdependency or thetinystoragedriverskeyringfeature appears outsidecrates/openhuman-keystore; or CARGO_BIN_EXE_openhuman-coreappears outsidetests/support/core_command.rs.
- a
- Add a self-test under
scripts/__tests__/.
Acceptance criteria
- With the tripwire on, the full
pnpm test:rustpasses on Linux CI. - Self-test: a fixture manifest that adds
keyringtoopenhuman-rpcfails the check, and so does a fixture test that spawns the binary directly.
Verification
node scripts/ci/check-keystore-boundary.mjs · node --test scripts/__tests__/check-keystore-boundary.test.mjs · pnpm rust:layout · CI Lite green
Agent brief
Depends on: L1, L2, L5, L6 · Blocks: L9 · Parallel with: L8
Research first
- How do the existing guards (
check-crate-chain.mjs,check-core-hosted-free.mjs) structure their self-tests? Copy that shape.
Workflow: test-to-green (it touches CI lanes) · Subagents: tdd-implementer (Sonnet), then code-reviewer
Gates: pnpm rust:layout · the CI scripts lane · pnpm format:check
L8 — [keystore] docs: repo map, storage and security docs, .env.example
Scope
-
AGENTS.md/CLAUDE.md: add anopenhuman-keystorerow to the repository map, update the crate-chain text block, and change theopenhuman-rpcrow so it no longer claims the keystore. -
docs/gitbooks/en/developing/architecture/storage.mdand the security docs: who installs which key source, the debug/release default,OPENHUMAN_KEYSTORE, and the tripwire. Keepzh/in sync, or mark it for translation per the repo's GitBook rules. -
.env.example: documentOPENHUMAN_KEYSTOREandOPENHUMAN_KEYSTORE_TRIPWIRE. -
crates/openhuman-embed/src/secret_storage.rsmodule docs now say that native providers belong toopenhuman-keystore.
Verification
pnpm docs:generate · pnpm docs:check
Agent brief
Depends on: L5 (L6 for the env names) · Blocks: L9 · Parallel with: L7
Workflow: implementing-an-epic step · Subagents: doc-writer, then code-reviewer · Gates: pnpm docs:check, pnpm format:check
L9 — [keystore] definition of done: macOS run with zero Keychain prompts
Scope
- On a macOS machine, delete the
openhumanKeychain items from a scratch login keychain (or run under a fresh user). Then, after a cleancargo clean -p openhuman-cli, run:pnpm test:rustpnpm debug web --script scripts/debug/web-scripts/stop-mid-turn.mjspnpm debug e2epnpm dev:app:web --no-browser
- Watch
log stream --predicate 'process == "securityd" OR subsystem == "com.apple.securityd"'and confirm there are noopenhumanitem accesses. - A release build of the desktop app still reads an existing
app:master_keyand decryptssecrets.enc. - Record the results in the epic. Close it.
Agent brief
Depends on: L1–L8 · Workflow: manual or test-to-green on a macOS runner · Subagents: completion-verifier
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTodo
Activity
M3gA-Mind commentedon Nov 16, 2026
Re-checked on current main by reading the code. The OS keystore is still a default feature of
openhuman-rpc(os-keyring, pulled in byserver), andOsMasterKeySourceis installed there. The encrypted file backend still asks the keychain beforemaster.key, and there's no tripwire for tests yet.#8666 and #8670 landed related pieces (an opt-in unattended unlock, and keeping profile secrets out of the interactive keyring on a file-keyring core), but the move to a host-tier crate hasn't happened. Keeping this open.