Repository navigation
fix(storage,daemon): wire cost columns and feed FTS-orphan drift into retry - #3439
Conversation
…e retry (polylogue-5vbs) Problem: make_fts_stage's path-scoped check/check_many are deliberate no-ops in archive/split-file mode (session/message writes already repair FTS in-transaction with an abort-on-failure policy), but nothing else ever notices FTS drift introduced OUTSIDE that write path -- external DB surgery, a partial migration, or a future writer that skips the write_effects.py registry. The session-scoped check_sessions/ execute_sessions retry primitives on the same stage are real and correct, but until now nothing fed them a stage="fts", subject_type="session_id" subject for that class of drift (only two sources/live/batch.py deferred-write call sites feed that subject, and only for their own writes). Solution: polylogue/daemon/fts_orphan_audit.py adds a bounded, quiet-cadence (hourly) sweep -- find_orphaned_fts_sessions_sync anti-joins blocks (via the existing idx_blocks_search_text_populated partial index) against messages_fts_docsize to find sessions with a block missing its FTS row, and run_fts_orphan_audit_once_sync records that as retryable convergence debt via CursorStore. Wired into the daemon's periodic loop family (daemon/cli.py) as periodic_fts_orphan_audit, following the existing periodic_fts_identity_drift_recompute shape (plain asyncio loop, not a ConvergenceStage -- convergence_stages.py's own verdict is "refactor before adding a fourth stage"). Verification: devtools test tests/unit/daemon/test_fts_orphan_audit.py -- 7 passed. Anti-vacuity test hand-orphans a block's messages_fts row outside the write path, proves the audit finds and records debt for it, then proves make_fts_stage's own check_sessions/execute_sessions (already tested elsewhere) genuinely repairs it -- closing the feeder gap end to end, not just recording debt that nothing drains. Ref polylogue-5vbs Co-Authored-By: Claude <[email protected]>
…/priced_at_ms (polylogue-f2qv.6)
Problem: live census (23,318 session_profiles rows) found cost_usd,
cost_credits, priced_with, and priced_at_ms 100% NULL, despite
session_model_usage (the single per-model cost authority) carrying real
catalog-priced cost_usd for 10,222 of 18,655 rows for the same sessions.
Root cause, traced to source: upsert_session_profile_costs
(storage/sqlite/archive_tiers/write.py) is the only writer ever declared
for these four columns and has zero production callers -- the value was
never computed and dropped, it was simply never wired into session-profile
materialization. _SESSION_PROFILE_BASE_COLUMNS/session_profile_insert_values
(storage/insights/session/storage.py) never referenced them at all, so
every INSERT left them at their column default (NULL).
Solution: extend the real materialization pipeline instead of routing
through the disconnected upsert helper (which a DELETE-then-INSERT full
profile replace would immediately clobber on the next rebuild anyway):
- SessionProfile (archive/session/models.py) gains nullable cost_usd/
cost_credits/priced_with fields, roundtripped through to_dict/from_dict
(archive/session/documents.py's SessionProfileDocument TypedDict).
- build_session_profile (archive/session/runtime.py) computes them from
the same cost_summary already used for total_cost_usd/total_credit_cost,
but gates on the model actually being in the PRICING catalog (mirroring
write.py's `if normalized in PRICING and billable > 0` for
session_model_usage) so an unrecognized model stays NULL rather than a
fabricated $0.00.
- SessionProfileRecord (storage/insights/session/records.py) gains the
same three fields plus priced_at_ms (derived from the record's own
materialized_at instant, mirroring session_model_usage's
time.time()-at-write-time semantics).
- build_session_profile_record (storage/insights/session/profiles.py) and
_SESSION_PROFILE_BASE_COLUMNS/session_profile_insert_values
(storage/insights/session/storage.py) thread them into the real INSERT,
shared by both the sync and async write paths.
upsert_session_profile_costs is kept: 4 test files use it as a seeding
helper for unrelated read-path tests (cost rollup, facade contracts) and
it is harmless dead weight, not part of this fix.
Verification: devtools test tests/unit/storage/test_session_profile_cost_columns.py
-- 3 passed, exercising the real production pipeline
(write_parsed_session_to_archive + rebuild_session_insights_sync). Proves
a catalog-priced model populates all four columns (cost_usd == total_cost_usd,
since both derive from the same cost_summary), an unpriced model leaves all
four NULL (no fabrication), and priced_at_ms advances on a later rebuild.
Also ran the broader affected surface: tests/unit/storage/test_session_profile_model_usage_consistency.py
tests/unit/storage/test_archive_tiers_write.py tests/unit/insights/test_cost_rollup_summary_path.py
tests/unit/cli/test_insights.py tests/unit/api/test_facade_contracts.py
tests/unit/storage/test_session_usage_reconciliation.py -- 397/398 passed;
the one failure (test_archive_tiers_api_raw_artifacts_read_source_tier) is
a pre-existing clock-hygiene flake unrelated to this change, reproduced
identically on master via git stash.
mypy --strict on every touched file: no issues found.
Ref polylogue-f2qv.6
Co-Authored-By: Claude <[email protected]>
Append investigation notes to polylogue-f2qv.6, polylogue-5vbs, and polylogue-m3p9 documenting root cause, fix commits, and residual scope for this session's cost-columns/FTS-orphan/created-at-null work. Co-Authored-By: Claude <[email protected]>
devtools verify --quick's mypy step failed on tests/unit/storage/ test_session_profile_cost_columns.py:94 (Returning Any from function declared to return "Row") -- sqlite3.Cursor.fetchone() types as Any. Cast the non-None result explicitly. Co-Authored-By: Claude <[email protected]>
|
Warning Review limit reached
Next review available in: 32 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (11)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 63512da0f9
ℹ️ 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".
| has_priced_model = any( | ||
| breakdown.normalized_model is not None and breakdown.normalized_model in PRICING | ||
| for breakdown in cost_summary.per_model |
There was a problem hiding this comment.
Require billable usage before marking a profile priced
For sessions that identify a catalog model but report no token usage, the seeded session_model_usage skeleton still produces a zero-token breakdown, so this predicate succeeds and writes cost_usd=0.0, priced_with, and priced_at_ms. That contradicts the adjacent session_model_usage contract, which requires both a catalog match and billable > 0, and turns an unknown cost into a fabricated priced zero; include a positive billable-token check before populating these nullable columns.
Useful? React with 👍 / 👎.
# Conflicts: # .beads/issues.jsonl
…ss (#3461) ## Summary Fixes a live-verified defect in the FTS freshness ledger (`fts_freshness_state`): `messages_fts` reported `state=ready, missing_rows=0` while an independent count showed 12,659+ blocks were actually unindexed. `threads_fts`, read from the same table, correctly reported `stale` for its own (much smaller) gap. Two commits: the write-path fix, and a schema CHECK (index v52) that makes the specific contradiction unconstructible going forward, including a fast-forward hazard the CHECK itself introduces. ## Problem Live evidence (`sqlite3 "file:/realm/db/polylogue/index.db?mode=ro"`, read-only, never mutated): | surface | state | source_rows | indexed_rows | missing_rows | detail | | --- | --- | --- | --- | --- | --- | | `messages_fts` | ready | 4,970,352 | 4,957,693 | **0** | "targeted changed-session repair complete" | | `threads_fts` | stale | 15,411 | 15,401 | 10 | "exact invariant failed" | Independent count at the time: `messages_fts_docsize` rows = 4,957,693; blocks with non-empty `search_text` = 4,970,352 → real gap = 12,659. `source_rows - indexed_rows` in the ledger's own row already proves the contradiction (12,659), yet `missing_rows=0` and `state=ready`. **Root cause**: `daemon/convergence_stages.py`'s `_mark_message_fts_ready_after_targeted_repair` ran after every session-scoped FTS repair and called `message_fts_readiness_sync(conn, verify_total_rows=False)` — a cheap existence check ("does the FTS index have any row at all" AND "does any indexable block exist at all"), not a completeness check. That boolean is true for almost any non-empty, previously-populated archive. The function then wrote `state=ready, missing_rows=0` **unconditionally** over the ledger's single **global** `messages_fts` row, discarding whatever accurate `missing_rows` an earlier exact snapshot (`fts_invariant_snapshot_sync`) had recorded. A correct answer to a scoped question ("are the sessions I just touched indexed?") was being written into a global field ("is the whole archive's FTS index complete?"). This is a **new instance of a class**, distinct from the one PR #3429 already fixed. #3429 (tracked by `polylogue-8zzs`/`polylogue-oitx`, both still open for their own remaining scope — CLI presentation and the Prometheus/`fts_status.py` defaults) was a hard-coded `100.0` default standing in for a `NULL`/unmeasured coverage. This is a **correct measurement of the wrong (scoped, not global) population** being asserted as the global verdict. Reconciled, not duplicated: neither existing bead covers this write-path mechanism, so this PR files a new one (`polylogue-rlvj`) rather than overloading `polylogue-8zzs`/`polylogue-oitx`. ### Why `threads_fts` gets this right `threads_fts`'s freshness row is only ever written from `fts_invariant_snapshot_sync` (the exact, archive-wide anti-join query) — nothing writes a scoped/cheap approximation into it. `session_work_events_fts` and `threads_fts`'s targeted-debt repair path (`repair_fts_surface` -> `dangling_repair.repair_stale_fts_rows`) always repairs and recounts the **whole surface**, never a session subset, so there is no scoped-vs-global mismatch to launder in the first place. `messages_fts` is the only surface with a session-scoped repair path, and that path's "mark ready" step was the one place fabricating the global verdict. ### `session_work_events_fts` sibling check (independent, not trusted) Live read-only query, independent of the ledger: ``` session_work_events total: 27,034 session_work_events_fts distinct ids: 27,034 anti-join gap: 0 ``` Matches the ledger's self-report (`27,034/27,034 ready`) exactly — this surface is genuinely fine, for the structural reason above (no scoped write path exists for it to be laundered through). ### Cause of the ~12,659 missing blocks Origin breakdown of the currently-orphaned blocks (live, read-only, anti-join `blocks` against `messages_fts_docsize`): | origin | orphaned sessions | orphaned blocks | | --- | --- | --- | | `claude-code-session` | 125 | 29,895 | | `chatgpt-export` | 1 | 3,356 | | `claude-ai-export` | 21 | 202 | (Total is higher than the original 12,659 measurement because the archive keeps growing live while this was being investigated — this repo's own agent worktree sessions, including the one that produced this PR, are among the `claude-code-session` rows.) Two distinct contributors: 1. **Hot-session catch-up lag** (most of the `claude-code-session` count): the daemon's documented quiet-window deferral (`CLAUDE.md`'s "Hot-file quiet deferral") intentionally defers FTS sync for actively-appending sessions until they go quiet — expected, self-healing, not a defect. 2. **Genuine static-session drift** (`chatgpt-export` + `claude-ai-export`, 22 sessions / ~3,558 blocks): these are already-imported, non-appending historical exports with no reason to still be unindexed. This is exactly the drift class `fts_orphan_audit` (PR #3439, hourly sweep, anti-joins `blocks` against `messages_fts_docsize` and feeds session-scoped `convergence_debt`) exists to catch and self-heal via the existing, correct `check_sessions`/`execute_sessions` retry path — **once a daemon build containing it is running against this archive**. This PR does not change that repair mechanism and does not itself backfill the missing rows; it stops the ledger from lying about whether they're missing. **What a pending rebuild resolves vs. what this PR fixes**: the live archive is at index `user_version=46` while `master` is at v52 now (v47-v52 span several `SEMANTIC_REPARSE` bumps), so an operator-scheduled `polylogue ops reset --index && polylogued run` is pending independently of this PR. A full rebuild will re-populate `messages_fts` from scratch and trivially closes any then-current gap — but that is orthogonal to this defect: the rebuild does not fix the ledger-writing bug itself (a fresh rebuild would eventually accumulate the same fabricated-ready state the next time a targeted repair ran, until this code fix is deployed). Conversely, this code fix does not retroactively index the 12,659 currently-missing blocks — ordinary daemon convergence (the orphan audit + session-scoped repair, both pre-existing and unchanged by this PR) does that once a daemon build containing this fix (and, ideally, #3439) runs against the archive. ## Solution **Commit 1** (`ae9f09df7`, `daemon/convergence_stages.py` + its test): `_mark_message_fts_ready_after_targeted_repair` now always sources its row from `fts_invariant_snapshot_sync` — the same exact, archive-wide anti-join query `threads_fts`'s freshness row is exclusively derived from, and the same query the hourly `fts_orphan_audit` sweep already runs at that cadence, so its cost is an already-accepted class for this surface. Replaced the two existing tests that encoded the old (buggy) contract with versions asserting the real counts, and added `test_targeted_fts_ready_marker_stays_stale_for_an_untouched_gap` — seeds two sessions, deletes one's FTS row (simulating exactly the drift `fts_orphan_audit` finds), and proves the marker reports the gap honestly instead of laundering it into `ready` when only the other session was "repaired". **Commit 2** (`e1287c0a1`, schema + fast-forward executor + its test): index schema v52 (`CONSTRAINT_ONLY`, following the `v33`/`v36`/`v51` precedent) adds a table-level CHECK to `fts_freshness_state`: `state != 'ready' OR (missing_rows = 0 AND excess_rows = 0 AND duplicate_rows = 0 AND source_rows = indexed_rows)`. This makes the exact contradiction the live incident exhibited unrepresentable at the database layer, not just fixed at one call site. This CHECK is unlike every prior `CONSTRAINT_ONLY` delta in this codebase in one respect: it is **not guaranteed satisfied by pre-existing data**. Any archive that ran the now-fixed buggy code (which is to say: every archive, including the live one) already carries exactly the poisoned row this incident describes. A naive shared-column copy-forward (`_apply_replace_table`'s existing generic mechanism) would raise `sqlite3.IntegrityError` and abort the *entire* fast-forward for such archives — turning a constraint-only bump into an accidental forced rebuild. `index_fast_forward_executor.py` gains a small per-table sanitizer hook (`_REPLACE_TABLE_SANITIZERS`) that downgrades any such row to `stale` against the OLD (unconstrained) table before the copy runs — an honest "needs reconvergence" verdict, not data loss (counts are preserved; the daemon's ordinary convergence recomputes a real value on the next pass). **Commit 3** (`37106a89e`): beads bookkeeping for `polylogue-rlvj`. ## Verification - `devtools test tests/unit/daemon/test_convergence_stages.py -k "targeted_fts or fts_repair or archive_fts"` -> 12 passed - `devtools test tests/unit/storage/test_index_fast_forward_executor.py tests/unit/storage/test_index_fast_forward_lifecycle.py tests/unit/storage/test_schema_policy_contracts.py tests/unit/storage/test_archive_tiers_ddl.py` -> 61 passed - `devtools test tests/unit/daemon/test_fts_global_repair.py tests/unit/daemon/test_fts_identity_convergence.py tests/unit/daemon/test_fts_orphan_audit.py tests/unit/daemon/test_fts_readiness_fallback.py tests/unit/pipeline/test_ingest_batch_fts_repair.py tests/unit/storage/test_bulk_fts_prefix_reextract.py tests/unit/storage/test_dangling_fts_derived_surfaces.py tests/unit/storage/test_fts5_query_correctness.py tests/unit/storage/test_fts_bloat_invariants.py tests/unit/storage/test_fts_escape_in_insights.py tests/unit/storage/test_fts_identity_ledger.py tests/unit/storage/test_fts_repair_sql.py` -> 184 passed - `devtools lab policy schema-versioning` -> "Schema evolution policy intact." - `devtools verify --quick` -> `exit_code: 0` (18/18 steps, format/lint/mypy/render-all-check/layering/topology/manifests/schema-versioning/schema-promotion-audit all green) - **Anti-vacuity, code fix**: `test_targeted_fts_ready_marker_stays_stale_for_an_untouched_gap` fails against the pre-fix code path by construction (the old code always wrote `ready`/`missing_rows=0` regardless of the sibling session's real gap) -- the new test is the regression guard. - **Anti-vacuity, sanitizer**: manually renamed the `_REPLACE_TABLE_SANITIZERS` dict key so the sanitizer no longer matches `fts_freshness_state`, re-ran `test_replace_table_sanitizes_poisoned_fts_freshness_ready_row`, confirmed it fails with `sqlite3.IntegrityError: CHECK constraint failed: state != 'ready' ...` (the exact failure mode this hook prevents), then restored the fix and confirmed green. - Not run: full `devtools verify` (non-quick, testmon-affected pytest across the whole repo) -- the targeted `devtools test` invocations above cover every file this PR touches plus its immediate FTS/schema neighborhood; not re-run broader than that per the repo's stated verification-cadence rule. - Live archive: read-only only, per environment constraint -- never written to, no `polylogue ops reset` or daemon run triggered. Ref polylogue-rlvj. Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
…jtc, bvnz, 5vbs) Reconciliation pass driven by devtools lab probe bead-pr-reconciliation: verified each bead's own acceptance criteria against the actual diff/AC matrix of its referencing merged PR(s), not just the PR's self-description. Closed (AC fully satisfied): - polylogue-bvnz: PR #3504, all 5 AC items satisfied. - polylogue-5vbs: PR #3439, AC's detection/repair branch satisfied via new daemon/fts_orphan_audit.py sweep. Left open with progress notes (partial, residual scope named): - polylogue-layg.1: PR #3486 satisfies 6/8 AC items; scale fixture + coverage manifest update still missing. - polylogue-hjpx: PR #3485 confirms AC1-5 satisfied (mostly by pre-existing landed work whose ancestry the bead's own stale note had missed), but bd close refuses on open child polylogue-yla8 (the live closure-gate audit AC1-5 doesn't substitute for). - polylogue-6j9c, polylogue-9kjtc: PR #3511 satisfies 2/3 AC items each; live-archive reprice pass over existing session_profiles rows still outstanding for both. Ref polylogue-93xe Co-Authored-By: Claude <[email protected]>
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Fixes two of three "mechanism exists but doesn't run" bugs verified live tonight against the operator's archive:
session_profiles.cost_usd/cost_credits/priced_with/priced_at_mswere structurally 100% NULL (polylogue-f2qv.6), and there was no feeder for FTS-orphan drift introduced outside the write path (polylogue-5vbs). The third bug investigated (polylogue-m3p9, growingsessions.created_at_msNULLs) turned out to already be fixed by a same-day upstream commit; no additional code change was needed or made for it.Problem
polylogue-f2qv.6 — cost columns 100% NULL. Live census: all 23,318
session_profilesrows hadcost_usd/cost_credits/priced_with/priced_at_msNULL, despitesession_model_usage(the single per-model cost authority) carrying real catalog-pricedcost_usdfor 10,222 of 18,655 rows for the same sessions. Root cause:upsert_session_profile_costs(storage/sqlite/archive_tiers/write.py) is the only writer ever declared for these four columns and had zero production callers — grepped the whole repo to confirm. The value was never computed and dropped; it was simply never wired into session-profile materialization._SESSION_PROFILE_BASE_COLUMNS/session_profile_insert_values(the actual INSERT the materializer uses) never referenced these column names at all.polylogue-5vbs — FTS orphan feeder gap. The bead's design section named a real gap:
make_fts_stage's path-scopedcheck/check_manyare deliberate no-ops in archive/split-file mode (in-transaction writes already repair FTS with an abort-on-failure policy), but nothing fed the real, working session-scopedcheck_sessions/execute_sessionsretry primitives a subject for drift introduced outside the write path (external DB surgery, partial migration, a future writer bug). Live measurement before/after this investigation showed the orphan count swinging from the bead's own same-day 10,837 down to 0 under heavy concurrent multi-agent write load — a moving target, not proof the underlying gap was closed. Tracing found twosources/live/batch.pycall sites (added 2026-07-26, after the bead's original framing) that do feed session-scoped debt, but only for their own two deferred-FTS writes — nothing covers drift from any other source.polylogue-m3p9 — NULL created_at_ms growth. Live re-measurement matched the bead's own 5,382 figure exactly. Drilling into the 5,263
claude-code-sessionNULL rows (98.7% of the total): every sampled row (30 of 5,192 zero-message rows, plus all 71 non-empty-message rows) is either genuinely message-less or has zero timestamped messages. This is exactly the shape PR #3428 (commitab8a92c1a, merged the same day just before this investigation) already fixed: non-conversational records misclassified asclaude-code-session. The storage-tier derive-from-messages fallback (write.py::_derive_session_timestamps_from_messages) is correct and already landed via a prior PR; it honors its own documented "genuinely undatable stays NULL" contract. The one residual gap (sources/live/append_ingest.pyskippingclassify_artifact) is already tracked aspolylogue-xwkhand issources/-scoped, outside this PR's allowed area.Solution
Cost columns (
polylogue/archive/session/models.py,documents.py,runtime.py,storage/insights/session/{records,profiles,storage}.py): extended the real materialization pipeline rather than routing through the disconnectedupsert_session_profile_costshelper (which a DELETE-then-INSERT full profile replace would immediately clobber on the next rebuild).SessionProfilegains nullablecost_usd/cost_credits/priced_withfields, computed inbuild_session_profilefrom the samecost_summaryalready used fortotal_cost_usd/total_credit_cost, gated on the model actually being in thePRICINGcatalog (mirrorssession_model_usage's "no fabrication" contract — NULL when nothing was catalog-priced, not a fake $0.00).SessionProfileRecordgains the same fields pluspriced_at_ms(derived from the record's ownmaterialized_at).upsert_session_profile_costsis left in place — four test files use it as a seeding helper for unrelated read-path tests; it's harmless dead weight, not part of this fix.FTS orphan feeder (
polylogue/daemon/fts_orphan_audit.py, new module): a bounded, hourly sweep —find_orphaned_fts_sessions_syncanti-joinsblocks(via the existingidx_blocks_search_text_populatedpartial index) againstmessages_fts_docsizeto find sessions with a block missing its FTS row, andrun_fts_orphan_audit_once_syncrecords that as retryablestage="fts", subject_type="session_id"convergence debt. Wired intodaemon/cli.py's periodic-loop family asperiodic_fts_orphan_audit, following the existingperiodic_fts_identity_drift_recomputeshape (a standalone asyncio loop, not a newConvergenceStage—convergence_stages.py's own 1498-cascade retro verdict is "refactor before adding a fourth stage").Verification
The one pre-existing failure (
test_archive_tiers_api_raw_artifacts_read_source_tier, a clock-hygiene gap wherefrozen_clockdoesn't patch aparsed_attimestamp) reproduces identically viagit stashon the base commit — unrelated to this change, not touched.New tests exercise the real production pipeline, not toy replicas:
write_parsed_session_to_archive+rebuild_session_insights_sync(the real ingest→materialize path). A catalog-priced model populates all four columns withcost_usd == total_cost_usd(same source computation); an unrecognized model leaves all four NULL;priced_at_msadvances on a later rebuild.messages_ftsrow directly (simulating drift outside the write path), proves the audit finds and records debt for it, then proves the already-existingmake_fts_stage.check_sessions/execute_sessionsgenuinely repairs it — anti-vacuity closing the loop end to end, not just recording debt nothing drains.Not done here
storage/sqlite/archive_tiers/archive.py's_session_cost_insight_from_archive_rowstill checkscost_provenance == "exact", a literal stringSessionCostSummarynever actually produces ("provider_reported"/"mixed"instead) — a separate read-path bug in a file outside this PR's allowed area, now unblocked (cost_usd is no longer structurally NULL) but not fixed here.Ref polylogue-f2qv.6, polylogue-5vbs, polylogue-m3p9
Co-Authored-By: Claude [email protected]