Skip to content

fix(devtools): validate and extend claim-vs-evidence economics - #3090

Merged
Sinity merged 3 commits into
masterfrom
feature/demo/claim-vs-evidence-v2
Jul 18, 2026
Merged

Sinity merged 3 commits into
masterfrom
feature/demo/claim-vs-evidence-v2

Conversation

@Sinity

@Sinity Sinity commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • Corrects the claim-vs-evidence construct-validity verdict inherited from a
    prior cut-off session and fixes the classifier bug it found (protocol-only
    <thinking> follow-ups no longer count as visible silent-proceed evidence).
  • Adds per-model/per-origin economy lanes (token/cache/cost, disjoint from
    Codex's inclusive input/output semantics) to the report.
  • Resolves polylogue-uwlu: Hermes sessions were invisible to the harness
    because the Hermes parser never extracted its own tool-outcome fields.

Problem

The operator's explicit concern for this demo shelf: "just because we ran a
report does not mean the dataset yielded notable insight, or that we
interpret it correctly." A prior session's construct-validity audit found the
old 24.1% silent-proceed headline unpublishable (fresh frame n=20 < 30,
mostly protocol-only reasoning misclassified as silent) but left two things
unfinished: the economy-column work, and a wrong implicit assumption that
n=20 reflected genuine corpus size.

Investigating that assumption (readiness_check MCP tool) found the live
archive's derived index is currently in a known, actively-tracked "poisoned"
raw-materialization state: only 4 of 73,295 raw source artifacts are
materialized (join_gap_count: 73291). That's polylogue-hjpx /
polylogue-hjpx.2, a separate P0/P1 raw-authority replay program not
authorized for live-archive repair yet — not something this PR touches, but
something the finding doc now says explicitly so nobody mistakes n=20 for
corpus size.

Separately, polylogue-uwlu asked why Hermes sessions never appear in the
by_model breakdown. Live ~/.hermes/state.db inspection showed Hermes tool
results already carry exit_code/success/error fields in their JSON
content envelope (1592/567/3390 of 4100 sampled tool messages respectively,
with real nonzero exit codes) — but hermes_state.py's _parse_message_row
only ever read text and discarded them, so ParsedContentBlock.is_error/
exit_code were always None for every Hermes tool result, making Hermes
structurally invisible to _structured_failure_rows (is_error=1 OR exit_code!=0) regardless of the model_name join originally suspected.

Solution

  • polylogue/archive/actions/followup.py +
    polylogue/storage/sqlite/archive_tiers/archive.py: classify bare
    <thinking>/<analysis>/<reasoning> envelopes as ambiguous instead of
    silent_proceed (Python classifier + its SQL twin, kept in lockstep).
  • polylogue/sources/parsers/hermes_state.py: new _tool_result_outcome()
    extracts Hermes's own exit_code/success/error envelope fields into
    is_error/exit_code (precedence: explicit error message > success flag >
    exit-code sign; absence of all three stays unknown, never guessed from
    prose — consistent with the existing NULL-means-unknown keystone
    invariant).
  • devtools/claim_vs_evidence.py: _economy_rows() rolls up
    session_model_usage + session_provider_usage_events per
    model/origin — disjoint token lanes, catalog vs. provider-reported cost,
    reasoning-token deltas (message_usage only, never cumulative token_count),
    $/silent-proceed — wired into the report JSON, README, public
    reproduction/summary artifacts.
  • docs/findings/claim-vs-evidence.md: records the corrected verdict and the
    archive-materialization caveat.

Verification

  • devtools test tests/unit/sources/parsers/test_hermes_state.py tests/unit/devtools/test_claim_vs_evidence.py — 17 passed (7 new Hermes
    outcome-mapping tests against real observed content shapes, 2 new
    _economy_rows short-circuit tests, 8 pre-existing).
  • mypy --strict on all touched files — clean.
  • devtools verify --quick — green (run 20260718T123938Z-quick-3801476-436deccd).
  • Smoke-tested (not committed) devtools workspace claim-vs-evidence --limit 50 --out-dir <scratch> --json against the live archive: runs end-to-end,
    economy section populates correctly from real session_model_usage rows.
    Not committed as a demo packet per the existing first-party-evidence-
    boundary note in the finding doc (a freshly generated packet should not be
    promoted to a public claim before the durable-tier query/finding kernel
    lands — that's Phase 1.5, tracked separately).

Ref polylogue-uwlu

Co-Authored-By: Claude [email protected]

Sinity and others added 3 commits July 18, 2026 14:39
…ion cut off)

Preserves the lane-A codex session's uncommitted working tree after the
Codex quota cutoff. Phase 0 verdict: the 24.1% silent-proceed headline is
not currently publishable (fresh frame n=20 < 30 minimum; 14 apparent
silent-proceeds were protocol-only <thinking> follow-ups, now classified
ambiguous in followup.py + archive.py). Phase 1 economy columns
(_economy_rows over session_model_usage, disjoint token/cost lanes) is
mid-implementation; tests partial. NOT verified — WIP preservation commit.

Co-Authored-By: Codex <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QUsH3Rhq6oAZpYPWcsZqnZ
…idence framing

Problem: polylogue-uwlu asked why Hermes sessions never appear in the
claim-vs-evidence by_model breakdown. Live ~/.hermes/state.db inspection
showed Hermes tool-result content already carries exit_code/success/error
signals (1592/567/3390 of 4100 tool messages respectively, with real
nonzero exit codes), but hermes_state.py's _parse_message_row only read
"text" via _content_text and never extracted them into
ParsedContentBlock.is_error/exit_code. Every Hermes tool_result was
therefore structurally invisible to _structured_failure_rows (which
requires is_error=1 OR exit_code!=0), regardless of the model_name
COALESCE join originally suspected.

What changed: add _tool_result_outcome() to map Hermes's JSON content
envelope onto is_error/exit_code (precedence: explicit error message >
success flag > exit-code sign; absence of all three stays unknown, never
guessed from prose - consistent with the "keystone" NULL-means-unknown
invariant). 7 focused tests in the new
tests/unit/sources/parsers/test_hermes_state.py pin the mapping against
shapes observed in real data.

Separately, corrected docs/findings/claim-vs-evidence.md: the inherited
"n=20, single Claude Code session" verdict is not a small-corpus finding.
readiness_check shows the live archive's derived index is in a known,
actively-tracked "poisoned" raw-materialization state (4 of 73,295 raw
artifacts materialized; the real corpus spans ~73k sessions across 10
origins including 193 Hermes sessions) - bead polylogue-hjpx/hjpx.2, owned
by a separate lane and not authorized for live-archive repair yet. Flagged
this so the n=20 frame isn't mistaken for corpus size, and so any live
number this report emits is read as provisional until that backlog clears.

Verification: devtools test tests/unit/sources/parsers/test_hermes_state.py
(7 passed) plus the existing Hermes/lineage/import selection (65 passed);
mypy --strict on the touched parser clean. Confirmed the report generator
still runs end-to-end against the live (degraded) archive without error
(smoke-tested, not committed as a demo packet per the existing
first-party-evidence-boundary note).

Ref polylogue-uwlu

Co-Authored-By: Claude <[email protected]>
Add direct unit tests for the two early-return paths in _economy_rows
(empty session_ids; archive missing session_model_usage entirely) that
were only reachable indirectly through build_report before. Both are
real conditions a caller can hit (a report with zero sampled sessions;
an older/rebuilding index without the usage rollup table) and were
previously unverified.

Verification: devtools test tests/unit/devtools/test_claim_vs_evidence.py
(10 passed); mypy --strict clean.

Co-Authored-By: Claude <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 6 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 949de3cb-3e28-4ad3-a2b4-c12226d05ca4

📥 Commits

Reviewing files that changed from the base of the PR and between 1e0246d and 88557c6.

📒 Files selected for processing (7)
  • devtools/claim_vs_evidence.py
  • docs/findings/claim-vs-evidence.md
  • polylogue/archive/actions/followup.py
  • polylogue/sources/parsers/hermes_state.py
  • polylogue/storage/sqlite/archive_tiers/archive.py
  • tests/unit/devtools/test_claim_vs_evidence.py
  • tests/unit/sources/parsers/test_hermes_state.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/demo/claim-vs-evidence-v2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Sinity
Sinity merged commit 5350427 into master Jul 18, 2026
3 checks passed
@Sinity
Sinity deleted the feature/demo/claim-vs-evidence-v2 branch July 18, 2026 13:22
Sinity added a commit that referenced this pull request Jul 18, 2026
…nce (#3093)

## Summary

Stacked on #3090 (needs `report["evidence"]["member_refs"]` added
there).
Represents each claim-vs-evidence report run as durable archive evidence
—
a content-addressed AnalysisDefinition, an AnalysisRun receipt, and
Finding
rows — instead of just a committed `report.json`.

## Problem

`polylogue-rxdo` (It.12/It.13 scope correction) requires that queries
and
analyses be first-party data structures in Polylogue, not a bespoke
devtools
side-pipeline. The rxdo QUERY-evidence core (content-addressed query
identity, canonical-plan evaluator, watched names, result manifests,
durable refs) already landed via #2813/#2826/#2899, and the
`FindingAssertion`/`PublicClaimDeclaration` write kernel + public-claims
projection already landed via #3065 (`polylogue-3tl.16`) — but nothing
had
ever actually written a real `FindingAssertion` into the operator's live
`user.db`; the "3 seeded findings" mentioned in 3tl.16's notes only
exist in
a throwaway temp archive used by `render public-claims`'s
no-`--archive-root`
fallback. This PR adds the smallest finding materialization over the
landed
core, per the addendum's It.13 hard boundary (no metric/pattern/cohort/
experiment definition objects, no registries, no scheduler).

