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

@ -127,6 +127,28 @@ sentinel files (`hyperhive-rate-limited`, `hyperhive-needs-login`) if the
JSON is absent, so existing containers keep working through the transition JSON is absent, so existing containers keep working through the transition
window before their next rebuild. window before their next rebuild.
### `/var/lib/hyperhive/build_logs.sqlite` (host)
Full stdout + stderr capture for every `nixos-container` / `nix
build` invocation the lifecycle layer fires. One row per invocation;
the row accumulates lines as the child runs.
Replaces the legacy 32-line stderr ring buffer that `lifecycle::run`
kept. The ring tail routinely truncated real eval errors ("tried
alternatives" blocks alone are often 30+ lines), so failures bailed
with an arbitrary tail whose full stream only lived in the host
journal. With this table the dashboard can surface the entire log.
Two indices:
- `(agent, started_at)` — backs the per-agent latest-N lookup used
by the agent card chip.
- `(status, finished_at)` — backs the retention sweep that runs
as part of the existing hourly vacuum.
Writes are best-effort: `append_stdout` / `append_stderr` / `finish`
log a warning on sqlite error and let the build continue. A failed
log row never blocks a rebuild.
### `/state/hyperhive-model` (per agent) ### `/state/hyperhive-model` (per agent)
Single-line text file holding the claude model name currently Single-line text file holding the claude model name currently

View file

@ -1,23 +1,7 @@
//! Sqlite-backed full build-log capture. One row per `nixos-container` //! Sqlite-backed full build-log capture — stdout + stderr per
//! / `nix build` invocation that the host-side lifecycle layer fires; //! `nixos-container` / `nix build` invocation, accumulated live.
//! the row accumulates stdout + stderr line-by-line as the child runs. //! Schema, indices, retention, and the rationale for replacing
//! //! the old ring buffer: `docs/persistence.md::/var/lib/hyperhive/build_logs.sqlite`.
//! 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.
use std::path::Path; use std::path::Path;
use std::sync::{Arc, Mutex, OnceLock}; use std::sync::{Arc, Mutex, OnceLock};