Conversation
…s Portal spend row
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
|
Reviewed by Codex gpt-6-luna (xhigh); verified and validated by Claude Thermo-nuclear review of #682 (Nous OpenCodex ledger):
No other findings. Routing, unreported rows, requestId session fallback, ignored |
|
Follow-up: both findings are fixed and pushed. Nothing left open. |
Lane B review: fixes at 1539d22I reviewed the full diff against Fixes (
Tests
The new tests catch regressions. As a mutation check, I made temporary changes in two batches. I backed up the files first and restored them afterwards; their sha256 matched before the commit.
Documented differences from upstream
Validation (Windows, toolchain 1.98.0)
UI proof: the Nous Portal row in Settings > Usage & Spend follows in a separate "UI proof (browser-use)" comment. |
UI proof (browser-use)At the maintainer's direction, I drove the app's WebView2 over CDP with the browser-use CLI Result: PASS (A0 to A6). The Usage & Spend tab shows the totals this branch computes, cent for Build
Fixture
Each fix in this branch changes the two-decimal totals if it regresses. The last column shows how
Nous Portal should show $6.14412 over 7 days and $6.203178 over 30 days. Tokens (input + output + Results
Not covered: the tray and float bar (native, so browser-use doesn't reach them, per the Note on A5 and A6. The table didn't update after the checkbox changed: it kept the previous CommandsScreenshotsThese are local to the proof machine, under
|
…route, unpriced instead of zero (stacked on #682)
|
Adversarial validation passed at cd41f8540fd0e53a7a4c9fbc1e0d1f75f2b1a9da Scope: attribute Nous OpenCodex ledger rows to Nous Portal spend (#682, upstream 0.68.0), validated as merged into release/v0.70.0 (merge cd41f85 = merge of 1539d22 into bf1e636). Attacks (highest-risk semantics, from the merged tree):
No defects found. READY for the un-draft rule. |
Summary
With OpenCodex import on, Usage & Spend now attributes OpenCodex ledger rows from
~/.opencodex/usage.jsonl(or$OPENCODEX_HOME/usage.jsonl) to the Nous Portal row when theirproviderisnous. This holds even when the model id names another vendor. The row's sourcelabel is "OpenCodex".
Pricing
A Nous row is priced in this order:
nous/<model>, or the bare<model>key.nous, model id kept whole, for exampleanthropic/claude-sonnet-4.6).Model prefixes never pull in another vendor's rates. A row without a price stays unpriced and
keeps its tokens.
A row is priced only when it reports both input and output tokens.
A consumed cache lane needs its own rate:
unpriced.
cache_writerate.Catalog lookups match exactly. A dated or versioned alias doesn't borrow the base entry.
A repeated
nous/prefix (modelnous/z-ai/glm-5) is stripped before the lookup.Legacy OpenAI-transport rows (
provider: "openai", modelnous/<id>) are routed to Nous butpriced only by a custom key.
Native Codex sessions never reach the Nous catalog.
Ledger rows
usageStatus: "unreported"rows keep their tokens and no dollars._meta.*fields and theconversationIDspelling are ignored. A row withoutconversationIdcounts as its own session, falling back torequestId.reproduces upstream's fixture costs.
Upstream reference
v0.68.0, all underSources/CodexBarCore/Vendored/unless noted:OpenCodexUsage/:OpenCodexRouteDispatcher.swift,OpenCodexUsagePricing.swift,OpenCodexUsageAggregator.swift,OpenCodexUsageParser.swift.CostUsage/:CostUsagePricing+Provider.swift,CostUsageCustomPricing.swift,ModelsDevPricing.swift,ModelsDevPricingTargetResolver.swift.Tests/CodexBarTests/OpenCodexNousUsageTests.swiftandTests/CodexBarTests/Fixtures/Providers/Nous/usage.jsonl.docs/nous.md, section "Local usage and spend".Ported / Deferred
Ported:
route_providermapsnousto the Nous subscription. The newspend_contract/opencodex/nous.rsprices Nous rows.
nous::custom_ratesis the single resolver for both the cost and the model'scustom-pricing flag.
ModelsDevPricingSnapshot::lookup_exactprovides the exact catalog lookup.CostUsagePricing::models_dev_cost_usdfollows upstreamcodexCostUSD(pricing:):cache_writerate.deepseek/<model>and similar) shares this function.usage.totalTokenswhen a row has no top-leveltotalTokens. The OpenCodexparse cache schema goes from 2 to 3, so cached rows are parsed again.
requestId, for all OpenCodex rows.nousto the routed OpenCodex providers, with source label"OpenCodex".
docs/PROVIDERS.mdgets a note.Deferred, or differs from upstream:
writes as separate lanes, which reproduces upstream's fan-out test values (
0.044862,0.059058,5.503258). Upstream's application-overlay path subtracts cache reads from inputinstead.
nous/<model>before the bare key. Upstream tries the bare keyfirst. This matters only when both keys exist with different rates.
refreshPricingIfNeededfirst. This,together with the general-path pricing gaps (
unwrap_or(0)on non-Nous rows, cache writes onthe routed path), is the stacked follow-up
port/micro-0.60.4-opencodex-unpriced.rust/src/cli/cost.rs. Onlycodex,claude,piandopencodegobuild a spend contractthere, so there's nothing to add.
Validation
Windows, toolchain 1.98.0, run at
1539d22f:cargo fmt --all --check: pass.cargo clippy --workspace --all-targets -- -D warnings: pass.Focused tests: 114 passed. These are
cargo test -p codexbar --lib --with the filtersnous,opencodex,spend_contract,cost_pricing,models_devandcodex_routed.cargo test -p codexbar: 2177 passed, 0 failed, 1 ignored.cargo test -p codexbar-desktop-tauri: 461 passed, 1 failed. The failure isbootstrap_payload_exposes_every_provider_variant. It reads host settings and fails the same wayon main.
New tests:
nous_tests.rs: upstream fixture costs, unreported tokens, and the cases where each fixapplies. Those are both input and output required, cache-lane guards, cache-write rates,
exact lookup, the self-prefix, legacy transport rows, malformed ids and the bare key.
cost_pricing_tests.rs: models.dev cost semantics, and that native Codexnous/staysunpriced.
models_dev_pricing.rs: exact lookup.A mutation check confirmed that the new tests catch each fix being reverted.
Line counts:
opencodex.rs992,nous.rs85,nous_tests.rs359.Review with fixes: #682 (comment)
Affected areas
UI proof
PASS at
1539d22f. I used browser-use over WebView2 CDP with an isolated fixture of 13 ledgerrows:
$6.14 · 1,946,083 tokensfor 7 days and$6.20 · 1,974,501 tokensfor30 days.
$0.20.Details: #682 (comment)