Expand description
Oxi Foundation v1 — provider profile parsing and Keychain-backed secrets.
Parses ~/.oxi/foundation/v1/profiles.json (or the path rooted at
$OXI_FOUNDATION_HOME for tests and deployment overrides) according to the
schema in doc/spec/oxi-foundation-v1.md §2. Profiles are non-secret by
construction: any field that could carry a secret is a parse-level rejection.
The SecretResolver trait lives at this CLI boundary and is never named
from oxibrain-core / oxibrain-store / oxibrain-index (see ARCHITECTURE
§15.7, ADR-007). Tests use InMemorySecretResolver; production uses
OsKeychainResolver when the CLI is built with --features os-keychain.
Resolution ladder for an extraction role (Task 3 §3):
OXIBRAIN_LLM_PROVIDER(CLI/env override) — wins outright.- Foundation profile for the requested role whose declared capabilities satisfy the configured extraction mechanism, and whose Keychain secret resolves. A missing/unavailable secret reports why that profile cannot run and falls through to (3) without sending extraction elsewhere.
- Existing
ANTHROPIC_*/OPENAI_*compatibility environment. - Local GGUF (C2 — no API key required).
Structs§
- Declared
Capabilities - Capabilities the profile’s remote model declares (§2.5 lists which
ExtractMechanismflags it advertises). Profiles whose declared set does not satisfy the configured mechanism are rejected before any Keychain lookup happens. - Foundation
Profiles - The full
profiles.jsondocument (§2.1). - InMemory
Secret Resolver - Deterministic in-memory
SecretResolverfor tests and the local-dev default. Constructed from a(service, account) -> secretmap or, when no map is provided, refuses every lookup so missing-secret behaviour is exercised by tests rather than masked. - Provider
Profile - A single Foundation profile (§2.1, §2.2). Parsed strictly: extra fields that look like secrets cause the whole file to be rejected (§2.5).
- Resolved
Profiles - A parsed and validated
FoundationProfilesready for role resolution. - Secret
Locator - A Keychain locator for the profile’s secret. The shape is fixed by §2.4:
{service, account}. The host’sSecretResolverturns this into a secret at runtime; the locator itself is safe to share.
Enums§
- Foundation
Error - Why a
profiles.jsonwas rejected at the parse boundary. The host must report one of these — never silently fall through to a different provider. - Profile
Role - The four roles a profile can declare (§2.3). Strongly typed so call sites compose against an enum, not a raw string.
- Provider
Kind - Map a Foundation profile’s
providerfield to the host’s adapter catalogue. Foundation v1 deliberately does not name “anthropic” or “openai” in the spec; the host picks the adapter that can honour the declared mechanism. Unknown provider kinds are a FoundationError::InvalidShape so a typo never silently maps to the wrong adapter.
Constants§
- ALLOWED_
ROLES - The set of legal role strings (§2.3). The host rejects profiles that list any role outside this set, so a typo never silently disables a profile.
- SCHEMA_
VERSION - The only
schema_versionthis host accepts. Any other value rejects the wholeprofiles.jsonat parse time — the host does not silently coerce. - SECRET_
FIELD_ NAMES - Field names whose presence in
profiles.jsonis a parse-level rejection (§2.5). The locator is the only credential surface; anything that smells like an inline secret is a hard fail.
Traits§
- Secret
Resolver - Resolves a Keychain locator to a secret. Production implementations read
the OS Keychain; tests use an in-memory map. The trait is never named from
oxibrain-core/oxibrain-store/oxibrain-index; only the CLI adapter boundary calls into it (ARCHITECTURE §15.7).
Functions§
- default_
secret_ resolver - Construct the production-default
SecretResolverfor the current build. - foundation_
home - Resolve the Foundation home directory.
- load_
profiles - Load
profiles.jsonfrom the standard location and validate it strictly.