feat: audit session transcripts for numeric claims with no tool evidence #13

Merged
david merged 1 commits from feat/claims-audit into main 2026-11-05 02:42:49 +00:00
Owner

Closes #12.

A figure gets derived once — sometimes against the wrong reference — then restated in later turns without being re-checked. Repetition raises confidence instead of prompting verification. That is exactly how "6,884 lines" (measured against bb852fa instead of main) survived five turns and drove a branch decision that had to be undone.

This adds a deterministic audit for it. No model calls, no token cost.

How it reads

  • sourced — a tool result in the same turn printed the same number and unit
  • stale — the number appeared in an earlier turn's tool output and is being restated now
  • unsupported — no tool ever printed it (usually a hypothetical)

The stale/unsupported split is the important part. Flagging every number would include "200ms" and "200MB" hypotheticals, which trains the reader to ignore the output.

Two calibration details worth reviewing

  1. Unit-aware matching. Matching the bare number makes 200MB "backed" by any output containing 200. The unit must agree, so 6884 lines is not backed by 6884 deletions — which is the honest verdict, and why the original mistake would land in unsupported rather than clean.
  2. The window is the turn, not the message. opencode emits one message per step, so a tool call and the prose citing it land in consecutive messages. Requiring same-message output flagged every legitimate result: the first run scored 0 sourced out of 16.

Usage

knox claims lint                 # most recent session
knox claims lint --session <id> --json

Output:

claims: 16 checked — 1 sourced, 4 stale, 11 unsupported
  ✗ stale       msg 93   11 files
  ✗ unsupported msg 95   200ms

Limitation, stated plainly

opencode persists messages on flush, so a live session has no rows yet — this audits completed sessions. A live guardrail needs the plugin context hook; that is the follow-up (#12 can be reopened or a new issue filed for it).

Tests

  • extraction, including that sub-10 counts are dropped as noise
  • unit-aware matching (6884 lines vs 6884 deletions vs 6,884 lines)
  • all three classifications, including a claim restated after a user message
  • go vet ./..., go test ./... green
Closes #12. A figure gets derived once — sometimes against the wrong reference — then restated in later turns without being re-checked. Repetition raises confidence instead of prompting verification. That is exactly how "6,884 lines" (measured against `bb852fa` instead of `main`) survived five turns and drove a branch decision that had to be undone. This adds a deterministic audit for it. No model calls, no token cost. ## How it reads - **sourced** — a tool result in the same turn printed the same number **and unit** - **stale** — the number appeared in an *earlier* turn's tool output and is being restated now - **unsupported** — no tool ever printed it (usually a hypothetical) The stale/unsupported split is the important part. Flagging every number would include "200ms" and "200MB" hypotheticals, which trains the reader to ignore the output. ## Two calibration details worth reviewing 1. **Unit-aware matching.** Matching the bare number makes `200MB` "backed" by any output containing 200. The unit must agree, so `6884 lines` is *not* backed by `6884 deletions` — which is the honest verdict, and why the original mistake would land in `unsupported` rather than clean. 2. **The window is the turn, not the message.** opencode emits one message per step, so a tool call and the prose citing it land in consecutive messages. Requiring same-message output flagged every legitimate result: the first run scored 0 sourced out of 16. ## Usage ```sh knox claims lint # most recent session knox claims lint --session <id> --json ``` Output: ``` claims: 16 checked — 1 sourced, 4 stale, 11 unsupported ✗ stale msg 93 11 files ✗ unsupported msg 95 200ms ``` ## Limitation, stated plainly opencode persists messages on flush, so a live session has no rows yet — this audits *completed* sessions. A live guardrail needs the plugin `context` hook; that is the follow-up (#12 can be reopened or a new issue filed for it). ## Tests - extraction, including that sub-10 counts are dropped as noise - unit-aware matching (6884 lines vs 6884 deletions vs 6,884 lines) - all three classifications, including a claim restated after a user message - `go vet ./...`, `go test ./...` green
david added 1 commit 2026-11-05 02:42:33 +00:00
feat: audit session transcripts for numeric claims with no tool evidence (#12)
build / test (push) Has been cancelled
build / image (push) Has been cancelled
ab9066486a
Adds a deterministic check for the failure mode where a figure is derived once
and then restated without being re-checked.

- internal/claims extracts number+unit assertions from assistant prose and
  matches them against tool output, unit-aware (matching a bare number makes
  "200MB" count as backed by any output containing 200).
- Classification: sourced (printed this turn), stale (printed in an earlier
  turn, restated now), unsupported (never printed by a tool).
- `knox claims lint [--session ID] [--json]` reads opencode.db.

The evidence window is the turn, not the message: opencode emits one message
per step, so a tool call and the prose citing it land in consecutive messages.

No model calls, so it costs nothing to run.
david merged commit 029c5078ba into main 2026-11-05 02:42:49 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: david/knox#13