Repository navigation
fix(insights): absent cost evidence is an estimate, not a known zero - #4368
Conversation
A profile row without a materialized cost_is_estimated column defaulted the flag to false while defaulting provenance to "unknown", so a session reported provenance unknown and cost not estimated at the same time -- that reads as "known to have cost $0.00". Only a provider-reported figure makes a cost known. A subscription session is priced as an API equivalent and is therefore always an estimate, so the flag now derives from provenance when the column is absent, and a materialized value still outranks that fallback. The portfolio and postmortem snapshots also drop their 100/91 token counts. The corpus behind them holds 24 messages, none carrying tokens and none carrying a model name, so those figures described data that is no longer in the fixture; zero is the honest count for it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_014BQsaB1NBY8mTR6yZByfMA
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 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: 4047123bab
ℹ️ 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".
…4368) ## Summary A profile whose cost evidence is absent now reports an estimate rather than a known zero. ## Problem `_row_to_session_profile_record` read `cost_is_estimated` from a row where that column does not exist and defaulted it to `false`, while defaulting `cost_provenance` to `"unknown"` in the same constructor. A profile therefore asserted *provenance unknown* and *cost not estimated* at once, which renders as "known to have cost $0.00". Only a provider-reported figure makes a cost known. A subscription session is priced as an API equivalent and is always an estimate. ## Solution The flag derives from provenance when the column is absent; a materialized value still outranks that fallback, so a writer's recorded value is never discarded. The portfolio and postmortem snapshots also drop their 100/91 token counts. The corpus behind them holds 24 messages, none carrying tokens and none carrying a model name, and `session_model_usage` is empty — those figures described data that is no longer in the fixture. Zero is the honest count for it, and `cost_is_estimated` returns to `true` in the same snapshots, which is what separates the stale half of this diff from the defect. ## Verification devtools test tests/unit/storage/test_profile_cost_confidence.py -> 2 passed devtools verify --quick -> exit 0 Mutation-checked: replacing the provenance fallback with a bare `False` makes the new test red. ## Residual risk This corrects how absent evidence is *reported*. It does not add the missing evidence: `polylogue-teyyg` covers cost catalogs that do not know the models currently in use. Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
…es (#4399) ## Summary Repair four red families across the `cli` and `sources` selections: browser-capture synthetic-ID normalization, Hermes named-SQLite admission, Codex unknown response-item preservation, and `MessageQueryRowPayload` repo parity. Regenerated declarations ship with them. ## Problem `legacy_browser_capture_native_id`, its `_UUID_PATTERN`, its `__all__` entry, and its call site were deleted by #4337 — a two-lane batch assembly about contract JSON and deployment smoke coverage, unrelated to browser capture — while all six of its contract tests were left in place. That is what turned them red (`git show 97cddc4 -- polylogue/browser_capture/identity.py`). The other three were independent gaps: an uncheckpointed Hermes WAL row lost at acquisition, a Codex unclassified response item double-counted by the conservation boundary because it declared no `wire_type`, and `repo` populated on the substrate row but dropped at the surface because `_from_row_generic` copies by field name only. ## Solution Restore the deleted normalization (byte-identical to the deleted body, minus a redundant wrapper); hoist `hermes_owned_sqlite_name` above the recognizer guard for `source_only` acquisition; carry the raw provider token on the unclassified Codex event via `_record_type`, a structural `record.get("type")` read with no inference; declare `repo` on `MessageQueryRowPayload`. ## Verification Each fix was reverted in isolation and the covering test run: - browser-capture: 6 failed, 44 passed - Hermes: 2 failed, 141 passed - Codex: 1 failed, with `assert ['codex_unclassified_response_item'] == [...]` naming the mechanism - repo parity: `test_generic_row_declarations_have_explicit_field_parity[MessageQueryRowPayload]` failed, 20 passed `devtools verify --quick` → exit 0, all 18 gates. `devtools render all --check` → exit 0, no `out of sync`. `devtools test tests/unit/sources tests/unit/surfaces` → 2734 passed, 0 failed. ## Residual risk `native_id` derivation for browser captures reverts to the pre-#4337 rule, which collapses `chatgpt:<uuid>:<hash>` to `<uuid>`. That collapse is deliberate convergence from #2345 — the extension minted a fresh synthetic ID per capture, fragmenting one conversation into many sessions. Blast radius on real data is zero: `/realm/state/polylogue/source.db` was last written 2026-08-16, before the regression window opened on 2026-08-27, so no capture was ingested un-normalized and nothing is re-identified on reindex. Normalization happens at parse, not in storage, so replay re-derives the same ID from the same blob. The Hermes exemption is scoped to `source_only` acquisition of two filenames and does not relax parser admission; the recognizer still gates `source_parsing.parse_one_source_path`. Consequence: a named Hermes SQLite whose schema the recognizer cannot classify is now acquired as a Hermes raw and may later fail parse with a typed refusal. The comment at `polylogue/sources/live/batch.py:1972-1975` ("Only the OriginSpec recognizer may admit a candidate") now sits above a guard carrying an exemption; filed separately rather than edited here. Pre-existing and not introduced: the 3-colon-part branch at `identity.py:27-29` returns `parts[1]` for any `provider:X:Y` where `X` has no `/`, without requiring `X` to look like a UUID. Shipped since #2345. The bead stays open. Its "35 red / 25 remaining" figures are stale — the five families it names as still red are green on current master (#4371, #4368, #4375, and the CLI pair), so the remainder must be re-enumerated rather than restated.
…4368) ## Summary A profile whose cost evidence is absent now reports an estimate rather than a known zero. ## Problem `_row_to_session_profile_record` read `cost_is_estimated` from a row where that column does not exist and defaulted it to `false`, while defaulting `cost_provenance` to `"unknown"` in the same constructor. A profile therefore asserted *provenance unknown* and *cost not estimated* at once, which renders as "known to have cost $0.00". Only a provider-reported figure makes a cost known. A subscription session is priced as an API equivalent and is always an estimate. ## Solution The flag derives from provenance when the column is absent; a materialized value still outranks that fallback, so a writer's recorded value is never discarded. The portfolio and postmortem snapshots also drop their 100/91 token counts. The corpus behind them holds 24 messages, none carrying tokens and none carrying a model name, and `session_model_usage` is empty — those figures described data that is no longer in the fixture. Zero is the honest count for it, and `cost_is_estimated` returns to `true` in the same snapshots, which is what separates the stale half of this diff from the defect. ## Verification devtools test tests/unit/storage/test_profile_cost_confidence.py -> 2 passed devtools verify --quick -> exit 0 Mutation-checked: replacing the provenance fallback with a bare `False` makes the new test red. ## Residual risk This corrects how absent evidence is *reported*. It does not add the missing evidence: `polylogue-teyyg` covers cost catalogs that do not know the models currently in use. Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
…es (#4399) ## Summary Repair four red families across the `cli` and `sources` selections: browser-capture synthetic-ID normalization, Hermes named-SQLite admission, Codex unknown response-item preservation, and `MessageQueryRowPayload` repo parity. Regenerated declarations ship with them. ## Problem `legacy_browser_capture_native_id`, its `_UUID_PATTERN`, its `__all__` entry, and its call site were deleted by #4337 — a two-lane batch assembly about contract JSON and deployment smoke coverage, unrelated to browser capture — while all six of its contract tests were left in place. That is what turned them red (`git show 97cddc4 -- polylogue/browser_capture/identity.py`). The other three were independent gaps: an uncheckpointed Hermes WAL row lost at acquisition, a Codex unclassified response item double-counted by the conservation boundary because it declared no `wire_type`, and `repo` populated on the substrate row but dropped at the surface because `_from_row_generic` copies by field name only. ## Solution Restore the deleted normalization (byte-identical to the deleted body, minus a redundant wrapper); hoist `hermes_owned_sqlite_name` above the recognizer guard for `source_only` acquisition; carry the raw provider token on the unclassified Codex event via `_record_type`, a structural `record.get("type")` read with no inference; declare `repo` on `MessageQueryRowPayload`. ## Verification Each fix was reverted in isolation and the covering test run: - browser-capture: 6 failed, 44 passed - Hermes: 2 failed, 141 passed - Codex: 1 failed, with `assert ['codex_unclassified_response_item'] == [...]` naming the mechanism - repo parity: `test_generic_row_declarations_have_explicit_field_parity[MessageQueryRowPayload]` failed, 20 passed `devtools verify --quick` → exit 0, all 18 gates. `devtools render all --check` → exit 0, no `out of sync`. `devtools test tests/unit/sources tests/unit/surfaces` → 2734 passed, 0 failed. ## Residual risk `native_id` derivation for browser captures reverts to the pre-#4337 rule, which collapses `chatgpt:<uuid>:<hash>` to `<uuid>`. That collapse is deliberate convergence from #2345 — the extension minted a fresh synthetic ID per capture, fragmenting one conversation into many sessions. Blast radius on real data is zero: `/realm/state/polylogue/source.db` was last written 2026-08-16, before the regression window opened on 2026-08-27, so no capture was ingested un-normalized and nothing is re-identified on reindex. Normalization happens at parse, not in storage, so replay re-derives the same ID from the same blob. The Hermes exemption is scoped to `source_only` acquisition of two filenames and does not relax parser admission; the recognizer still gates `source_parsing.parse_one_source_path`. Consequence: a named Hermes SQLite whose schema the recognizer cannot classify is now acquired as a Hermes raw and may later fail parse with a typed refusal. The comment at `polylogue/sources/live/batch.py:1972-1975` ("Only the OriginSpec recognizer may admit a candidate") now sits above a guard carrying an exemption; filed separately rather than edited here. Pre-existing and not introduced: the 3-colon-part branch at `identity.py:27-29` returns `parts[1]` for any `provider:X:Y` where `X` has no `/`, without requiring `X` to look like a UUID. Shipped since #2345. The bead stays open. Its "35 red / 25 remaining" figures are stale — the five families it names as still red are green on current master (#4371, #4368, #4375, and the CLI pair), so the remainder must be re-enumerated rather than restated.
|
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
A profile whose cost evidence is absent now reports an estimate rather than a
known zero.
Problem
_row_to_session_profile_recordreadcost_is_estimatedfrom a row where thatcolumn does not exist and defaulted it to
false, while defaultingcost_provenanceto"unknown"in the same constructor. A profile thereforeasserted provenance unknown and cost not estimated at once, which renders as
"known to have cost $0.00".
Only a provider-reported figure makes a cost known. A subscription session is
priced as an API equivalent and is always an estimate.
Solution
The flag derives from provenance when the column is absent; a materialized value
still outranks that fallback, so a writer's recorded value is never discarded.
The portfolio and postmortem snapshots also drop their 100/91 token counts. The
corpus behind them holds 24 messages, none carrying tokens and none carrying a
model name, and
session_model_usageis empty — those figures described datathat is no longer in the fixture. Zero is the honest count for it, and
cost_is_estimatedreturns totruein the same snapshots, which is whatseparates the stale half of this diff from the defect.
Verification
Mutation-checked: replacing the provenance fallback with a bare
Falsemakesthe new test red.
Residual risk
This corrects how absent evidence is reported. It does not add the missing
evidence:
polylogue-teyygcovers cost catalogs that do not know the modelscurrently in use.