Populate TurnRecord.fidelity from OpenCode parser (#89)#116
Merged
willwashburn merged 2 commits intomainfrom Apr 26, 2026
Merged
Populate TurnRecord.fidelity from OpenCode parser (#89)#116willwashburn merged 2 commits intomainfrom
willwashburn merged 2 commits intomainfrom
Conversation
Mirror the Claude parser's pattern: fold per-field token presence from both the assistant message's `tokens` block and any `step-finish` parts into a Coverage accumulator, then stamp `fidelity` on every emitted turn at `granularity: 'per-turn'`. Capability flags (`hasToolCalls`, `hasToolResultEvents`, `hasSessionRelationships`, `hasRawContent`) are always true; usage flags reflect *presence*, not non-zero numeric value, so a turn that never received cache fields honestly reports `hasCacheReadTokens: false` instead of silently rendering `cacheRead === 0`. Closes the "0 vs unknown" ambiguity for OpenCode in `summarizeFidelity` and `hasMinimumFidelity`.
Resolve CHANGELOG conflict by keeping all three Unreleased entries (#112 Claude fork/continuation, #84 Codex fidelity, #89 OpenCode fidelity). Also fix a build break that landed on main with #112: the new relationshipIdHash dedup test in packages/reader/src/claude.test.ts was importing from @relayburn/ledger, which already depends on @relayburn/reader — the back-import created a cycle that broke `tsc --build` on a fresh CI checkout (Publish Package run 24957227734). Reproduce the canonical key in the test inline so the assertion still exercises the same dedup contract without the cyclic dep. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced Apr 26, 2026
Open
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
fidelityon everyTurnRecordemitted byparseOpencodeSession/parseOpencodeSessionIncrementalatgranularity: 'per-turn', mirroring theWorkingRecord.usageCoverageaccumulator pattern from the Claude parser.tokensblock (folded across both the assistant message and anystep-finishparts that carry tokens), so a turn that never received cache fields honestly reportshasCacheReadTokens: falseinstead of silently renderingcacheRead === 0. Capability flags (hasToolCalls,hasToolResultEvents,hasSessionRelationships,hasRawContent) are always true.summarizeFidelity(no moreunknownbucket on OpenCode-produced turns) andhasMinimumFidelity.Test plan
pnpm run buildpnpm run test:ts(458 pass, 0 fail; 6 new tests)parseOpencodeSession fidelity (issue #89)suite covers a full-fidelity turn (existingsimplefixture), a tokens-missing turn (partial), a turn with cache fields populated (hasCacheReadTokensandhasCacheCreateTokensbothtrue), and a step-finish-rollup turn (cache flags arrive on thestep-finishpart rather thanm.tokens).summarizeFidelity over an OpenCode session (issue #89)analyze-side test confirmsunknown === 0for the produced turns.Refs
Closes #89. Refs #41, #76.