Expand description
Read-only-by-intent database-integrity and WAL/checkpoint diagnostics. Non-mutating-by-intent database, WAL, and checkpoint diagnostics (read-only operator surface).
Answers “is a reader pinning the checkpoint / why is the WAL at 64MiB” without raw SQL against a production store.
NOT read-only. checkpoint_probe issues a real
PRAGMA wal_checkpoint(PASSIVE), and a PASSIVE checkpoint that succeeds
BACKFILLS WAL frames into the main database — ordinary database-page
writes, on the happy path. That I/O is the point: the busy/log_frames/
checkpointed_frames triple reports a one-row backfill gap; a sustained
pinned-frame report additionally requires a matching checkpoint run.
SQLite exposes no read-only API for those counters. The
guarantee is that nothing here changes logical state or destroys
evidence, not that nothing touches the disk.
What IS guaranteed, and what the narrowings below buy:
- never creates a missing database file,
- never escalates to TRUNCATE,
- never perturbs the counters it reports,
- never increments write-traffic acquisition counters,
- never deletes a walpin sidecar entry.
Deliberate narrowings make those claims true rather than aspirational:
checkpoint_proberuns a singlePRAGMA wal_checkpoint(PASSIVE)— which never blocks readers or writers — and does NOT route throughcrate::checkpoint::checkpoint_once: that path mutatesTruncateState, may escalate to TRUNCATE, and double-counts the ADR-091 process-global counters. A verb that reports state must not perturb the state it reports.- The probe’s connection comes from
ConnectionPool::open_standalone_writer_untracked, opened withoutSQLITE_OPEN_CREATE. A missing database yieldscheckpoint_probe: nullplus acheckpoint_probe_error, never a freshly created file. - WAL-pin attribution combines the read-only OS holder census with
walpin::inspect_live, a separate bounded sidecar enumerator whose purpose flag prohibits every unlink. It applies the same descriptor- bound trust and liveness checks as checkpoint attribution, but reports stale cleanup candidates rather than consuming them. A complete census plus a complete, conclusive sidecar walk can therefore report complete; truncation, unknown entries, or holders absent from the sidecar degrade explicitly. - Graph-edge integrity uses three scalar SELECTs on the same guarded standalone connection. It exposes the exact pre-V14 duplicate-ID group count plus raw live-edge/list-ledger counts and never repairs or deletes data.
- FTS5 segment diagnostics decode each index’s documented one-row
structure record (
%_data.id = 10). They never runCOUNT(*)over or scan a%_idxtable, so observing segment health is bounded even when the corpus itself is large.
Checkpoint counters are process-global, while reader and writer acquisition
counters belong to the supplied pool and can reset when it is reconstructed.
Every payload carries BuildIdentity and
ProcessIdentity for the
process producing the reading. The PID, OS start time, and main-pool generation
identify the main pool’s counter window; a secondary pool’s reader/writer
counters have their own reconstruction window. Checkpoint counters remain global.
Structs§
- Build
Identity - Which build produced this reading.
- Checkpoint
Counters - ADR-091 checkpoint counters, read as one snapshot.
- Checkpoint
PinDiagnostics - Checkpoint-row evidence used to report a sustained backfill ceiling.
- Checkpoint
Probe - Raw
PRAGMA wal_checkpoint(PASSIVE)return row. - Collection
Cost - What this report cost to assemble, per section, in milliseconds.
- Database
Object Size - Database
Size Composition - Page-accounted file-size composition from SQLite’s read-only
dbstatvirtual table in aggregate mode. - DbDiagnostics
- Disk
Guard Diagnostics - The configured write-admission reserve and the volume metadata used to sample it. The reserve is an admission floor, not reserved disk capacity.
- Graph
Edge Integrity - Live graph-edge rows compared with the durable list-cursor ledger.
- Process
Identity - The serving OS process and the main pool’s reader/writer counter generation.
- Reader
Contention Diagnostics - One typed snapshot of reader route, saturation, and hold-lifecycle signals.
- Runtime
Audit Batch Metrics - Process-wide audit-batch health counters, supplied by the runtime layer
that owns the audit-batch control.
khive-dbnever produces these itself — a directkhive-dbcaller always sees the correspondingWriterContentionDiagnosticsfields asNoneplus an explicit reason. - WalCeiling
Diagnostics - The full database-integrity, reader/writer-contention, and WAL/checkpoint payload.
- WalFile
State - Absolute-free WAL file state for one database path.
- WalPin
Attribution - WAL-pin attribution: who currently holds the database open, and how complete that answer is.
- WalPin
Census Process Start - OS-reported start time for one holder confirmed by the process census.
- WalPin
Holder - One PID’s live heartbeat as reported to an operator.
- Writer
Contention Diagnostics - One typed snapshot of writer-contention signals.
Enums§
- Database
Object Kind - SQLite b-tree role reported by the size-composition diagnostic.
- Database
Storage Class - Operational storage grouping.
mixed_row_and_embeddingis deliberately separate: SQLite cannot attribute bytes within a table page to one column, so counting all ofknowledge_sectionsas pure vector bytes would be a false precision claim. - WalPin
Attribution Status - Overall quality of the WAL-pin attribution answer.
- WalPin
Census - Tagged OS holder-census result.
Functions§
- checkpoint_
counters - Snapshot the process-global ADR-091 counters.
- checkpoint_
probe - Issue one PASSIVE checkpoint on
connand return the raw triple. - collect
- Assemble the report for
pool’s database. - collect_
with_ audit_ append_ failures - Assemble the report with the runtime’s process-wide count of swallowed best-effort audit append failures.
- collect_
with_ audit_ append_ failures_ interruptibly - Assemble diagnostics without allowing request abandonment to leave the graph SELECT or OS holder census running detached.
- collect_
with_ runtime_ audit_ metrics_ for_ process_ interruptibly - Collect one already-open pool while retaining the main pool’s process and generation identity. A secondary pool must not claim or advance the main pool generation when its pool-scoped counters are inspected.
- collect_
with_ runtime_ audit_ metrics_ interruptibly - Like
collect_with_audit_append_failures_interruptibly, additionally threading through the runtime’s audit-batch health counters.Nonewhen no audit-batch control is registered with the calling runtime instance — the correspondingwriter_contentionfields then report unavailable with a reason, exactly likeaudit_append_failuresdoes for a directkhive-dbcaller. - wal_
file_ state - Stat
<db_path>-waland report its size in bytes. - wal_
pin_ attribution - Build the WAL-pin attribution for
db_path.