Skip to content

fix(crabbox): measure warm-image cleanup deadlines on the monotonic clock - #169908

Merged
obviyus merged 1 commit into
openclaw:mainfrom
SunnyShu0925:fix/crabbox-warm-image-deadline-monotonic-095
Oct 12, 2026
Merged

obviyus merged 1 commit into
openclaw:mainfrom
SunnyShu0925:fix/crabbox-warm-image-deadline-monotonic-095

Conversation

@SunnyShu0925

@SunnyShu0925 SunnyShu0925 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Crabbox warm-image cleanup shares a 60-second budget across checkpoint deletion subprocesses. Measuring the deadline with Date.now() lets clock corrections exhaust the budget early or inflate the remaining subprocess timeout.

What Changed

The collection, capacity-reclamation, and release cleanup deadlines now use performance.now() for both the deadline and remaining allowance. Existing subprocess timeout normalization handles fractional milliseconds. This follows the same clock-domain correction as #168771.

Persisted image creation, demand, and refusal timestamps remain wall-clock values. Retention rules, configured durations, cleanup authority, and retry/deletion-obligation handling are unchanged. Thanks @SunnyShu0925 for the report, fix, and regression coverage.

User Impact

Clock corrections no longer shorten or extend an in-flight warm-image cleanup budget. Normal cleanup behavior is unchanged.

Evidence

Built the pinned main baseline (e3ec1f2eeaf6b3a24b7e17362383b3c3c6b366b3) and this exact head in isolated Linux containers. Exercised the shipped Gateway with the Crabbox extension enabled and two expired warm-image records. A fake crabbox executable on PATH performs real, deliberately slow subprocess work; no cloud service or credentials are involved. A preload changes only the Gateway process's Date.now(), never the system clock.

Scenario Main This PR
No jump; two short deletes Both complete in 4.103s Both complete in 4.052s
+2h after first delete First sweep exhausts its budget after about 2s; second image remains Both complete in 4.308s
No jump; second delete takes 65s Terminated at 59.980s; retirement obligation retained Terminated at approximately 60s; retirement obligation retained
-2h after first delete; second delete takes 65s Both complete after 67.232s, exceeding the configured budget Terminated at 59.982s; retirement obligation retained

The forward-jump baseline was additionally traced at the actual Gateway cleanup deadline: its next remaining-budget read moved forward by two hours and stopped the sweep. A clock jump can also make the Gateway scheduler run a subsequent maintenance sweep promptly; one initial run observed that retry clear the remaining image. The defect is the prematurely exhausted original budget, not a claim that cleanup can never retry.

Focused checks: both affected test files passed (29 tests; 37.76s wrapper wall time). Changed-file oxfmt and oxlint passed. A separate bounded real OpenAI gpt-5-mini CLI smoke returned the requested marker with one provider request.

No overlap with Pash/Sarah changes. #169886 touches only crabbox-worker-node-enrollment.ts, not this PR's three files.

Merge Risk

Two-way door: reverting restores the former deadline calculation without a migration. No schema, persisted timestamp format, public API, permissions, or configuration changes. Blast radius is limited to Crabbox warm-image cleanup timing during allocation, maintenance, and teardown.

@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 12, 2026
@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR measures Crabbox warm-image cleanup budgets with a monotonic clock.

Example: Two cleanup executables share a 60-second budget, and the wall clock rewinds 90 seconds after the first command takes about one second.

  • Before: The second command can receive about 149 seconds instead of the remaining 59 seconds.
  • After: The supplied production-run output shows the second command receiving 58,980 milliseconds.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, correct repair with production-owner and real-subprocess evidence; the proof covers the changed timing boundary without live cloud allocation.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The updated terminal evidence exercises createCrabboxWarmImageManager through runCommandWithTimeout spawning real local commands, with native performance.now() and injected forward/backward wall-clock steps; both executables retain decreasing shared allowances, while focused regressions cover exhausted-budget debt retention.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: System clock corrections can leave expired snapshots awaiting cleanup or make cleanup commands run beyond their intended allowance.
Reason: The change restores the documented elapsed-time budget without changing defaults, retention, public APIs, or permissions.

Merge readiness

✅ Ready for maintainer review

This PR fixes a concrete cleanup-budget defect still present on current main; the previous finding is resolved, and no introduced correctness or security defect remains.

Priority: P2
Reviewed head: 214a6ecd5a33e09857060a567332d990e19a9297

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Crabbox plugin receives allocation, teardown, and periodic maintenance requests, tracks checkpoint retirement obligations, and sends bounded deletion commands through OpenClaw's subprocess runner.

flowchart LR
  A[Worker lifecycle and maintenance] --> B[Warm image manager]
  B --> C[Warm image state store]
  B --> D[Shared monotonic cleanup budget]
  D --> E[Checkpoint command adapter]
  E --> F[Subprocess runner]
  F --> G[Crabbox executable]
Loading

Technical review

Best possible solution:

Land the focused monotonic-clock substitution while preserving epoch timestamps, existing cleanup authority, and retained deletion obligations.

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

Current-main source shows wall-clock deadlines flowing into elapsed-time subprocess timeouts; the contributor reports a failing pre-fix regression, but this read-only review ran no target code.

Is this the best way to solve the issue?

