Migrate burn compare to grouped SQL aggregates (#88)#130
Open
willwashburn wants to merge 1 commit intomainfrom
Open
Migrate burn compare to grouped SQL aggregates (#88)#130willwashburn wants to merge 1 commit intomainfrom
willwashburn wants to merge 1 commit intomainfrom
Conversation
Read the per-(model, activity) compare table from `archive.sqlite` via a single grouped `SELECT … GROUP BY model, activity, source` plus a tiny per-cell median-retries follow-up, instead of streaming every turn through `queryAll()` + an in-memory reduce. New `compareFromArchive` helper in `@relayburn/analyze` carries the SQL path and returns the same `CompareTable` shape; `runCompare` calls `buildArchive()` to catch the archive up to the freshly-ingested ledger tail before reading. Output (text, CSV, `--json`) is byte-identical to the legacy path for the parity fixture; per-source reasoning-mode handling (Codex's `included_in_output`) is preserved by grouping on `source` alongside `(model, activity)`. All existing flags (`--models`, `--since`, `--project`, `--session`, `--workflow`, `--agent`, `--min-sample`) work through the SQL path. New `--no-archive` flag (also honored via `RELAYBURN_ARCHIVE=0`) keeps the in-memory path as a parity-validation / safety-net fallback. Tests: parity fixture (deep-equal across every cell vs the in-memory table), filter coverage for each flag, empty / single-cell edges, and a Codex-reasoning regression guard. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced Apr 26, 2026
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.
Summary
burn comparenow reads fromarchive.sqliteby default via a single groupedSELECT … GROUP BY model, activity, source(plus a per-cell median-retries follow-up), instead of streaming the full ledger and reducing in memory.compareFromArchive(query, opts)helper in@relayburn/analyzecarries the SQL path;runComparecallsbuildArchive()first so the archive reflects the freshly-ingested ledger tail.--json) is byte-identical to the legacy path for the parity fixture; all existing flags (--models,--since,--project,--session,--workflow,--agent,--min-sample) work through the SQL path.--no-archiveflag (also honored via envRELAYBURN_ARCHIVE=0) keeps the in-memory path as a parity-validation / safety-net fallback.included_in_output) is preserved by grouping onsourcealongside(model, activity).Test plan
pnpm run test:ts(519 tests pass)(model, category)cell + per-model totals against the in-memorybuildCompareTablefor a mixed fixture (multiple models, edit/non-edit categories, varied retries, cache-heavy turns, an unpriced model, and a Codex-source turn with reasoning tokens).--models(incl. pre-seeded absent models),--since,--project(literal path AND projectKey),--session,--workflow/--agent(stamp-folded enrichment),--min-sample.costForTurnfor a Codex turn withreasoning_tokens > 0).Refs
burn compareto grouped SQL aggregates over archive #88burn archive(#40) #78🤖 Generated with Claude Code