Skip to content

fix(team-reports): keep the worker response budget on the monotonic clock - #186531

Merged
obviyus merged 2 commits into
openclaw:mainfrom
SunnyShu0925:fix/team-reports-run-worker-response-budget-monotonic
Oct 28, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
SunnyShu0925:fix/team-reports-run-worker-response-budget-monotonic

Conversation

@SunnyShu0925

@SunnyShu0925 SunnyShu0925 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A Team Reports generation can fail with worker task timed out after a forward wall-clock correction while a report worker awaits its host response. The runner computes a remaining elapsed budget from Date.now, while the existing worker pool measures it with performance.now. A +2-hour correction collapses the response budget to 1 ms despite a healthy model response.

Fix

Thanks to @SunnyShu0925 for the original fix and report; the contributor commit is preserved. Both private runner deadline reads now use performance.now, matching WorkerTaskPool. The 45-minute ceiling, epoch reporting, scheduling, protocol, storage and configuration stay unchanged. No new helper or SDK export.

The new regression is consolidated into the existing completion/SQLite lifecycle table, preserving both cancellation/settlement cases. A native setImmediate promise replaces the manual MessageChannel turn-drain helper. Test mocks and timers are restored after each case. Whole-PR delta against merge base: production 0; tests −1 line.

Evidence

  • Both main 15b2d6594ed2292e139c7c65571f8fbb141c9009 and candidate built in secretless node:24.22.1 Docker.
  • Real built Gateway, actual enabled plugin, native report and SQLite workers; public team-reports.generate, status, and get operations. Main +2-hour wall step fails with worker timeout twice; candidate succeeds twice. No-step controls succeed twice each. All six successful runs store valid model-source summaries. Deterministic local model HTTP provider and injected healthy GitHub response; no external credentials or system-clock changes.
  • Same focused tests: main 2 passed / 1 regression failed; candidate 3 passed. Oxlint 0 warnings/errors; Oxfmt applied.
  • Full wire/provider/stored-result proof.

Merge Risk

Two clock substitutions at the duration producer; no persisted state or public contract changes. The separate deferred scheduler retry owner remains in #186534. Proof does not claim live external-provider reliability or a real host NTP adjustment.

…lock

TeamReportsRunner seeded its 45-minute run deadline with Date.now() and
reported the remaining response budget from the same wall clock, while
WorkerTaskPool arms that budget from performance.now(). A forward
wall-clock step collapsed the remaining budget to the 1 ms floor and
cancelled a healthy worker response, so the report run failed with
"worker task timed out".

Stepping only Date.now() forward two hours during a report request makes
main hand the pool 1 ms and reject; the monotonic deadline keeps
2,699,180 ms and the run resolves.
@clawsweeper

clawsweeper Bot commented Oct 28, 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 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. 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 clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 28, 2026
@clawsweeper

clawsweeper Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR uses performance.now() for Team Reports worker response budgets and adds a clock-step regression to the existing lifecycle tests.

Example: The Gateway wall clock advances two hours while a report worker awaits a model response.

  • Before: The remaining response budget collapses to 1 ms, causing worker task timed out.
  • After: The response retains its elapsed-time budget and the report completes successfully.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A minimal, complete repair with shipped-entry-point differential evidence, preserved lifecycle assertions, and no actionable finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The exact candidate is exercised through a built Gateway's public Team Reports operations with native report and SQLite workers, a local HTTP model provider, and a Gateway-only two-hour wall-clock step; baseline generation times out while candidate generation stores valid model summaries, twice per scenario. Supplied focused results also show the regression red on baseline and green on candidate. Inspected account-UI screenshots are unrelated and were not counted.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Healthy Team Reports generation can fail after a forward host-clock correction.
Reason: Elapsed-time budgets should survive wall-clock corrections, and this repair restores that behavior without adding configuration or changing report semantics.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR fixes a current Team Reports timeout defect with a minimal repair and convincing Gateway evidence; no actionable defect was found.

