Repository navigation
fix(storage): drop price_catalogs and session_model_usage pricing FK columns - #3696
Conversation
…columns Problem: polylogue-v2mg kept price_catalogs while dropping model_prices and session_reported_costs as zero-consumer tables, on the stated justification that "session_model_usage.priced_with FK, active_price_catalog_id" are genuine reads. A 2026-07-31 shipped-but-dead audit (polylogue-resk) measured that justification false in all three named particulars: priced_with and priced_at_ms had zero production SELECTs (every reference was an INSERT/UPDATE in write.py, the DDL FK line, or prose -- the only SELECTs were in tests/unit/storage/test_pricing_chain_roundtrip.py), and active_price_catalog_id's only non-test caller was pricing_seed.py itself (a seeded-already check, not a genuine read). Live data confirmed the column carried no information (18,655 session_model_usage rows, 10,222 with priced_with set, exactly 1 distinct value). Re-verified against current source before acting; all three particulars still held. Solution: index.db is a rebuildable derived tier, so this drops price_catalogs via the index-tier same-version benign-DDL registry (index_convergence.py, same mechanism v2mg used for model_prices/session_reported_costs) and drops session_model_usage.priced_with/priced_at_ms plus the FK and the CHECK half that referenced priced_with via a new INDEX_SCHEMA_VERSION v61 CONSTRAINT_ONLY delta (lifecycle.py), a dead-column-removal REPLACE_TABLE copy-forward in the same shape as v33/v36/v38/v41/v44. pricing_seed.py (seed_price_catalog, active_price_catalog_id) is deleted along with its bootstrap.py/write.py call sites. write.py's _price_provider_usage_tokens/_upsert_provider_usage_model_ rollup/_increment_provider_usage_model_rollup/_aggregate_message_tokens_into_ model_usage no longer compute or write priced_with/priced_at_ms. While investigating, found the audit's "session_profiles.priced_with/ priced_at_ms are write-only too" side-note does not hold: those are a DIFFERENT, unrelated pair of columns (no FK to price_catalogs, sourced from cost_compute.py's _PRICE_SNAPSHOT_VERSION, not pricing_seed.py) with a real production reader -- daemon/http.py's _profile_panel_payload serves them in the session-insights HTTP reader panel via hydrate_session_profile. Those are left untouched; this is documented at the session_model_usage DDL and in the benign-DDL registry entry so a future audit does not re-conflate the two. Verification: - devtools lab policy schema-versioning -> "Schema evolution policy intact." - devtools test tests/unit/storage/test_index_fast_forward_executor.py tests/unit/storage/test_index_fast_forward_lifecycle.py -> 23 passed, including a new test_v61_replace_table_drops_pricing_columns_and_keeps_the_rest that builds a pre-v61-shaped session_model_usage table (FK + wider CHECK), seeds a 'priced' row, runs the real REPLACE_TABLE executor, and asserts priced_with/priced_at_ms are gone while token/cost/provenance data survive. - devtools test across the affected surface (archive_tiers write/ddl, pricing roundtrip, origin usage report, cost reconciliation probe, schema upgrade lane, cli insights, api facade contracts, cost rollup summary, session profile cost columns, claim vs evidence) -> 527 passed, 5 failed; all 5 failures reproduce identically on a clean stash of this diff (4 in test_insights.py: timestamp/phases assertions; 1 in test_facade_contracts.py: test_no_undiscovered_async_methods, an unrelated get_setting/list_settings/ set_setting contract gap) -- pre-existing, not selected by this change. - devtools verify --quick -> exit 0 (format, lint, mypy --strict, render all --check all clean). Ref polylogue-resk
Removes TestPriceCatalogSeed (price_catalogs no longer exists) and every priced_with/priced_at_ms assertion or fixture INSERT against session_model_usage from test_pricing_chain_roundtrip.py, test_origin_usage_report.py, test_cost_reconciliation_probe.py, test_insights.py, and test_archive_tiers_write.py. Adds test_v61_replace_table_drops_pricing_columns_and_keeps_the_rest and test_v61_pricing_column_drop_is_a_clone_safe_constraint_copy_forward to cover the new v61 fast-forward delta, and updates test_archive_tiers_ddl.py's cost-table assertion to expect price_catalogs absent from a fresh archive (mirroring the existing model_prices/ session_reported_costs assertions). Ref polylogue-resk
The committed docs/examples/demo-tour/ evidence encodes a manifest hash derived from the live archive schema; dropping price_catalogs and the session_model_usage pricing columns (polylogue-resk) changed it. Regenerated via polylogue.demo.tour.run_demo_tour and copied the two files devtools lab policy demo-tour-freshness flagged as masked-different (command-output/01-claim-versus-receipt.txt, transcript.txt) back into docs/examples/demo-tour/. report.json/report.md only differed in the wall-clock duration fields the freshness check already masks, so those were left as committed. Ref polylogue-resk
|
Warning Review limit reached
Next review available in: 1 minute You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. 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 (19)
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 |
Summary
Drops
price_catalogs(a whole table) andsession_model_usage.priced_with/priced_at_ms(plus the FK and CHECK-half that referenced them) as dead weight:polylogue-v2mgkeptprice_catalogsalive on a justification that a 2026-07-31 shipped-but-dead audit measured false in all three named particulars, and this PR re-verified those particulars against current source before acting and removed the dead code, not just the label.Problem
polylogue-v2mg(closed) droppedmodel_pricesandsession_reported_costsas zero-consumer tables but keptprice_catalogs, with this justification quoted verbatim inindex_convergence.py:polylogue-reskmeasured all three particulars false:session_model_usage.priced_with— zero productionSELECTs. Every non-test reference was an INSERT/UPDATE/NULL-clear inwrite.pyor the DDL FK line.session_model_usage.priced_at_ms— same shape, write-only.active_price_catalog_id— its only non-test caller waspricing_seed.pyitself (a seeded-already check, not a genuine read).Live data: of 18,655
session_model_usagerows, 10,222 hadpriced_withset with exactly 1 distinct value. Actual pricing resolution goes through the in-processpolylogue.archive.semantic.pricing.PRICINGdict — the same defectv2mgwas closing formodel_prices.I re-verified all three particulars against current source (not just trusting the bead) before acting; nothing had drifted true since the finding.
One correction to the audit itself: its side-note that "
session_profiles.priced_with/priced_at_msare write-only too" does not hold. Those are a different, unrelated pair of columns — no FK toprice_catalogs, sourced fromcost_compute.py's_PRICE_SNAPSHOT_VERSIONrather thanpricing_seed.py— with a real production reader:daemon/http.py's_profile_panel_payloadserves them in the session-insights HTTP reader panel viahydrate_session_profile. Those columns are left untouched; this PR documents the distinction at thesession_model_usageDDL comment and in the benign-DDL registry entry so a future audit doesn't re-conflate the two.Solution
index.dbis the rebuildable derived tier, so this uses the two mechanisms the repo already has for derived-tier changes:price_catalogsdrops via the index-tier same-version benign-DDL registry (index_convergence.py), the same mechanismv2mgused formodel_prices/session_reported_costs— a whole-tableDROP TABLE IF EXISTS, idempotent, no version bump needed.session_model_usage.priced_with/priced_at_msand the CHECK half that referencedpriced_withdrop via a newINDEX_SCHEMA_VERSIONv61,CONSTRAINT_ONLYdelta (lifecycle.py) using theREPLACE_TABLEfast-forward operation — a dead-column-removal copy-forward in the same shape as the existing v33/v36/v38/v41/v44 precedents (existing rows copy-forward on every surviving column, no raw reparse).pricing_seed.py(seed_price_catalog,active_price_catalog_id) is deleted along with itsbootstrap.py/write.pycall sites.write.py's_price_provider_usage_tokens/_upsert_provider_usage_model_rollup/_increment_provider_usage_model_rollup/_aggregate_message_tokens_into_model_usageno longer compute or writepriced_with/priced_at_ms.docs/plans/layering.yaml's writer-module inventory drops the now-deletedpricing_seed.pyentry;docs/schema.mdno longer listsprice_catalogsamong the cost tables.Test changes remove
TestPriceCatalogSeedand everypriced_with/priced_at_msfixture/assertion againstsession_model_usage(tests againstsession_profiles, a different table, are untouched), and add two new tests exercising the v61 fast-forward specifically: a declaration-shape test and a genuine data round-trip test that builds a pre-v61-shapedsession_model_usagetable (FK + wider CHECK), seeds a'priced'row, runs the realREPLACE_TABLEexecutor, and assertspriced_with/priced_at_msare gone while token/cost/provenance data survive.The committed
docs/examples/demo-tour/evidence encodes a manifest hash derived from the live archive schema, so it drifted with this change; regenerated viapolylogue.demo.tour.run_demo_tourand copied back the two filesdevtools lab policy demo-tour-freshnessflagged.Verification
devtools lab policy schema-versioning→Schema evolution policy intact.devtools test tests/unit/storage/test_index_fast_forward_executor.py tests/unit/storage/test_index_fast_forward_lifecycle.py→23 passed, including the newtest_v61_replace_table_drops_pricing_columns_and_keeps_the_rest.devtools testacross the full affected surface (archive_tiers write/ddl, pricing roundtrip, origin usage report, cost reconciliation probe, schema upgrade lane, cli insights, api facade contracts, cost rollup summary, session profile cost columns, claim vs evidence) →527 passed, 5 failed; all 5 failures reproduce identically on a cleangit stashof this diff (4 intest_insights.py: pre-existing timestamp/phases assertions; 1 intest_facade_contracts.py::test_no_undiscovered_async_methods, an unrelatedget_setting/list_settings/set_settingcontract gap) — confirmed pre-existing, not caused by this change.devtools lab policy demo-tour-freshness→fresh tour output matches committed docs/examples/demo-tour/ (masked).devtools verify --quick→exit_code: 0(format, lint,mypy --strict,render all --checkall clean).Ref polylogue-resk