Skip to content

fix(insights): derive profile cost and token lanes from usage evidence - #4577

Merged
Sinity merged 6 commits into
masterfrom
chore/suite-cull
Sep 3, 2026
Merged

Sinity merged 6 commits into
masterfrom
chore/suite-cull

Conversation

@Sinity

@Sinity Sinity commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Summary

Deletes tests that cannot fail for the reason they claim, and replaces three
clusters of weak tests with fewer, denser ones. Net −46 collected tests in
the corpus, no reduction in any protected area.

Problem

The corpus run is ~20,800 tests and ~68 minutes. Sampling the expensive files
and the reader suite found four classes of test that cost time without
protecting behavior.

Fossils. tests/unit/daemon/test_web_reader.py booted a real HTTP server
and then asserted the reader shell's inline JavaScript source text:

assert "var readiness = s.component_readiness || {};" in body
assert "function renderMaterializationChip(" in body
assert 'No saved views. Click "Save current view"' in body

Renaming a local variable turns these red; serving a broken page does not.
24 such tests across TestReaderInformability (all 15), TestReaderSavedViewsUI
(4 of 5), TestReaderSelectionOperations (2), the action-affordance rail, the
raw-tab fetch shape, and test_reader_smoke_lane_is_documented — which read
its own file and asserted two identifiers appear in it.

The CLI help snapshots pinned prose that no contract declares: the root
--help text, the PTY-rendered grid, and the same grid again at 60 and 120
columns (assert output == snapshot, four tests plus a CliRunner twin).

Tautologies. test_maintenance_registration.py carried eleven assertions
of the form assert isinstance(plan_command, click.Command). These pass for
any implementation that still applies @click.command(), and the same file's
list_commands tests already assert every command name is registered.

Duplicates. The dynamic-completer matrix ran 3 shells x 5 completers,
twice, for 30 cases. Only session_id yields items in the synthetic corpus, so
the other 12 seeded cases put an empty list through format_completion and
asserted isinstance(items, list) — true of the empty list. These are the
suite's single most expensive parametrization (cwd_prefix-fish 121.8s,
cwd_prefix-zsh 120.1s, cwd_prefix-bash 81.7s, repo-zsh 66.3s).

Two normalize_role Hypothesis properties drew 100 examples each from a
4-member role set and a 4x6 grid — ~190 redundant executions.

Benchmarks as unit tests. TestPerformanceBudget seeds a 500-session
archive and asserts elapsed_ms < 500, in the serial storage-scale phase whose
32 tests take 679s of a 4058s job at zero parallelism.

Solution

Class Tests removed Tests added File
Fossil (inline JS) 24 0 test_web_reader.py
Fossil (help prose) 5 4 test_help_snapshots.py (deleted), test_terminal_snapshots.py
Tautology 11 0 test_maintenance_registration.py
Duplicate 30 13 test_completion_matrix.py
Duplicate (Hypothesis) 2 12 test_source_laws.py
Benchmark relocation 3 3 (in tests/benchmarks/) test_scale.py
Dropped-column rewrite 4 2 test_session_profile_model_usage_consistency.py

Every kept test_web_reader.py test hits a served route through the real
daemon and checks a served contract. The dist bundle's mount points, hashed
asset transport, cache policy and ETag revalidation were already covered
densely by test_app_serves_semantic_ssr_and_manifest_hashed_assets, so
nothing replaces the deleted assertions. test_browser_capture_reader_boundary
keeps its XSS contract on the served bytes; only its two trailing inline-JS
assertions are gone. TestReaderPrivacy's absolute-path leak checks are
contracts on served output and stay.

The help snapshots become one parametrized structural check across 60/80/120
columns that also proves no rendered line exceeds the terminal width — a claim
the snapshots never made — and the invalid-option snapshot becomes an assertion
that the error names the rejected option.

The completer matrix becomes three tests with distinct claims: every completer
resolves to [] on an empty archive (one shell — with no items there is no
per-shell formatting to exercise); session_id yields archive-derived items
that each of the three shells formats; every completer resolves without raising
against a seeded archive.

