Skip to content

fix(daemon): keep service update authority deadline on the monotonic clock - #183104

Merged
steipete merged 2 commits into
openclaw:mainfrom
SunnyShu0925:fix/bug-120-daemon-service-update-authority-deadline-wall-clock
Oct 26, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
SunnyShu0925:fix/bug-120-daemon-service-update-authority-deadline-wall-clock

Conversation

@SunnyShu0925

@SunnyShu0925 SunnyShu0925 commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Queued native service commands can time out early or wait beyond their intended budget when the system wall clock changes during an update or maintenance operation.

User Impact

Native command admission keeps its elapsed-time budget across system-clock corrections. Existing timeout values, queue ordering, and live authority checks remain in place.

Why This Change Was Made

Use the existing inspection clock's monotonic default instead of overriding it with Date.now(). This also preserves the clock supplied by an active inspection-budget scope. The regression advances elapsed time before stepping the wall clock, so it exercises an actual queued command with budget remaining.

Thanks to @SunnyShu0925 for the original fix and regression. The contributor's commit is preserved.

Evidence

  • Regression red → green: with the old wall-clock override, the queued-command test rejects with Native command admission timed out; with the fix, all 28 tests pass across service-update-authority-runner, service-update-authority, service-inspection-budget, and systemd-peer-queue.
  • Real-process comparison: the production authority owner queues /usr/bin/true behind /bin/sleep 0.1. After a simulated +60-second Date.now() step, the old implementation rejects admission with ETIMEDOUT; the fixed implementation runs the child successfully with exit code 0.
  • Targeted oxlint and oxfmt pass. Production LOC delta: 0; tests: +22; documentation: +3. The four-file test run took 302 seconds on a loaded host, dominated by cold worker compilation; individual test execution remained short. Exact-head CI is recorded in this PR's checks.
  • Full update/Doctor CLI and native service-manager transitions were not live-tested in this pass; the live comparison used isolated child processes through the changed authority owner and did not touch an installed Gateway.

@clawsweeper

clawsweeper Bot commented Oct 25, 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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS labels Oct 25, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 25, 2026
@clawsweeper

clawsweeper Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR makes queued native-service command deadlines use the existing monotonic clock instead of wall time.

Example: A command has a 20 ms admission budget; after 5 ms, the system clock jumps forward 60 seconds.

  • Before: The queued command incorrectly rejects with ETIMEDOUT.
  • After: The command retains its remaining elapsed-time budget and runs after its predecessor finishes.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A minimal, useful repair with a distinct regression and real-process boundary evidence; broader CLI transitions were not exercised.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied production-owner comparison uses real sleep and true child processes across an injected wall-clock step, recording old-code ETIMEDOUT and fixed-code exit 0; this directly exercises the changed admission boundary without claiming full update or Doctor coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A system-clock correction can make queued update or maintenance commands fail early or exceed their intended waiting budget.
Reason: The change restores elapsed-time timeout behavior without adding configuration, changing stored state, or weakening authority checks.

Merge readiness

✅ Ready for maintainer review

Keep this PR: current main retains the wall-clock deadline bug, and this focused fix preserves queue ordering, scoped accounting, and live authority checks. No actionable defects found; exact-head CI is still pending.

Priority: P2
Reviewed head: 06e62a0c0dcafae29a1d786a1d67bb4f3f7fdc61

Before merge

None.

Findings

None.

Agent review details

How this fits together

Update and maintenance operations submit native commands through a scoped FIFO queue that checks current authority and passes the remaining timeout to the child-process runner.

flowchart LR
  A[Update or maintenance] --> B[Scoped native command queue]
  C[Inspection or monotonic clock] --> B
  B --> D[Live authority checks]
  D --> E[Native child process]
  E --> F[Result and cleanup settlement]
Loading

Technical review

Best possible solution:

Use the existing clock default and retain the focused regression, FIFO queue, and live authority checks.

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

