Skip to content

fix(team-reports): keep the deferred tick retry on the elapsed clock - #186534

Merged
obviyus merged 2 commits into
openclaw:mainfrom
SunnyShu0925:fix/team-reports-deferred-retry-monotonic
Oct 28, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
SunnyShu0925:fix/team-reports-deferred-retry-monotonic

Conversation

@SunnyShu0925

@SunnyShu0925 SunnyShu0925 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

When a scheduled Team Reports tick defers behind an active run, its 60-second retry is a duration. Main submits it as atMs: Date.now() + 60_000, so a backward wall-clock correction can postpone it by the size of that correction. Calendar slots correctly remain wall-clock instants; only the deferred retry has the wrong shape.

Fix

Thanks to @SunnyShu0925 for the original report, fix and proof. Contributor commits are retained. The existing plugin schedule helper forwards { atMs } | { delayMs }; deferred retries pass the 60-second delay and inherit the real host scheduler's elapsed anchor. Closed-day/intraday calendar slots and startup grace remain absolute. No new clock helper, policy, schema, configuration or public API.

Forward-step behavior is still the host scheduler's existing minimum-of-wall-and-elapsed policy. This fix prevents backward corrections from postponing the retry; it does not promise a new forward-step policy.

Evidence

Both unpatched main 3e1e3652ff2599345668754cec60f0a4fdd8fd15 and candidate built in secretless node:24.22.1 Docker. Real built Gateways loaded the actual plugin, native report and SQLite workers, and host service scheduler. The harness retained real startup grace and calendar timers, started manual generation through the public RPC, held fixture GitHub acquisition across the calendar slot, then released it and stepped only process-local Date.now backward one hour.

  • Main: calendar tick at 304.277s; no retry within >75 seconds, manual report succeeds but no scheduled run starts.
  • Candidate: tick at 304.782s; retry at 364.733s, manual and scheduled reports persist successfully.
  • No-step controls: both revisions retry at ~60 seconds and persist both reports.
  • Focused scheduler suite: 22 passed on candidate; identical tests on main 21 passed / 1 failed because the deferred run never completes after rewind.
  • Changed-file Oxlint: 0 warnings/errors; Oxfmt applied.

The regression now extends the existing concurrency/deferred-tick case with one wall correction instead of adding a duplicate scenario. Existing lifecycle and next-calendar-slot assertions remain. Removed standalone clock scaffolding and unused scheduler fixture injection. Whole-PR delta against merge base: tests 0; production +4 lines, necessary to forward the existing two scheduler shapes and document the retry clock domain.

Full runtime proof. Acquisition is a deterministic injected healthy GitHub response; summaries are disabled. No external credentials or host/system clock changes. Proof covers real scheduling, native workers and persisted outcomes, not live GitHub reliability.

Merge Risk

Small change at the deferred-duration producer. Existing scheduler owner and service cancellation remain authoritative. No state migration; #186531's worker response-budget owner is separate.

@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. labels Oct 28, 2026
@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. 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 schedules deferred Team Reports retries as relative delays so backward wall-clock corrections cannot postpone them.

Example: A scheduled report defers behind manual collection, then the wall clock moves backward one hour.

  • Before: The 60-second retry can wait roughly 61 minutes.
  • After: The retry runs after roughly 60 elapsed seconds.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused owner-level repair with exact-head Gateway differential evidence, reported red/green regression coverage, and no open findings; broad CI remains pending.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Exact-head evidence exercises public team-reports.generate and status on isolated built Gateways with the actual plugin, host scheduler, native workers, and SQLite store: the candidate retries after approximately 60 elapsed seconds despite a one-hour backward correction and persists successful reports; baseline fails that scenario and both no-step controls succeed. Acquisition uses fixed healthy responses, so this proves scheduling rather than live GitHub reliability.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Automatic reports can be postponed by a backward clock correction after deferring behind an active run.