test_session_profile_model_usage_consistency.py was red at head: #4225
dropped the duplicated total_*_tokens columns from session_profiles, and
the test selected them. It now asserts through the derivation
session_model_usage feeds — build_session_profile fed from the persisted
usage rows, hydrated by the materializer's own load_sync_batch /
hydrate_sessions — and keeps its anti-vacuity condition: a Codex session
whose only usage evidence is a cumulative token_count event must report the
disjoint lanes (4,000 fresh input / 96,000 cache read), not the word-count
estimate the pre-fix builder produced. The "undercounted before" half is gone;
it can no longer be expressed without the dropped columns.

Product fix (commits 2-3)

The rewrite above exposed a live defect. #4225 made session_model_usage the
single authority and removed all nine cost and token columns from
session_profiles, but the profile readers still ran
SELECT * FROM session_profiles. _row_to_session_profile_record fell through
to its _row_int(row, ..., 0) defaults, so every SessionProfileRecord
reported zero tokens, $0.00, and the record's default provenance.
insights/portfolio.py sums profile.total_input_tokens and
profile.total_cost_usd across the analyzed set, so portfolio and postmortem
read a flat zero on any archive.

The read path now recomputes through compute_session_cost -- the same
function the materializer uses, so the provenance vocabulary
(provider_reported / catalog_priced / mixed / unknown, the semantics
#4261 revised) keeps exactly one implementation. A SQL projection was tried
first and rejected: archive.py's expression emits origin_reported /
priced for SessionSummary, and the profile mapper computes
cost_is_estimated as cost_provenance != "provider_reported", so porting
that expression would have marked every provider-reported cost as estimated.

session becomes optional in compute_session_cost. Without a hydrated
session the message-length fallback is simply unavailable, so usage rows with
real token counters price exactly as they would with a session in hand, while
identity-only rows (chatgpt-export and claude-ai-export write a real
model_name with zero counters) keep the unknown disposition
_per_model_from_model_usage already assigns them rather than being upgraded
to an estimate. Absent evidence stays unknown, never a priced zero
(polylogue-9kjtc). That is a loss of richness for those two origins against
what the materializer computed when it had messages in hand, and never a
fabricated figure.

Batched: one session_model_usage query per read call, grouped by session, so
N profiles cost N dict lookups over one query. Measured 27 us per profile,
5.4 ms across portfolio's 200-session cap
, pricing catalog loaded once.

Applied to the repository route (get_session_profile,
get_session_profiles_batch, list_session_profiles), the full-rebuild
stream, and the rebuild/refresh record loaders. Read-path only: no DDL, no
schema version, no lifecycle delta.

Two tests cover it through the repository route: the Codex
cumulative-token_count fixture reports the lanes and cost
compute_session_cost derives from the same rows (red if the overlay is
removed), and a session with its usage rows deleted reports unknown
provenance, 0.0 cost, and cost_is_estimated true.

Verification

Every touched file, one devtools test <files> -n 2 invocation at a time, on
the free-threaded Nix interpreter the project requires:

Selection Result
test_web_reader.py 150 passed, 1 failed (inherited)
test_terminal_snapshots.py test_maintenance_registration.py 22 passed
test_completion_matrix.py test_source_laws.py 278 passed in 89s
test_session_profile_model_usage_consistency.py tests/unit/insights/ 729 passed, 1 failed (basetemp artifact)
test_scale.py 9 passed
tests/benchmarks/test_archive_read_budgets.py 3 passed
test_cost_compute test_pricing tests/unit/cost/ profile roundtrip + staleness 90 passed
tests/unit/api/ + insight readiness / summaries / registry 504 passed, 3 failed (inherited)

~1,785 passed. Five failures, none caused by this branch, each classified
against the corpus run be5bcc08 at head 42e501ec7 — this branch's exact
base — rather than assumed:

  • test_degraded_search_index_returns_route_state_not_zero_results — red in
    the corpus run. A degraded FTS index answers 503 where the test expects 200
    with a route state. Which is correct is a product question, out of scope for
    a test cull.
  • test_record_context_delivery_requires_initialized_user_tier,
    test_insight_readiness_report_marks_missing_insight_tables,
    test_archive_tiers_api_session_costs_read_index_tier — all three red in the
    corpus run (SchemaSkewError on the ops tier, no such column: r.tool_outcome, and a priced/exact status-vocabulary drift).
  • test_git_commit_adapter_raises_explicitly_for_non_repository — passed in
    the corpus run. It asserts git fails outside a repository, but devtools test in a worktree puts tmp_path under .cache/verify/ inside the
    worktree, so git resolves a repo and the adapter does not raise. A latent
    fragility in that test, not a regression here.

The reader suite's 6 remaining inherited fossils were repaired in this branch
(commit 5) rather than left red, since they are the same class it exists to
remove.

Cost check on the touched hot file: test_completion_matrix.py was 535s / 151
tests on master and is now 134 tests inside an 89s two-file run at -n 2.

Not run: the full corpus. Per-PR CI runs only the quick gate, so a green
check here does not mean the suite ran.

Residual risk

tests/unit/infra/test_workload_artifacts.py is the largest remaining
opportunity and is deliberately untouched: 1,559s across 89 tests, of which six
corruption/forgery tests cost 617s. They already use a minimal corpus (2
sessions x 2 messages), so the cost is the archive build machinery itself, not
scale — each test calls build_seeded_archive twice after clearing the
validation memo. Folding the four manifest-tamper tests into one test that
builds once and applies each tampering in turn would roughly halve that, at the
cost of coupling the cases. This is the seeded-archive cache's integrity
contract; rewriting it unverified is how a gate gets silently weakened, so it
wants its own change with its own verification.

Deleted assertions that could be re-added as real contracts, if desired: the
reader shell's chip-quality CSS vocabulary and selection-toolbar region hooks
are genuine DOM contracts, but they were asserted as substrings of the inline
script rather than against parsed DOM. A DOM-level check belongs with the
visual lane (tests/visual/test_reader_semantic_cards.py), not as a string
search over served JavaScript.

Left alone as protected: tests/unit/security/, tests/integration/,
tests/property/, test_parsers_props.py, test_null_guard_properties.py,
origin specs and real fixtures, and replay-parity tests. Two candidates were
identified inside them and not cut — tests/unit/cli/test_help_contract.py
pins CLI group-header strings, and tests/unit/core/test_message_laws.py::test_message_role_is_typed_enum
asserts isinstance(msg.role, Role) on a strategy that can only produce
Role — the first because the header taxonomy is plausibly a declared surface,
the second because it sits among the core property tests.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz

Sinity and others added 6 commits September 3, 2026 00:15
Fossils. `test_web_reader.py` asserted the reader shell's inline JavaScript
source text -- function names, state-field names, prompt strings -- from a
booted HTTP server. 24 such tests are gone; every remaining test hits a served
route and checks a served contract, including the dist manifest, hashed asset
transport and island mount points already covered by
`test_app_serves_semantic_ssr_and_manifest_hashed_assets`. The CLI `--help`
snapshots (root, PTY, 60/120 columns) pinned prose no contract declares; they
are replaced by one parametrized structural check that also proves no line
exceeds the terminal width, and the invalid-option snapshot by an assertion
that the error names the rejected option.

Tautologies. Eleven `isinstance(cmd, click.Command)` assertions in
`test_maintenance_registration.py` only caught a wholly removed decorator; the
same file's `list_commands` tests already assert every command name is
registered.

Duplicates. The dynamic-completer matrix ran 3 shells x 5 completers twice
(30 cases) where only `session_id` yields items for per-shell
`format_completion` to act on; it is now 13 cases across three tests with
distinct claims. Two `normalize_role` Hypothesis properties over a 4-member
role set drew 100 examples each; they collapse into one parametrize that
enumerates the space exhaustively.

Benchmarks. `TestPerformanceBudget` asserted wall-clock SLAs on a 500-session
archive from inside the storage-scale phase; it moves to `tests/benchmarks/`,
which the corpus run excludes.

`test_session_profile_model_usage_consistency.py` selected the
`total_*_tokens` columns #4225 dropped from `session_profiles`. It now asserts
through the derivation `session_model_usage` feeds, keeping its anti-vacuity
condition: a Codex session whose only usage evidence is a cumulative
`token_count` event must report the disjoint lanes, not a word-count estimate.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz
#4225 removed the duplicated `total_*_tokens` columns from `session_profiles`
and redirected the ArchiveStore summary queries to `session_model_usage`, but
not the profile readers. They still ran `SELECT * FROM session_profiles`, so
`_row_to_session_profile_record` fell through to `_row_int(row, ..., 0)` and
every `SessionProfileRecord` reported zero tokens. Portfolio and postmortem
token lanes (`insights/portfolio.py`, summing `profile.total_input_tokens`
across the analyzed set) therefore read a flat zero on any archive.

`session_profile_usage_lanes_sql` projects the four lanes as correlated
subqueries over `session_model_usage`, matching the pattern the cost lanes
already use, and is applied by every SELECT that feeds the mapper: the
repository route (`get_session_profile`, `get_session_profiles_batch`,
`list_session_profiles`), the full-rebuild stream, and the rebuild/refresh
old-record loads.

Read-path only: no DDL, no schema version, no lifecycle delta.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz
#4225 made `session_model_usage` the single authority and removed all nine
cost and token columns from `session_profiles`, but the profile readers still
ran `SELECT * FROM session_profiles`. `_row_to_session_profile_record` fell
through to its `_row_int(row, ..., 0)` defaults, so every
`SessionProfileRecord` reported zero tokens, $0.00, and the record's default
provenance. `insights/portfolio.py` sums `profile.total_input_tokens` and
`profile.total_cost_usd` across the analyzed set, so portfolio and postmortem
read a flat zero on any archive.

The read path now recomputes through `compute_session_cost` — the same
function the materializer uses, so the provenance vocabulary
(`provider_reported` / `catalog_priced` / `mixed` / `unknown`, matching the
semantics #4261 revised) keeps exactly one implementation. `session` becomes
optional there: without a hydrated session the message-length fallback is
simply unavailable, so usage rows with real token counters price exactly as
they would with a session in hand, while identity-only rows (chatgpt-export
and claude-ai-export write a real `model_name` with zero counters) keep the
`unknown` disposition `_per_model_from_model_usage` already assigns them
rather than being upgraded to an estimate. Absent evidence stays `unknown`,
never a priced zero (polylogue-9kjtc).

Batched: one `session_model_usage` query per read call, grouped by session, so
a batch of N profiles costs N dict lookups over one query. Measured 27 us per
profile, 5.4 ms across portfolio's 200-session cap, with the pricing catalog
loaded once.

Applied to the repository route (`get_session_profile`,
`get_session_profiles_batch`, `list_session_profiles`), the full-rebuild
stream, and the rebuild/refresh record loaders. Read-path only: no DDL, no
schema version, no lifecycle delta.

Supersedes the SQL token-lane projection from the previous commit, which this
subsumes.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz
A session with no usage evidence prices as `unknown` and contributes 0.0 to
the portfolio total, because absent evidence is not a bill. Nothing said how
many such sessions were in the total, so "$12.40 across 200 sessions" read
identically whether none or most of them were unpriced — the absence became a
known zero at the point a human reads it.

`CostMetric.unpriced_session_count` carries the count. It is required rather
than defaulted: a caller that cannot say how much of its total is unpriced
would be making exactly the claim this prevents. Both aggregators populate it
from `cost_provenance == "unknown"`, and both portfolio renderers append the
clause only when it is non-zero, so a fully priced report stays quiet. The
CLI's JSON surface carries it through `model_json_document`.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz
Six tests were red on master before this branch: `/` and `/s/{id}` now serve
the Vite bundle from `static/dist`, and these still asserted the retired
inline shell's JavaScript identifiers (`renderSidebarState`,
`getSessionIdFromURL`, `renderInspectorEvidence`), its exact `<title>`, and
that session prose never appeared in the page.

They are the same fossil class as the rest of this branch's reader cull; the
earlier pass missed them because they list region names in a tuple rather than
inline in the assertion.

- `test_root_returns_html_with_required_regions` becomes
  `test_root_serves_the_archive_overview_island_bundle`: the served contract is
  the island mount plus a hashed module script.
- The two deep-link tests collapse into
  `test_session_deep_link_serves_the_session_read_bundle`; the inspector-hook
  half was a duplicate of the assertion and read-view route tests.
- The browser-capture boundary keeps its live claim and drops its obsolete one:
  the reader server-renders session content by design, so the prose is expected
  in the page and what must never survive is live markup. It now asserts the
  dangerous fragment appears only escaped.
- The evidence-summary cost expectation moves from `0.0` to `None`: absent
  pricing evidence is not a known-zero bill (#4261).

One inherited red remains in this file and is out of scope for a test cull:
`test_degraded_search_index_returns_route_state_not_zero_results` expects a
degraded FTS index to answer 200 with a route state, and the route answers 503.
Which of the two is correct is a product question.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz
@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Team

Run ID: 7a306677-653b-4e0d-8070-1a09ead26125


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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-03T03:13:37.711253Z e4d82af PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Sinity
Sinity merged commit f701143 into master Sep 3, 2026
2 of 3 checks passed
@Sinity
Sinity deleted the chore/suite-cull branch September 3, 2026 03:04

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e4d82af8c2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread polylogue/insights/postmortem.py Resolved
Comment thread polylogue/insights/postmortem.py Resolved
Sinity added a commit that referenced this pull request Sep 3, 2026
unpriced_session_count and the "across N sessions" cost line (#4577),
the relative-age redaction, and the planner stat row counts after the
runtime index additions.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz
Sinity added a commit that referenced this pull request Sep 29, 2026
)

## Summary

Lands worker 8's review-debt fixes for `polylogue-1tyq5.107`, `.108` and
`.109` (storage reads, usage, query objects, connection profile),
rebased onto current master and reviewed. Of 52 findings: 24 fixed with
regression tests, 9 already fixed on master, 19 not reached.

## Problem

The worker's commit could not be run by its author. On review, several
fixes were right in intent but wrong in shape:
- the writer refusal of unprovisioned tiers also removed the index
version-zero exemption and changed attached-sibling and reader checks;
- `ReadFrame.resume` rebound on every external commit, which resets
`data_version` and would hide a mixed source census from
`_require_current_source_census_frame`;
- the effective-context fix changed the API route only, leaving the
pinned `read.effective_context` operation reading own rows with the old
boundary rule;
- the profile snapshot fix covered only the batch read;
- the attachment-library order used `attachment_refs.position`, an
identity coordinate rather than a display ordinal;
- the subscription conversion reported $0 for an unrated model or an
undeclared tier.

## Solution

- Worker commit, rebased unchanged.
- Follow-up commit: writers refuse a never-provisioned tier only when
they open it directly; every reader path keeps master's absent-tier
answer. `resume` rebinds only for a held read transaction and refuses
while a stream pins the snapshot. `effective_context_window` plus one
boundary query is now the single owner for both effective-context
routes, and both compose the lineage transcript. Single, batch and list
profile reads hold one snapshot. Library pages order by attachment ID
within a message, matching the session read. Checkpoint blockers stay
named when the checkpoint failed. The cumulative lane uses the same
counter-evidence rule as the request lane. Subscription equivalents are
`None` when the rate or tier is unknown. `put_query` raises instead of
asserting.

No Origin to Provider reversal is added. `coverage.provider` was already
present and is unchanged.

## Verification

- `agentctl job start polylogue verify_quick --workspace
/realm/worktrees/salvage-w8 --wait` → job 2311 `succeeded` (head
65a248e762, same tree as 02c3d8c).
- `agentctl job start polylogue pytest_focused --workspace
/realm/worktrees/salvage-w8 --wait -- <30 test files>` → job 2314: `790
passed, 4 failed`. All four failures are inherited: job 2294 reproduces
them with every production file reset to `origin/master`:
-
`test_diagnostics.py::test_latency_plain_zero_rows_reports_unknown_drop_accounting`
-
`test_facade_contracts.py::test_archive_facet_buckets_count_unique_sessions_for_duplicate_hits`
  - `test_facade_contracts.py::test_no_undiscovered_async_methods`
-
`test_mapped_bytes_budget.py::test_async_attached_tier_profiles_map_main_only[configure_read_connection]`
- Anti-vacuity: in a worktree with every changed production file reset
to `origin/master`, the new regression tests fail on their assertions
(job 2262: `40 failed`; job 2315: `3 failed`, covering the revised
attachment test, the updated budget test and the cumulative-lane test).

## Self-review

- **Siblings and owners.** Effective context had two deciders, the API
route and `operations/read_view_extras.py`. Both now call
`effective_context_window`. The one-snapshot fix covers all three
profile reads. Reportedness now uses the same counter-evidence rule for
the request and cumulative lanes. The schema refusal applies only where
a writer opens a tier. Reader, sibling, sealed-staging and
`assert_tier_schema_supported` callers keep master behaviour.
- **The fix itself.** Rebinding on any stale `revalidate()` would have
defeated the census end check, so it was dropped.
`ReadFrameExpiredError` from `resume` during a stream is an existing
typed error, and the census never resumes mid-stream. The `assert` in
`put_query` became a raise.
- **Memory and limits.** Session-cost IDs page at the connection's
physical bind limit, with no new cap. Both effective-context routes
still compose the whole transcript, as `get_messages` already did. See
residuals.
- **Cost per unit.** Attachment-library paging still uses the existing
OFFSET. The new `LEFT JOIN messages` is on the primary key.
- **Interruption.** The added read transactions roll back in `finally`.
`ReadFrame.close` retires stream cursors before closing the connection.
- **Ordering and races.** Messages, boundary and blocks are read in one
snapshot, as are profile rows and usage. `resume` never proves an anchor
on a held snapshot.
- **Failure classification.** A canonical-DDL build failure is
`upgrade_runtime`, separate from `retry` and drift. Checkpoint blockers
are kept on error.
- **Silent outcomes.** A lane without counter evidence is `unavailable`,
and a lane with an explicit zero is `reported`. An unknown subscription
rate or tier is `None`, not $0.
- **Cleanup on failure.** Every added `BEGIN DEFERRED` ends with
`ROLLBACK` in `finally`.
- **Identity and keys.** No hash or ID changes.
- **Lossless transforms.** Not applicable.
- **Degenerate inputs.** NaN and infinite snapshot bounds are refused.
Negative or reversed boundary ranges fall back to the plain prefix. An
empty ID list returns early.
- **Consumers.** The CLI renderer uses the lane fields.
`test_mapped_bytes_budget` was updated to three writers.
`read_view_extras` uses the new owner.
- **Tests and stubs.** The monkeypatch targets (`_own_messages`,
`read_model_usage_batch_async`, `_resolve_subscription_tier_setting`)
exist and are called on the production route. Each test states its
anti-vacuity condition.
- **Trust boundaries.** No change.

## Per-finding dispositions

| key | disposition | evidence | test |
|---|---|---|---|
| 107-01 (#4642) | not reached | still real: Invalidation returns
children, not the former parent cohorts; only the current session
receives an explicit delegation refresh. | — |
| 107-02 (#4690) | not reached | still real: LIKE requires an immediate
subagents basename and the parent check uses parts[-3]. | — |
| 107-03 (#4642) | not reached | still real: Retired-alias invalidation
selects only resolved links to the withdrawing claimant; graph inbound
lookup only addresses the written session. | — |
| 107-04 (#4690) | not reached | still real: Unresolved multi-name
observations are skipped and sidecars can bind the known sibling; no
full parent cohort revisit on a second child arrival. | — |
| 107-05 (#4056) | not reached | still real: Every controller submits to
one four-worker adapter, regardless of its capacity. | — |
| 107-06 (#4606) | fixed-already |
`polylogue/storage/sqlite/connection_profile.py:900-910; :1193-1206`
holds on current master | — |
| 107-07 (#4610) | fixed-already |
`polylogue/storage/sqlite/connection_profile.py:932-945` holds on
current master | — |
| 107-08 (#4611) | fixed-already |
`polylogue/storage/sqlite/connection_profile.py:932-945` holds on
current master | — |
| 107-09 (#4687) | fixed | `_assert_schema_supported` keeps the
empty-tier exemption for read-only opens only;
`open_connection`/`open_daemon_connection` on a never-provisioned tier
now raise `SchemaSkew` before any SQL. Attached siblings keep the
absent-tier read answer. |
`test_writers_refuse_an_uninitialized_durable_tier` |
| 107-10 (#5248) | fixed | `mapped_bytes_budget` and
`MappedBytesBudgetCheck.concurrent_profile_budget_bytes` count three
ordinary writer profiles (index, source, publication reservation). |
`test_memory_budget_includes_source_and_reservation_writers` |
| 107-11 (#4794) | not reached | still real: A pathname stat after
opening can stamp the connection with a replacement inode. | — |
| 107-12 (#4794) | fixed | `ReadFrame.resume` rebinds a live frame whose
connection holds a read transaction before proving the anchor, and
refuses with `ReadFrameExpiredError` while a stream pins the snapshot. |
`test_resume_releases_a_held_snapshot_before_proving_the_anchor,
::test_resume_refuses_while_a_stream_pins_the_snapshot` |
| 107-13 (#5401) | not reached | still real: Cancel interrupts a running
statement but leaves a cursor suspended at yield open. | — |
| 107-14 (#5401) | fixed | `ReadFrame.close` closes registered stream
cursors before the connection, so later generator cleanup has nothing to
do. | `test_stream_can_be_closed_after_its_frame` |
| 107-15 (#5401) | fixed | `read_frame` and `ReadFrame.__init__` refuse
NaN and infinite snapshot bounds. |
`test_read_frame_rejects_nonfinite_snapshot_bounds` |
| 107-16 (#4183) | fixed | `format_session_markdown` uses the recorded
`source_url` when an attachment has no local path. |
`test_markdown_uses_remote_attachment_urls_without_a_local_path` |
| 107-17 (#5454) | not reached | still real: The session filter selects
physical attachment refs only, excluding a composed parent prefix. | — |
| 107-18 (#5454) | fixed | The attachment library orders by session sort
key (newest first), then message position/variant, then attachment ID
within a message (as the session read does), before LIMIT/OFFSET. |
`test_attachment_library_pages_keep_session_and_transcript_order` |
| 107-19 (#5420) | fixed-already |
`polylogue/analysis/archive_models.py:79;
polylogue/storage/derived/session/profiles.py:248;
polylogue/storage/sqlite/queries/mappers_insight_profiles.py:54-56`
holds on current master | — |
| 107-20 (#4985) | fixed | `effective_context_window` (the single owner,
used by both the API and the pinned `read.effective_context` operation)
falls back to the plain prefix unless 0 <= start <= end. |
`test_effective_context_rejects_invalid_ranges` |
| 107-21 (#4985) | fixed | The boundary query selects the newest
compaction first; an incomplete newest row yields the plain prefix
instead of an older summary. |
`test_newest_incomplete_compaction_does_not_reuse_an_older_summary` |
| 107-22 (#4357) | fixed | Both effective-context routes now compose the
lineage transcript before applying the local boundary. |
`test_effective_context_includes_a_forks_inherited_prefix,
::test_pinned_operation_and_api_share_one_effective_context_decision` |
| 107-23 (#4357) | fixed | Messages and the boundary are read in one
deferred read transaction. |
`test_effective_context_reads_boundary_in_the_message_snapshot` |
| 107-24 (#4577) | fixed | Single, batch and list profile reads hold one
read snapshot across the profile rows and the usage overlay. |
`test_profile_rows_and_usage_overlay_share_one_snapshot` |
| 107-25 (#4630) | not reached | still real: LIMIT is applied to thread
ids before hydration drops roots without profiles. | — |
| 108-01 (#4200) | fixed | `put_query` returns the persisted row
(including promotion metadata) after the idempotent insert. |
`test_put_query_returns_existing_promotion_contract` |
| 108-02 (#4200) | not reached | still real: The tombstone predicate
checks only the caller-provided result_set_id. | — |
| 108-03 (#4357) | fixed | `get_effective_context` hydrates blocks and
derived text inside the same snapshot as the messages. |
`test_effective_context_hydrates_structured_tool_blocks` |
| 108-04 (#4799) | fixed | Compaction context snapshots take `event
position + 1`, leaving position 0 to the session-start snapshot. |
`test_context_snapshot_start_precedes_the_first_compaction` |
| 108-05 (#4546) | fixed-already |
`polylogue/storage/sqlite/schema_manifest.py:92-129` holds on current
master | — |
| 108-06 (#4546) | fixed | A failure to build the canonical index
manifest is classified `upgrade_runtime`, separately from archive read
failures (`retry`) and drift. |
`test_canonical_ddl_runtime_failure_requests_runtime_upgrade` |
| 108-07 (#4579) | fixed-already |
`polylogue/storage/sqlite/archive_tiers/archive.py:6694-6697;
:8603-8616; polylogue/storage/sqlite/queries/sessions_search.py:25-27;
polylogue/mcp/server_support.py:546-555` holds on current master | — |
| 108-08 (#4637) | fixed-already |
`polylogue/storage/sqlite/schema.py:113-128;
polylogue/storage/sqlite/schema_bootstrap.py:87-101` holds on current
master | — |
| 108-09 (#4637) | not reached | still real: An installed read-only
source tree cannot host the persistent memo, so short-lived processes
recompute source closures. | — |
| 108-10 (#4601) | not reached | still real: The existing async
identity-adoption helper inserts without a commit. A compliant fix must
remove unsupported legacy adoption rather than perpetuate it. | — |
| 108-11 (#5401) | fixed | Read frames are named as checkpoint blockers
only when the checkpoint left busy pages or undrained log, or failed. |
`test_successful_checkpoint_does_not_label_current_snapshot_as_a_blocker`
|
| 108-12 (#4317) | not reached | still real: Cumulative input always
subtracts cache; origin is explicitly discarded. | — |
| 108-13 (#4317) | not reached | still real: Duplicate non-Codex
disjoint-input report, retained separately. | — |
| 108-14 (#4317) | not reached | still real: The exported canonical
projection has no production caller; writer paths still fold usage
separately. | — |
| 108-15 (#4317) | not reached | still real: Each cumulative session
rebuilds the entire grouped dictionary. | — |
| 108-16 (#4317) | not reached | still real: Default tuple ordering
compares nullable model names against strings in projection and rollup.
| — |
| 108-17 (#4317) | fixed-already | `polylogue/storage/usage.py:237-247`
holds on current master | — |
| 108-18 (#4317) | not reached | still real: Reasoning-only or
total-only evidence can become a complete zero-cost projection. | — |
| 108-19 (#4317) | not reached | still real: Costs are rounded to six
decimal places before further aggregation. | — |
| 108-20 (#4927) | fixed-already | `polylogue/storage/usage.py:589-595`
holds on current master | — |
| 108-21 (#4927) | fixed | The plaintext usage report renders
`provider_request_lanes`/`provider_cumulative_lanes` and prints
`unavailable` for an unreported lane. |
`test_usage_cli_renders_disjoint_lanes_and_unavailable_requests` |
| 108-22 (#4927) | fixed | Request-lane reportedness counts events that
carry a last/request counter (`request_counter_event_count`), in both
the SQL and streaming stats paths. The cumulative lane follows the same
counter-evidence rule. |
`test_request_lane_reportedness_requires_request_counter_evidence` |
| 108-23 (#4927) | fixed | Same change: cumulative-only events stay
`unavailable`; an explicit request zero stays `reported`. |
`test_request_lane_reportedness_requires_request_counter_evidence` |
| 108-24 (#4293) | fixed | The cache-rate coverage check runs before a
stored priced cost is reused. |
`test_stored_price_does_not_hide_a_missing_cache_rate` |
| 108-25 (#4217) | fixed | `session_usage_costs_for_connection` batches
IDs at the connection's `SQLITE_LIMIT_VARIABLE_NUMBER`. |
`test_session_cost_lookup_pages_at_the_connection_bind_limit` |
| 109-01 (#4217) | fixed | Model names are normalized before the credit
lookup; a token-bearing row whose model still has no credit rate makes
the session's subscription amount unknown (None), not $0. |
`test_session_subscription_fallback_normalizes_provider_qualified_models,
::test_session_subscription_amount_is_unknown_without_a_rate_or_tier` |
| 109-02 (#4217) | fixed | Credits pass through `credits_to_usd` with
the archive's configured tier (default `pro`); a tier the catalog no
longer declares yields None. |
`test_session_subscription_amount_is_dollars_not_raw_credits` |

Worker claims narrowed rather than rejected: 107-09, 107-12, 107-18,
107-22 and 107-24 (see Problem), and 109-01/109-02 (fail closed). No
worker `fixed` claim was dropped as not real.

## Derived-identity closure

`devtools schema closure` on the changed files. IN:
`storage/sqlite/connection_profile.py`, `queries/attachment_records.py`,
`queries/message_query_reads.py`, `query_objects.py`,
`query_store_archive.py`, `run_projection_relations.py`, `schema.py`,
`wal_checkpoint.py`, `storage/usage.py`. Out:
`cli/commands/diagnostics.py`, `operations/read_view_extras.py`,
`rendering/core_markdown.py`,
`queries/session_insight_profile_reads.py`. Land this before a rebuild
starts.

## Residuals

- 19 findings remain not reached, and their beads stay open.
- The pinned `read.effective_context` operation returns messages without
hydrated blocks. The API route hydrates them. This predates the PR.
- Both effective-context routes compose the full transcript in memory,
as `get_messages` does.
- `_attach_sibling_tiers` still admits an empty sibling tier on a writer
connection. Only direct writer opens refuse.
- Four inherited test failures on master are listed above.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
@Sinity

Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

Closing out open Codex review threads on this PR (evidence checked against master at 749f608):

Resolving every thread listed; confirmed defects are fixed under the named bead.

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