## Solution

`devtools/claim_vs_evidence_evidence.py`:

- **AnalysisDefinition identity** — `build_query_definition()` registers
the
  structured-failure-followup selection (predicate, classification/
  sensitivity scope, `n_min`, handler-class taxonomy, a bumpable
`CLASSIFIER_DEFINITION_VERSION`) as a content-addressed `QueryObject`
via
  `put_query`. Deliberately not a DSL-executable plan — the paired
  next-turn/window-3 lookahead has no predicate-grammar representation —
  but stable provenance identity, matching the "durable identity JSON is
provenance, not source syntax to reverse-compile" doctrine already
stated
  in `convergence_standing_queries.py`.
- **AnalysisRun receipt** — matched `tool_result` refs become a
`ResultSetManifest` (`exactness=capped`, `persistence_class=finding`);
an
`EvaluationReceipt` binds the run to source/user/index tier generations
and the runtime build. Both are content-addressed *including* `now_ms`,
so
  a retried call at the same instant is a safe no-op, while a genuinely
later regeneration correctly records a new run instead of colliding with
  the first.
- **Finding rows** — the headline rate is written as an
  `AssertionKind.FINDING` (`finding_kind="claim-vs-evidence"`, already a
  registered kind) wired to the identities above. `public_claim` stays
  `None` unless the run's own `n_min`/classified-outcome gates are
  satisfied — an unpublishable run still gets an honest private evidence
  record, never a fabricated public rate through the existing
  public-claims projection.
