Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(inference,security): correct stale inference docs and derive keyring active_mode from the backend\n\nTwo independent defects from the e2e coverage wave.\n\n#6075 — two `inference` docs stated the opposite of the code.\n\nPart 1: the managed per-tier vision map returns `true` for the reasoning and\nvision tiers, but four comments claimed otherwise ("currently all `false`" /\n"only `reasoning-v1`"). All four are corrected, and the map is now pinned\nexhaustively — every tier constant and every `hint:` alias, the `false` arms\nincluded — so a future arm flip fails a test and forces the docs to be\nrevisited. The issue named one of the four sites; the other three describe the\nsame map and had drifted the same way.\n\nPart 2: `claude_code_settings.json` is written to the directory\n`workspace_dir_from_config` returns, which is the parent of `config.config_path`\n— the OpenHuman config dir, next to `config.toml`. The RPC schema description\nand the module docs said "under the workspace", which reads as\n`Config::workspace_dir` (`~/.openhuman/workspace`) or the user's project root.\nDocs corrected at all three sites, plus a test that builds a config whose three\ncandidate directories are distinct and asserts which one receives the file.\nThe storage location itself is unchanged: moving it would orphan every existing\ninstall's persisted toggle.\n\n#6076 — `keyring_consent_status` reported `active_mode: os_keyring` for every\nnon-OS backend.\n\n`current_status()` branched on `keyring::is_available()` alone, and\n`probe_availability()` short-circuits to `true` for `file`, `mock` and\n`encrypted_file`. All three therefore claimed the OS keyring beside a\n`backend_name` that said otherwise, and a recorded `declined` decision could not\nmove it. In staging and production — where `encrypted_file` is the documented\ndefault — the shipped app told users their secrets were in the OS keychain while\nthey were in `{workspace}/secrets.enc`.\n\nThe derivation now follows the backend identity, extracted as a pure\n`active_mode_for(available, backend_name, cached)` so every combination is\ntestable without touching the process-global backend `OnceLock`:\n\n os + available -> os_keyring\n os + probe failed -> consent outcome (unchanged)\n encrypted_file -> local_encrypted_file (new)\n file / mock -> local_plaintext_file (new)\n anything else -> consent_pending, with a warning\n\n`StorageMode` gains two variants rather than reusing `local_encrypted`: that\nvalue means "the user consented to the SecretStore fallback", which is a\ndifferent mechanism and a different location from the `encrypted_file` backend's\n`secrets.enc`. Reusing it would have conflated an operator's configuration with\na consent decision. `file` is plaintext `dev-keychain.json` with no OS keychain\ninvolvement at all, so it must not be labelled encrypted in either sense.\n`available` is untouched — the file backends genuinely are usable, and the wallet\nguards and snapshot loops that read it are unaffected.\n\nAlso fixes the consumer the issue names: `SecurityPanel` looked up\n`keyring.settings.mode.${activeMode}` with a snake_case mode against camelCase\ni18n keys, so no lookup ever matched and the badge rendered the literal key\n(`declined` was the sole exception, spelled the same either way). A mode -> key\nmap bridges the two; an unknown mode still falls through to the raw value, so\nversion skew shows what the core reported rather than borrowing another mode's\nlabel.\n\nNote for the issue's blast radius: SecurityPanel's two consent buttons sit\ninside `{!keyringStatus.available && ...}`, and `available` is `true` for\n`encrypted_file`, so that section is already hidden in staging/prod — this\nchanges the badge, not the buttons. `policy_tests.rs` did not pin\n`current_status()`. `activeMode` is typed `string` in the frontend, so the new\nvariants break no types or fixtures.\n\nCloses #6075\nCloses #6076\n

