Repository navigation
fix(cron): deliver and record primary webhook outcomes - #117783
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed August 2, 2026, 1:23 AM ET / 05:23 UTC. ClawSweeper reviewWhat this changesMoves primary cron webhook delivery into the tracked cron-run lifetime, records delivered or failed outcomes before finalization, and leaves only completion-destination webhooks on detached fanout. Merge readiness⛔ Blocked until real behavior proof is added - 3 items remain Keep this PR open for human merge review. The source-backed repair correctly targets a real silent-delivery path, and the latest commit addresses the previously reported cancellation and trigger-state cases, but the PR still lacks inspectable after-fix real HTTP evidence for the integrated Gateway path. Likely related people: @steipete (high), @mbelinky (medium), and @advaitpaliwal (medium). Priority: P1 Review scores
Verification
How this fits togetherGateway cron executes command, script, or agent jobs, records a terminal run and delivery state, then emits a finished event. On current main, webhook-mode delivery is dispatched after that event; this PR makes the primary webhook part of the owned run while retaining detached secondary completion notifications. flowchart LR
Job[Scheduled cron job] --> Execute[Execute command or agent payload]
Execute --> Primary[Primary webhook delivery]
Primary --> Record[Persist delivery outcome]
Record --> Event[Finished cron event]
Event --> Secondary[Detached completion notification]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +346, Tests +631. Total +977 across 17 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep primary webhook delivery and its terminal record in the cron-run owner, keep only explicit completion destinations detached, and attach redacted integrated HTTP proof showing the persisted run state and receiver result before merge. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible. Current main resolves webhook-mode jobs for detached finished-event delivery while the run-state projection records the requested webhook as unknown before the detached result is available. Is this the best way to solve the issue? Yes in design: making primary webhook delivery part of the run owner is the narrowest way to make delivery and history agree, while retaining detached fanout only for completion destinations. Real integrated evidence is still required before merge. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 03c28795f8c6. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
1205ce4 to
7674061
Compare
b43a410 to
0b340e2
Compare
0b340e2 to
b1d9f14
Compare
|
Merged via squash.
|
* fix(cron): record primary webhook delivery * fix(cron): preserve accepted webhook delivery
What Problem This Solves
Cron jobs configured with
--webhookcould complete successfully, produce their payload, deliver nothing, and recorddeliveryStatus: "unknown"— a silent failure indistinguishable from success in run history.Reproduced on the production team host (dist 120fa5d): a command job with a webhook target fired twice on schedule, both runs
status: okwith the payload insummary, zero POSTs observed,deliveryStatus: "unknown"recorded. Both command jobs and isolated agent jobs were affected.docs/cli/cron.mdexplicitly promises command jobs "route output through the sameannounce,webhook, ornonedelivery modes".Why This Change Was Made
The root cause was split ownership. Command execution only handled announce delivery (
server-cron.ts); webhook mode returneddelivered: falsewithout sending. Cron then finalized state/history, converting that into terminal"unknown"(timer-trigger.ts). Only afterwards did the gateway dispatch a detached webhook from the finished event, whose errors were logged and swallowed — they could never repair the already-persisted history. (For loopback URLs specifically, the SSRF guard correctly rejects private addresses — that boundary is intentional and unchanged; the bug was that the rejection, like every other delivery failure, vanished into"unknown".)Provenance: not a recent regression. Command jobs plus their webhook docs arrived together in #89712 (author @mbelinky, merged by Vincent Koc) already relying on the detached path; per-job webhook delivery originated in #17901 (author Advait Paliwal, merged by Tyler Yust); #116923 later made the unobserved state explicitly
unknownwithout adding reconciliation.The fix makes primary webhook delivery a recorded part of the cron run:
not-delivered/timeout, and operator cancellation interrupts an in-flight send immediately (both proven with real-HTTP regressions; review round 2 required this).not-deliveredby a late cancellation (review round 3).delivered; HTTP, timeout, secret-owner, invalid-target, and SSRF failures recordnot-deliveredplus a concretedeliveryError.unknownis no longer the terminal state for a configured webhook.completionDestinationwebhooks, preventing double POSTs.No announce/channel behavior, Discord code, config surface, or schema changed.
User Impact
Webhook-configured jobs now actually deliver, and every outcome is honestly recorded:
deliveredon success,not-deliveredwith the concrete error otherwise — including the previously invisible SSRF-blocked case. Runs finalize within their configured deadline even against dead endpoints, and shutdown/cancellation cannot strand a run in delivery.Evidence
delivered; 503 → one POST,not-deliveredwithHTTP 503; hanging endpoint → finalized at the job deadline, command result preservedok, deliverynot-delivered/timeout; cancellation mid-hang → finalized in under a second with the cancellation reason; accepted-POST-then-cancel race → staysdelivered; trigger-evaluates-false → not-requested status, no deliveryError; isolated-agent webhook sibling →delivered.node scripts/run-vitest.mjs src/cron: 160 files, 1,934 tests passed. Gateway webhook/cron suites: 113 passed. Timeout/watchdog regressions: 69/69.git diff --check.gpt-5.6-sol, high): three review rounds surfaced an abort-scope escape, a settled-delivery cancellation race, and the trigger-not-fired mapping — each fixed with regressions; final round clean, "patch is correct" (0.86).Production delta net +311 (delivery moved into the run lifecycle with signal/deadline plumbing — an ownership move, not a patch); tests net +541.