Skip to content

fix(codex): remote transfer budgets grow after clock rewinds - #155603

Merged
obviyus merged 4 commits into
openclaw:mainfrom
SunnyShu0925:fix/remote-workspace-media-monotonic-081
Sep 22, 2026
Merged

obviyus merged 4 commits into
openclaw:mainfrom
SunnyShu0925:fix/remote-workspace-media-monotonic-081

Conversation

@SunnyShu0925

@SunnyShu0925 SunnyShu0925 commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: remote Codex file reads and attachment batches can receive more than their configured transfer allowance after the system clock moves backward.

User Impact

User impact: transfer budgets decrease with elapsed time instead of growing after a clock correction. File contents, byte limits, path protections, cancellation, and existing timeout configuration remain unchanged.

Why This Change Was Made

The two existing transfer owners now measure elapsed time with the monotonic clock. Remaining milliseconds are rounded down before reaching the native integer timeout field, and an exhausted allowance still rejects before another request. An omitted file-read timeout remains omitted. No new configuration, timeout default, protocol, or permission is introduced.

Evidence

  • With unchanged production code, the focused clock-rewind regressions fail in both owners: a 500ms allowance becomes 5500ms for the next chunk or attachment. The expired-budget cases also incorrectly complete. The omitted-timeout control passes.
  • With the repair, the same controlled transition yields 399ms after 100.25ms elapsed, preserving integer request values. Negative or sub-millisecond remaining allowances stop before another request rather than being revived to 1ms. The omitted-timeout and existing byte, path, and cancellation controls remain intact.
  • The focused test file passes 28 tests in 20.69s wall time, including 9.822s of worker preparation. The existing batch test's real sleep was replaced with controlled clocks.
  • The affected extension test-type project, scoped type-aware lint, formatting, and source-size/assertion-safety checks pass.

Production-client proof

A normal Gateway chat.send at 4d03fbcaf033 invoked the registered Codex message dry-run path through the production app-server client and actual stdio JSON-RPC. A controlled peer executed the received fixed, bounded Node file-reader command against two temporary files.

  • Successful chunk and batch transfer: a 524,305-byte file required two reads, followed by a 17-byte attachment. After a 5-second rewind of the Gateway process's wall clock, the real RPC timeout values decreased 2998 → 2966 → 2907ms. Both Gateway-staged files matched the source byte hashes, and the conversation recorded a successful prepared dry-run reply.
  • Reduced-deadline enforcement: the first response returned in 2002ms, within its 2998ms allowance. After the rewind, the next real RPC carried 993ms. The production client returned command/exec timed out after approximately 997ms, before the peer's delayed real-reader response at 1505ms. No further chunk or second-attachment request was dispatched, and the conversation retained the tool error.

The peer was synthetic; this is actual Gateway/client/stdio/file-reader proof, not a native Rust Codex app-server, hosted provider, or actual NTP-adjustment run. Only the task-owned Gateway process's wall clock was shifted. Its clock fault, processes, connections, and port claim were cleaned up. This does not establish an indefinite hang.

The branch subsequently integrated the pinned upstream tooling declaration prerequisite, resolving the observed UI typecheck's missing-module-declaration error; that exact typecheck now passes. The 25 inspected transfer, client, direct-caller, fixture, and dependency inputs remain byte-identical to the runtime proof. Other inherited hook and SQLite lifecycle changes were source-inspected, not runtime-replayed; the observations above remain attributed to 4d03fbcaf033.

@clawsweeper

clawsweeper Bot commented Sep 22, 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 commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 22, 2026
@clawsweeper

clawsweeper Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 22, 2026, 6:29 AM ET / 10:29 UTC (Revision 4).

ClawSweeper review

What this changes

The PR makes remote Codex file and attachment transfers measure their remaining timeout with a monotonic clock and adds clock-rewind regression coverage.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: current main and the latest release still contain the reported defect. The patch has no identified correctness finding, but production-transport proof remains incomplete.

Priority: P2
Reviewed head: 4d03fbcaf033895543d0b88db29bde015907f479

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The repair and regression coverage are focused and source-consistent, while the remaining transport-proof gap limits merge readiness.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: Needs real behavior proof before merge: the current body demonstrates both transfer owners with controlled clocks and request fixtures, while the prior review records partial child-process proof through an execFile adapter. Neither establishes deadline enforcement through the production app-server client. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: Needs real behavior proof before merge: the current body demonstrates both transfer owners with controlled clocks and request fixtures, while the prior review records partial child-process proof through an execFile adapter. Neither establishes deadline enforcement through the production app-server client. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 9 items Introduced patch: The pinned introduction delta changes only the remote-media implementation and its tests. Both existing budget owners use performance.now(), floor remaining milliseconds, and reject exhausted allowances before issuing another request. Omitted file-read timeouts remain omitted.
Still necessary on main: The fetched main implementation still calculates both chunk and batch budgets using Date.now(). A backward clock step therefore increases the allowance passed to subsequent requests.
Latest-release check: The source at the supplied v2026.9.5 release commit also uses Date.now() for both budgets. The release blob was inspected through GitHub REST after local object retrieval failed.
Findings None None.
Security None None.

How this fits together

OpenClaw’s Codex plugin retrieves remote workspace files through the Codex app-server connection. It stages those bytes as Gateway-managed attachments before channel delivery.

flowchart TD
  A[Remote attachment request] --> B[Attachment batch budget]
  B --> C[Chunked file reader]
  C --> D{Time remaining?}
  D -->|Yes| E[Codex app-server command]
  E --> F[Gateway-managed attachment]
  D -->|No| G[Timeout error]
  F --> H[Channel delivery]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: Needs real behavior proof before merge: the current body demonstrates both transfer owners with controlled clocks and request fixtures, while the prior review records partial child-process proof through an execFile adapter. Neither establishes deadline enforcement through the production app-server client. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Complete next step (P2) - Add production app-server deadline-enforcement evidence to the PR body. Terminal output or redacted logs are sufficient; screenshots or recordings are welcome when they show the behavior. Remove private endpoints, IP addresses, keys, and other private data. Updating the body should trigger re-review; otherwise ask a maintainer to comment @clawsweeper re-review.
Agent review details

Security

None.

PR surface

Source +2, Tests +52. Total +54 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 6 4 +2
Tests 1 65 13 +52
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 71 17 +54

Review metrics

Metric Value Why it matters
Reported focused validation cost 28 tests; 20.69 seconds wall The reported total includes 9.822 seconds of preparation, and the revised batch coverage removes a real sleep.

Technical review

Best possible solution:

Keep timeout accounting in the two existing transfer owners, using monotonic elapsed time and positive integer allowances without changing configuration or transport semantics.

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

Yes, from source: rewinding Date.now() between chunks or attachments increases the remaining allowance on current main. The controlled-clock regressions target that mechanism; this review did not execute them.

Is this the best way to solve the issue?

Yes. Updating the existing budget owners and rounding for Codex’s integer timeout field is a narrow repair that preserves omitted-timeout behavior and existing safeguards.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This fixes a bounded remote-transfer timeout defect triggered by backward wall-clock adjustments.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Needs real behavior proof before merge: the current body demonstrates both transfer owners with controlled clocks and request fixtures, while the prior review records partial child-process proof through an execFile adapter. Neither establishes deadline enforcement through the production app-server client. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

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)
  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Provide redacted after-fix output exercising the remote-media owners through the production app-server client, showing that a backward clock step does not extend the budget and expiry prevents another request.

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-22T09:22:11.165Z sha 91a583b0dc6671aba6fe99a41e3d4dce49d1a385 :: needs real behavior proof before merge. :: [P2] Preserve the nullable timeout type in the regression test
  • reviewed 2026-09-22T09:56:46.229Z sha 35a4955 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-22T10:05:31.764Z sha 35a4955 :: needs real behavior proof before merge. :: none

…oss wall-clock rewinds

readBoundedCodexRemoteWorkspaceFile and prepareCodexRemoteWorkspaceMessageMedia
measured their remaining transfer budget with Date.now(). A wall-clock rewind
(NTP correction, manual clock change, or resume from sleep) widened the
per-chunk command/exec timeout past the caller's original allowance, so a
remote file transfer could hang well beyond requestTimeoutMs.

Switch the deadline math to the monotonic clock (performance.now) and floor
the remaining allowance to a positive integer, matching the six sibling files
in the same module and the fix already landed for provider discovery (openclaw#155323).
@SunnyShu0925
SunnyShu0925 force-pushed the fix/remote-workspace-media-monotonic-081 branch from 91a583b to 35a4955 Compare September 22, 2026 09:51
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 22, 2026
@obviyus obviyus self-assigned this Sep 22, 2026
@obviyus obviyus changed the title fix(codex): keep remote workspace media transfer budget monotonic across wall-clock rewinds fix(codex): remote transfer budgets grow after clock rewinds Sep 22, 2026
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@obviyus I noticed you've taken over this PR (73dda0c + the ancestry-preserving merge in 4d03fbc — thank you for keeping the contributor attribution, and for the much stronger table-driven regression tests).

I had just finished putting together the production-transport evidence ClawSweeper's Revision 3 review still lists as a blocker ("production app-server budget-enforcement evidence"). Since you've taken the lead, I'd rather not touch the PR body and risk disrupting your plan — so I'm leaving the results here in case they're useful to you:

Production transport proof (real CodexAppServerClient over stdio → minimal JSON-RPC app-server stub → the real production CODEX_BOUNDED_REMOTE_FILE_READER argv reading a real 1,574,098-byte file across 4 chunks), with Date.now rewound −5s mid-transfer:

  • Leg 1 — budget stays monotonic: per-chunk command/exec timeoutMs observed by the server: [9999, 8362, 7236, 5520] — all within the 10s allowance and non-increasing; exact byte roundtrip 1574098/1574098. The pre-fix Date.now() math on the same timeline would have sent [13354, 12235, 10519] ms (up to 3.4s over budget).
  • Leg 2 — enforcement through the real transport: with the same −5s rewind and a 4s budget, a deliberately stalled second chunk failed with command/exec timed out at 4001 ms elapsed (pre-fix math would have allowed ~9s); the server observed timeoutMs=3786 for the stalled chunk.

Happy to share the driver + stub scripts (tsx, ~200 lines total) if you want to reproduce it — otherwise feel free to use or ignore this as you see fit.

@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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 22, 2026
@obviyus
obviyus merged commit 3750260 into openclaw:main Sep 22, 2026
104 checks passed
@obviyus

obviyus commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Merged as 3750260. Thanks @SunnyShu0925 for the fix and additional transport evidence.

Chunk and attachment-batch budgets now use monotonic elapsed time with integer remaining allowances. The 28 focused tests pass. The registered Gateway flow also preserved both files' bytes and demonstrated the production client's reduced-deadline timeout without dispatching further reads. That proof used a controlled peer executing the real bounded Node reader, not the native Rust app-server or a hosted provider.

Applicable PR CI and the exact-head review passed (tier A, zero findings); landed through the ordinary guarded merge route.

@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@obviyus Thanks for merge~

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 23, 2026
…w#155603)

## What Problem This Solves

Fixes: remote Codex file reads and attachment batches can receive more than their configured transfer allowance after the system clock moves backward.

## User Impact

User impact: transfer budgets decrease with elapsed time instead of growing after a clock correction. File contents, byte limits, path protections, cancellation, and existing timeout configuration remain unchanged.

## Why This Change Was Made

The two existing transfer owners now measure elapsed time with the monotonic clock. Remaining milliseconds are rounded down before reaching the native integer timeout field, and an exhausted allowance still rejects before another request. An omitted file-read timeout remains omitted. No new configuration, timeout default, protocol, or permission is introduced.

## Evidence

- With unchanged production code, the focused clock-rewind regressions fail in both owners: a **500ms** allowance becomes **5500ms** for the next chunk or attachment. The expired-budget cases also incorrectly complete. The omitted-timeout control passes.
- With the repair, the same controlled transition yields **399ms** after **100.25ms** elapsed, preserving integer request values. Negative or sub-millisecond remaining allowances stop before another request rather than being revived to 1ms. The omitted-timeout and existing byte, path, and cancellation controls remain intact.
- The focused test file passes **28 tests** in **20.69s wall time**, including **9.822s** of worker preparation. The existing batch test's real sleep was replaced with controlled clocks.
- The affected extension test-type project, scoped type-aware lint, formatting, and source-size/assertion-safety checks pass.

### Production-client proof

A normal Gateway `chat.send` at `4d03fbcaf033` invoked the registered Codex `message` dry-run path through the production app-server client and actual stdio JSON-RPC. A controlled peer executed the received fixed, bounded Node file-reader command against two temporary files.

- **Successful chunk and batch transfer:** a 524,305-byte file required two reads, followed by a 17-byte attachment. After a 5-second rewind of the Gateway process's wall clock, the real RPC timeout values decreased **2998 → 2966 → 2907ms**. Both Gateway-staged files matched the source byte hashes, and the conversation recorded a successful prepared dry-run reply.
- **Reduced-deadline enforcement:** the first response returned in **2002ms**, within its **2998ms** allowance. After the rewind, the next real RPC carried **993ms**. The production client returned `command/exec timed out` after approximately **997ms**, before the peer's delayed real-reader response at **1505ms**. No further chunk or second-attachment request was dispatched, and the conversation retained the tool error.

The peer was synthetic; this is actual Gateway/client/stdio/file-reader proof, not a native Rust Codex app-server, hosted provider, or actual NTP-adjustment run. Only the task-owned Gateway process's wall clock was shifted. Its clock fault, processes, connections, and port claim were cleaned up. This does not establish an indefinite hang.

The branch subsequently integrated the pinned upstream [tooling declaration prerequisite](openclaw@fbd27c6), resolving the observed UI typecheck's missing-module-declaration error; that exact typecheck now passes. The 25 inspected transfer, client, direct-caller, fixture, and dependency inputs remain byte-identical to the runtime proof. Other inherited hook and SQLite lifecycle changes were source-inspected, not runtime-replayed; the observations above remain attributed to `4d03fbcaf033`.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex 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