- **Privacy stamp** — reuses the existing
`PublicClaimDeclaration.disclosure`
field (`public` only when publishable, otherwise no declaration at all)
  rather than inventing new privacy/retention machinery; `rxdo.2`'s
  excision/dependency-resolver layer stays explicitly out of scope.

Writes go through `open_daemon_connection` — the same connection helper
`polylogue/daemon/convergence_standing_queries.py` uses for its own
standing-query materialization — via a new opt-in
`--materialize-evidence`
flag on `devtools workspace claim-vs-evidence` (off by default; report
generation stays read-only unless explicitly requested). Not a bare
`sqlite3.connect` against the live `user.db`, and not a generic finding
registry/metric/pattern/cohort/experiment system/scheduler.

## Verification

- `devtools test tests/unit/devtools/test_claim_vs_evidence_evidence.py
  tests/unit/devtools/test_claim_vs_evidence.py
  tests/unit/storage/test_public_claims_projection.py` — 23 passed.
- `mypy --strict` on both touched devtools modules — clean.
- `devtools verify --quick` — green.
- **Live smoke test**: ran `--materialize-evidence` against the actual
live
  archive with the daemon running concurrently (pid confirmed alive
  throughout, no lock contention). Registered 1 `QueryObject`, 1
`ResultSetManifest` (20 members), 2 `EvaluationReceipt`s (two runs a few
  seconds apart), 2 private `FINDING` assertions.
  `list_public_finding_inputs()` correctly returns zero rows — today's
  n=20 result is honestly not publishable, and the projection reflects
  that rather than a fabricated rate.