Shanu03bf5cccf2d5
diff --git a/app/src/components/settings/panels/SecurityPanel.tsx b/app/src/components/settings/panels/SecurityPanel.tsx
index 1b85dfd7e9..eb744c3284 100644
--- a/app/src/components/settings/panels/SecurityPanel.tsx
+++ b/app/src/components/settings/panels/SecurityPanel.tsx
@@ -9,11 +9,37 @@ import SettingsPanel from '../layout/SettingsPanel';
const MODE_BADGE_VARIANT: Record<string, 'success' | 'warning' | 'neutral' | 'danger'> = {
os_keyring: 'success',
+ // Operator-configured encrypted_file backend: secrets.enc, unlocked by a
+ // master key in the OS keychain. A deliberate posture, not a degraded one.
+ local_encrypted_file: 'success',
+ // Consent fallback after the OS keyring failed.
local_encrypted: 'warning',
+ // Plaintext dev-keychain.json, no encryption at all.
+ local_plaintext_file: 'danger',
consent_pending: 'neutral',
declined: 'danger',
};
+/**
+ * `activeMode` arrives snake_case from the core; the `keyring.settings.mode.*`
+ * i18n keys are camelCase. Without this map every lookup missed and the badge
+ * rendered the literal key ("keyring.settings.mode.os_keyring") — `declined`
+ * was the only mode that ever resolved, because it is spelled the same in both
+ * conventions.
+ *
+ * An unrecognised mode deliberately falls through to the raw value, keeping the
+ * existing version-skew behaviour: the badge shows what the core reported
+ * instead of silently mislabelling it as a mode this build does know.
+ */
+const MODE_I18N_KEY: Record<string, string> = {
+ os_keyring: 'osKeychain',
+ local_encrypted: 'encryptedFile',
+ local_encrypted_file: 'localEncryptedFile',
+ local_plaintext_file: 'localPlaintextFile',
+ consent_pending: 'consentPending',
+ declined: 'declined',
+};
+
const SecurityPanel = () => {
const { snapshot } = useCoreState();
const { t } = useT();
@@ -23,6 +49,7 @@ const SecurityPanel = () => {
const keyringStatus = snapshot.keyringStatus;
const modeBadgeVariant =
MODE_BADGE_VARIANT[keyringStatus.activeMode] ?? MODE_BADGE_VARIANT.consent_pending;
+ const modeI18nKey = MODE_I18N_KEY[keyringStatus.activeMode] ?? keyringStatus.activeMode;
const handleRetryProbe = async () => {
setIsLoading(true);
@@ -58,9 +85,7 @@ const SecurityPanel = () => {
control={
<div className="flex items-center gap-3">
<SettingsBadge variant={modeBadgeVariant}>
- {t(
- `keyring.settings.mode.${keyringStatus.activeMode}` as Parameters<typeof t>[0]
- )}
+ {t(`keyring.settings.mode.${modeI18nKey}` as Parameters<typeof t>[0])}
</SettingsBadge>
<span className="text-xs text-content-muted">
{t('keyring.settings.backend')}: {keyringStatus.backendName}
diff --git a/app/src/components/settings/panels/__tests__/SecurityPanel.test.tsx b/app/src/components/settings/panels/__tests__/SecurityPanel.test.tsx
index 6f3665b980..5bd0ce1dbf 100644
--- a/app/src/components/settings/panels/__tests__/SecurityPanel.test.tsx
+++ b/app/src/components/settings/panels/__tests__/SecurityPanel.test.tsx
@@ -64,17 +64,33 @@ describe('SecurityPanel — storage mode badge (lines 11, 27)', () => {
mockRetryKeyringProbe.mockResolvedValue(undefined);
});
- it('renders os_keyring mode badge — key not in en.ts so t() returns key', () => {
+ // The core sends activeMode snake_case; the en.ts keys are camelCase. These
+ // used to assert the raw key ('keyring.settings.mode.os_keyring'), which is
+ // what the badge actually rendered before MODE_I18N_KEY bridged the two --
+ // 'declined' was the only mode that resolved, because it is spelled the same
+ // either way. Each mode now asserts its real label.
+ it('renders os_keyring mode badge with its translated label', () => {
setupState(makeKeyringStatus({ activeMode: 'os_keyring' }));
renderWithProviders(<SecurityPanel />);
- // 'keyring.settings.mode.os_keyring' not in en.ts → rendered as key
- expect(screen.getByText('keyring.settings.mode.os_keyring')).toBeInTheDocument();
+ expect(screen.getByText('OS Keychain')).toBeInTheDocument();
});
- it('renders local_encrypted mode badge', () => {
+ it('renders local_encrypted mode badge with its translated label', () => {
setupState(makeKeyringStatus({ activeMode: 'local_encrypted' }));
renderWithProviders(<SecurityPanel />);
- expect(screen.getByText('keyring.settings.mode.local_encrypted')).toBeInTheDocument();
+ expect(screen.getByText('Local Encrypted')).toBeInTheDocument();
+ });
+
+ it('renders local_encrypted_file mode badge with its translated label', () => {
+ setupState(makeKeyringStatus({ activeMode: 'local_encrypted_file' }));
+ renderWithProviders(<SecurityPanel />);
+ expect(screen.getByText('Encrypted file')).toBeInTheDocument();
+ });
+
+ it('renders local_plaintext_file mode badge with its translated label', () => {
+ setupState(makeKeyringStatus({ activeMode: 'local_plaintext_file' }));
+ renderWithProviders(<SecurityPanel />);
+ expect(screen.getByText('Unencrypted file')).toBeInTheDocument();
});
it('renders declined mode badge (line 27 — MODE_BADGE_VARIANT.declined = danger)', () => {
@@ -84,10 +100,10 @@ describe('SecurityPanel — storage mode badge (lines 11, 27)', () => {
expect(screen.getByText('Declined')).toBeInTheDocument();
});
- it('renders consent_pending mode badge', () => {
+ it('renders consent_pending mode badge with its translated label', () => {
setupState(makeKeyringStatus({ activeMode: 'consent_pending' }));
renderWithProviders(<SecurityPanel />);
- expect(screen.getByText('keyring.settings.mode.consent_pending')).toBeInTheDocument();
+ expect(screen.getByText('Not configured')).toBeInTheDocument();
});
});
diff --git a/app/src/components/settings/panels/__tests__/SecurityPanel.unknownMode.test.tsx b/app/src/components/settings/panels/__tests__/SecurityPanel.unknownMode.test.tsx
index 171ce2934b..bde79a86b4 100644
--- a/app/src/components/settings/panels/__tests__/SecurityPanel.unknownMode.test.tsx
+++ b/app/src/components/settings/panels/__tests__/SecurityPanel.unknownMode.test.tsx
@@ -1,15 +1,16 @@
/**
* SecurityPanel — the unknown-mode fallback.
*
- * `SecurityPanel.test.tsx` (sibling) is thorough: 18 tests, 100% line and
- * function coverage. One branch survives it — the
- * `?? MODE_BADGE_VARIANT.consent_pending` fallback at `SecurityPanel.tsx:24-25`,
- * which only runs when `keyringStatus.activeMode` is a value the UI does not
- * know.
+ * `SecurityPanel.test.tsx` (sibling) is thorough: it covers every mode's label
+ * and the whole consent flow. One branch survives it — the
+ * `?? MODE_BADGE_VARIANT.consent_pending` fallback, which only runs when
+ * `keyringStatus.activeMode` is a value the UI does not know.
*
* That is a version-skew path, not dead code: `activeMode` is typed as a plain
- * string and arrives from the core, so a core that grows a fifth mode hands this
- * panel something absent from `MODE_BADGE_VARIANT`.
+ * string and arrives from the core, so a core that grows a new mode hands this
+ * panel something absent from `MODE_BADGE_VARIANT`. It has happened once
+ * already — #6076 added `local_encrypted_file` and `local_plaintext_file`, and
+ * an older UI build against a newer core lands exactly here.
*
* **The fallback itself cannot be asserted, and this file does not pretend to.**
* `Badge` declares `defaultVariants: { variant: 'neutral' }` (`ui/Badge.tsx:22`)
@@ -20,8 +21,9 @@
* harmless belt-and-braces; it is not load-bearing.
*
* What IS asserted below: an unknown mode still renders (no crash, no blank
- * row), and the four known modes stay visually distinguishable — which is the
- * signal this row actually carries.
+ * row), the four consent-outcome modes stay visually distinguishable, and all
+ * six modes carry distinct, translated labels — which is the signal this row
+ * actually carries.
*/
import { cleanup } from '@testing-library/react';
import { afterEach, describe, expect, it, vi } from 'vitest';
@@ -68,11 +70,14 @@ describe('SecurityPanel — unknown storage mode', () => {
it('still renders the mode the core reported, even when unrecognised', () => {
const badge = render('hardware_token_v2');
- // The raw mode reaches the label (via a missing i18n key, so the key shows).
+ // The raw mode reaches the label. `MODE_I18N_KEY` deliberately falls
+ // through to the raw `activeMode` for an unknown mode, so the lookup still
+ // misses and the key shows — rather than silently borrowing the label of a
+ // mode this build does know.
expect(badge.textContent).toContain('hardware_token_v2');
});
- it('uses a distinct badge styling for each mode it does know', () => {
+ it('uses a distinct badge styling for each consent-outcome mode', () => {
const seen = new Map<string, string>();
for (const mode of ['os_keyring', 'local_encrypted', 'consent_pending', 'declined']) {
cleanup();
@@ -84,4 +89,38 @@ describe('SecurityPanel — unknown storage mode', () => {
// "declined", which is the whole signal this row carries.
expect(new Set(seen.values()).size).toBe(4);
});
+
+ it('gives every mode a distinct label, including the backend-configured ones', () => {
+ // There are six modes and only four badge variants, so the two
+ // operator-configured backends (#6076) necessarily share a variant with a
+ // consent outcome — `local_encrypted_file` with `os_keyring` (both are a
+ // deliberate, encrypted posture) and `local_plaintext_file` with `declined`.
+ // The *label* is what has to stay unambiguous, so assert that instead of
+ // widening the variant assertion above into something impossible.
+ const labels = new Set<string>();
+ for (const mode of [
+ 'os_keyring',
+ 'local_encrypted',
+ 'local_encrypted_file',
+ 'local_plaintext_file',
+ 'consent_pending',
+ 'declined',
+ ]) {
+ cleanup();
+ labels.add(render(mode).textContent ?? '');
+ }
+
+ expect(labels.size).toBe(6);
+ // And none of them fell through to a raw i18n key.
+ for (const label of labels) {
+ expect(label).not.toContain('keyring.settings.mode.');
+ }
+ });
+
+ it('never labels the plaintext file backend as encrypted', () => {
+ // `file` is plaintext dev-keychain.json. Reusing the `local_encrypted`
+ // label here would restate #6076 in the UI layer.
+ const badge = render('local_plaintext_file');
+ expect(badge.textContent).toBe('Unencrypted file');
+ });
});
diff --git a/app/src/lib/i18n/ar.ts b/app/src/lib/i18n/ar.ts
index 41fb2dfa35..81b2bb5d79 100644
--- a/app/src/lib/i18n/ar.ts
+++ b/app/src/lib/i18n/ar.ts
@@ -6080,6 +6080,8 @@ const messages: TranslationMap = {
'keyring.settings.storageMode': 'وضع تخزين الأسرار',
'keyring.settings.mode.osKeychain': 'سلسلة مفاتيح النظام',
'keyring.settings.mode.encryptedFile': 'مشفَّر محلياً',
+ 'keyring.settings.mode.localEncryptedFile': 'ملف مشفَّر',
+ 'keyring.settings.mode.localPlaintextFile': 'ملف غير مشفَّر',
'keyring.settings.mode.consentPending': 'غير مُهيَّأ',
'keyring.settings.mode.declined': 'مرفوض',
'keyring.settings.availability': 'توفّر سلسلة المفاتيح',
diff --git a/app/src/lib/i18n/bn.ts b/app/src/lib/i18n/bn.ts
index df8d7a4b70..c874dae8f5 100644
--- a/app/src/lib/i18n/bn.ts
+++ b/app/src/lib/i18n/bn.ts
@@ -6224,6 +6224,8 @@ const messages: TranslationMap = {
'keyring.settings.storageMode': 'গোপনীয়তা সঞ্চয়স্থান মোড',
'keyring.settings.mode.osKeychain': 'OS কীচেইন',
'keyring.settings.mode.encryptedFile': 'স্থানীয় এনক্রিপ্টেড',
+ 'keyring.settings.mode.localEncryptedFile': 'এনক্রিপ্টেড ফাইল',
+ 'keyring.settings.mode.localPlaintextFile': 'এনক্রিপ্ট করা হয়নি এমন ফাইল',
'keyring.settings.mode.consentPending': 'কনফিগার করা হয়নি',
'keyring.settings.mode.declined': 'প্রত্যাখ্যান করা হয়েছে',
'keyring.settings.availability': 'কিচেন প্রাপ্যতা',
diff --git a/app/src/lib/i18n/de.ts b/app/src/lib/i18n/de.ts
index c3a8b0267e..44fc204ab5 100644
--- a/app/src/lib/i18n/de.ts
+++ b/app/src/lib/i18n/de.ts
@@ -6388,6 +6388,8 @@ const messages: TranslationMap = {
'keyring.settings.storageMode': 'Geheimnisspeicher-Modus',
'keyring.settings.mode.osKeychain': 'OS-Schlüsselbund',
'keyring.settings.mode.encryptedFile': 'Lokal verschlüsselt',
+ 'keyring.settings.mode.localEncryptedFile': 'Verschlüsselte Datei',
+ 'keyring.settings.mode.localPlaintextFile': 'Unverschlüsselte Datei',
'keyring.settings.mode.consentPending': 'Nicht konfiguriert',
'keyring.settings.mode.declined': 'Abgelehnt',
'keyring.settings.availability': 'Schlüsselbund-Verfügbarkeit',
diff --git a/app/src/lib/i18n/en.ts b/app/src/lib/i18n/en.ts
index 1641176490..d6e42f1753 100644
--- a/app/src/lib/i18n/en.ts
+++ b/app/src/lib/i18n/en.ts
@@ -6963,6 +6963,8 @@ const en: TranslationMap = {
'keyring.settings.storageMode': 'Secret storage mode',
'keyring.settings.mode.osKeychain': 'OS Keychain',
'keyring.settings.mode.encryptedFile': 'Local Encrypted',
+ 'keyring.settings.mode.localEncryptedFile': 'Encrypted file',
+ 'keyring.settings.mode.localPlaintextFile': 'Unencrypted file',
'keyring.settings.mode.consentPending': 'Not configured',
'keyring.settings.mode.declined': 'Declined',
'keyring.settings.availability': 'Keychain availability',
diff --git a/app/src/lib/i18n/es.ts b/app/src/lib/i18n/es.ts
index 0364a571fd..96f9afe4b9 100644
--- a/app/src/lib/i18n/es.ts
+++ b/app/src/lib/i18n/es.ts
@@ -6351,6 +6351,8 @@ const messages: TranslationMap = {
'keyring.settings.storageMode': 'Modo de almacenamiento de secretos',
'keyring.settings.mode.osKeychain': 'Llavero del SO',
'keyring.settings.mode.encryptedFile': 'Local cifrado',
+ 'keyring.settings.mode.localEncryptedFile': 'Archivo cifrado',
+ 'keyring.settings.mode.localPlaintextFile': 'Archivo sin cifrar',
'keyring.settings.mode.consentPending': 'No configurado',
'keyring.settings.mode.declined': 'Rechazado',
'keyring.settings.availability': 'Disponibilidad del llavero',
diff --git a/app/src/lib/i18n/fr.ts b/app/src/lib/i18n/fr.ts
index 92d8f1e168..5e2f6bdd53 100644
--- a/app/src/lib/i18n/fr.ts
+++ b/app/src/lib/i18n/fr.ts
@@ -6379,6 +6379,8 @@ const messages: TranslationMap = {
'keyring.settings.storageMode': 'Mode de stockage des secrets',
'keyring.settings.mode.osKeychain': 'Trousseau du système',
'keyring.settings.mode.encryptedFile': 'Local chiffré',
+ 'keyring.settings.mode.localEncryptedFile': 'Fichier chiffré',
+ 'keyring.settings.mode.localPlaintextFile': 'Fichier non chiffré',
'keyring.settings.mode.consentPending': 'Non configuré',
'keyring.settings.mode.declined': 'Refusé',
'keyring.settings.availability': 'Disponibilité du trousseau',
diff --git a/app/src/lib/i18n/hi.ts b/app/src/lib/i18n/hi.ts
index ba7835b026..94828a2e73 100644
--- a/app/src/lib/i18n/hi.ts
+++ b/app/src/lib/i18n/hi.ts
@@ -6224,6 +6224,8 @@ const messages: TranslationMap = {
'keyring.settings.storageMode': 'रहस्य भंडारण मोड',
'keyring.settings.mode.osKeychain': 'OS कीचेन',
'keyring.settings.mode.encryptedFile': 'स्थानीय एन्क्रिप्टेड',
+ 'keyring.settings.mode.localEncryptedFile': 'एन्क्रिप्टेड फ़ाइल',
+ 'keyring.settings.mode.localPlaintextFile': 'बिना एन्क्रिप्शन वाली फ़ाइल',
'keyring.settings.mode.consentPending': 'कॉन्फ़िगर नहीं किया गया',
'keyring.settings.mode.declined': 'अस्वीकृत',
'keyring.settings.availability': 'कीचेन उपलब्धता',
diff --git a/app/src/lib/i18n/id.ts b/app/src/lib/i18n/id.ts
index 9d4057a5a1..60f0ec0449 100644
--- a/app/src/lib/i18n/id.ts
+++ b/app/src/lib/i18n/id.ts
@@ -6254,6 +6254,8 @@ const messages: TranslationMap = {
'keyring.settings.storageMode': 'Mode penyimpanan rahasia',
'keyring.settings.mode.osKeychain': 'Keychain OS',
'keyring.settings.mode.encryptedFile': 'Lokal terenkripsi',
+ 'keyring.settings.mode.localEncryptedFile': 'Berkas terenkripsi',
+ 'keyring.settings.mode.localPlaintextFile': 'Berkas tanpa enkripsi',
'keyring.settings.mode.consentPending': 'Belum dikonfigurasi',
'keyring.settings.mode.declined': 'Ditolak',
'keyring.settings.availability': 'Ketersediaan keychain',
diff --git a/app/src/lib/i18n/it.ts b/app/src/lib/i18n/it.ts
index fde717d9f8..e882cffa6e 100644
--- a/app/src/lib/i18n/it.ts
+++ b/app/src/lib/i18n/it.ts
@@ -6333,6 +6333,8 @@ const messages: TranslationMap = {
'keyring.settings.storageMode': 'Modalità archiviazione segreti',
'keyring.settings.mode.osKeychain': 'Portachiavi del SO',
'keyring.settings.mode.encryptedFile': 'Locale crittografato',
+ 'keyring.settings.mode.localEncryptedFile': 'File crittografato',
+ 'keyring.settings.mode.localPlaintextFile': 'File non crittografato',
'keyring.settings.mode.consentPending': 'Non configurato',
'keyring.settings.mode.declined': 'Rifiutato',
'keyring.settings.availability': 'Disponibilità portachiavi',
diff --git a/app/src/lib/i18n/ko.ts b/app/src/lib/i18n/ko.ts
index b471dfc1a9..c41dd0bc7f 100644
--- a/app/src/lib/i18n/ko.ts
+++ b/app/src/lib/i18n/ko.ts
@@ -6153,6 +6153,8 @@ const messages: TranslationMap = {
'keyring.settings.storageMode': '비밀 저장 모드',
'keyring.settings.mode.osKeychain': 'OS 키체인',
'keyring.settings.mode.encryptedFile': '로컬 암호화',
+ 'keyring.settings.mode.localEncryptedFile': '암호화된 파일',
+ 'keyring.settings.mode.localPlaintextFile': '암호화되지 않은 파일',
'keyring.settings.mode.consentPending': '구성되지 않음',
'keyring.settings.mode.declined': '거부됨',
'keyring.settings.availability': '키체인 가용성',
diff --git a/app/src/lib/i18n/pl.ts b/app/src/lib/i18n/pl.ts
index b4573a5a6d..121e6d7588 100644
--- a/app/src/lib/i18n/pl.ts
+++ b/app/src/lib/i18n/pl.ts
@@ -6319,6 +6319,8 @@ const messages: TranslationMap = {
'keyring.settings.storageMode': 'Tryb przechowywania sekretów',
'keyring.settings.mode.osKeychain': 'Pęk kluczy systemu',
'keyring.settings.mode.encryptedFile': 'Lokalnie zaszyfrowany',
+ 'keyring.settings.mode.localEncryptedFile': 'Zaszyfrowany plik',
+ 'keyring.settings.mode.localPlaintextFile': 'Niezaszyfrowany plik',
'keyring.settings.mode.consentPending': 'Nie skonfigurowano',
'keyring.settings.mode.declined': 'Odrzucono',
'keyring.settings.availability': 'Dostępność pęku kluczy',
diff --git a/app/src/lib/i18n/pt.ts b/app/src/lib/i18n/pt.ts
index 8eb69772af..c4f2d04162 100644
--- a/app/src/lib/i18n/pt.ts
+++ b/app/src/lib/i18n/pt.ts
@@ -6323,6 +6323,8 @@ const messages: TranslationMap = {
'keyring.settings.storageMode': 'Modo de armazenamento de segredos',
'keyring.settings.mode.osKeychain': 'Chaveiro do SO',
'keyring.settings.mode.encryptedFile': 'Local criptografado',
+ 'keyring.settings.mode.localEncryptedFile': 'Arquivo criptografado',
+ 'keyring.settings.mode.localPlaintextFile': 'Arquivo não criptografado',
'keyring.settings.mode.consentPending': 'Não configurado',
'keyring.settings.mode.declined': 'Recusado',
'keyring.settings.availability': 'Disponibilidade do chaveiro',
diff --git a/app/src/lib/i18n/ru.ts b/app/src/lib/i18n/ru.ts
index d834f52ecc..6f3da1c0c3 100644
--- a/app/src/lib/i18n/ru.ts
+++ b/app/src/lib/i18n/ru.ts
@@ -6289,6 +6289,8 @@ const messages: TranslationMap = {
'keyring.settings.storageMode': 'Режим хранения секретов',
'keyring.settings.mode.osKeychain': 'Связка ключей ОС',
'keyring.settings.mode.encryptedFile': 'Локальное шифрование',
+ 'keyring.settings.mode.localEncryptedFile': 'Зашифрованный файл',
+ 'keyring.settings.mode.localPlaintextFile': 'Незашифрованный файл',
'keyring.settings.mode.consentPending': 'Не настроено',
'keyring.settings.mode.declined': 'Отклонено',
'keyring.settings.availability': 'Доступность связки ключей',
diff --git a/app/src/lib/i18n/zh-CN.ts b/app/src/lib/i18n/zh-CN.ts
index d2c0e1ccbc..fa7f234e7e 100644
--- a/app/src/lib/i18n/zh-CN.ts
+++ b/app/src/lib/i18n/zh-CN.ts
@@ -5879,6 +5879,8 @@ const messages: TranslationMap = {
'keyring.settings.storageMode': '密钥存储模式',
'keyring.settings.mode.osKeychain': '操作系统密钥链',
'keyring.settings.mode.encryptedFile': '本地加密',
+ 'keyring.settings.mode.localEncryptedFile': '加密文件',
+ 'keyring.settings.mode.localPlaintextFile': '未加密文件',
'keyring.settings.mode.consentPending': '未配置',
'keyring.settings.mode.declined': '已拒绝',
'keyring.settings.availability': '密钥链可用性',
diff --git a/docs/TEST-COVERAGE-MATRIX.md b/docs/TEST-COVERAGE-MATRIX.md
index 4d574f546d..0707f941cd 100644
--- a/docs/TEST-COVERAGE-MATRIX.md
+++ b/docs/TEST-COVERAGE-MATRIX.md
@@ -272,7 +272,7 @@ End-to-end coverage of the agent harness via the web-chat RPC surface against an
| 6.3.1 | Steer a running sub-agent | RU | `src/openhuman/agent/orchestration/running_subagents.rs`, `src/openhuman/agent/orchestration/tools/steer_subagent.rs` | ✅ | `steer_subagent` injects a steer/collect message into a running async sub-agent's run-queue; registry enforces parent ownership + terminal guard. |
| 6.3.2 | Wait for a sub-agent result | RU | `src/openhuman/agent/orchestration/running_subagents.rs`, `src/openhuman/agent/orchestration/tools/wait_subagent.rs` | ✅ | `wait_subagent` blocks on the completion `watch` with a timeout; prunes terminal entries, leaves entries intact on timeout. |
| 6.3.3 | Steer lands in child history | RU | `src/openhuman/agent/harness/subagent_runner/ops_tests.rs::run_queue_steer_lands_in_subagent_history` | ✅ | End-to-end: a queued steer is drained by the child `run_turn_engine` and appears as a `[User steering message]` user turn in the provider request. |
-| 6.3.9 | Vision sub-agent reads attached images | RU | `src/openhuman/agent/registry/agents/loader.rs::vision_agent_loads_on_vision_hint`, `src/openhuman/inference/provider/factory_tests.rs::vision_tier_is_vision_capable`, `src/openhuman/agent/harness/engine/core.rs::gate_tests`, `src/openhuman/agent/multimodal_tests.rs::extract_image_placeholders_pulls_att_tokens_in_order` | ✅ | Orchestrator (non-vision `chat-v1`) keeps the image as a placeholder, delegates to `vision_agent` on the `vision-v1` tier, which rehydrates the on-disk attachment and reads it. Engine gate prefers per-tier `current_model_vision`; turn placeholders forwarded into the sub-agent prompt. |
+| 6.3.9 | Vision sub-agent reads attached images | RU | `src/openhuman/agent/registry/agents/loader.rs::vision_agent_loads_on_vision_hint`, `src/openhuman/inference/model_context_tests.rs::oh_tier_vision_map_is_exhaustively_pinned`, `src/openhuman/agent/harness/engine/core.rs::gate_tests`, `src/openhuman/agent/multimodal_tests.rs::extract_image_placeholders_pulls_att_tokens_in_order` | ✅ | Orchestrator (non-vision `chat-v1`) keeps the image as a placeholder, delegates to `vision_agent` on the `vision-v1` tier, which rehydrates the on-disk attachment and reads it. Engine gate prefers per-tier `current_model_vision`; turn placeholders forwarded into the sub-agent prompt. |
| 6.3.11 | Async-by-default archetype delegation (durable ref) | RU | `src/openhuman/agent/orchestration/tools/tools_e2e_tests.rs::archetype_delegation_defaults_to_async_with_durable_session_e2e`, `src/openhuman/agent/orchestration/tools/archetype_delegation.rs::parameters_schema_advertises_async_default_blocking_opt_in` | ✅ | `delegate_*` / `build_workflow` with a parent turn + chat thread return `[async_subagent_ref]` (task_id + subagent_session_id) immediately, persist a durable reusable session, and queue the result for background delivery as a new turn; `blocking: true` opts back into inline dispatch, and no-thread contexts fall back automatically. |
| 6.3.12 | Cross-turn sub-agent roster (durable store merge) | RU | `src/openhuman/agent/orchestration/running_subagents.rs::snapshot_and_block_scope_to_parent_and_reflect_live_status` | ✅ | `[active_subagents]` merges the in-memory registry with the per-workspace `subagent_sessions` store, so a cold-booted parent still sees earlier workers (id, status, task title) and resumes instead of re-delegating; Closed sessions excluded, other parents' sessions never leak. |
diff --git a/src/openhuman/inference/model_context.rs b/src/openhuman/inference/model_context.rs
index 4539953919..7b5fc48388 100644
--- a/src/openhuman/inference/model_context.rs
+++ b/src/openhuman/inference/model_context.rs
@@ -226,7 +226,8 @@ pub fn model_vision_enabled(model: &str, config: &crate::openhuman::config::Conf
/// - **Managed OpenHuman tiers** consult the hardcoded per-tier map
/// ([`crate::openhuman::inference::provider::factory::oh_tier_supports_vision`]) —
/// the remote backend does not advertise per-tier capability, so the core owns
-/// it. Currently only `reasoning-v1` is vision-capable.
+/// it. Currently `reasoning-v1` and `vision-v1` — plus their `hint:reasoning`
+/// / `hint:vision` aliases — are vision-capable; every other tier is not.
/// - **Custom/BYOK models** consult the user-set `model_registry.vision` flag
/// ([`model_vision_enabled`]).
pub fn model_supports_vision(model: &str, config: &crate::openhuman::config::Config) -> bool {
diff --git a/src/openhuman/inference/model_context_tests.rs b/src/openhuman/inference/model_context_tests.rs
index f2a819cc87..7f9226c361 100644
--- a/src/openhuman/inference/model_context_tests.rs
+++ b/src/openhuman/inference/model_context_tests.rs
@@ -123,9 +123,12 @@ fn model_supports_vision_combines_tier_map_and_registry() {
vision: true,
..Default::default()
}];
- // `reasoning-v1` is the one vision-capable managed tier; the rest are not.
+ // `reasoning-v1` and `vision-v1` are the vision-capable managed tiers; the
+ // rest are not.
assert!(model_supports_vision("reasoning-v1", &config));
assert!(model_supports_vision("hint:reasoning", &config));
+ assert!(model_supports_vision("vision-v1", &config));
+ assert!(model_supports_vision("hint:vision", &config));
assert!(!model_supports_vision("chat-v1", &config));
assert!(!model_supports_vision("hint:chat", &config));
assert!(!model_supports_vision("burst-v1", &config));
@@ -155,3 +158,56 @@ fn o1_o3_segment_match_does_not_overmatch() {
);
assert_eq!(context_window_for_model("octo3thing"), None);
}
+
+/// Pins the complete managed-tier vision map — every tier constant and every
+/// `hint:` alias `oh_tier_supports_vision` accepts.
+///
+/// The map's capability set is documented in three places (the
+/// `inference.resolve_model` handler comment, the `oh_tier_supports_vision`
+/// doc, and the [`model_supports_vision`] doc) and those comments drifted out
+/// of sync with it once already (#6075: they claimed the map was "currently all
+/// `false`" long after two tiers returned `true`). Asserting every arm — the
+/// `false` ones included — means a future arm flip fails here and forces the
+/// docs to be revisited, instead of only the two `true` arms being covered.
+#[test]
+fn oh_tier_vision_map_is_exhaustively_pinned() {
+ use crate::openhuman::config::{
+ MODEL_AGENTIC_V1, MODEL_BURST_V1, MODEL_CHAT_V1, MODEL_CODING_V1, MODEL_REASONING_QUICK_V1,
+ MODEL_REASONING_V1, MODEL_SUMMARIZATION_V1, MODEL_VISION_V1,
+ };
+ use crate::openhuman::inference::provider::factory::oh_tier_supports_vision;
+
+ for tier in [
+ MODEL_REASONING_V1,
+ "hint:reasoning",
+ MODEL_VISION_V1,
+ "hint:vision",
+ ] {
+ assert!(
+ oh_tier_supports_vision(tier),
+ "{tier} must be reported vision-capable"
+ );
+ }
+
+ for tier in [
+ MODEL_CHAT_V1,
+ "hint:chat",
+ MODEL_REASONING_QUICK_V1,
+ MODEL_AGENTIC_V1,
+ "hint:agentic",
+ MODEL_BURST_V1,
+ "hint:burst",
+ MODEL_CODING_V1,
+ "hint:coding",
+ MODEL_SUMMARIZATION_V1,
+ "hint:summarization",
+ // Anything the map does not name at all falls through to `false`.
+ "gpt-5",
+ "",
+ ] {
+ assert!(
+ !oh_tier_supports_vision(tier),
+ "{tier} must not be reported vision-capable"
+ );
+ }
+}
diff --git a/src/openhuman/inference/provider/claude_code/mod.rs b/src/openhuman/inference/provider/claude_code/mod.rs
index d742230d09..97ca67b2ea 100644
--- a/src/openhuman/inference/provider/claude_code/mod.rs
+++ b/src/openhuman/inference/provider/claude_code/mod.rs
@@ -48,6 +48,13 @@ pub(crate) static ENV_TEST_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(()
/// parent so the RPC layer and the chat factory agree on the exact path. Falls
/// back to `~/.openhuman` (then `./.openhuman`) when the config path has no
/// parent.
+///
+/// **"Workspace" here is provider-local and means the OpenHuman config
+/// directory** (`~/.openhuman` by default) — the parent of `config.config_path`.
+/// It is deliberately *not*
+/// [`crate::openhuman::config::Config::workspace_dir`] (the internal state dir
+/// `~/.openhuman/workspace`) and *not* the user's project root
+/// (`config.action_dir`, where the CLI's file tools run).
pub fn workspace_dir_from_config(config: &crate::openhuman::config::Config) -> PathBuf {
config
.config_path
diff --git a/src/openhuman/inference/provider/claude_code/settings.rs b/src/openhuman/inference/provider/claude_code/settings.rs
index 74d5bf686c..708153d9bf 100644
--- a/src/openhuman/inference/provider/claude_code/settings.rs
+++ b/src/openhuman/inference/provider/claude_code/settings.rs
@@ -2,11 +2,18 @@
//!
//! The only Claude-Code-specific knob exposed to the user — full access
//! (`bypassPermissions` + full native toolset) vs the default `acceptEdits`
-//! posture — lives in a small JSON file under the user's workspace rather than
-//! in the central [`crate::openhuman::config::Config`]. Keeping it module-local
-//! means the toggle is easy to reason about and trivial to remove, and it
-//! avoids threading a Claude-Code-only flag through the shared config/RPC
-//! plumbing.
+//! posture — lives in its own small JSON file rather than in the central
+//! [`crate::openhuman::config::Config`]. Keeping it module-local means the
+//! toggle is easy to reason about and trivial to remove, and it avoids
+//! threading a Claude-Code-only flag through the shared config/RPC plumbing.
+//!
+//! **Where the file actually is:** the directory
+//! [`super::workspace_dir_from_config`] returns — the parent of
+//! `config.config_path`, i.e. the OpenHuman **config directory** (`~/.openhuman`
+//! by default), so the file sits next to `config.toml`. Despite the parameter
+//! name below, that is *not* [`crate::openhuman::config::Config::workspace_dir`]
+//! (the internal state dir, `~/.openhuman/workspace`) and *not* the user's
+//! project root (`config.action_dir`).
//!
//! Read at turn time by [`super::driver`]; written by the
//! `inference.claude_code_set_full_access` RPC. The
@@ -17,7 +24,8 @@ use std::path::{Path, PathBuf};
use serde::{Deserialize, Serialize};
-/// File name (under `workspace_dir`) holding the persisted toggle.
+/// File name holding the persisted toggle, written into the directory the
+/// caller passes (the OpenHuman config dir — see the module docs).
const SETTINGS_FILE: &str = "claude_code_settings.json";
/// Persisted Claude Code provider settings. Defaults are the safe posture.
@@ -34,8 +42,11 @@ fn settings_path(workspace_dir: &Path) -> PathBuf {
workspace_dir.join(SETTINGS_FILE)
}
-/// Load settings from `workspace_dir`. A missing or unreadable/corrupt file
-/// yields defaults (full access OFF) — fail safe, never fail open.
+/// Load settings from `workspace_dir` — the Claude Code provider's own notion
+/// of a workspace, which is the OpenHuman config dir (see the module docs), not
+/// [`crate::openhuman::config::Config::workspace_dir`]. A missing or
+/// unreadable/corrupt file yields defaults (full access OFF) — fail safe, never
+/// fail open.
pub fn load(workspace_dir: &Path) -> ClaudeCodeSettings {
let path = settings_path(workspace_dir);
match std::fs::read(&path) {
@@ -72,9 +83,10 @@ pub fn save(workspace_dir: &Path, settings: &ClaudeCodeSettings) -> std::io::Res
Ok(())
}
-/// Load settings for the workspace implied by `config` (resolved via
-/// [`super::workspace_dir_from_config`]). Keeps workspace resolution + file IO
-/// out of the RPC handler so `schemas.rs` stays a thin delegator.
+/// Load settings for the directory implied by `config` — the parent of
+/// `config.config_path`, resolved via [`super::workspace_dir_from_config`].
+/// Keeps path resolution + file IO out of the RPC handler so `schemas.rs` stays
+/// a thin delegator.
pub fn load_for_config(config: &crate::openhuman::config::Config) -> ClaudeCodeSettings {
load(&super::workspace_dir_from_config(config))
}
diff --git a/src/openhuman/inference/provider/claude_code/settings_tests.rs b/src/openhuman/inference/provider/claude_code/settings_tests.rs
index f8a81537a8..e90280cf43 100644
--- a/src/openhuman/inference/provider/claude_code/settings_tests.rs
+++ b/src/openhuman/inference/provider/claude_code/settings_tests.rs
@@ -38,3 +38,51 @@ fn load_corrupt_file_returns_safe_defaults() {
);
let _ = std::fs::remove_dir_all(&dir);
}
+
+/// Pins **where** the settings file lands (#6075 part 2): beside `config.toml`
+/// in the OpenHuman config dir.
+///
+/// The RPC schema description and this module's docs both name that location,
+/// and they previously said "under the workspace" — which reads as
+/// `Config::workspace_dir` (`~/.openhuman/workspace`) or the user's project
+/// root. Building a config whose three candidate directories are all distinct
+/// makes the assertion discriminating: it fails if the resolution ever moves to
+/// either of the other two, so the docs cannot silently go stale again.
+#[test]
+fn save_for_config_writes_beside_config_toml_not_workspace_or_action_dir() {
+ let tmp = tempfile::TempDir::new().expect("tempdir");
+ let config_dir = tmp.path().join("config-dir");
+ let workspace_dir = config_dir.join("workspace");
+ let action_dir = tmp.path().join("projects");
+ std::fs::create_dir_all(&workspace_dir).expect("workspace dir");
+ std::fs::create_dir_all(&action_dir).expect("action dir");
+
+ let config = crate::openhuman::config::Config {
+ config_path: config_dir.join("config.toml"),
+ workspace_dir: workspace_dir.clone(),
+ action_dir: action_dir.clone(),
+ ..Default::default()
+ };
+
+ let saved = save_full_access_for_config(&config, true).expect("save settings");
+ assert!(saved.full_access);
+
+ assert!(
+ config_dir.join(SETTINGS_FILE).is_file(),
+ "settings must land next to config.toml in {}",
+ config_dir.display()
+ );
+ assert!(
+ !workspace_dir.join(SETTINGS_FILE).exists(),
+ "settings must NOT land in Config::workspace_dir"
+ );
+ assert!(
+ !action_dir.join(SETTINGS_FILE).exists(),
+ "settings must NOT land in Config::action_dir"
+ );
+
+ assert!(
+ load_for_config(&config).full_access,
+ "load_for_config must read back from the same directory it wrote to"
+ );
+}
diff --git a/src/openhuman/inference/provider/factory_part_01.rs b/src/openhuman/inference/provider/factory_part_01.rs
index 68570fbd93..aecd724173 100644
--- a/src/openhuman/inference/provider/factory_part_01.rs
+++ b/src/openhuman/inference/provider/factory_part_01.rs
@@ -249,10 +249,11 @@ pub(crate) fn is_raw_passthrough_model(model: &str) -> bool {
/// constants and their `hint:*` forms (callers may pass either pre- or
/// post-resolution).
///
-/// `reasoning-v1` is multimodal; the rest return `false` — flip an individual
-/// arm to `true` once that tier is confirmed multimodal on the backend. This is
-/// the **only** place to change managed-model vision; BYOK/custom models are
-/// handled separately by the user-set `model_registry.vision` flag
+/// `reasoning-v1` and the dedicated `vision-v1` tier are multimodal; every
+/// other tier returns `false` — flip an individual arm to `true` once that tier
+/// is confirmed multimodal on the backend. This is the **only** place to change
+/// managed-model vision; BYOK/custom models are handled separately by the
+/// user-set `model_registry.vision` flag
/// ([`crate::openhuman::inference::model_context::model_vision_enabled`]).
pub(crate) fn oh_tier_supports_vision(model: &str) -> bool {
use crate::openhuman::config::{
diff --git a/src/openhuman/inference/schemas_part_01.rs b/src/openhuman/inference/schemas_part_01.rs
index 4d5af6e6c3..65a5506949 100644
--- a/src/openhuman/inference/schemas_part_01.rs
+++ b/src/openhuman/inference/schemas_part_01.rs
@@ -543,7 +543,7 @@ pub fn schemas(function: &str) -> ControllerSchema {
"claude_code_settings" => ControllerSchema {
namespace: "inference",
function: "claude_code_settings",
- description: "Read the persisted Claude Code provider settings (currently just the full-access toggle). Self-contained per-install state stored under the workspace, not in the central config.",
+ description: "Read the persisted Claude Code provider settings (currently just the full-access toggle). Self-contained per-install state kept in its own claude_code_settings.json beside config.toml in the OpenHuman config directory — not inside the central config file, and not under the internal workspace dir (config.workspace_dir).",
inputs: vec![],
outputs: vec![json_output(
"settings",
@@ -648,8 +648,10 @@ fn handle_inference_resolve_model(params: Map<String, Value>) -> ControllerFutur
);
// Whether the resolved model accepts image input — drives the chat UI's
// image-attachment affordance. Managed OpenHuman tiers consult the
- // core-owned per-tier map (currently all `false`); custom/BYOK models are
- // covered by the user's per-model `model_registry.vision` flag.
+ // core-owned per-tier map, which returns `true` for the reasoning and
+ // vision tiers (and their `hint:` aliases) and `false` for every other
+ // tier; custom/BYOK models are covered by the user's per-model
+ // `model_registry.vision` flag.
let vision =
crate::openhuman::inference::model_context::model_supports_vision(&resolved, &config);
to_json(RpcOutcome::new(
diff --git a/src/openhuman/security/keyring/README.md b/src/openhuman/security/keyring/README.md
index 5fe01bb159..cfc1c217a5 100644
--- a/src/openhuman/security/keyring/README.md
+++ b/src/openhuman/security/keyring/README.md
@@ -89,6 +89,7 @@ Discovered consumers (`crate::openhuman::security::keyring::*`):
- **Test builds resolve the workspace per thread, not per process.** `WORKSPACE_DIR` and `OPENHUMAN_WORKSPACE` are shared by every concurrently-running test, so consulting them made the whole test binary share one credential store pinned to whichever workspace won the race. When the winner was a `TempDir` held by a test's env guard, that directory was deleted at the end of that test and — because `FileBackend::read_map` treats a missing file as an empty map — the next write silently reset the store, so unrelated tests read their own freshly-written secrets back as `None`. Under `cfg(test)`, `workspace_dir_for_file_backend()` therefore ignores both and uses `test_scope::current_workspace()`: a thread-local override when a test binds one with `test_scope::ScopedWorkspace`, otherwise a stable per-process directory under the system temp dir. Backends are then cached **per resolved directory**. Two consequences worth knowing: test runs never read or write the developer's real `~/.openhuman/dev-keychain.json`, and a test wanting a private credential store must use `ScopedWorkspace` — setting `OPENHUMAN_WORKSPACE` no longer steers the keyring. Production selection is unchanged.
- **Cleaning up historical leakage:** `node scripts/prune-dev-keychain.mjs` reports (and with `--apply` removes, after taking a backup) `dev-keychain.json` entries keyed by dead `TempDir` basenames, left behind before the isolation fix. Dry run by default.
- **`is_available()` is cached after the first probe.** The probe performs delete/set/get/delete round-trips on the `os` backend; running it per-call triggered repeated macOS permission dialogs and starved frequent pollers. Non-os backends short-circuit to `true`. A failed probe is logged at `warn` because it silently flips `use_keychain` off.
+- **`is_available()` answers "is the active backend usable", never "are secrets in the OS keychain".** Because the file backends short-circuit to `true`, availability says nothing about *where* secrets are — which is why `keyring_consent::policy::active_mode_for` derives `active_mode` from `backend_name()` and consults availability only for the `os` backend. Deriving it from `is_available()` alone is #6076: the shipped staging/production app told users their secrets were in the OS keychain while they were in `{workspace}/secrets.enc`. Consumers that genuinely want the usability answer (wallet guards, snapshot loops) read `available` and are unaffected.
- **`force_backend_for_test` panics if `BACKEND` is already initialized** — it must run before any keyring call in the same process (dedicated test binary or very top of a test).
- **`migrate_from_file` never deletes the source unless the verified write succeeds**, so failures are retryable.
- **`encrypted_file` corrupt/undecryptable files are quarantined** (renamed `secrets.enc.corrupt.<ts>`) and treated as empty rather than crashing.
diff --git a/src/openhuman/security/keyring_consent/policy.rs b/src/openhuman/security/keyring_consent/policy.rs
index 7bc364d037..a6b497788a 100644
--- a/src/openhuman/security/keyring_consent/policy.rs
+++ b/src/openhuman/security/keyring_consent/policy.rs
@@ -81,23 +81,82 @@ pub fn check_secret_access() -> PolicyDecision {
}
}
+/// Backend identifiers as [`crate::openhuman::security::keyring::backend_name`]
+/// reports them. Kept here rather than matched as bare literals so the mapping
+/// below reads as a table and a rename upstream fails in one place.
+const BACKEND_OS: &str = "os";
+const BACKEND_ENCRYPTED_FILE: &str = "encrypted_file";
+const BACKEND_FILE: &str = "file";
+const BACKEND_MOCK: &str = "mock";
+
+/// Translate a recorded consent decision into the mode it selected.
+///
+/// Only meaningful on the `os` path: consent is asked for exactly when the OS
+/// keyring was the intended store and could not be used.
+fn consent_mode(cached: Option<&ConsentPreference>) -> StorageMode {
+ match cached {
+ Some(p) if p.storage_mode == "local_encrypted" => StorageMode::LocalEncrypted,
+ Some(p) if p.storage_mode == "declined" => StorageMode::Declined,
+ _ => StorageMode::ConsentPending,
+ }
+}
+
+/// Decide what [`StorageMode`] describes this process, from the **backend
+/// identity** first and availability second.
+///
+/// Split out of [`current_status`] as a pure function so every combination can
+/// be asserted without touching the process-global backend `OnceLock` (which
+/// `force_backend_for_test` can only set once per test binary).
+///
+/// This used to branch on `available` alone, which was wrong for every
+/// non-`os` backend: `probe_availability` short-circuits to `true` for `file`,
+/// `mock` and `encrypted_file`, so all three reported `os_keyring` beside a
+/// `backend_name` that said otherwise, and a recorded `declined` decision could
+/// not move it (#6076). In staging and production — where `encrypted_file` is
+/// the default — that told the user their secrets were in the OS keychain while
+/// they were in `{workspace}/secrets.enc`.
+fn active_mode_for(
+ available: bool,
+ backend_name: &str,
+ cached: Option<&ConsentPreference>,
+) -> StorageMode {
+ match backend_name {
+ // The only backend that actually stores secrets in the OS credential
+ // store — and only while its probe passes.
+ BACKEND_OS => {
+ if available {
+ StorageMode::OsKeyring
+ } else {
+ consent_mode(cached)
+ }
+ }
+ // Operator-configured backends. No consent was ever asked for, so the
+ // consent cache says nothing about where these secrets are.
+ BACKEND_ENCRYPTED_FILE => StorageMode::LocalEncryptedFile,
+ BACKEND_FILE | BACKEND_MOCK => StorageMode::LocalPlaintextFile,
+ // A backend added without extending this table. Reporting `os_keyring`
+ // is exactly the bug above, so claim nothing instead: `backend_name`
+ // still ships in the payload and names it.
+ other => {
+ warn!(
+ "{LOG_PREFIX} unrecognised keyring backend '{other}': reporting \
+ active_mode=consent_pending rather than guessing where secrets live"
+ );
+ StorageMode::ConsentPending
+ }
+ }
+}
+
/// Build the current keyring status for RPC / snapshot consumption.
pub fn current_status() -> KeyringStatus {
let available = crate::openhuman::security::keyring::is_available();
let backend_name = crate::openhuman::security::keyring::backend_name();
+ let cached = CONSENT_CACHE.read().clone();
- let (active_mode, failure_reason) = if available {
- (StorageMode::OsKeyring, None)
- } else {
- let reason = classify_failure_reason(&backend_name);
- let cached = CONSENT_CACHE.read().clone();
- let mode = match cached {
- Some(ref p) if p.storage_mode == "local_encrypted" => StorageMode::LocalEncrypted,
- Some(ref p) if p.storage_mode == "declined" => StorageMode::Declined,
- _ => StorageMode::ConsentPending,
- };
- (mode, Some(reason))
- };
+ let active_mode = active_mode_for(available, &backend_name, cached.as_ref());
+ // `failure_reason` stays tied to the probe, not to the mode: a file backend
+ // is genuinely available, it just is not the OS keyring.
+ let failure_reason = (!available).then(|| classify_failure_reason(&backend_name));
KeyringStatus {
available,
diff --git a/src/openhuman/security/keyring_consent/policy_tests.rs b/src/openhuman/security/keyring_consent/policy_tests.rs
index 8c8911c3f2..9e0f7bec56 100644
--- a/src/openhuman/security/keyring_consent/policy_tests.rs
+++ b/src/openhuman/security/keyring_consent/policy_tests.rs
@@ -96,3 +96,132 @@ fn initialize_is_change_gated() {
);
assert_eq!(CONSENT_CACHE.read().clone(), Some(changed));
}
+
+fn consent(mode: &str) -> ConsentPreference {
+ ConsentPreference {
+ storage_mode: mode.to_string(),
+ consented_at_ms: Some(1),
+ }
+}
+
+/// #6076: the `os` backend is the only one that may report `os_keyring`, and
+/// only while its probe passes.
+#[test]
+fn active_mode_os_backend_reports_os_keyring_only_when_available() {
+ assert_eq!(
+ active_mode_for(true, BACKEND_OS, None),
+ StorageMode::OsKeyring
+ );
+ // Probe failed, nothing recorded yet → the consent prompt is pending.
+ assert_eq!(
+ active_mode_for(false, BACKEND_OS, None),
+ StorageMode::ConsentPending
+ );
+ // A recorded decision is honoured, in both directions.
+ assert_eq!(
+ active_mode_for(false, BACKEND_OS, Some(&consent("local_encrypted"))),
+ StorageMode::LocalEncrypted
+ );
+ assert_eq!(
+ active_mode_for(false, BACKEND_OS, Some(&consent("declined"))),
+ StorageMode::Declined
+ );
+ // An unparseable persisted value must not be read as consent.
+ assert_eq!(
+ active_mode_for(false, BACKEND_OS, Some(&consent("something_else"))),
+ StorageMode::ConsentPending
+ );
+}
+
+/// The regression itself: `probe_availability` short-circuits to `true` for
+/// every non-OS backend, so `available` alone reported `os_keyring` for all of
+/// them. The mode must now follow the backend identity.
+#[test]
+fn active_mode_non_os_backends_never_report_os_keyring() {
+ for backend in [
+ BACKEND_ENCRYPTED_FILE,
+ BACKEND_FILE,
+ BACKEND_MOCK,
+ "brand_new",
+ ] {
+ for available in [true, false] {
+ for cached in [
+ None,
+ Some(consent("local_encrypted")),
+ Some(consent("declined")),
+ ] {
+ let mode = active_mode_for(available, backend, cached.as_ref());
+ assert_ne!(
+ mode,
+ StorageMode::OsKeyring,
+ "backend={backend} available={available} must not claim os_keyring"
+ );
+ }
+ }
+ }
+}
+
+/// `encrypted_file` is the staging/production backend: secrets are in
+/// `{workspace}/secrets.enc`, so it gets its own mode rather than borrowing the
+/// consent outcome's `local_encrypted`.
+#[test]
+fn active_mode_encrypted_file_is_its_own_mode_and_ignores_consent() {
+ for cached in [
+ None,
+ Some(consent("local_encrypted")),
+ Some(consent("declined")),
+ ] {
+ assert_eq!(
+ active_mode_for(true, BACKEND_ENCRYPTED_FILE, cached.as_ref()),
+ StorageMode::LocalEncryptedFile
+ );
+ }
+}
+
+/// `file` is plaintext `dev-keychain.json` with no OS keychain involvement at
+/// all — it must not be labelled "encrypted" in either sense.
+#[test]
+fn active_mode_plaintext_backends_report_plaintext() {
+ for backend in [BACKEND_FILE, BACKEND_MOCK] {
+ let mode = active_mode_for(true, backend, Some(&consent("local_encrypted")));
+ assert_eq!(mode, StorageMode::LocalPlaintextFile, "backend={backend}");
+ }
+}
+
+/// A backend added upstream without extending the table must claim nothing
+/// rather than defaulting back into the bug.
+#[test]
+fn active_mode_unknown_backend_claims_nothing() {
+ assert_eq!(
+ active_mode_for(true, "brand_new", None),
+ StorageMode::ConsentPending
+ );
+}
+
+/// The self-contradiction from the report: `activeMode: os_keyring` shipping
+/// beside `backendName: file` in one object. Asserted over the real
+/// `KeyringStatus` payload, not just the mode, since that pairing is what a
+/// consumer sees.
+#[test]
+fn status_payload_mode_and_backend_never_contradict() {
+ for (backend, available) in [
+ (BACKEND_OS, true),
+ (BACKEND_OS, false),
+ (BACKEND_ENCRYPTED_FILE, true),
+ (BACKEND_FILE, true),
+ (BACKEND_MOCK, true),
+ ] {
+ let status = KeyringStatus {
+ available,
+ failure_reason: None,
+ active_mode: active_mode_for(available, backend, None),
+ backend_name: backend.to_string(),
+ };
+ if status.active_mode == StorageMode::OsKeyring {
+ assert_eq!(
+ status.backend_name, BACKEND_OS,
+ "only the os backend may report os_keyring"
+ );
+ }
+ }
+}
diff --git a/src/openhuman/security/keyring_consent/schemas.rs b/src/openhuman/security/keyring_consent/schemas.rs
index b280216710..fd76919a18 100644
--- a/src/openhuman/security/keyring_consent/schemas.rs
+++ b/src/openhuman/security/keyring_consent/schemas.rs
@@ -40,7 +40,7 @@ fn keyring_consent_schema(function: &str) -> ControllerSchema {
outputs: vec![FieldSchema {
name: "result",
ty: TypeSchema::Json,
- comment: "Structured keyring status.",
+ comment: "Structured keyring status: { available, activeMode, backendName, failureReason? }. activeMode says where secrets actually are and is derived from the backend, not from availability — os_keyring (working OS credential store) | local_encrypted (OS keyring failed, user consented to the local encrypted fallback) | local_encrypted_file (encrypted_file backend: {workspace}/secrets.enc) | local_plaintext_file (file/mock backend: plaintext dev-keychain.json) | consent_pending | declined. available reports whether the active backend is usable, which is true for the file backends.",
required: true,
}],
},
@@ -69,7 +69,7 @@ fn keyring_consent_schema(function: &str) -> ControllerSchema {
outputs: vec![FieldSchema {
name: "result",
ty: TypeSchema::Json,
- comment: "Updated keyring status after re-probe.",
+ comment: "Updated keyring status after re-probe, same shape as keyring_consent.status. Only the os backend can change here: the file backends always probe available, so their activeMode is unaffected by a re-probe.",
required: true,
}],
},
diff --git a/src/openhuman/security/keyring_consent/types.rs b/src/openhuman/security/keyring_consent/types.rs
index 5da2b425f6..cb70b88a6d 100644
--- a/src/openhuman/security/keyring_consent/types.rs
+++ b/src/openhuman/security/keyring_consent/types.rs
@@ -2,12 +2,41 @@
use serde::{Deserialize, Serialize};
+/// Where the process's secrets actually live.
+///
+/// The first two variants are **consent outcomes** — the OS keyring was the
+/// intended store, it could not be used, and the user answered the consent
+/// prompt. The next two are **operator-configured backends**: nobody was asked
+/// anything, `OPENHUMAN_KEYRING_BACKEND` (or the staging/production default)
+/// simply selected a different store. Keeping those apart matters because they
+/// are not the same storage: a consented `LocalEncrypted` fallback means
+/// per-field `SecretStore` encryption inside the config, while
+/// `LocalEncryptedFile` means the `encrypted_file` backend's single
+/// `{workspace}/secrets.enc`.
+///
+/// Read [`KeyringStatus::backend_name`] alongside this — the two answer
+/// different questions and must never contradict each other (#6076: every
+/// non-OS backend reported `OsKeyring` while `backend_name` said otherwise).
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum StorageMode {
+ /// The `os` backend, probed and working: macOS Keychain, Windows
+ /// Credential Manager, or Linux Secret Service.
OsKeyring,
+ /// Consent outcome: the OS keyring failed and the user agreed to the
+ /// local encrypted fallback.
LocalEncrypted,
+ /// Operator-configured `encrypted_file` backend — one ChaCha20-Poly1305
+ /// `{workspace}/secrets.enc`, unlocked by a master key held in the OS
+ /// keychain. The staging/production default.
+ LocalEncryptedFile,
+ /// Operator-configured `file` (or test-only `mock`) backend. `file` is a
+ /// **plaintext** `{workspace}/dev-keychain.json` with no encryption and no
+ /// OS keychain involvement at all — dev/test only.
+ LocalPlaintextFile,
+ /// The OS keyring is unavailable and the user has not answered yet.
ConsentPending,
+ /// Consent outcome: the user refused local storage.
Declined,
}
@@ -16,6 +45,8 @@ impl std::fmt::Display for StorageMode {
match self {
Self::OsKeyring => write!(f, "os_keyring"),
Self::LocalEncrypted => write!(f, "local_encrypted"),
+ Self::LocalEncryptedFile => write!(f, "local_encrypted_file"),
+ Self::LocalPlaintextFile => write!(f, "local_plaintext_file"),
Self::ConsentPending => write!(f, "consent_pending"),
Self::Declined => write!(f, "declined"),
}
diff --git a/src/openhuman/security/keyring_consent/types_tests.rs b/src/openhuman/security/keyring_consent/types_tests.rs
index 798d5da517..3e558cdc3c 100644
--- a/src/openhuman/security/keyring_consent/types_tests.rs
+++ b/src/openhuman/security/keyring_consent/types_tests.rs
@@ -5,6 +5,8 @@ fn storage_mode_serialization_roundtrip() {
let modes = [
StorageMode::OsKeyring,
StorageMode::LocalEncrypted,
+ StorageMode::LocalEncryptedFile,
+ StorageMode::LocalPlaintextFile,
StorageMode::ConsentPending,
StorageMode::Declined,
];
@@ -15,10 +17,28 @@ fn storage_mode_serialization_roundtrip() {
}
}
+/// `Display` and the serde representation must agree: `activeMode` reaches the
+/// frontend as the serialized string, while logs and `RpcOutcome` messages use
+/// `Display`, and `SecurityPanel` keys its badge variant + i18n lookup off the
+/// serialized form. A variant whose two spellings diverge renders as an unstyled
+/// unknown mode.
#[test]
-fn storage_mode_display() {
- assert_eq!(StorageMode::OsKeyring.to_string(), "os_keyring");
- assert_eq!(StorageMode::ConsentPending.to_string(), "consent_pending");
+fn storage_mode_display_matches_serde() {
+ for (mode, wire) in [
+ (StorageMode::OsKeyring, "os_keyring"),
+ (StorageMode::LocalEncrypted, "local_encrypted"),
+ (StorageMode::LocalEncryptedFile, "local_encrypted_file"),
+ (StorageMode::LocalPlaintextFile, "local_plaintext_file"),
+ (StorageMode::ConsentPending, "consent_pending"),
+ (StorageMode::Declined, "declined"),
+ ] {
+ assert_eq!(mode.to_string(), wire, "Display for {mode:?}");
+ assert_eq!(
+ serde_json::to_value(mode).unwrap(),
+ serde_json::Value::String(wire.to_string()),
+ "serde for {mode:?}"
+ );
+ }
}
#[test]