Skip to content

Populate TurnRecord.fidelity from OpenCode parser (#89)#116

Merged
willwashburn merged 2 commits intomainfrom
feat/opencode-fidelity-89
Apr 26, 2026
Merged

Populate TurnRecord.fidelity from OpenCode parser (#89)#116
willwashburn merged 2 commits intomainfrom
feat/opencode-fidelity-89

Conversation

@willwashburn
Copy link
Copy Markdown
Member

@willwashburn willwashburn commented Apr 26, 2026

Summary

  • Stamp fidelity on every TurnRecord emitted by parseOpencodeSession / parseOpencodeSessionIncremental at granularity: 'per-turn', mirroring the WorkingRecord.usageCoverage accumulator pattern from the Claude parser.
  • Usage coverage flags reflect presence on the upstream tokens block (folded across both the assistant message and any step-finish parts that carry tokens), so a turn that never received cache fields honestly reports hasCacheReadTokens: false instead of silently rendering cacheRead === 0. Capability flags (hasToolCalls, hasToolResultEvents, hasSessionRelationships, hasRawContent) are always true.
  • Closes the "0 vs unknown" ambiguity for OpenCode in summarizeFidelity (no more unknown bucket on OpenCode-produced turns) and hasMinimumFidelity.

Test plan

  • pnpm run build
  • pnpm run test:ts (458 pass, 0 fail; 6 new tests)
  • New parseOpencodeSession fidelity (issue #89) suite covers a full-fidelity turn (existing simple fixture), a tokens-missing turn (partial), a turn with cache fields populated (hasCacheReadTokens and hasCacheCreateTokens both true), and a step-finish-rollup turn (cache flags arrive on the step-finish part rather than m.tokens).
  • New summarizeFidelity over an OpenCode session (issue #89) analyze-side test confirms unknown === 0 for the produced turns.

Refs

Closes #89. Refs #41, #76.


Open in Devin Review

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`.
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenCode parser: populate TurnRecord.fidelity

1 participant