Ref polylogue-rxdo.13

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Codex <[email protected]>
Co-authored-by: Claude Fable 5 <[email protected]>
Sinity added a commit that referenced this pull request Jul 18, 2026
…3096)

## Summary

Phase 2 of the Lane A demo-credibility mission: eight short, real,
verifiable walkthroughs proving Polylogue's ordinary day-to-day surfaces
(find, read, search, resume, cost, lineage, MCP, status/health) work
end-to-end, not just in unit tests. (Phases 0/1/1.5 landed separately as
#3090 and #3093.)

## Problem

The demo shelf had construct-validity, economics, and forensics demos
but
nothing proving the *ordinary* features work. A skeptical outsider had
no
fast, verifiable answer to "do the basic features actually work."

## Solution

`.agent/demos/basic-usage/` — each walkthrough is the exact command, its
real captured output, and a one-line "what this proves":

1. **find** — a fielded DSL query plus a pipeline aggregate.
2. **read** — exact-ref transcript read (the captured transcript happens
to
show the assistant claiming "All tests pass" right after a tool result
with `exit_code=1` — a live illustration of the claim-vs-evidence gap,
   not manufactured for the point).
3. **search** — free-text FTS across three origins, every hit
   provenance-bearing.
4. **resume** — real runtime-native resume command generation.
5. **cost** — `analyze usage`'s disjoint token lanes and per-provenance
   pricing.
6. **lineage** — a forked session's transcript composing its parent's
   prefix, cross-checked against the parent's own transcript to prove
   genuine composition.
7. **MCP** — a real stdio JSON-RPC client/server round-trip (search →
   `get_session_summary`) via `devtools/continuity_replay.py`'s
   `StdioMCPContinuityRoute`, not a mocked handler.
8. **status/health** — daemon status plus named archive-debt rows,
captured
via the direct-archive fallback path so it reproduces identically for a
   reader with no daemon running.

Every walkthrough runs against Polylogue's deterministic demo archive,
not
the live one — this repository is public, and the live archive was
independently found to be in an unrelated degraded materialization state
(see `docs/findings/claim-vs-evidence.md`) that would have made live
numbers non-representative regardless.

`devtools/basic_usage_demo_check.py` (wired as `devtools workspace
basic-usage-demo-check`) re-runs all eight walkthroughs against a fresh
seed and asserts output *shape* — not exact volatile counts — so a
regression in any surface fails loudly instead of silently rotting the
demo.

## Privacy note

An earlier attempt to demo the interactively-connected MCP `search` tool
against this session's live archive surfaced real private session
content
into the session's own transcript — the tool has no archive-root
override
parameter (contrary to my initial assumption); it queries whatever
archive
the connected server process was launched against. That output was never
written to any file and is not part of this change; the MCP walkthrough
here uses the isolated stdio subprocess route instead, which accepts an
explicit archive root.

## Verification

- `devtools test tests/unit/devtools/test_basic_usage_demo_check.py` — 2
  passed (one end-to-end run of all 8 checks against a fresh seed, one
  anti-vacuity proof the lineage check can actually fail).
- `mypy --strict` — clean.
- `devtools render all --check` — clean (regenerated `docs/devtools.md`
and
  the demo-shelf indexes).
- `devtools verify --quick` — green, run against fresh master.

Co-Authored-By: Claude <[email protected]>

Co-authored-by: Claude <[email protected]>
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.

1 participant