fix: preserve request cost history and recover quota pricing surfaces - #40
Merged
Mars-Sea merged 3 commits intoSep 14, 2026
Merged
Conversation
Follow-up to the review of the previous two commits: no behaviour changes, so the 486-test suite and the generated bundle are unchanged in substance. - Record the ONE real gap in the durable cost facts: the fold implements the 0.1.5 token-meter replacement rule (`llm/retry-started` closes the slot, so a retried attempt adds), while the 0.1.2/0.1.3-era fold replaced on `(turn, step)` alone and never handled that event. On those engines the two folds disagree by the retried attempt's tokens, and the client's per-bucket equality gate against `tokenUsage` then hides the readout instead of showing a wrong figure. Retries are routine on this route and both versions are declared compatible, so it is a live gap rather than a theoretical one. The note also says why the equality gate must NOT be loosened to work around it. - Record why the settings usage card reads availability from the Host report: a composition literal is a stripped secret and the CLI auth file is not in the credentials store, so both are invisible to the browser while the Host serves requests with them. `state.anyAccountConfigured` must not gate that card or the post-save refresh, and `shouldRefresh` stays `idle`-only so a failed fetch cannot become an automatic request loop. - `requestRates()`: document that a tiered row returns its band and does not then apply `peak` (the page publishes the two dimensions independently and no row carries both today), and that the band `find` is order-dependent on purpose because both the generator and the wire parser reject non-ascending bounds or a bounded last band. - Fix two stale claims this work left behind: the controller JSDoc was attached to `PriceRetryTimer` and still called the cache "one-shot" (it now has a bounded 1/2/4 s retry budget and a rebind reload), and `ensure()` claimed the composer mounting was a trigger when its only callers are the namespace landing and a manual refresh. Same for the two AGENTS.md one-liners, plus the module/test entries the layout block was missing. - Note that `isPeakHour()` in `src/client/session-cost.ts` is a dead third copy of the weekday rule (only its own test calls it; it is DCE'd out of the bundle) so the next reader deletes it rather than re-wiring it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the six review findings in #38. This PR targets
feat/pr36-panel-and-session-cost, so its diff contains only the repairs; merge it into #38 before merging that feature into main.Session costs previously applied the latest model and the viewing time to all cumulative tokens. A durable Host projection now retains each request's model, attempt timestamp and prompt context band, replaying both v1 usage samples and v2 message/attempt settlements. Samples replace within an attempt, retries add, and equivalent billing groups remain compact. The client verifies that cost facts and token totals describe the same history before displaying an estimate.
Validation: 486 tests passed,
npm run typecheck,npm run build,npm pack --dry-run,git diff --check, and livenode scripts/sync-model-prices.mjs --check(68 rows match). Regression coverage includes real projection-registry history restoration/checkpoint views, v1/v2 retry semantics, model/time changes, context boundaries, credit presence, unknown/zero subtotal suppression, settings-card Host availability, bilingual command ratios and bounded price retries.The estimate uses the installed published-rate snapshot; it is not a provider invoice. Live browser/Host interaction and invoice reconciliation were not performed. No dependency metadata changes or release publication.