pub fn count_for_memory(
conn: &Connection,
memory_id: i64,
) -> Result<usize, AppError>Expand description
GAP-SG-40: counts the rows actually persisted in memory_chunks for a
memory. Single-chunk bodies are stored inline in the memories row and
append no chunk rows, so this returns 0 for them; multi-chunk bodies
return the exact number of persisted chunk rows. Callers query this AFTER
the transaction commits so the reported chunks_persisted reflects the
observable database state rather than a pre-commit estimate.