The current-main clock selection and remaining-time arithmetic establish the failure path; supplied red-to-green and real-process comparisons corroborate it, without executing target code during this review.

Is this the best way to solve the issue?

This is the smallest complete fix: remove the wall-clock override at the existing queue owner, preserve scoped clocks, and add one distinct behavioral regression.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Unscoped native-command deadline clock changes intended behavior with a stated reason (97c7b35: Native commands gained serialized custody and bounded admission; the later inspection-budget change preserved wall-clock timing outside inspection scopes.)
  • Scoped inspection-budget accounting keeps the original intent (0c91469: Exclude synchronous custody checks from manager inspection budgets while charging asynchronous waiting and retaining every authority check.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 2444509 adds src/daemon/service-update-authority.ts:137 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 244450952c01; files: src/daemon/service-update-authority.ts)
  • Jason (Json): Raw commit 97c7b35 adds src/daemon/service-update-authority.ts:40 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 97c7b3593392; files: src/daemon/service-update-authority.ts)

PR surface

Source 0, Tests +22, Docs +3. Total +25 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 1 1 0
Tests 1 22 0 +22
Docs 1 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 26 1 +25

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Clock corrections can incorrectly expire or extend queued update and maintenance commands; the affected timing condition has a focused repair.
  • 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.
  • 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-25T01:38:56.952Z sha 8fd3db9cb0c13f80c6d66de7c0980f753bfba4d3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-25T05:35:39.325Z sha dbc554c :: needs maintainer review before merge. :: none

Reviewed October 25, 2026, 4:40 PM ET / 20:40 UTC (Revision 3).

…clock

The native command admission deadline in service-update-authority.ts used
Date.now() (wall clock) as the fallback for getServiceInspectionClock. Wall
clock jumps from NTP corrections or manual changes cause queued commands to
expire prematurely or hang indefinitely.

Switch to performance.now() (monotonic), aligning with every other daemon
caller and the getServiceInspectionClock default.
@SunnyShu0925
SunnyShu0925 force-pushed the fix/bug-120-daemon-service-update-authority-deadline-wall-clock branch from 8fd3db9 to dbc554c Compare October 25, 2026 05:21
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

Hi @clawsweeper, CI is green after rebasing onto main (check-prod-types and check-test-types-core-2 now pass), and I added real behavior proof exercising the shipped authority path with real systemd user native operations (queued native command across a clock step, normal elapsed-time expiry, and a before/after table). Requesting re-review.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. 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. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 25, 2026
Use the existing inspection clock default so wall-clock corrections cannot
expire or extend queued native-service commands. Preserve scoped accounting,
FIFO admission, and live authority checks.

Tighten the clock-step regression, document the elapsed-time contract, and
integrate current main. Real child-process proof reproduces premature expiry
with the old clock and successful admission with the fix.

Co-authored-by: 0668000539 <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Oct 25, 2026
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 25, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 25, 2026
@steipete
steipete merged commit 8023658 into openclaw:main Oct 26, 2026
131 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 26, 2026
…clock (openclaw#183104)

The native command admission deadline in service-update-authority.ts used
Date.now() (wall clock) as the fallback for getServiceInspectionClock. Wall
clock jumps from NTP corrections or manual changes cause queued commands to
expire prematurely or hang indefinitely.

Switch to performance.now() (monotonic), aligning with every other daemon
caller and the getServiceInspectionClock default.

Co-authored-by: 0668000539 <[email protected]>
RomneyDa added a commit that referenced this pull request Oct 28, 2026
…clock (#183104)

The native command admission deadline in service-update-authority.ts used
Date.now() (wall clock) as the fallback for getServiceInspectionClock. Wall
clock jumps from NTP corrections or manual changes cause queued commands to
expire prematurely or hang indefinitely.

Switch to performance.now() (monotonic), aligning with every other daemon
caller and the getServiceInspectionClock default.

Co-authored-by: 0668000539 <[email protected]>

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

Labels

docs Improvements or additions to documentation gateway Gateway runtime 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: XS 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