docs: add build_logs.sqlite section to persistence.md, trim build_logs.rs module doc

This commit is contained in:
damocles 2026-06-01 10:34:51 +02:00
commit 1b8a6be8ce
2 changed files with 26 additions and 20 deletions

View file

@ -1,23 +1,7 @@
//! Sqlite-backed full build-log capture. One row per `nixos-container`
//! / `nix build` invocation that the host-side lifecycle layer fires;
//! the row accumulates stdout + stderr line-by-line as the child runs.
//!
//! Replaces the legacy 32-line stderr ring buffer in
//! `lifecycle::run` / `lifecycle::prebuild_toplevel`. The ring tail
//! routinely truncated the actual eval error (a "tried alternatives"
//! block alone is often 30+ lines), so failures bailed with an
//! arbitrary tail and the full stream only lived in the host journal.
//! With this table the dashboard can surface the entire log.
//!
//! Storage lives next to the broker / approvals dbs (one file at
//! `<db_path>/build_logs.sqlite`). Two indices:
//! `(agent, started_at)` for the per-agent latest-N lookup that backs
//! the agent card chip; `(status, finished_at)` for the retention
//! sweep that runs as part of the existing hourly vacuum.
//!
//! Writes are best-effort: every `append_*` / `finish` call logs a
//! warning on sqlite error and lets the build continue. A failed log
//! row never breaks a rebuild.
//! Sqlite-backed full build-log capture — stdout + stderr per
//! `nixos-container` / `nix build` invocation, accumulated live.
//! Schema, indices, retention, and the rationale for replacing
//! the old ring buffer: `docs/persistence.md::/var/lib/hyperhive/build_logs.sqlite`.
use std::path::Path;
use std::sync::{Arc, Mutex, OnceLock};