Repository navigation
fix: reject negative provider usage percentages - #332
Conversation
|
@sfl review |
There was a problem hiding this comment.
✅ Verdict: PASS • Round 1
Confidence: 9/10 · Project risk: 4/10 (codexbar)
Review done by claude-opus-5-5 (adversarial to codex)
The PR filters out negative usage percentages in the Codex, Claude (structured and flat) and Cursor parsers before they are clamped into windows. Responses with only invalid windows now return each parser's existing error, and new public-parser tests cover issue #331's acceptance criteria. I found no evidenced defect: each filter sits before the existing clamp, Claude's dedupe and fallback order now skip an invalid entry instead of being blocked by it, and zero and over-limit handling is unchanged.
🔨 Full-Spectrum Review Summary
Effort: high
Review time: 1m 13s
Token count: Unavailable
| Pass | 🔴 Critical | 🟠 High | 🟡 Medium | ⚪ Low |
|---|---|---|---|---|
| 🔒 Security | 0 | 0 | 0 | 0 |
| ✅ Accuracy | 0 | 0 | 0 | 0 |
| 🧰 Quality & Maintainability | 0 | 0 | 0 | 0 |
| Total | 0 | 0 | 0 | 0 |
Key Findings
No material defects found.
Coverage
- Files reviewed:
crates/codexbar-providers/src/claude.rscrates/codexbar-providers/src/codex.rscrates/codexbar-providers/src/cursor.rscrates/codexbar-providers/tests/usage_percentage.rs
- Context read:
crates/codexbar-providers/src/lib.rscrates/codexbar-providers/Cargo.tomlCargo.tomlcrates/codexbar-core/src/lib.rscrates/codexbar-core/src/account.rscrates/codexbar-core/src/metric.rscrates/codexbar-providers/tests/claude_quota_reset.rs
- Verified:
gh api userreturnedHemSoftunder the per-process personal profile- Compare
base_commit.shais899bf3fe7c589ce45ca7ca96c9684d43e1f956d1, the last commit is56f51ce12c41ca43e056edb1e0abb208936cadbb, ahead 1 and behind 0 - PR #332's API head and base match the reserved SHAs
- Codex
Window::from_jsonfilter runs before the/100clamp;parse_usagestill errors with "no usage windows for this account" when every window is dropped - Claude's structured loop rejects a negative
percentbefore the label dedupe, so a valid flatfive_hourcan still fill the session slot - Claude flat
find_mapfalls through from a negativeseven_daytoseven_day_oauth_apps - Cursor
filter_mapdrops a negative field, keeps its siblings and keeps the "no usage percentages" error when all are dropped -0.0 >= 0.0holds, so a JSON negative zero is still read as a genuine zero- The integration test uses only public items:
claude/codex/cursormodules,parse_usagesignatures,AccountSnapshot::metrics/messages,Metric::label/used_fraction - Expected labels in the tests (
Weekly,5-hour window,Auto,API) and the Claude session note text match the exact-SHA source - Workspace clippy lints are
all = warnonly, and existing integration tests already useunwrap
- Not verified:
- Runtime and test results: the PR's claims of passing tests and gates were not reproduced because execution is forbidden
- Whether the app keeps a previous good snapshot when a parser now returns
Err: dashboard code outside the diff was not read - Other providers (Gemini, Copilot, Grok, OpenCode) were not checked for the same negative-percentage pattern; they are outside issue #331's scope
- CI check status for the head was not read
- Tests run: None. Reviewer execution is disabled.
HemSoft full-spectrum review • 3 evidence-based passes • Reviewed head 56f51ce12c41ca43e056edb1e0abb208936cadbb • SFL v0
Risk level: 4/10 (codexbar)
Worked on by: gpt-6.1-sol on Home, for Franz.
Closes #331.
Codex, Claude and Cursor accepted a provider percentage of
-25as a successful0% reading. Reject negative percentages before collecting quota windows, keeping
valid siblings and Claude's structured-to-flat and weekly alias fallbacks.
All-invalid responses follow each parser's existing error path. Genuine zero and
the existing upper clamp remain compatible.
Validation
the compatibility control passed; all nine passed after the fix.
cargo fmt --all --check, workspace Clippy with--locked -- -D warnings,and
cargo test --workspace --locked(1,123 passed, six ignored, native fixture passed).953579f after all seven CI and all three
Package jobs passed. Mini and Home main were fast-forwarded to that revision
with tracked-clean guards and the preexisting audit bytes preserved.
without conflicts. All four parser/test blobs are identical to the original
reviewed head 56f51ce.
charter's conflict-free main-update rule. No duplicate review was requested.
prerequisite's main CI43089937291 also passed.
unedited, with zero unresolved threads. Effective rules require no formal
approval and preserve all seven strict checks without bypass actors.
gh x status --refreshreports checks pass and AI-for the new commit ID;the documented main-update PASS reuse rule supplies review consent without
manufacturing a current-SHA bot verdict.
Council: not required for bounded parser validation. Owner remains
chief-dispatch-8fcc69c4-codexbar-parser through review, checks, guarded merge,
main CI, actual source sync, cleanup and exact release. All validation used
synthetic inputs; no provider request, credential access, application or browser
launch occurred. Existing branches, worktrees and audit bytes remain retained.