Skip to content

OS keystore only in shipped host binaries; tests, e2e and dev runs use the file store (no macOS Keychain prompts) #8095

Open

Description

@senamakel

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) reads keyring::Entry("openhuman","app:master_key"). OsKeyringBackend (backend.rs:18) wraps tinystoragedrivers::secrets::KeyringSecrets.
  • crates/openhuman-rpc/src/host/secret_storage.rs is 57 LOC. Its install() (:12) calls keyring::install() (keyring/mod.rs:13), which always installs OsMasterKeySource, then installs the persistent encrypted_file backend.
  • host::cli (host.rs:105), host::desktop (:269) and host::tui (:318) all call it. Any process booted through them, including the openhuman-core binary that tests spawn, therefore resolves the master key from the OS keychain unless OPENHUMAN_KEYRING_MASTER_KEY(_FILE) is set (encrypted_file_backend.rs:235-253).
  • crates/openhuman-rpc/Cargo.toml:15 makes os-keyring a default feature, and :25 makes server imply os-keyring. keyring 3 (apple/windows/linux-native) and tinystoragedrivers/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 whether keyring/master.key exists.
  • secret_storage::is_available() (ops.rs:210) probes the master key, and keyring_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_key semantics). 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.rs move 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.mjs and pnpm rust:layout stay 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_*, app core_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_resolvable checks keyring/master.key before probing the host source
  • L5 embed + new openhuman-keystore crate: move rpc::keyring, hosts install it, rpc drops os-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; keyring only in openhuman-keystore; core spawns only through the helper
  • L8 docs: AGENTS/CLAUDE repo map, storage and security docs, .env.example, init_keyring_workspace comment
  • L9 definition of done: macOS run of the full local test and debug matrix with zero Keychain prompts

Suggested order

  1. 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.
  2. 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.
  3. L6 builds on L5. L7 builds on L1, L5 and L6.
  4. L8 runs in parallel with L7. L9 is last.

Related

Decisions (settled 2026-10-18)

  • D1: the OS keystore moves to a new host-tier crate, crates/openhuman-keystore, which sits above openhuman-rpc and is installed by app, cli and tui in main. 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:web and cargo run. OPENHUMAN_KEYSTORE=os opts back in.
  • D3: the first debug boot of a workspace that already has a secrets.enc adopts the existing OS master key into keyring/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,115
  • tests/storage_default_import_e2e.rs:96
  • tests/embedded_server_shutdown_e2e.rs:85, which runs in-process serve_desktop
  • tests/memory_cortexdb_live.rs:153, which sets BACKEND=file but not the key, while storage secrets still call storage_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::Command for CARGO_BIN_EXE_openhuman-core. It sets OPENHUMAN_KEYRING_MASTER_KEY to a fixed test key, removes _FILE and OPENHUMAN_KEYRING_BACKEND, and sets HOME/USERPROFILE to a scratch dir when the caller gives one. Add in_process_test_key_env() for in-process boots, under env_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.rs keeps its own TEST_MASTER_KEY but re-uses the helper's constant).
  • scripts/test-rust-with-mock.sh: export a fixed OPENHUMAN_KEYRING_MASTER_KEY when unset, as test-rust-e2e.sh:184 does, and log that it did (without the value).
  • Correct the init_keyring_workspace() doc comment.

