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 plugin_messages;
27mod read_all;
28mod read_id;
29mod row;
30mod rows;
31mod shadow;
32mod write;
33mod writer;
34
35pub use listen::*;
36pub use lookup::*;
37pub use plugin_messages::*;
38pub use read_all::*;
39pub use read_id::*;
40pub use row::*;
41pub use rows::*;
42pub use shadow::*;
43pub use write::*;
44pub use writer::*;