Expand description
§K1 daemon library
kcode-k1-daemon-lib is the library-only composition root for one private K1 loopback daemon. Its sole public operation owns a process-lifetime Tokio runtime, startup, readiness output, SIGINT/SIGTERM shutdown, and fixed safe failure output. Call it exactly once from a small local binary:
use std::path::PathBuf;
fn main() -> std::process::ExitCode {
kcode_k1_daemon_lib::run(PathBuf::from("/srv/k1"))
}A local development binary can use a floating kcode-k1-daemon-lib = "*" dependency and run cargo update && cargo run to select the newest published daemon-library release before startup. Cargo resolves transitive dependencies within that release’s declared requirements; incompatible dependency generations require a newer daemon-library release.
This crate defines no binary target, CLI parsing, environment configuration, installation, migration, or deployment behavior.
§Root and state
The supplied trusted root maps only to <root>/state/. That state root retains the current DaemonFiles, ordering, peering, invites, accounts, groups, access-profile, replay, and invite-stock ownership and formats. It creates no Web roots and validates or serves neither web/ nor web-modules/.
The daemon binds only 127.0.0.1:4450; its public origin and accepted single Host authority are exactly http://localhost:4450 and localhost:4450. It serves /config.json, Terms, registration, /me, exact-ID People, Groups, and Access Profiles through the existing K1 HTTP leaves. Those leaves retain authentication, signing, replay, CORS, envelopes, and route semantics. Unknown non-API paths use Axum’s ordinary 404.
Kennedy Server may serve the browser UI separately on port 4321. This library remains only the loopback API backend and preserves the existing cross-origin K1 HTTP behavior; it does not serve, copy, proxy, or discover the UI.
§Output and failure
On readiness, stdout receives one flushed JSON line with event, public_origin, and the reconciled unused invite count. Startup over 100 ms emits the existing structured stderr warning. Startup failure emits only kcode-k1-daemon: startup failed and returns exit code 1; listener failure emits its fixed concise line and returns 1. SIGINT or SIGTERM returns success. This library has no Web hosting, static fallback, SemVer module routes, proxy, UI copying, or browser acceptance guarantee.
Functions§
- run
- Runs one K1 daemon rooted at
k1_rootuntil it receives SIGINT or SIGTERM.