Harden the CLI for 0.2.0 - #148
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
Adversarial review. I focused on the surfaces where a bug is expensive and hard to walk back — the two migrations, the submit path, and the telemetry change — rather than trying to cover 82 files evenly. The identity/lease/watermark machinery is well built: advisory locks are taken in a consistent order (user+date first, then device ids sorted), RLS is on with nothing granted to I haven't pushed commits — the SQL fix needs your design intent, and pushing into an active draft of this size would just create conflicts. 1. A day can silently freeze at stale numbers (correctness)
Two defects compose here. The guard is a conjunction over seven metrics, so one decrease rejects everything. A resubmission where cost went up but The skip is invisible, and the CLI treats invisible as done. Nothing in the function reports it — I grepped the whole migration for a skip/stale/noop signal and there is none. The outcome comes back The escape hatch doesn't cover this. Note the interaction with the dependency change below. Opening the ccusage floor is what makes a recomputed-downward cost likely, and this guard's response to that is to discard it without telling anyone. What I'd do: keep monotonicity as the default for a same-content retry, but decide on one defensible key rather than a seven-way conjunction, and make a skip a first-class outcome ( 2. Error telemetry goes dark (observability)Three changes land together: The net effect is that a production CLI failure now records an event name, The fingerprint itself is good work and the path normalization is careful. But it hashes The privacy concern behind this is real; messages do carry home directories, hostnames, and collector stderr. Deleting the field is a heavier remedy than the risk needs. Send a redacted message alongside the fingerprint: strip 3.
|
Why
The July 23 audit found correctness and reliability gaps across collection, local state, transport, ingestion, identity reconciliation, and release packaging. Retries could advance state incorrectly, concurrent submissions could race, collector fallback pricing could silently produce inaccurate totals, and scheduled runs lacked bounded failure behavior.
This release makes each date a durable unit of work: validate before submission, persist before network I/O, commit atomically on the server, and advance local state only for contiguous proven outcomes. It also removes Straude's exact ccusage patch pin so new models and sources can flow through as soon as a stable upstream collector supports them.
What changed
Correct ingestion and identity
submit_usage_day_v2ingestion with per-agent storage, idempotent request/date outcomes, explicit partial responses, and legacy-request adaptation.>=20.0.18, including later compatible majors, while rejecting old, prerelease, and malformed version claims.Bounded and recoverable CLI
0600config/outbox writes, corruption preservation, crash recovery, process-aware single-flight leases, queued overlap handling, and contiguous watermarks.--by-agent, strict live-pricing retries, and fail-closed handling for zero-priced Claude/Codex usage, including reasoning-only and partially priced mixed-model rows.Upstream ccusage compatibility
20.0.18, which includes the issue #934 pricing fix, Claude advisor accounting, Kimi/Moonshot coverage, and the latest native performance work.>=20.0.18) while keepingbun.lockfixed at20.0.18for reproducible repository CI.ccusage@latestin isolation, runs the production GPT-5.6 fixture/parser, enforces a 60-second budget, and proves unknown paid usage fails closed.Release and operations
CI reliability cleanup
npmexecution failed first, then directnpm.cmdexecution failed withspawn EINVAL. The script now invokes npm's JavaScript CLI through Node without a shell, and the packaged Windows test remains as the regression gate.process.execPath.Impact
Validation
bun install --frozen-lockfilebun run lintbun run typecheckbun run test(635 web tests and 270 CLI tests)bun run buildbun --cwd packages/cli test:packagedagainst installed ccusage20.0.18bun --cwd packages/cli canary:ccusageagainst the production GPT-5.6 fixtureLocal Docker/OrbStack was unavailable, so the real-Supabase regression was proven in the clean GitHub CI environment instead.
Rollout
This PR does not deploy or publish. After merge, follow
docs/CLI_OPERATIONS.md: deploy the backward-compatible server path through the 5% / 25% / 100% gates, publish only after production accepts v2, run historical repair after the healthy window, and enforce the v1 cutoff on schedule.