Skip to content

Stop re-sending task-failure push notifications after every Gateway restart - #158035

Closed
Sanjays2402 wants to merge 1 commit into
openclaw:mainfrom
Sanjays2402:fix/webpush-task-failure-replays-156888
Closed

Sanjays2402 wants to merge 1 commit into
openclaw:mainfrom
Sanjays2402:fix/webpush-task-failure-replays-156888

Conversation

@Sanjays2402

Copy link
Copy Markdown
Contributor

Every Gateway restart was re-sending "task failed" push notifications for background tasks that had already failed long ago. The restore path re-projects retained failed records through the task registry observers, the subscription layer rebroadcasts them as task/upserted, and the Web Push classifier could not tell a re-projection from a fresh failure. Tasks with a silent notify policy were also notifying, which defeats the point of the policy.

What this changes:

  • server-task-subscriptions.ts now marks the broadcast payload with becameFailed when the upsert actually transitions a task into failed/timed_out, computed from the observer's previous record. Restore replays and retention no-ops (previous already terminal) do not get the flag.
  • The payload also carries the task's notifyPolicy. It is intentionally kept out of the public TaskSummary schema.
  • event-web-push.ts only sends the failure push when becameFailed is set, and skips tasks whose policy includes "silent".

Task UI updates are untouched, and broadcast/observer retry semantics are unchanged.

Fixes #156888

Testing: added regression cases in event-web-push.test.ts covering a re-projected failed task (no push), a silent-policy failure (no push), and a genuine transition into failure (push still sent). The two existing task-failure cases now carry the new flag. I verified the decision logic with a standalone repro of the exact conditions since the full vitest harness would not start on my machine, so a CI run is appreciated.

Restore replays and retention no-ops re-project already-failed task
records, and each re-projection was sending a duplicate 'task failed'
push after every Gateway restart. The task subscription layer now marks
upserts that actually transition into failed/timed_out with becameFailed
and carries the task notifyPolicy on the broadcast payload; the Web Push
classifier only notifies on that transition and skips silent-policy
tasks. Fixes openclaw#156888.
@clawsweeper

clawsweeper Bot commented Sep 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 triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. gateway Gateway runtime size: S labels Sep 25, 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. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. 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. labels Sep 25, 2026
@clawsweeper

clawsweeper Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 25, 2026, 5:56 AM ET / 09:56 UTC.

ClawSweeper review

What this changes

The branch marks task failure transitions in Gateway events and uses that marker and a task notification policy to decide whether Web Push sends a failure alert.

Merge readiness

⛔ Blocked before merge - 4 items remain

The restart replay guard addresses the reported duplicate notification path, but the silent-policy guard cannot match the policy value that the Gateway publishes. The linked issue remains open, and this PR needs that correction and real behavior proof before merge.

Priority: P2
Reviewed head: 7b9a1b7fa2a040bb678e4db93c01017239bab860

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The transition guard is focused, but the silent-policy contract mismatch and absence of observed production-path recovery keep the PR below merge readiness.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The changed Gateway subscription and Web Push classifier are covered by injected-event tests and an asserted standalone decision-logic repro, but no supplied observation shows an after-fix restart replay and fresh failure through the production publication path. A redacted Gateway-to-Web-Push trace would address the gap; redact private endpoints, device identifiers, and credentials before posting it. Updating the PR body should trigger a fresh review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The changed Gateway subscription and Web Push classifier are covered by injected-event tests and an asserted standalone decision-logic repro, but no supplied observation shows an after-fix restart replay and fresh failure through the production publication path. A redacted Gateway-to-Web-Push trace would address the gap; redact private endpoints, device identifiers, and credentials before posting it. Updating the PR body should trigger a fresh review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 8 items Introduced failure guard: The introduced Web Push guard checks whether notifyPolicy is an array containing silent.
Actual notification policy contract: TaskNotifyPolicy is a string union that includes silent; the subscription broadcasts event.task.notifyPolicy directly.
Broadcast producer: The Gateway places the task's scalar notifyPolicy in its task event payload.
Findings 1 actionable finding [P2] Compare the published scalar notification policy
Security None None.

How this fits together

The task registry sends task changes to Gateway subscriptions, which broadcast task events. Web Push classifies those events and sends alerts to eligible subscribed browsers.

