Skip to content

Add fidelity / coverage columns to archive turns and sessions #110

@willwashburn

Description

@willwashburn

Context

PR #78's archive schema deliberately omits coverage / fidelity columns:

Coverage / fidelity columns from the (still-open) coverage issue — the schema is deliberately additive so they slot in without a rebuild requirement.

Issue #40 calls out the requirement explicitly:

The archive should not blur:

  • zero tokens
  • missing tokens
  • aggregate-only sources
  • cost-only sources
  • fully attributed per-turn sources

Issue #41 (coverage and fidelity metadata) and PR #76 are the upstream — they add fidelity flags to TurnRecord. The archive needs the equivalent columns so SQL queries can filter / group by them without re-deriving in memory.

Today, compare and summary cells render instead of $0.00 / 0% for missing data; that decision currently lives in the analyze layer. Once the archive carries the flags, downstream consumers can express it as WHERE has_full_attribution = 1 rather than re-checking each row.

Proposal

  1. Once Coverage and fidelity metadata: distinguish missing, zero, aggregate-only, and partial usage #41 / PR Add coverage and fidelity metadata to TurnRecord (#41) #76 lands the canonical fidelity flags on TurnRecord, add the columns to the archive's turns table additively (no rebuild required — ALTER TABLE ... ADD COLUMN with sensible defaults). Suggested:
    • attribution_fidelity TEXT — one of full, aggregate_only, cost_only, missing, zero.
    • tokens_present INTEGER — boolean: did the source give us per-turn token counts?
    • cost_present INTEGER — boolean: cost only?
  2. Add session-level rollups to sessions:
    • min_fidelity TEXT — worst fidelity observed in the session.
    • has_full_attribution INTEGER.
  3. Bump ARCHIVE_VERSION only if the additive ALTER strategy doesn't fit; otherwise, keep it stable so existing archives pick up the new columns on next build.
  4. Update buildArchive() to read the fidelity flags from TurnRecord and persist them; update foldStamps() callers if any stamp source contributes to fidelity.

Tests:

  • ALTER TABLE migration on an existing archive populates the new columns on next build.
  • A mixed-fidelity fixture (Claude full + Codex aggregate-only) yields the right per-turn attribution_fidelity and the right session-level min_fidelity.
  • compare / summary queries can filter by fidelity (WHERE attribution_fidelity = 'full') and produce the expected subset.

Acceptance criteria

Out of scope

Refs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions