Repository navigation
fix(team-reports): keep the missed closed day when catch-up runs after midnight - #165780
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 10:47 AM ET / 14:47 UTC (Revision 2). ClawSweeper reviewWhat this changesTeam Reports retains the day before startup for its first automatic report run when that run occurs after UTC midnight. Merge readiness✅ Ready for maintainer review This PR remains useful: current main still misses the closed day in the reported scenario. The new production-worker trace resolves the previous proof request; no actionable patch defects were found. Likely related people: steipete (high-confidence routing). Priority: P2 Review scores
Verification
How this fits togetherTeam Reports collects GitHub and optional Discord activity into stored daily reports and weekly or monthly rollups. Its scheduler selects report dates and sends them through the report worker to the plugin-owned SQLite store. flowchart TD
A[Service startup] --> B[Remember prior UTC day]
C[Configured schedule] --> D[First automatic run]
B --> D
D --> E[Select missing and current days]
E --> F[Report worker collects or reuses activity]
F --> G[Stored reports and rollups]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +4, Tests +26, Docs +1. Total +31 across 3 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep catch-up date selection in the scheduler and reuse the existing worker pipeline to recover the missed day without changing startup timing or accepted reports. Do we have a high-confidence way to reproduce the issue? Yes: current-main source deterministically omits the day before startup when the first tick crosses midnight, and the contributor supplies matching before/after production-worker traces. This reviewer did not execute the scenario. Is this the best way to solve the issue? Yes: retaining the startup date repairs the scheduler's date-selection invariant while preserving the existing grace period, cadence, worker, and accepted-day reuse. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against bff90d69144c. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
…r midnight The startup catch-up moved into the first scheduled run, but that run computes yesterday from its own fire time. When the first run lands after the next UTC midnight (intraday 0 or 24, or a late-day restart with the default 4-hour cadence), the day before startup is never collected. Capture the catch-up day at start and include it in the first run.
8815a1f to
73717ad
Compare
|
Addressed the review on 8815a1f32d6, now rebased to 73717ad on main 6693bb9:
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
* commit 'c39d9b0692dbaafa5b1bfe02514c9f6411ab5546': (30 commits) fix(ci): clear MCP audit and service-worker test blockers (#166217) test(gateway): wait for steering admission in FIFO fixtures fix(llama-cpp): managed setup crashes and loops on macOS below 13.3 (#163358) perf(worktrees): avoid full session parsing during GC (#166072) fix(update): recover stopped legacy managed services (#166232) perf(gateway): stream bounded link preview metadata (#166195) perf(diagnostics): release completed Git operation state (#166214) chore(deps): update fs-safe to 0.24.1 and clone plugin source captures (#166189) feat(clients): adopt worker-local inference placement (#163647) test: serialize PowerShell completion process suites (#166229) test: stabilize release timing boundaries (#166218) refactor(sessions): persist run outcomes only; liveness comes from the run registry (#165733) test(gateway): prove mention refresh after config retargeting fix(team-reports): keep the missed closed day when catch-up runs after midnight (#165780) test(gateway): join WebChat queue admission and drain completion fix(logging): reject blank diagnostic stability query fields (#145532) fix(agents): report unparseable serialized edit arguments (#163577) improve(anthropic): log Claude Code version probe failures (#157697) fix(agents): clarify prompt-size provider failures (#159712) fix(memory): re-throw non-ENOENT/ENOTDIR errors in root memory file lookup (#107921) ...
…r midnight (openclaw#165780) The startup catch-up moved into the first scheduled run, but that run computes yesterday from its own fire time. When the first run lands after the next UTC midnight (intraday 0 or 24, or a late-day restart with the default 4-hour cadence), the day before startup is never collected. Capture the catch-up day at start and include it in the first run. Co-authored-by: yetval <[email protected]>
Summary
Team Reports can permanently skip a closed daily report after a gateway restart. If the gateway was down when day D-1 should have closed (default 00:05 UTC on day D) and it comes back late on day D, the first automatic run lands after the next UTC midnight and collects only D and D+1. Nothing ever collects D-1. Weekly and monthly rollups built from stored daily activity leave that day out.
When it triggers:
schedule.intradayEveryHoursset to 0 or 24, and any restart on day D after the closed-day slot.Before #165356 (df96d22), startup queued a catch-up 60 seconds after the restart for the day before startup.
Root cause
extensions/team-reports/src/scheduler.tsnow defers catch-up to the first scheduled tick, but works out "yesterday" from the tick's fire time instead of the startup time:nextIntradayDuecaps at the next midnight, and the closed-day slot is on the following day. So the first tick can fire on D+1, wherenow - DAY_MSis D. The day before startup (D-1) drops out of the catch-up window.Fix
Capture the catch-up day when the scheduler starts. The first run includes it when it is not already one of that run's days:
The first run still passes
reuseCollectedDays, so a day that already has an accepted closed report is reused, not collected again. Startup still triggers no report job, and the five-minute grace window and later cadence are unchanged.Why this is the right boundary
The scheduler owns choosing which days the catch-up run covers. The worker's accepted-day reuse already makes an extra day cheap when it was collected before. Manual generation, intraday ticks after the first run, and closed-day recurrence are untouched. The docs sentence on the first scheduled run now says it also covers the day before startup.
Verification
scheduler.tssince the PR opened, refactor(channels): deslop channels #165883, changed theTeamReportsHealthtype and does not overlap these lines).extensions/team-reports/src/scheduler.test.ts: two newintradayEveryHours0 and 24 cases, and the existing 23:58 restart case now expects the missed 2026-08-18 closed day. Before the rebase, the file passed with the patch and those 3 cases failed with onlyscheduler.tsreverted to main.Real behavior proof
Behavior addressed: after a restart late on day D with no closed report for D-1, the first automatic Team Reports run skips D-1 and collects only D and D+1, so that daily report is never produced.
Real environment tested: the real TeamReportsScheduler handing its run to the real TeamReportsRunner, which runs the production
extensions/team-reports/src/run.worker.tsworker thread (generateReportPeriods, GitHub source and response parsing, activity aggregation) against the real worker-backed Team Reports SQLite store, on pristine main 6693bb9 and on this branch at 73717ad. The only replaced boundary is GitHub HTTP: inside the worker,globalThis.fetchanswers api.github.com with one repo and one commit byalexin each requested day window, so no real API calls are made; the SSRF-guarded fetch path and its host policy still run. The host timer surface is stubbed so the first due task fires at its due time, and the clock is pinned to the simulated time in both threads. Summaries are disabled. The day list and report are read back from SQLite via store.listRuns() and store.getPeriod().Exact steps or command run after this patch: from the repo root, NODE_OPTIONS="--import fake-github.mjs" node_modules/.bin/tsx proof.mts 2026-10-05T21:00:00Z 4, then the same with 2026-10-05T10:00:00Z 0. The script starts the scheduler on an empty store at the given time, advances to the first scheduled task, runs it through the production report worker until the run row finishes, and prints the persisted run days and the stored 2026-10-04 day report. scheduler.ts was swapped to the main copy for BEFORE and restored for AFTER; everything else was identical.
Evidence after fix:
Observed result after fix: the first automatic run now carries 2026-10-04 into the production report worker, and a closed 2026-10-04 day report with its activity is stored. On main the same run never requests that day and no report for it exists.
What was not tested: no live GitHub or Discord API calls (GitHub HTTP answered in-process inside the worker), no full gateway process, summaries disabled, and the scoped local gates and full build were not run after the rebase.