flowchart LR
  A[Task registry change] --> B[Gateway task subscription]
  B --> C[Task event with transition and policy]
  C --> D[Web Push classification]
  D --> E[Eligible browser subscriptions]
  E --> F[Failure alert]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The changed Gateway subscription and Web Push classifier are covered by injected-event tests and an asserted standalone decision-logic repro, but no supplied observation shows an after-fix restart replay and fresh failure through the production publication path. A redacted Gateway-to-Web-Push trace would address the gap; redact private endpoints, device identifiers, and credentials before posting it. Updating the PR body should trigger a fresh review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Compare the published scalar notification policy (P2) - The task registry defines notifyPolicy as a string, and the Gateway broadcasts that string directly. Array.isArray(value.notifyPolicy) is therefore false for a real silent task, so the alert still sends. Compare with "silent" and make the regression fixture use that production value.
  • Resolve merge risk (P1) - The added tests inject task events directly into Web Push; they do not establish that a restart replay is suppressed while a fresh failure still sends through the registry and Gateway subscription boundary.
  • Complete next step (P2) - Fix the scalar silent-policy guard and its test fixture, then add redacted after-fix proof of replay suppression and fresh-failure delivery.

Findings

  • [P2] Compare the published scalar notification policy — src/gateway/event-web-push.ts:103-104
Agent review details

Security

None.

PR surface

Source +33, Tests +41. Total +74 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 36 3 +33
Tests 1 41 0 +41
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 77 3 +74

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #156888
Summary: The PR explicitly targets the linked restart replay report, but its silent-policy portion remains defective.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Repair the policy check and prove the event path (recommended)
    Compare the published scalar policy with silent, correct the test fixture, and show that restore replays stay quiet while fresh failures notify.

Technical review

Best possible solution:

Use the registry's scalar notification policy when classifying Web Push events, and verify replay suppression and fresh-failure delivery through the task publication boundary.

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

Yes, from source: the Gateway publishes notifyPolicy as a string, while the new Web Push guard accepts only an array. The read-only review did not execute a Gateway restart.

Is this the best way to solve the issue?

No. Transition metadata is a plausible narrow repair for restart replays, but the policy comparison and its fixture must use the actual task event contract.

Full review comments:

  • [P2] Compare the published scalar notification policy — src/gateway/event-web-push.ts:103-104
    The task registry defines notifyPolicy as a string, and the Gateway broadcasts that string directly. Array.isArray(value.notifyPolicy) is therefore false for a real silent task, so the alert still sends. Compare with "silent" and make the regression fixture use that production value.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add merge-risk: 🚨 message-delivery: The introduced policy check fails to suppress alerts for tasks whose notification policy is silent.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.

Label justifications:

  • P2: The patch addresses a limited-scope notification bug but leaves silent tasks able to generate failure alerts.
  • merge-risk: 🚨 message-delivery: The introduced policy check fails to suppress alerts for tasks whose notification policy is silent.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The changed Gateway subscription and Web Push classifier are covered by injected-event tests and an asserted standalone decision-logic repro, but no supplied observation shows an after-fix restart replay and fresh failure through the production publication path. A redacted Gateway-to-Web-Push trace would address the gap; redact private endpoints, device identifiers, and credentials before posting it. Updating the PR body should trigger a fresh review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Correct the silent-policy comparison and fixture to use the registry's string value.
  • Provide a redacted after-fix Gateway/Web Push trace showing a restart replay stays quiet and a new failure sends.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper

clawsweeper Bot commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: Stop re-sending task-failure push notifications after every Gateway restart This is item 1/3 in the current shard. Shard 21/81.

This temporary status tracks the active review worker. The completed review will appear in the durable ClawSweeper review comment.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@obviyus

obviyus commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

Thanks @Sanjays2402 for working on this. #159179 has since removed the Tasks/TaskFlow runtime from main, so the code path this PR fixes no longer exists. On main at 00f3a206302, the task subscriptions and src/tasks are gone. The current Web Push classifier returns no notification for every failed or timed-out task event, including the becameFailed case, so the restart-replay push can't occur. Closing as superseded by #159179. (#156989 was closed for the same reason.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Web Push re-sends "background task failed" for an already-failed subagent task on every gateway restart

2 participants