Changing both deadline seeds and remaining-budget reads at the existing owner fixes the mismatch with minimal complexity and preserves persistent timestamp semantics.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Collection and capacity cleanup deadlines keeps the original intent (a82042f: Warm-image cleanup bounded provider commands while deleting snapshots before their ownership records; later mixed-executable maintenance preserved the shared budget.)
  • Release cleanup deadline keeps the original intent (826ca75: Prepared-capacity lifecycle work retained cleanup ownership until provider deletion was confirmed and shared the release cleanup allowance.)
  • Existing budget regressions keeps the original intent (fix(crabbox): maintain warm images across mixed CLI binaries #142166: Tests protect decreasing cross-executable allowances and retention of deletion obligations when the shared budget is exhausted.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 826ca75 adds extensions/crabbox/src/crabbox-worker-warm-image.ts:93 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 826ca75b3bf4; files: extensions/crabbox/src/crabbox-worker-warm-image.ts)

PR surface

Source 0, Tests +61. Total +61 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 6 6 0
Tests 2 94 33 +61
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 100 39 +61

Review metrics

Metric Value Why it matters
Production versus test LOC Production +6/-6; tests +94/-33 Production size is unchanged; test growth adapts existing budget regressions and adds a wall-clock-rewind case without new production seams.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Clock adjustments can prematurely stop checkpoint cleanup or inflate its timeout, with impact limited to Crabbox warm-image operations.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-12T13:15:44.190Z sha c8933144d8116c5211719ca825df4b305c5fa444 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-12T13:56:58.987Z sha c8933144d8116c5211719ca825df4b305c5fa444 :: needs real behavior proof before merge. :: [P2] Move the release-budget regression to the monotonic clock

Reviewed October 12, 2026, 10:18 AM ET / 14:18 UTC (Revision 3).

…lock

Ref: BUG-095-crabbox-warm-image-deadline-wall-clock-budget
@SunnyShu0925
SunnyShu0925 force-pushed the fix/crabbox-warm-image-deadline-monotonic-095 branch from c893314 to 214a6ec Compare October 12, 2026 14:11
@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 12, 2026
@obviyus

obviyus commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus
obviyus merged commit c3d6aa1 into openclaw:main Oct 12, 2026
127 of 129 checks passed
@obviyus

obviyus commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

Landed in c3d6aa1. Thanks @SunnyShu0925, Crabbox cleanup budgets follow elapsed time.

obviyus added a commit that referenced this pull request Oct 12, 2026
…oss wall-clock skew (#168731)

The Codex inference WebSocket handshake deadline used wall-clock time, so a wall-clock jump failed an admitted handshake almost immediately after a forward jump, or let it hang past its 10-second budget after a backward jump. The handshake deadline and its callback checks now use monotonic elapsed time, matching #168771 and #169908. Persisted state is unchanged. The queued-admission permit deadline still uses wall-clock time; that is noted as a follow-up. Proof: an isolated built Gateway running the native Codex runtime against the repository's fake app-server, with a loopback TLS WebSocket upstream and clock jumps simulated inside the inference and permit code only. Normal open: 12 ms on main, 11 ms with the PR. +2h: HTTP 504 after 6 ms on main, after 10,037 ms with the PR. -2h: still pending at 15,018 ms on main, 504 at 10,075 ms with the PR. A slow upstream with no jump timed out at about 10 s on both. Thanks @SunnyShu0925.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…lock (openclaw#169908)

Crabbox warm-image cleanup measured its subprocess time budget with wall-clock time, so a wall-clock correction exhausted the budget early after a forward jump, or let cleanup overrun after a backward jump. The budget now follows monotonic elapsed time, matching openclaw#168771, and persisted image timestamps are unchanged. Proof: an isolated Gateway with the Crabbox extension, a fake crabbox CLI and wall-clock jumps simulated inside the process only. Normal cleanup took about 4s on both. With +2h, main's first sweep exhausted its budget after about 2s, while the PR completed in 4.3s. With -2h, main ran 67.2s, while the PR stopped at the 60s budget. A slow no-jump control stopped at about 60s on both. Thanks @SunnyShu0925.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…oss wall-clock skew (openclaw#168731)

The Codex inference WebSocket handshake deadline used wall-clock time, so a wall-clock jump failed an admitted handshake almost immediately after a forward jump, or let it hang past its 10-second budget after a backward jump. The handshake deadline and its callback checks now use monotonic elapsed time, matching openclaw#168771 and openclaw#169908. Persisted state is unchanged. The queued-admission permit deadline still uses wall-clock time; that is noted as a follow-up. Proof: an isolated built Gateway running the native Codex runtime against the repository's fake app-server, with a loopback TLS WebSocket upstream and clock jumps simulated inside the inference and permit code only. Normal open: 12 ms on main, 11 ms with the PR. +2h: HTTP 504 after 6 ms on main, after 10,037 ms with the PR. -2h: still pending at 15,018 ms on main, 504 at 10,075 ms with the PR. A slow upstream with no jump timed out at about 10 s on both. Thanks @SunnyShu0925.

Co-authored-by: Ayaan Zaidi <[email protected]>
hilsbos pushed a commit to hilsbos/openclaw that referenced this pull request Oct 22, 2026
…oss wall-clock skew (openclaw#168731)

The Codex inference WebSocket handshake deadline used wall-clock time, so a wall-clock jump failed an admitted handshake almost immediately after a forward jump, or let it hang past its 10-second budget after a backward jump. The handshake deadline and its callback checks now use monotonic elapsed time, matching openclaw#168771 and openclaw#169908. Persisted state is unchanged. The queued-admission permit deadline still uses wall-clock time; that is noted as a follow-up. Proof: an isolated built Gateway running the native Codex runtime against the repository's fake app-server, with a loopback TLS WebSocket upstream and clock jumps simulated inside the inference and permit code only. Normal open: 12 ms on main, 11 ms with the PR. +2h: HTTP 504 after 6 ms on main, after 10,037 ms with the PR. -2h: still pending at 15,018 ms on main, 504 at 10,075 ms with the PR. A slow upstream with no jump timed out at about 10 s on both. Thanks @SunnyShu0925.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 805f43b)
Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: crabbox P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

2 participants