feat(desktop): NIP-AM agent-usage archive backend + cache-read schema - #4000
Open
wpfleger96 wants to merge 1 commit into
Open
feat(desktop): NIP-AM agent-usage archive backend + cache-read schema#4000wpfleger96 wants to merge 1 commit into
wpfleger96 wants to merge 1 commit into
Conversation
wpfleger96
force-pushed
the
duncan/agent-usage-backend
branch
from
July 31, 2026 20:53
1613f34 to
12f1f29
Compare
wpfleger96
force-pushed
the
duncan/agent-usage-backend
branch
from
August 3, 2026 18:28
12f1f29 to
635b030
Compare
Add the NIP-AM agent-usage archive backend (query engine, SQLite migrations, ingestion pipeline, buzz-acp first-turn fix) from PR #2035. This is the backend-only base of a stacked split; the UI lives in the companion stack PR. Backend surface: - `desktop/src-tauri/src/archive/`: archive query engine, metric index store, store migrations, pipeline integration, and full Rust test suite (agent_usage, metric_store, store, migration tests) - `desktop/src/shared/api/tauriArchive.ts`: wire types + Tauri command bridge (`get_agent_usage_series`) - `desktop/src/features/local-archive/archiveSyncManager.ts`: `persistedAgentMetrics` notifier wired to the archiveSyncManager - `crates/buzz-acp/`: first-turn baseline fix (Task E from #2035) Cache-read schema addition (M2 migration): Adds `turn_cache_read_tokens` and `cumulative_cache_read_tokens` columns to `agent_metric_index` via a new one-shot additive migration (M2). These columns persist the optional NIP-AM `cacheReadTokens` fields so that Hayt's Phase-0 cache-threading events (crates/buzz-acp, separate PR) start being persisted the day both PRs merge. All pre-migration rows receive NULL (fail-closed). M2 runs before M1 in the migration chain so the M1 rebuild always operates against the full schema. Three M2 migration tests: fresh DB, post-M1 upgrade, and idempotency. Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
wpfleger96
force-pushed
the
duncan/agent-usage-backend
branch
from
August 3, 2026 18:56
635b030 to
39e1a91
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds the NIP-AM agent-usage archive backend — the Rust query engine, SQLite schema and migrations, ingestion pipeline wiring,
buzz-acpfirst-turn baseline fix, and the minimal TS contract layer. No UI is included; this PR merges first. The companion UI stack PR opens with this as its base.Also adds M2 schema migration:
turn_cache_read_tokensandcumulative_cache_read_tokenscolumns onagent_metric_index. These columns persist the optional NIP-AMcacheReadTokensfields (fail-closed: NULL for all pre-migration rows).cache_write_tokensis not persisted — the wire payload carries no write-side field.Files
desktop/src-tauri/src/archive/— agent_usage, metric_store, store_migrations, pipeline, mod, store, libtauriArchive.ts,archiveSyncManager.ts+ testusage.rs,acp.rs,pool.rs(first-turn baseline fix)Migration chain
M2 (additive column additions) runs before M1 (index rebuild) so the M1 rebuild always operates against the full schema. All migrations are idempotent; existing DBs get NULL for the new columns.
Stack
Stack: this PR → agent-usage-ui
Review note
The archive engine and
buzz-acpcontent was reviewed at3d6c9c413(PR #2035, 9/9/9). The only addition relative to the reviewed tree is the M2 cache-column migration. Equivalence: tree diff between stack tip and3d6c9c413touches only the 6 files indesktop/src-tauri/src/archive/that constitute the M2 addition.