The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
keyring_consent
Gates the fallback from the OS keyring to local encrypted storage behind
explicit user consent. All code that reads or writes secrets should call
policy::check_secret_access() instead of secret_storage::is_available() directly,
so the app never silently drops to local storage without the user agreeing.
Responsibilities
- Decide, from backend identity and cached consent, whether secret access may
proceed (
PolicyDecision::Proceed/ConsentRequired/Declined). - Report
KeyringStatus(available,failure_reason,active_mode,backend_name) for the settings UI. - Persist and cache the user's consent decision (
ConsentPreference). - Publish
DomainEvent::KeyringConsentRequired/KeyringDecryptFailedwhen the frontend needs to prompt or warn the user.
Key files
| File | Purpose |
|---|---|
types.rs |
StorageMode, KeyringFailureReason, KeyringStatus, ConsentPreference, PolicyDecision |
policy.rs |
check_secret_access, current_status, active_mode_for, record_consent/build_consent_preference/apply_consent, retry_probe, notify_master_key_unavailable, notify_decrypt_failure |
ops.rs |
RPC handler bodies: keyring_status, keyring_consent_decide, keyring_retry_probe |
schemas.rs |
Controller registration for the keyring_consent RPC namespace |
mod.rs |
Module doc + re-exports |
Public surface
StorageMode: where secrets actually live.OsKeyring(no consent needed); the consent outcomesLocalEncrypted/ConsentPending/Declined(only reachable when theosbackend was intended and could not be used); and the operator-configured backendsLocalEncryptedFile(encrypted_file) /LocalPlaintextFile(file/mock), for which no consent was ever asked. The last two groups are kept distinct fromLocalEncryptedbecause they are not the same storage; see the type's doc comment.KeyringStatus:available,failure_reason: Option<KeyringFailureReason>,active_mode: StorageMode,backend_name: String.active_modeis derived frombackend_namefirst and availability second (policy::active_mode_for). Deriving it fromavailablealone previously made every non-osbackend reportOsKeyring(#6076).ConsentPreference { storage_mode, consented_at_ms }: the persisted decision.PolicyDecision::{Proceed, ConsentRequired, Declined}: returned bycheck_secret_access().policy::check_secret_access() -> PolicyDecision: the gate every secret read/write path should call. ReturnsProceedimmediately ifsecret_storage::is_available(); otherwise consults the cached consent (local_encrypted→Proceed,declined→Declined, none → publishesKeyringConsentRequiredonce and returnsConsentRequired).policy::current_status() -> KeyringStatus: snapshot for RPC/UI.policy::record_consent(mode)/build_consent_preference+apply_consent: record a decision; the RPC handler persists to disk before updating the in-memory cache so cache and disk never diverge on a failed persist.policy::retry_probe(): resets the keyring availability cache and re-evaluates status; only theosbackend can change here, since file backends always probe available.
RPC / controllers
Namespace keyring_consent, three functions (schemas.rs):
keyring_consent.status: currentKeyringStatus.keyring_consent.decide: recordmode("local_encrypted"or"declined"); persists viadesktop::app_state::update_local_statethen updates the cache.keyring_consent.retry_probe: reset and re-run the OS keyring probe.
Persistence
The consent decision is persisted through
desktop::app_state::StoredAppStatePatch { keyring_consent, .. } /
update_local_state (app-state snapshot), and mirrored into a process-wide
in-memory cache (policy::CONSENT_CACHE) so check_secret_access never
touches disk on the hot path. policy::initialize re-populates the cache from
a loaded app-state snapshot; it is change-gated so repeated snapshots with an
unchanged value are a silent no-op.
Relates to
../keyring/README.md owns backend selection
(os / encrypted_file / file / mock) and the actual secret storage
(get/set/delete, SecretStore, encrypted_file_backend.rs). This
domain never stores a secret itself. It only gates and reports on which
backend is active and whether the user consented to it. active_mode_for
matches on secret_storage::backend_name()'s identifiers ("os",
"encrypted_file", "file", "mock") to answer that question.
Used by
credentials/profiles/keychain.rsandcredentials/credential_ref.rs: consent preflight before profile secrets and credential refs touch the keyring.web3/wallet/ops/state.rs: mnemonic goes to the keychain only onProceed.desktop/app_state/: carrieskeyring_consentin the stored app state andkeyring_statusin the snapshot;policy::initializeis fed from there.