feat(sight): add unified summary command#796
Open
jfeng18 wants to merge 1 commit into
Open
Conversation
`agentsight summary` rolls up the headline numbers from the three
observability streams agentsight + tokenless already record into one
glanceable report:
* Sessions & token usage (genai_events.db)
* Interruptions by severity (interruption_events.db)
* Tokenless savings (~/.tokenless/stats.db)
Each data source degrades independently: a missing/unreadable/wrong-schema
database contributes zeros (tokenless: an explicit "not available" note)
rather than aborting the whole report, so the command always exits 0.
Supports `--last N` (hours, default 24) and `--json`. The text and JSON
views report identical numbers for the same data (both clamp).
Adds TokenlessStatsStore::summary_in_window, which aggregates stats.db
savings over a time window. stats.db stores RFC3339 text timestamps, so
it normalises each row to UTC epoch seconds via strftime('%s', ...) —
robust to the stored timezone offset rather than relying on lexicographic
string comparison.
Tested: unit tests for the windowed aggregate (timezone normalisation,
graceful degradation), the JSON/text clamp contract, the independent
degradation matrix (each source missing or wrong-schema), and saturating
window math for absurd --last; end-to-end on a host with a live collector,
cross-checked against direct SQL.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
f9ed28b to
c41b51c
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
agentsight summary— one command that rolls up the headline numbers from the three observability streams agentsight + tokenless already record, into a single glanceable report:--last N(hours, default 24) and--json. Text and JSON report identical numbers for the same data.Why
The three streams (sessions+tokens, interruptions, tokenless savings) each live behind their own subcommand and database. There was no single "how are my agents doing right now" view; tokenless savings in particular were effectively invisible.
summarysurfaces all of it at a glance.How
bin/cli/summary.rs(SummaryCommand).TokenlessStatsStore::summary_in_window: aggregatesstats.dbsavings over a time window.stats.dbstores RFC3339 text timestamps, so it normalises each row to UTC epoch seconds viastrftime('%s', ...)— robust to the stored timezone offset rather than relying on lexicographic string comparison.agentsight.rs/cli/mod.rsand re-exports the new type fromstorage/sqlite/mod.rs.No changes to BPF probes, the collection pipeline, other subcommands, or the tokenless crate.
Testing
E2E on a host with a live collector + real databases (cross-checked against direct SQL — exact match):
--json: sessions, interruptions-by-severity, and tokenless totals all match raw SQL.stats.dbabsent → "not available";--last 0empty window;--help.--last u64::MAX: degrades to "everything", no overflow/inverted window.stats.db): text and JSON both clamp to 0 — consistent.Unit tests (the live collector holds the real genai/interruption DBs open, so the missing/corrupt cases for those are covered by path-injection unit tests rather than by moving production data):
summary_in_window: timezone normalisation, empty window, missing-table degradation.build_json: clamp contract (negative → 0, identical to text).time_range_ns: saturating math (no inversion for absurd--last).Verification status
cargo test, local + on the host)cargo clippyclean on the new code (note: agentsight's CI runscargo test, not clippy/fmt)Known limitation (tracked separately)
Under heavy write contention
summary(like every agentsight DB reader) could transiently report zeros, because the sharedcreate_connectionsets nobusy_timeout. This pre-dates this change and affects all readers, so it's deferred to its own focused PR rather than bundled here. Not observed in 30/30 live runs.🤖 Generated with Claude Code