Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesMeasure the usage-report publication wait with monotonic time so wall-clock changes cannot extend its deadline. Example: A stale usage.cost report encounters a busy refresh owner while Date.now moves backward by 90 seconds.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — probable (reviewed change; reproduction). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review Keep this PR: it fixes a current-main deadline bug with a minimal clock correction, and both prior findings are resolved; no introduced defects were found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway usage requests pass calendar ranges to the shared cost-cache runtime, which reads committed worker aggregates, requests stale-session refreshes, and returns totals after a bounded publication wait. flowchart TD
A[Usage client] --> B[Gateway usage RPC]
B --> C[Cost report cache]
C --> D[Shared report deadline]
D --> E[Aggregate worker]
D --> F[Refresh publication owner]
E --> G[Committed usage totals]
F --> G
Technical reviewBest possible solution: Merge the two-line monotonic deadline correction and consolidated regression once the existing checks pass. Do we have a high-confidence way to reproduce the issue? Current-main source seeds a wall-clock deadline before awaited aggregate I/O and subtracts the corrected clock afterward; the supplied built-Gateway comparison demonstrates the resulting rollback delay, although this read-only review ran no reproduction. Is this the best way to solve the issue? This is the smallest complete fix: both elapsed-budget reads use the existing monotonic clock while calendar ranges, persisted timestamps, refresh ownership, and result semantics remain unchanged. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e7f054619274. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource 0, Tests 0. Total 0 across 3 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed October 27, 2026, 9:05 PM ET / October 28, 2026, 01:05 UTC (Revision 2). |
Built Gateway clock-step proofBaseline main: The experiment runs real built Gateways in secretless Linux/Node 24.22.1 isolation. A task-owned synthetic transcript is primed to 30 tokens / 0.03 cost. The actual built refresh-lock owner then holds publication while another 70-token entry makes the source stale. The shipped
The candidate retains the same partial committed projection and totals while respecting the ten-second publication wait. This does not claim to bound report computation itself. The first baseline response was captured successfully before an auxiliary cleanup client hit a stale keep-alive socket; the proof control transport was corrected, and subsequent runs released the real lock and shut down their Gateways. That cleanup issue is not counted as a product failure. The former standalone real-time rollback test was folded into the existing publication-budget table. It now advances fake monotonic timers while independently rewinding Whole-PR line delta: production +2/-2 (net 0), tests +29/-29 (net 0). No baseline or ceiling change. The production fix remains SunnyShu's two-line clock-domain correction; fixture reuse removes duplicated setup rather than adding another clock seam. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in 2e25064. Thanks @SunnyShu0925. Cost usage reports no longer wait out a clock rollback. |
…clock (openclaw#186388) fix(usage): keep the cost usage report refresh deadline on the monotonic clock The cost usage report's refresh deadline was measured with the wall clock, so after a backward clock step a report waited for the full size of the step before returning. The deadline now uses monotonic time; totals and partial-cache behavior are unchanged. Evidence: built Gateway usage.cost reports with Date.now stepped back 90 seconds inside the process only. On main the report took 100.8s and 100.9s (twice); with this change 10.6s and 10.7s (twice), matching the no-step runs of about 10.5s on both refs. Details: openclaw#186388 (comment). Thanks @SunnyShu0925. Co-authored-by: SunnyShu <0668000539@local> Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
A wall-clock rollback during a stale cost/usage report read can stretch its intended ten-second publication wait by the amount of the rollback. A normal cost report can therefore stall for a minute or more behind a busy refresh owner.
Why This Change Was Made
SunnyShu's fix seeds the report-refresh deadline with
performance.now()and computes its remaining budget with the same monotonic clock. Both reads surround awaited aggregate I/O, so mixing wall-clock corrections into that budget was incorrect.The follow-up moves the rollback regression into the existing publication-budget table and reuses fixtures. Controlled monotonic timers and an independent
Date.now()rewind replace the former ten-/hundred-second unit-test waits. Existing completion, stale/partial response, cancellation, and independent refresh-owner contracts remain covered.User Impact
Usage reports retain the same committed totals and partial-result semantics when refresh publication remains busy, but their wait no longer inherits a wall-clock offset. Calendar ranges, persisted timestamps, refresh ownership, queue behavior, schemas and public APIs are unchanged. This bounds publication waiting, not report computation.
Evidence
Built Gateway proof and measured outputs, comparing main
a055ff33bbe74d95357f5d77bedc2cebdbd89c48with the candidate through the shippedusage.costRPC:Every report returned the same 30 tokens / 0.03 cost with
refreshingstatus and one stale file while the actual built refresh-lock owner held publication. The fixture uses isolated synthetic state and a process-local clock preload; no system/VM clock or report callback was changed. Full setup and cleanup limitations are disclosed in the linked proof.Merge Risk
Two-way door: reverting restores the prior elapsed-wait calculation without a storage or configuration migration. Blast radius is stale cost/usage aggregate reports waiting for refresh publication; ordinary timestamp and report-value semantics are unchanged.