The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(secrets): route both keyring status surfaces through one backend→mode assertion\n\nSupersedes the inline check merged in #6139. Both PRs landed the same day against\nthe same assertion — #6139 first, this one written from a base where the problem\nwas still live — so this builds on #6139's file rather than reverting it: its doc\ncomment, its #6076 rationale and its six-mode enum guard are all kept.\n\nWhat this adds over the inline version:\n\n * The probe surface was still unguarded. `keyring_consent_retry_probe` only\n checked enum membership, so `backendName: "file"` with\n `activeMode: "os_keyring"` — the exact #6076 mismatch — would have passed\n there. Both surfaces now go through the same assertion and cannot drift.\n * The `"os"`-but-unavailable branch. `active_mode_for` falls back to the\n RECORDED CONSENT when an OS backend's probe fails; the inline\n `_ => "consent_pending"` reported that as a mismatch.\n * A `label` per call site, so a failure says which surface broke rather than\n leaving the reader to work it out from a line number.\n\nVerified on top of #6139:\n\n clean: running 9 tests ... 8 passed; 0 failed; 1 ignored\n fault injected ("file" | "mock" mapped to "os_keyring", i.e. #6076 back):\n secrets_devices_e2e.rs:347:28\n keyring_consent_status: the file/mock backend is plaintext dev-keychain.json\n and must say so rather than claiming the OS keyring\n left: "local_plaintext_file" right: "os_keyring"\n running 9 tests ... 7 passed; 1 failed\n\nThe label is demonstrated at the status site; the probe site passes the other\nliteral through the same code path. Source restored byte-identical after the\ninjection.\n\nRefs #6139, #6096, #6076\n\nClaude-Session: https://claude.ai/code/session_01Rx5Fzc5keoeUQB3MwMFqMM\n
M3gA-Mind74101bd083fe
diff --git a/tests/raw_coverage/secrets_devices_e2e.rs b/tests/raw_coverage/secrets_devices_e2e.rsindex 9249e5ef62..df50b8837b 100644--- a/tests/raw_coverage/secrets_devices_e2e.rs+++ b/tests/raw_coverage/secrets_devices_e2e.rs@@ -302,6 +302,61 @@ allowed_commands = ["ls", "cat"]// ── keyring consent ──────────────────────────────────────────────────────────+/// Assert the BACKEND -> MODE pairing, not merely that the mode is in the enum.+///+/// #6076 was exactly a mismatched pair — `backendName: "file"` with+/// `activeMode: "os_keyring"` — so a predicate that only rejects+/// `consent_pending`/`declined` would let that regression back in while a comment+/// claimed to guard it. Mirrors `active_mode_for` in+/// `security/keyring_consent/policy.rs`, including the branch #6139's inline+/// version could not reach: an `os` backend whose probe FAILED falls back to the+/// recorded consent, not to `consent_pending` unconditionally.+///+/// `label` names the call site, so a failure says which of the two surfaces broke.+fn assert_mode_matches_backend(status: &Value, label: &str) {+ let available = status+ .get("available")+ .and_then(Value::as_bool)+ .unwrap_or_else(|| panic!("{label}: `available` must be a boolean: {status}"));+ let backend = status+ .get("backendName")+ .and_then(Value::as_str)+ .unwrap_or_else(|| panic!("{label}: the backend must be named: {status}"));+ let mode = status+ .get("activeMode")+ .and_then(Value::as_str)+ .unwrap_or_else(|| panic!("{label}: status must report an `activeMode`: {status}"));++ match backend {+ "os" if available => assert_eq!(+ mode, "os_keyring",+ "{label}: a working OS credential store is the one case that may claim \+ `os_keyring`: {status}"+ ),+ // Probe failed: the mode falls back to whatever consent was recorded.+ "os" => assert!(+ ["consent_pending", "local_encrypted", "declined"].contains(&mode),+ "{label}: an unavailable OS keyring reports the recorded consent: {status}"+ ),+ "encrypted_file" => assert_eq!(+ mode, "local_encrypted_file",+ "{label}: the encrypted_file backend stores secrets in \+ {{workspace}}/secrets.enc: {status}"+ ),+ // What CI runs: no OS credential store, so secrets are plaintext on disk.+ "file" | "mock" => assert_eq!(+ mode, "local_plaintext_file",+ "{label}: the file/mock backend is plaintext dev-keychain.json and must \+ say so rather than claiming the OS keyring: {status}"+ ),+ // An unrecognised backend claims nothing — the deliberate fallback in policy.rs.+ _ => assert_eq!(+ mode, "consent_pending",+ "{label}: an unrecognised backend must not guess where secrets live: {status}"+ ),+ }+}+/// All three keyring-consent controllers.////// The anchor is the **persisted file**, not `activeMode`. `policy::current_status`@@ -366,30 +421,8 @@ async fn keyring_consent_status_decide_and_retry_probe() {.is_some_and(|n| !n.is_empty()),"the backend must be named so the settings panel can show it: {status}");+ assert_mode_matches_backend(status, "keyring_consent_status");if available {- // Assert the BACKEND -> MODE pairing, not merely that the mode is in the- // enum. #6076 was exactly a mismatched pair — `backendName: "file"` with- // `activeMode: "os_keyring"` — so a predicate that only rejects- // `consent_pending`/`declined` would let that regression back in while a- // comment claimed to guard it. Mirrors `active_mode_for` in- // `security/keyring_consent/policy.rs:125-146`.- let backend = status- .get("backendName")- .and_then(Value::as_str)- .expect("backendName asserted non-empty above");- let expected = match backend {- "os" => "os_keyring",- "encrypted_file" => "local_encrypted_file",- "file" | "mock" => "local_plaintext_file",- // An unrecognised backend reports `consent_pending` rather than- // guessing — the deliberate fallback in `policy.rs`.- _ => "consent_pending",- };- assert_eq!(- mode, expected,- "a usable `{backend}` backend must report `{expected}`; reporting anything \- else is the #6076 mismatch this test exists to catch: {status}"- );assert!(status.get("failureReason").is_none(),"`failureReason` is skipped when the keyring works: {status}"@@ -528,21 +561,7 @@ async fn keyring_consent_status_decide_and_retry_probe() {.is_some_and(|n| !n.is_empty()),"the probe result must name the backend it probed: {probe}");- assert!(- probe- .get("activeMode")- .and_then(Value::as_str)- .is_some_and(|m| [- "os_keyring",- "local_encrypted",- "local_encrypted_file",- "local_plaintext_file",- "consent_pending",- "declined",- ]- .contains(&m)),- "the probe must return a valid storage mode: {probe}"- );+ assert_mode_matches_backend(probe, "keyring_consent_retry_probe");}// ── devices ──────────────────────────────────────────────────────────────────