Priority: P2
Reviewed head: aacf93bcf3243cc9f4bf4da3fdb011c8c2b61752

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Team Reports scheduler submits generation to a worker through TeamReportsRunner, which handles host-side storage and model requests and supplies their remaining response budget.

flowchart LR
A[Report generation request] --> B[Team Reports scheduler]
B --> C[TeamReportsRunner]
C --> D[WorkerTaskPool]
D --> E[Report worker]
E --> F[Host storage or model request]
F --> C
B --> G[Stored report outcome]
Loading

Technical review

Best possible solution:

Use the existing runner's monotonic clock for both response-budget calculations while retaining pool deadline enforcement and lifecycle coverage.

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

Current-main source establishes the clock mismatch, and supplied Gateway output demonstrates matching baseline failures and candidate successes; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The two clock substitutions repair the duration producer directly, preserve the original worker architecture, and leave calendar scheduling and persisted timestamps with their existing owners.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Worker response deadline keeps the original intent (9dc8955: Move collection off the Gateway event loop while preserving bounded execution and report results.)
  • Worker lifecycle regression coverage keeps the original intent (6e23cf0: Preserve native cancellation and settlement of admitted SQLite and model work while removing inert lifetime plumbing.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 9dc8955 adds extensions/team-reports/src/run-worker.ts:11 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9dc89550610b; files: extensions/team-reports/src/run-worker.ts)

PR surface

Source 0, Tests -1. Total -1 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 2 2 0
Tests 1 14 15 -1
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 16 17 -1

Review metrics

Metric Value Why it matters
Production versus test LOC Production +2/-2; tests +14/-15 The complete repair adds no production machinery and consolidates the distinct clock-step regression into existing lifecycle coverage.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: A forward wall-clock correction can abort otherwise healthy Team Reports generation; the affected plugin workflow has limited blast radius.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster 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 (1 earlier review cycle)
  • reviewed 2026-10-28T05:03:22.162Z sha 5649a1d :: needs maintainer review before merge. :: none

Reviewed October 28, 2026, 10:52 AM ET / 14:52 UTC (Revision 2).

@obviyus

obviyus commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Built Gateway proof — real Team Reports generation

Candidate aacf93bcf3243cc9f4bf4da3fdb011c8c2b61752 retains @SunnyShu0925's production commit. Main baseline 15b2d6594ed2292e139c7c65571f8fbb141c9009.

Both revisions installed and built successfully in secretless node:24.22.1 Docker. The actual enabled Team Reports plugin initialized its real SQLite worker and report worker. An authenticated-protocol operator connection invoked shipped team-reports.status, team-reports.generate({period:'day',date:'2026-10-26'}), and team-reports.get. The driver polls persisted run status, not private runner helpers.

GitHub acquisition uses an explicitly injected fetch fixture (empty repository list, healthy source status); the genuine summary-model HTTP request goes to a local streaming OpenAI-compatible provider. That provider arms a Gateway-only +2-hour Date.now offset before returning a valid summary. Performance.now and system/host clocks are unchanged; report-worker computation and SQLite transport remain real. No GitHub/Discord/provider credentials were used. Each run has fresh task-only profile, state, workspace and config; the built CLI confirms the config path before Gateway startup.

Final differential, twice per row:

revision    clock step     persisted run result       model HTTP requests
main        +2 hours       error: worker task timed out  1
candidate   +2 hours       ok                            1
main        none           ok                            1
candidate   none           ok                            1

All six successful runs returned stored report documents with summary.source: model and the supplied member summary; healthy GitHub collection had no warnings. Main's forward-step failures happened after the real summary request returned, not during setup. This demonstrates the user-visible generate operation, host callback response budget, native worker transport and stored outcome end to end.

Focused regression after consolidation into the existing lifecycle table:

main:      2 passed / 1 failed (clock step: worker task timed out)
candidate: 3 passed

