mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Adds the Rust backend half of the NIP-AM local agent usage feature (Rev 3 frozen plan): a rebuildable agent_metric_index parsed from archived kind-44200 rows, a pure per-field accounting ladder (agent_usage.rs) computing token/cost deltas with adjacent-cumulative preference and direct-value fallback, and the get_agent_usage_series Tauri command wiring backfill, orphan repair, collection-enabled detection, and A13's hasArchivedEvidence into one series response. commit_archive now indexes kind-44200 rows in the same transaction as the canonical event insert, and upsert_archived_event/gc_orphaned_events return/enforce the new-row and cascade-delete invariants (A5/A6) that persistedAgentMetrics and the index's rebuildability depend on. get_agent_usage_series' SQLite core is split into a plain sync fn so it can be driven directly against an in-memory Connection in tests without a Tauri AppState. Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>