Skip to main content

objectiveai_cli/db/logs/
mod.rs

1//! Postgres-backed log writer.
2//!
3//! The `logs.*` schema (defined in `schema.sql`) is a hybrid:
4//!
5//! - **Six tier blob tables** (request + response × agent / vector /
6//!   function) store the full chunk body as JSONB. Requests are
7//!   written once on first chunk arrival; responses get UPDATEd per
8//!   tick when their body changes.
9//! - **Fourteen streaming-content tables** carry the per-message,
10//!   per-part incrementally-updating content yielded by the SDK's
11//!   chunk-type `log_rows()` iterators.
12//!
13//! Diff detection: every row written has a deterministic PK shape
14//! `(response_id, index[, sub_index])`. The writer holds a shadow map
15//! keyed identically and hashes each row's body columns. Three
16//! verdicts come out: `Insert` (first sight), `Update` (changed
17//! body), `Skip` (unchanged). The SQL helpers in [`write`] dispatch
18//! flat INSERT or UPDATE per verdict — no `ON CONFLICT` ambiguity.
19//!
20//! The writer is the sole caller and is single-instance per stream,
21//! so the shadow's verdict is authoritative — concurrent races on
22//! the same row id can't happen.
23
24mod listen;
25mod lookup;
26mod read_all;
27mod read_id;
28mod row;
29mod rows;
30mod shadow;
31mod write;
32mod writer;
33
34pub use listen::*;
35pub use lookup::*;
36pub use read_all::*;
37pub use read_id::*;
38pub use row::*;
39pub use rows::*;
40pub use shadow::*;
41pub use write::*;
42pub use writer::*;