Completion and committed-SQLite cancellation/cleanup assertions remain. A native setImmediate promise replaces the hand-written MessageChannel turn-drain helper. The wall-step regression deliberately fakes only setTimeout/clearTimeout and spies Date.now; performance remains native to isolate the faulty wall-derived response duration. It does not pretend advancing fake timers also advances monotonic time. All mocks and real timers are restored after each case.

Targeted Oxlint: 0 warnings/errors; Oxfmt applied. Simplification: production remains the contributor's minimal two clock substitutions (net0); tests net −1 against merge base (rather than +52). No public API, config, scheduling policy, storage, or 45-minute timeout change. #186534's scheduler retry is separate.

Final proof Pueue11451 succeeded. Logs/wire frames/provider requests/config paths/stored reports: proofs/186531/attempt-baseline-{control-vUTjWO,control-OV8ZHh,forward-Z2Qciz,forward-uY5ffJ}/ and attempt-candidate-{control-1SW6hQ,control-wrHwwh,forward-TBqvxf,forward-SH8KoH}/. Harness prove.mjs, fixture.mjs, compare.sh; focused tests-{baseline,candidate}.log, lint.log; build logs retained. Earlier setup probes and invalid-summary fixture attempts are not counted in the final table. Limits: scripted external acquisition/model, no live GitHub/Discord or real NTP adjustment.

@obviyus

obviyus commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 28, 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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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 28, 2026
@obviyus
obviyus merged commit 3e1e365 into openclaw:main Oct 28, 2026
119 of 124 checks passed
@obviyus

obviyus commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Landed in 3e1e365. Thanks @SunnyShu0925. Team Reports workers no longer time out when the wall clock jumps.

obviyus added a commit that referenced this pull request Oct 28, 2026
…186534)

fix(team-reports): keep the scheduler's deferred retry on the monotonic clock

When a scheduled Team Report was deferred behind a manual collection, the scheduler timed the retry with Date.now. If the wall clock moved back, the retry stayed parked far past its 60 s delay. The retry now uses performance.now, as the runner's reply budget does since #186531.

Evidence: real built Gateway with the Team Reports plugin, the host scheduler and native report and SQLite workers. After a real calendar tick was deferred behind a manual collection, Date.now was rewound one hour inside the process only. Main's retry stayed parked beyond 75 s; with this change it dispatched after 59.95 s and stored a successful scheduled report. No-step controls dispatched at about 60 s and succeeded on both refs. Details: #186534 (comment).

Thanks @SunnyShu0925.

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

fix(team-reports): keep the report worker's reply budget on the monotonic clock

The Team Reports runner measured the time left for a worker reply with Date.now, so a forward wall-clock step made a healthy report worker time out. The budget now uses performance.now, as the other extension budgets have since the openclaw#186484 sweep.

Evidence: real built Gateway with the Team Reports plugin enabled, native report and SQLite workers, and a local HTTP summary provider. With Date.now stepped forward 2 hours inside the process only, main failed with "worker task timed out" (twice); with this change the reports succeeded (twice). No-step controls succeeded twice on each ref, and all successful runs stored valid summaries. Details: openclaw#186531 (comment).

Thanks @SunnyShu0925.

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

fix(team-reports): keep the scheduler's deferred retry on the monotonic clock

When a scheduled Team Report was deferred behind a manual collection, the scheduler timed the retry with Date.now. If the wall clock moved back, the retry stayed parked far past its 60 s delay. The retry now uses performance.now, as the runner's reply budget does since openclaw#186531.

Evidence: real built Gateway with the Team Reports plugin, the host scheduler and native report and SQLite workers. After a real calendar tick was deferred behind a manual collection, Date.now was rewound one hour inside the process only. Main's retry stayed parked beyond 75 s; with this change it dispatched after 59.95 s and stored a successful scheduled report. No-step controls dispatched at about 60 s and succeeded on both refs. Details: openclaw#186534 (comment).

Thanks @SunnyShu0925.

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

P2 Normal backlog priority with limited blast radius. plugin: team-reports proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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