Repository navigation
Conversation
|
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 findings:
|
|
Fixes landed at head 8f096d8: all 3 findings fixed, nothing left. Commands run: cargo +1.98.0 fmt --all, clippy -D warnings (rust crate, all targets), cargo test --lib cli:: (208 passed). Tauri crate clippy skipped: no changes outside the rust crate. |
…-period-core' into port/micro-0.67.0-cost-period-cli-serve
|
Delivered and validated on port/micro-0.67.0-cost-period-cli-serve at e5e0e0f. Validation: cargo test --manifest-path rust/Cargo.toml (2209 passed, 3 suites, 1 ignored), cargo clippy --all-targets -D warnings (3 pre-existing manual_range_contains / nonminimal_bool findings in alibabatokenplan/cli.rs, kiro/usage_limits.rs, openai/subscription.rs — all files last touched in 0.55-0.60 commits already on main, none touched by this branch; rustc 1.96 lint drift), cargo fmt --all --check clean for this branch's changed files. Pushed as fast-forward 8f096d8..e5e0e0f. |
…erve /cost (stacked on #648)
|
Adversarial validation passed at 4988b27 Scope: cost --period and period-aware serve /cost (#653, upstream 0.67.0), validated as merged into release/v0.70.0 (merge 4988b27 = merge of e5e0e0f into 545d39d). Attacks (highest-risk semantics, from the merged tree):
No defects found. READY for the un-draft rule. |
Summary
Part B of upstream 0.67.0 item 1: wires the
CostReportingPeriodcore (#648) intocodexbar costandserve/cost. Stacked on #648.codexbar cost --period month-to-date|all.--daysis nowOption<u32>so "explicitly passed" is detectable:--days N(clamped to 1..=365) always selects a rolling window and wins over--period; with neither flag the savedcost_reporting_periodapplies, which isrolling:30by default, so an unconfigured install behaves as before.Last 30 days,Month to date,All,Today). The empty-scan messages now say "in the selected period" instead of repeating a day count.reportingPeriod(raw string),historyLabel, and atotalsobject for the selected window (inputTokens,outputTokens,cachedTokens,reasoningTokens,totalTokens,totalCost;nullwhen a scan found nothing without a known zero). Existingcost,tokens,sessions_count,spendContractfields keep their meaning;days_scannedis the resolved day count.--remote/--summary-onlykeep the 1..=365 protocol: month to date is sent as its current day count, All is rejected unless--days Nis passed.serve/costresolves the saved period on every request and feeds it to the scanner, Antigravity, Muse and thedays_scanned/totalsfields, plusreportingPeriod/historyLabel. Daily chart rows follow the period (All charts the latest 365 days).rust/src/cli/cost_period.rs(resolve_period,window_days,stamp_period,cost_totals_json);CostReportingPeriod::label()is added to the core.docs/CLI.mddocuments the flags, JSON fields and the compatibility surfaces.Upstream reference
9f76e1194).v0.67.0(GET only):Sources/CodexBarCLI/CLICostCommand.swift(decodeCostReportingPeriod,costTotals,reportingPeriod,historyLabel),CLIServeCommand.swift(/costperiod resolution),docs/cost-reporting-periods.md,docs/cli.md.Ported / Deferred
Ported: everything above.
Not changed on purpose (documented compatibility surfaces, 30-day meaning kept): the dashboard cost line ("last 30 days"),
dashboard/snapshot.rsandsource.rs30-day handling, and the Prometheus gaugecodexbar_cost_last_30_days_usd. The dashboard page reads only thedailyarrays from/cost, so its bar charts now span the selected period and are self-labelled by their first/last dates.Deferred or divergent:
/costresponse cache exists locally (upstream caches responses, so its cache key folds in the period identity). Each request re-resolves the saved period, and the scanners' disk caches are already keyed by the resolved day range (Port upstream 0.67.0: add CostReportingPeriod core and range-aware cost scanners #648), so a period or month change never reuses another window's entries. No cache-key test applies.totalsomits upstream'sprovenance,coverageandincompleteRequestCount(no local equivalent). Token key iscachedTokensrather than upstream'scacheReadTokensbecause the local Claude count includes cache creation.--daysabove 365 is now clamped to 365 (upstream behavior; the spend contract and host summaries already clamped or rejected it).--group-by sessionuses the rolling conversation index, so All lists the latest 365 days at most (heading reports the window used).spendContract.dailystill clamps to 1..=365 days, so under All it reports the latest year.Validation
Run with
+1.98.0on E-cores, target dir slot-5:cargo fmt --all: cleancargo clippy -p codexbar --all-targets -- -D warnings: passcargo clippy --workspace --all-targets -- -D warnings: the Tauri crate build script failed with a stale-path error inside the slot-5 target dir (failed to read plugin permissions ... doubao-agent-icon ... app_hide.toml), unrelated to this change; the Tauri crate is untouched and does not referenceCostArgsor/cost.cargo test -p codexbar cli:: -- --test-threads=4: 208 passed, 0 failedcargo test -p codexbar -- --test-threads=4(full): 2199 passed, 0 failed, 1 ignored; doc/integration 1 passed--days/--periodabsent vs given), resolver matrix (--daysbeats--period, both absent uses saved, invalid--period, host summary rejects All), JSON payload stamp/totals (rolling, month to date, token-history providers),label().cost --period weeklyexits with "--period must be month-to-date or all";cost -p codex --period all --summary-onlyis rejected with the override hint;cost -p claude --period month-to-date --jsonreportsreportingPeriod: month-to-date,historyLabel: Month to date,days_scanned: 29, period start 2026-09-01;--days 7and--period allheadings readLast 7 daysandAll.cli/cost.rs840,cli/cost_period.rs189,serve/data.rs227).Affected areas
rust/src/cli/cost.rs,rust/src/cli/cost_period.rs(new),rust/src/cli/mod.rs,rust/src/cli/serve/data.rs,rust/src/cost_reporting_period.rs(label),docs/CLI.md. No Tauri or frontend changes; no new dependencies.UI proof
Not applicable. CLI and HTTP output only.