Acceptance criteria

  • Every root test that spawns openhuman-core or calls host::* gets the key from the helper. rg 'CARGO_BIN_EXE_openhuman-core' tests matches only tests/support/core_command.rs.
  • Regression test: a spawned openhuman-core inference get_client_config (the cli_model_overrides case) logs master key loaded from OPENHUMAN_KEYRING_MASTER_KEY and never host 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:58 sets an invalid key, and cli_model_overrides_e2e.rs:165 a malformed one. Keep those explicit overrides.
  • Which other root tests boot host::* in-process? Run rg '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 --help only and safe today, but should carry the same setup
  • crates/openhuman-app/src/core_process_tests.rs:129,177,209,246 (ensure_running → host::desktop at core_process.rs:320); its test_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_KEY in each rpc tests/host_*.rs before the host call. They already set_var the 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_desktop asserts that the master key resolved from the env, not the host source. Read the [keyring:encrypted_file] master key loaded from log line or expose the source name through secret_storage status.

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_status expose the master-key source so the assertion can avoid scraping logs? Check security/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:371
  • scripts/debug/harness-cache-audit.mjs:493
  • scripts/debug/harness-subagent-rpc-audit.mjs:714
  • scripts/debug/capture-first-inference.mjs:53 with --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/ (or scripts/lib/), scratchCoreEnv(base). It sets OPENHUMAN_KEYRING_BACKEND=encrypted_file and a random OPENHUMAN_KEYRING_MASTER_KEY per 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.mjs ever 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 fake MasterKeySource and create keyring/master.key. storage_master_key_resolvable() returns true and the fake's load count 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.key and an OS key that disagree? If so, is "resolvable" still the right answer, given that try_load_master_key prefers 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.rs has 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-keyring is an rpc default (Cargo.toml:15).
  • server implies 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_source and installed_master_key_source to the public openhuman_embed::secret_storage facade. rpc re-exports it as openhuman_rpc::embed::secret_storage.
  • New crate crates/openhuman-keystore, depending on openhuman-rpc (default-features = false), keyring 3 (apple/windows/linux-native), tinystoragedrivers secrets,keyring, zeroize and hex. Move backend.rs and master_key.rs with their _tests.rs unchanged. Expose pub fn install() with today's semantics.
  • rpc: delete src/keyring/ and the os-keyring feature, remove it from default and from server, and drop the keyring dependency and the tinystoragedrivers/keyring feature. host/secret_storage.rs::install() keeps only the persistent encrypted_file backend and leaves an already-installed key source alone.
  • Hosts install the keystore before host::*, behind each host's os-keyring feature (now dep:openhuman-keystore):
    • crates/openhuman-cli/src/main.rs:36
    • crates/openhuman-app/src/core_process.rs:320 and the bundled CLI at lib.rs:3485
    • crates/openhuman-tui/src/runner.rs, before process::init_master_key() at :134
  • Gates:
    • scripts/ci/check-crate-chain.mjs: add openhuman-keystore: ['openhuman-rpc'], and let app, cli and tui name it.
    • scripts/lib/feature-forwarding.mjs:491,719 and scripts/ci/product-features.txt:110: os-keyring becomes 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 keyring is empty, and so is the same query for openhuman-rpc --features server.
  • cargo tree -p openhuman-cli -i keyring shows it only through openhuman-keystore.
  • Regression test (rpc): host::cli booted in a test with no keystore installed leaves installed_master_key_source() as None, and the master key comes from keyring/master.key.
  • Regression test (keystore): the existing master_key_tests.rs and backend_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 before host::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 --workspace unifies features. Once openhuman-keystore is a workspace member, tinystoragedrivers-secrets/keyring is still compiled into tinymcp and other crates during workspace test builds. Confirm that nothing there calls KeyringSecrets; the touchpoint audit found none.
  • The openhuman-app gateway and mcp subcommands boot through lib.rs::run_core_from_args. Every entry needs the install.
  • Is openhuman-keystore the 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 that cargo test -p openhuman-rpc cannot 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.toml members
  • 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:web runs a debug openhuman-core serve (scripts/run-dev-web.sh:171) on the real workspace.
  • pnpm dev:app runs cargo 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 is OPENHUMAN_KEYSTORE=os (or OPENHUMAN_KEYRING_BACKEND=os), which opts in for debugging the keychain itself. OPENHUMAN_KEYSTORE=file forces the file store in a release build.
    • Log the decision once: [keystore] source=os|file reason=<release|debug|env>.
  • Adoption, so that a debug build does not orphan an existing dev workspace's secrets.enc. On the first debug boot where secrets.enc exists and keyring/master.key does not:
    • read the OS key once;
    • write it to keyring/master.key (mode 0600, through file_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, every OsMasterKeySource and OsKeyringBackend operation 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.enc and a mock OS entry holding key K, the first boot writes master.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.key written and secrets.enc left unchanged.
  • Tripwire test: with the env set, OsMasterKeySource::load panics.

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

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 (new policy.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=1 in scripts/test-rust-with-mock.sh, scripts/test-rust-e2e.sh, scripts/ci/rust-coverage.sh, app/scripts/e2e-run-session.sh, e2e-web-session.sh and .github/workflows/test-reusable.yml.
  • Add a new check to pnpm rust:layout, scripts/ci/check-keystore-boundary.mjs, which fails when:
    • a keyring dependency or the tinystoragedrivers keyring feature appears outside crates/openhuman-keystore; or
    • CARGO_BIN_EXE_openhuman-core appears outside tests/support/core_command.rs.
  • Add a self-test under scripts/__tests__/.

Acceptance criteria

  • With the tripwire on, the full pnpm test:rust passes on Linux CI.
  • Self-test: a fixture manifest that adds keyring to openhuman-rpc fails 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 an openhuman-keystore row to the repository map, update the crate-chain text block, and change the openhuman-rpc row so it no longer claims the keystore.
  • docs/gitbooks/en/developing/architecture/storage.md and the security docs: who installs which key source, the debug/release default, OPENHUMAN_KEYSTORE, and the tripwire. Keep zh/ in sync, or mark it for translation per the repo's GitBook rules.
  • .env.example: document OPENHUMAN_KEYSTORE and OPENHUMAN_KEYSTORE_TRIPWIRE.
  • crates/openhuman-embed/src/secret_storage.rs module docs now say that native providers belong to openhuman-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 openhuman Keychain items from a scratch login keychain (or run under a fresh user). Then, after a clean cargo clean -p openhuman-cli, run:
    • pnpm test:rust
    • pnpm debug web --script scripts/debug/web-scripts/stop-mid-turn.mjs
    • pnpm debug e2e
    • pnpm dev:app:web --no-browser
  • Watch log stream --predicate 'process == "securityd" OR subsystem == "com.apple.securityd"' and confirm there are no openhuman item accesses.
  • A release build of the desktop app still reads an existing app:master_key and decrypts secrets.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


Activity

  1. added
    test
    rust-core
    security
    os:macos
    priority: p1
    on Oct 18, 2026
  2. M3gA-Mind commented on Nov 16, 2026

    @M3gA-Mind
    Collaborator

    Re-checked on current main by reading the code. The OS keystore is still a default feature of openhuman-rpc (os-keyring, pulled in by server), and OsMasterKeySource is installed there. The encrypted file backend still asks the keychain before master.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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

os:macospriority: p1rust-coresecuritytest

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions