Add fidelity columns to archive turns and sessions (#110)#120
Merged
willwashburn merged 2 commits intomainfrom Apr 26, 2026
Merged
Add fidelity columns to archive turns and sessions (#110)#120willwashburn merged 2 commits intomainfrom
willwashburn merged 2 commits intomainfrom
Conversation
Materialize TurnRecord.fidelity onto the analytics archive so SQL consumers can filter / group by attribution quality without re-deriving in memory. - turns gains attribution_fidelity (FidelityClass string), tokens_present and cost_present. - sessions gains min_fidelity (worst class observed across known-fidelity turns) and has_full_attribution (1 iff every fidelity-tagged turn is full). - Older lines that pre-date the upstream parser fidelity work persist NULL rather than guessing. - Migration is additive: openArchive() runs idempotent ALTER TABLE ADD COLUMN guarded by PRAGMA table_info, so existing archives forward- migrate without a rebuild and ARCHIVE_VERSION stays at 1. - getArchiveStatus() / burn archive status --json now returns a fidelityHistogram (counts per attribution_fidelity value, NULL bucket surfaced as "unknown"). Refs #40 #41 #78. Closes #110. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…-columns-110 # Conflicts: # packages/cli/CHANGELOG.md # packages/ledger/CHANGELOG.md
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
attribution_fidelity,tokens_present,cost_presentcolumns to the archiveturnstable, andmin_fidelity+has_full_attributionrollups tosessions. Vocabulary matchesTurnRecord.fidelity.classexactly (full,usage-only,partial,aggregate-only,cost-only).openArchive()runs idempotentALTER TABLE … ADD COLUMNguarded byPRAGMA table_info, so existing archives forward-migrate without a rebuild andARCHIVE_VERSIONstays at 1.NULLrather than guessing — downstream queries should readNULLas "unknown". When the upstream parsers populatefidelity, the next archive build picks up the values automatically.burn archive status --jsonnow returns afidelityHistogram(counts perattribution_fidelity, withNULLbucketed asunknown). Text-mode output is unchanged.Test plan
pnpm run buildpasses.pnpm run test:tspasses (457 tests, 5 new).full+ Codex turn lacking fidelity + cost-only) yielding the expected per-turnattribution_fidelityand the right session-levelmin_fidelity(cost-only) /has_full_attribution(0).has_full_attribution = 1for an all-fullsession andNULLwhen no turn carries fidelity at all.rebuildArchive().ALTER-on-existing path: an archive built without the new columns is forward-migrated on nextopenArchive()without dropping data, and a subsequent build populates the new columns for new turns.burn archive status --jsonexposingfidelityHistogram.Refs
Closes #110. Refs #40, #41, #78.
Out of scope (future follow-ups #95, #100, #105, #108): wiring consumer commands (
burn compare, etc.) to filter by fidelity in SQL.🤖 Generated with Claude Code