# K1 daemon library
`kcode-k1-daemon-lib` is the library-only composition root for one private K1 loopback daemon.
## Public API
`run(PathBuf) -> ExitCode` is the sole public operation. Call it once from a small local binary. It owns the Tokio runtime, hidden no-echo Vault passphrase prompt, startup/readiness output, SIGINT/SIGTERM shutdown, and safe failure output.
## State and HTTP
The trusted root maps only to `<root>/state/`. Existing ordering, peering, invites, accounts, groups, access profiles, replay, Persons, and daemon-file state retain their ownership and formats. The encrypted Vault opens at `<root>/state/vault`; startup retrieves only its `gemini-api-key` value. Gemini uses that key, while Terra uses the local Codex login and never retrieves an OpenAI key.
Audio is always composed during startup, before listener bind: classification state is `<root>/state/audio-classification` and Access state is `<root>/state/access`. The subsystem preserves the fixed Gemini `gemini-3.1-pro-preview` and local Terra `gpt-5.6-terra` authorization model IDs, the existing eight independent classification lanes, and the same status and persistence behavior. The audio adapter contributes these eight signed authenticated routes: submit, user and group discovery, status, fragment audio, labels, retry, and discard.
The Persons access wrapper is stateless and reuses the existing Persons, Access, and Access Profile instances. The daemon exposes its signed create, universal read, authorized rename, and directly discovered manageable-Person list routes, with no directory/group expansion or request-supplied model.
The daemon binds only `127.0.0.1:4450`; its public/signing origin and only Host authority are `http://localhost:4450` and `localhost:4450`. It serves `/config.json`, Terms, registration, `/me`, exact-ID People, Groups, Access Profiles, authenticated Persons access, and authenticated audio through existing K1 HTTP leaves. Existing signing, replay, CORS, envelopes, fallback, Vault, and readiness behavior remain unchanged.
Fresh stock links retain `http://localhost:4321/lib/kcode-k1-ui/*/account.html?invite=<code>`. This library defines no binary target, CLI, static serving, audio host abstraction, UI/browser work, migration, retry, polling, package-owned request limits, generic Access/Profile changes, proxy, or deployment behavior.
## Provider composition
Gemini alone receives `Accounting` and the existing 30-minute operation timeout. Terra analysis uses one shared long-lived `kcode-k1-codex-adapter` opened during daemon startup before Audio construction and listener bind. The Codex executable is the exact `K1_CODEX_EXECUTABLE` OS value when that variable is present and otherwise `codex-safe`; the adapter working directory is the daemon process current directory. Its immutable configuration fixes model `gpt-5.6-terra`, reasoning effort `medium`, empty base instructions, and exactly the `record_speaker_labels` and `record_speaker_analysis` dynamic tools supplied by `kcode-speaker-v3-terra-analysis`.
Adapter initialization has no daemon-owned timeout or accounting. A startup failure prints the adapter error's safe `Display` text after the daemon startup prefix; raw adapter diagnostics are never logged. All unrelated startup failures retain the exact generic `kcode-k1-daemon: startup failed` line.
## Version 0.7.2
Version 0.7.2 performs the approved Audio Codex-adapter backend cutover. It selects `kcode-k1-codex-adapter` 0.3.0, `kcode-speaker-v3-terra-analysis` 0.2.0 with only `adapter`, and `kcode-speaker-v3-analysis` 0.3.0 with only `adapter-providers`. It exact-pins Access Full Audio 0.7.2, Audio Classification 0.5.4, Full Audio 0.3.5, and HTTP Audio 0.1.3. This production dependency selection contains no `kcode-codex-terra`; no direct HTTP, persistence, authorization, route, model-ID, or scheduling API changes are introduced.
## Version 0.7.3
Version 0.7.3 changes only the no-override Codex executable default from `codex` to the Kennedy Server launcher `codex-safe`. The exact `K1_CODEX_EXECUTABLE` OS-string override and all other behavior remain unchanged.