Skip to content

feat: split provider and catalog model costs - #4493

Merged
Sinity merged 2 commits into
masterfrom
feature/packet/polylogue-4jcof
Aug 31, 2026
Merged

Sinity merged 2 commits into
masterfrom
feature/packet/polylogue-4jcof

Conversation

@Sinity

@Sinity Sinity commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Summary

Keep provider-reported and catalog-computed model costs in separate columns and restore summed precedence on archive cost rollups.

Problem

The split-cost migration had changed two cohort queries to select one provider row instead of summing the cohort, reporting 5.0 for three 5.0 sessions instead of 15.0.

Solution

Use SUM(provider_cost_usd) before SUM(catalog_cost_usd) on both cost-rollup surfaces and related archive readers. Keep catalog pricing and provider pass-through writes nominally separate, remove stale retired-column consumers, and add a three-session regression asserting 15.0 on both rollups. Rebased onto origin/master with the cost change at schema version 80 and its semantic-reparse declaration.

Verification

  • .venv/bin/python -m devtools test tests/unit/demo/test_demo_seed_verify.py tests/unit/storage/test_archive_tiers_write.py::test_read_archive_session_page_composes_bounded_sql_work_regardless_of_session_size tests/unit/storage/test_archive_tiers_write.py::test_read_archive_session_page_matches_full_composition_windows tests/unit/storage/test_archive_tiers_archive.py::test_archive_tiers_archive_facade_repairs_missing_fts_on_identical_repeat tests/unit/storage/test_archive_tiers_archive.py::test_pinned_read_only_store_blocks_all_archive_tier_mutations tests/unit/storage/test_session_insight_refresh.py::test_full_rebuild_restores_thread_spine_membership_and_markers: 21 passed.
  • .venv/bin/python -m devtools test tests/unit/storage/test_cost_queries.py tests/unit/storage/test_pricing_chain_roundtrip.py: 18 passed.
  • .venv/bin/python -m devtools verify --quick: all checks passed, including mypy, schema versioning, layering, and privacy registry.

Residual risk

Full corpus verification was not run. Existing index generations need the declared semantic reparse before old cost rows are replaced; public compatibility payloads retain their cost_usd and cost_provenance field names.

@Sinity
Sinity enabled auto-merge (squash) August 31, 2026 19:22
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 31, 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-08-31T19:34:54.651319Z 99f607d 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.

@coderabbitai

coderabbitai Bot commented Aug 31, 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a8da49a8-c383-46f8-b9fa-c97f270b8266


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 7440d08 into master Aug 31, 2026
2 of 3 checks passed
@Sinity
Sinity deleted the feature/packet/polylogue-4jcof branch August 31, 2026 19:23

@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: 99f607da5e

ℹ️ 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/storage/usage.py Resolved
Sinity added a commit that referenced this pull request Sep 1, 2026
## Summary

Keep provider-reported and catalog-computed model costs in separate
columns and restore summed precedence on archive cost rollups.

## Problem

The split-cost migration had changed two cohort queries to select one
provider row instead of summing the cohort, reporting 5.0 for three 5.0
sessions instead of 15.0.

## Solution

Use `SUM(provider_cost_usd)` before `SUM(catalog_cost_usd)` on both
cost-rollup surfaces and related archive readers. Keep catalog pricing
and provider pass-through writes nominally separate, remove stale
retired-column consumers, and add a three-session regression asserting
15.0 on both rollups. Rebased onto `origin/master` with the cost change
at schema version 80 and its semantic-reparse declaration.

## Verification

- `.venv/bin/python -m devtools test
tests/unit/demo/test_demo_seed_verify.py
tests/unit/storage/test_archive_tiers_write.py::test_read_archive_session_page_composes_bounded_sql_work_regardless_of_session_size
tests/unit/storage/test_archive_tiers_write.py::test_read_archive_session_page_matches_full_composition_windows
tests/unit/storage/test_archive_tiers_archive.py::test_archive_tiers_archive_facade_repairs_missing_fts_on_identical_repeat
tests/unit/storage/test_archive_tiers_archive.py::test_pinned_read_only_store_blocks_all_archive_tier_mutations
tests/unit/storage/test_session_insight_refresh.py::test_full_rebuild_restores_thread_spine_membership_and_markers`:
21 passed.
- `.venv/bin/python -m devtools test
tests/unit/storage/test_cost_queries.py
tests/unit/storage/test_pricing_chain_roundtrip.py`: 18 passed.
- `.venv/bin/python -m devtools verify --quick`: all checks passed,
including mypy, schema versioning, layering, and privacy registry.

## Residual risk

Full corpus verification was not run. Existing index generations need
the declared semantic reparse before old cost rows are replaced; public
compatibility payloads retain their `cost_usd` and `cost_provenance`
field names.
Sinity added a commit that referenced this pull request Sep 3, 2026
The upward walk that resolves a session's repository stopped at nothing,
so with the managed temp trees inside the checkout every scratch path
resolved to the checkout itself. The walk now stops before a listed
ceiling, as git does, and the ceiling is part of the normalization
cache key.

Tests: tool results without structural evidence are admitted as unknown
with not_reported (#4539) and the writer refusal is exercised on a block
with no evidence at all; block payloads carry tool_outcome (#4502); a
provider-reported cost rolls up as "exact" (#4493); the v61 replace-table
keeps the surviving canonical columns; the bulk-delete canaries and the
naive-join survivor use TEMP objects on the opened connection so the
schema manifest check at open no longer refuses them (#4472, #4594).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz
@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 0914f89):

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

@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 76.F007 / P1: fixed-already at the checked revision: Writing a provider session total assigns its shares to selected model rows and clears provider_cost_usd on every other model row, so an append model switch cannot retain the previous total beside the new one. See polylogue/storage/sqlite/archive_tiers/write.py:212.
  • 76.F083 / P1: fixed-already at the checked revision: The origin-reported pricing lane selects provider_cost_usd ahead of catalog_cost_usd for stored dollars, preserving a provider charge distinct from its catalog estimate. See polylogue/storage/usage.py:2083.

Only the rows listed above are dispositioned. Held findings remain open.

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