Reason: The narrow repair restores the existing retry duration without changing calendar slots, configuration, public APIs, or persisted state.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR fixes a current-main scheduling defect with a focused change; no actionable correctness or security findings remain.

Priority: P2
Reviewed head: 63dcbbb43a05d3205f7b45c142004a25b87bfe85

Before merge

None.

Findings

None.

Agent review details

How this fits together

Team Reports converts calendar slots and deferred collection requests into host-owned scheduled jobs, then records report outcomes through its existing workers and store.

flowchart TD
A[Calendar slot] --> B[Team Reports scheduler]
C[Active manual report] --> B
B --> D[Relative deferred retry]
D --> E[Host service scheduler]
E --> F[Report worker]
F --> G[Report store]
Loading

Technical review

Best possible solution:

Use the existing host scheduler’s delayMs contract for deferred retries while retaining absolute calendar scheduling and service-owned cancellation.

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

Current-main source establishes the absolute-deadline failure path, and the supplied built-Gateway differential confirms it; this read-only review ran no target code.

Is this the best way to solve the issue?

This is the smallest complete fix: correct the retry producer’s timing shape and reuse the existing clock and lifecycle owners without new machinery.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Team Reports deferred scheduling changes intended behavior with a stated reason (7924cf3: The merged lifetime refactor centralized cancellation and work joining in the host service scheduler while retaining absolute due times.)
  • Deferred-run lifecycle regression keeps the original intent (d3101b5: The original plugin tests protect non-overlapping collection and deferred scheduled execution; the patch retains those assertions and adds a clock rewind.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +4, Tests 0. Total +4 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 9 5 +4
Tests 1 2 2 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 11 7 +4

Review metrics

Metric Value Why it matters
Production versus test growth Production net +4 lines; tests net 0 lines The necessary growth forwards the two existing timing shapes and documents clock ownership; the regression extends an existing lifecycle case.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Backward clock corrections can delay deferred automatic reports, with limited impact on an optional reporting plugin.
  • 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 (5 earlier review cycles)
  • reviewed 2026-10-28T05:07:18.324Z sha 93da87c32caf902bac8e41b98495a17fc8448664 :: needs real behavior proof before merge. :: [P3] Remove the redundant event-loop polling from the regression
  • reviewed 2026-10-28T09:07:38.080Z sha 89098485bb5e128987fa3c791cba89ef6e47e554 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-28T11:17:28.853Z sha ad3c99b885216765f59d0ff3195138ca89ddcf85 :: needs changes before merge. :: none
  • reviewed 2026-10-28T11:25:05.210Z sha 4fadb65 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-28T11:44:57.101Z sha 4fadb65 :: needs maintainer review before merge. :: none

Reviewed October 28, 2026, 11:59 AM ET / 15:59 UTC (Revision 6).

@SunnyShu0925
SunnyShu0925 force-pushed the fix/team-reports-deferred-retry-monotonic branch from 93da87c to 8909848 Compare October 28, 2026 09:02
@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. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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
@SunnyShu0925
SunnyShu0925 force-pushed the fix/team-reports-deferred-retry-monotonic branch from 8909848 to ad3c99b Compare October 28, 2026 11:12
@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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed 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. 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 added the status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. label Oct 28, 2026
A scheduled tick that arrives while another run is collecting defers its retry
to `Date.now() + 60_000`, which the host scheduler treats as an absolute
wall-clock instant with no elapsed anchor, so a backward wall-clock correction
postpones the retry by the size of the correction. Pass `{ delayMs }` instead:
the scheduler that owns the calculation anchors relative jobs on the elapsed
clock. Calendar slots (closed day, intraday, startup grace) stay on `atMs`.
@SunnyShu0925
SunnyShu0925 force-pushed the fix/team-reports-deferred-retry-monotonic branch from ad3c99b to 4fadb65 Compare October 28, 2026 11:19
@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. labels Oct 28, 2026
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@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 status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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
@obviyus

obviyus commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Built Gateway scheduler differential

Candidate 63dcbbb43a05d3205f7b45c142004a25b87bfe85, preserving @SunnyShu0925's commits. Unpatched main baseline 3e1e3652ff2599345668754cec60f0a4fdd8fd15.

Both revisions built in secretless node:24.22.1 Docker. The actual enabled Team Reports plugin used the real host service scheduler, native report worker and SQLite store. Each isolated Gateway had its own task profile/config/state/port, confirmed by its built CLI. No system clock, native timers, or performance clock were changed.

The harness leaves the real five-minute startup grace and real calendar timer intact. Through public team-reports.generate, it starts a manual report shortly before the configured UTC closed-day slot. A task-owned injected GitHub fetch holds collection for approximately 10 seconds across that slot, then returns healthy empty activity. The scheduler's normal debug log records the calendar tick and deferred dispatch. Immediately after the tick, only that Gateway process's Date.now steps backward one hour; the manual report is released and completes successfully. We observe the actual scheduler, subsequent collection, and persisted run outcomes through team-reports.status, not replayed helpers or a fabricated scheduler.

Elapsed times from the independent driver performance clock:

revision   clock change   calendar tick    deferred dispatch   persisted runs
main       -1 hour        304.277s         none within >75s    manual ok; no scheduled run
candidate  -1 hour        304.782s         364.733s            manual ok; closed-day ok
main       none           304.745s         364.712s            manual ok; closed-day ok
candidate  none           351.375s         411.562s            manual ok; closed-day ok

The candidate dispatches the retry ~60 seconds after the tick despite the wall correction; main leaves it parked. Both ordinary-clock controls dispatch at the normal ~60-second interval and persist successful scheduled reports. GitHub responses are fixtures, summaries are disabled, and there are no external credentials. This proves scheduling/worker/store behavior, not live external-source reliability.

Regression consolidated into the pre-existing concurrent-manual/deferred-intraday lifecycle case. Its existing no-overlap, manual outcome, scheduled report and next-calendar-slot assertions remain; the only behavioral addition is a backward wall correction after the manual run completes. The existing test service scheduler uses separate Date.now/performance.now clocks; Vitest fakes both by default, and setSystemTime changes wall time without advancing performance. This removes the added standalone test, duplicate blocked-collection scaffolding, clock fixture imports and now-unused scheduler injection option.

candidate focused scheduler suite: 22 passed
main + identical regression:       21 passed / 1 failed
  deferred tick never completes after rewind (test timeout)
changed-file Oxlint:               0 warnings / 0 errors
Oxfmt:                            applied
whole-PR test delta:               0 lines
whole-PR production delta:         +4 lines

The small production growth is the existing schedule helper accepting/forwarding either absolute or relative time, a named retry duration, and a clock-domain comment. Calendar slots and startup grace remain absolute; retries reuse the host scheduler's existing relative/elapsed deadline owner. No new clock helper, scheduler policy, schema, public API or configuration. Forward-correction behavior remains the host scheduler's existing minimum-of-wall-and-elapsed contract; this repair specifically prevents backward correction from postponing retries.

Retained evidence proofs/186534/attempt-baseline-backward-JfFolj/, attempt-candidate-backward-Ik7uBR/, attempt-baseline-control-gGq4jS/, attempt-candidate-control-RS5I8X/: wire frames, real Gateway logs, network records, process-local clock receipts, persisted run statuses. Harness prove.mjs, fixture.mjs, compare.sh; tests and build logs alongside them. Pueue11473 and11474 succeeded. An earlier setup with an already-skewed bootstrap clock failed the Gateway ownership startup check and is retained separately, not counted as a product reproduction.

@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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 28, 2026
@obviyus
obviyus merged commit c3aa6e1 into openclaw:main Oct 28, 2026
108 of 112 checks passed
@obviyus

obviyus commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Landed in c3aa6e1. Thanks @SunnyShu0925. Deferred Team Reports retries now run on time after a wall-clock change.

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