Skip to content

fix(claude): preserve claude-swap measurement timestamps - #3485

Merged
steipete merged 1 commit into
mainfrom
fix/claude-swap-measurement-time
Sep 8, 2026
Merged

fix(claude): preserve claude-swap measurement timestamps#3485
steipete merged 1 commit into
mainfrom
fix/claude-swap-measurement-time

Conversation

@steipete

@steipete steipete commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Repeated claude-swap refreshes displayed cached measurements as freshly updated because the parser discarded usageFetchedAt and the projection always used the current clock. Preserve the optional source timestamp using the existing parser; older adapters and malformed optional timestamps keep their existing fallback without dropping valid usage windows.

Extracted from #3452, with credit to @QuantIntellect. Its remaining last-known usage display and source-chosen account switching stay separate. This changes no adapter arguments, credential access, cache schema, or account activation behavior.

Validation: the regression fails on the baseline and passes after the fix, including fractional timestamps, repeated refreshes, exhausted-window retention, and malformed optional fields. Focused ClaudeSwap suites pass. make check passes using macOS system Bash (Homebrew Bash stalled in the existing signing fixture's here-document). Independent P0–P2 review is clean. The full suite passed all 1,032 selections across 86 groups on the first attempt, with no retries or timeouts. Exact-head CI passes all jobs, including both macOS shards, all three Linux builds, lint and the aggregate gate.

Live proof: the actual built CLI dashboard --identity redacted with an isolated synthetic adapter reproduced both baseline account timestamps being replaced by the poll time. The candidate preserves each distinct source measurement timestamp and the same quota values. The Developer ID–signed app also launched in an isolated synthetic profile and opened its real Settings menu through native automation. No real provider credentials, browser sessions, or personal history were used.

The changelog entry will be carried in #3488 to keep sibling branches independent.

Carry the optional source usageFetchedAt value into account snapshots so repeated reads of a cached measurement do not reset its age. Preserve valid usage and existing refresh-time behavior for older or malformed optional fields.

Extracted from #3452; remaining last-good usage and source-selected switching stay separate.

Co-authored-by: Persian ROss <37_privacy.blends@icloud.com>
@clawsweeper

clawsweeper Bot commented Sep 8, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 8, 2026
@clawsweeper

clawsweeper Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed September 7, 2026, 10:32 PM ET / September 8, 2026, 02:32 UTC.

ClawSweeper review

What this changes

Preserve claude-swap’s optional measurement timestamp in account usage displays, with regression tests and documentation for the existing fallback.

Merge readiness

Ready for maintainer review

This remains a necessary, focused fix with no blocking findings. The recorded production CLI proof supports readiness, and neither fetched main nor the latest release contains the correction.

Priority: P2
Reviewed head: d519d1a225bbd55b346040a3475889cdf4fb337c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A narrow, maintainable correction with focused regressions, recorded production-path validation, and no actionable findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The owner’s pinned-head receipt exercises the changed parser and projection through the built dashboard CLI with an isolated adapter, observing preserved source dates and unchanged quota values after the fix; native Settings startup is supplemental.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The owner’s pinned-head receipt exercises the changed parser and projection through the built dashboard CLI with an isolated adapter, observing preserved source dates and unchanged quota values after the fix; native Settings startup is supplemental.
Evidence reviewed 8 items Pinned change and repository policy: The checkout matches the verified original head. The complete introduced delta contains four files, and the working tree is clean. Root AGENTS.md was read fully; no nested AGENTS.md or maintainer-notes directory was found. Its guidance favors the existing shared projection and isolated CLI/parser validation.
Optional parsing and narrow projection: The parser accepts usageFetchedAt only as a parseable string using the existing fractional/plain ISO-8601 parser. The projection uses that date or the existing refresh-time fallback. Retention still preserves snapshot.updatedAt and evaluates reset expiry against the current clock.
Still necessary on fetched main: Fetched main still constructs these snapshots with updatedAt: now. The adapter subtree has no changes between the pinned base and fetched main, so the later main changes do not supply this fix.
Findings None None.
Security None None.

How this fits together

CodexBar reads account usage from the optional claude-swap executable and converts its JSON into shared account snapshots. Those snapshots supply usage values and measurement ages to the app and CLI dashboard.

flowchart LR
  A[claude-swap account JSON] --> B[Validate account rows]
  B --> C{Valid measurement time?}
  C -->|Yes| D[Use source time]
  C -->|No| E[Use refresh time]
  D --> F[Account usage snapshot]
  E --> F
  F --> G[App and CLI dashboard]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test delta production +5 net lines; tests +65; docs +2 The small production increase carries one optional timestamp through existing models, with focused regression coverage.

Technical review

Best possible solution:

Keep measurement age tied to the adapter’s source timestamp while preserving refresh-time behavior for older or malformed payloads.

Do we have a high-confidence way to reproduce the issue?

Yes: fetched main discards the measurement timestamp and assigns each projected snapshot the poll time. The supplied built-CLI comparison demonstrates that mechanism; this review verified it from source without executing it.

Is this the best way to solve the issue?

Yes: reusing the existing timestamp parser and shared projection fixes both app and CLI consumers without introducing another freshness model or changing adapter configuration.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 9810f24b0609.

Labels

Label justifications:

  • P2: Incorrect measurement age affects the optional claude-swap usage display with a limited blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The owner’s pinned-head receipt exercises the changed parser and projection through the built dashboard CLI with an isolated adapter, observing preserved source dates and unchanged quota values after the fix; native Settings startup is supplemental.
  • proof: sufficient: Contributor real behavior proof is sufficient. The owner’s pinned-head receipt exercises the changed parser and projection through the built dashboard CLI with an isolated adapter, observing preserved source dates and unchanged quota values after the fix; native Settings startup is supplemental.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • sf-jin-ku: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-08T01:02:39.571Z sha d519d1a :: needs maintainer review before merge. :: none
  • reviewed 2026-09-08T01:20:07.530Z sha d519d1a :: needs maintainer review before merge. :: none
  • reviewed 2026-09-08T01:59:30.467Z sha d519d1a :: needs maintainer review before merge. :: none

@steipete

steipete commented Sep 8, 2026

Copy link
Copy Markdown
Owner Author

Validation on d519d1a225bbd55b346040a3475889cdf4fb337c:

  • make test: all 1,032 selections / 86 groups passed on the first attempt, with zero failures, retries, or timeouts (1,130.8 seconds including discovery).
  • make check: passed, zero SwiftLint violations. The existing signing fixture hung inside Homebrew Bash heredoc_write; a fresh private TMPDIR reproduced it, and the identical checks passed with macOS system Bash selected through a task-local PATH.
  • Focused ClaudeSwap tests pass. The new raw-JSON regression failed before the fix, then passed with fractional timestamp, repeated-refresh, retained exhausted-window, and malformed optional-field coverage.
  • Independent local and committed-branch autoreview through P2: no actionable findings.

Live built-binary proof used only an owned synthetic cswap --list --json fixture and isolated HOME/config/cache roots. Baseline dashboard --identity redacted replaced both accounts’ measurement dates with its poll time. The candidate kept 2026-09-07T08:54:23Z and 2026-09-07T08:55:03Z, retaining the same 25% and 50% usage. The Developer ID-signed app also launched in an isolated synthetic profile; native automation opened its real Settings menu and verified the General window before quitting. That is an app startup/navigation smoke check; the changed timestamp behavior was proven through the shared production CLI pipeline.

Exact-head CI passed every job, including both macOS shards, all three Linux builds, lint and the aggregate gate. The current PR head still matches the tested commit and is mergeable. This PR is land-ready; merge authorization remains with the orchestrator. The changelog is collected in #3488, which should land after this PR and the dependency update #3487. No real credentials, browser cookies or personal history were accessed for these proofs.

Exact-head receipt tightened: after the unrelated main fast-forward, the committed d519d1a was rebuilt and the same built CLI and signed-app Settings smoke were repeated successfully.

@clawsweeper clawsweeper Bot added the proof: sufficient Contributor real behavior proof is sufficient. label Sep 8, 2026
@steipete
steipete merged commit 6818f82 into main Sep 8, 2026
9 checks passed
steipete added a commit that referenced this pull request Sep 8, 2026
Collect #3485 and #3487 with contributor credit and a Highlights lead-in, preserving current main entries. Land after both implementation PRs. No issue is closed and no version or release is published.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant