Skip to content

refactor(tasks): move state notification acknowledgements off the Gateway thread - #151815

Merged
steipete merged 14 commits into
mainfrom
codex/task-state-notification-ack-20260918
Sep 21, 2026
Merged

steipete merged 14 commits into
mainfrom
codex/task-state-notification-ack-20260918

Conversation

@steipete

@steipete steipete commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Related: #151917

What Problem This Solves

State-change notifications write acknowledgments on the Gateway thread, and delayed acknowledgment can target a replacement task run.

User Impact

Acknowledgment writes use the existing state worker while preserving sent/session-queued outcomes, producing task identity, newest watermarks, and current requester origin. No configuration, schema, retention, or operator change is required.

Why This Change Was Made

Capture task receipt and event before preparation/transport yields, revalidate the original run before persistence, and retain separate best-effort watermark/timestamp transactions. Join already-started acknowledgment work during cleanup without replaying committed writes.

This remains the parent of the coordinated two-PR sequence. Complete Terminal candidate 8964be4e0d9dbebee0ae80f35945482b1f1f3162 contains terminal persistence and asynchronous preparation; keep it queued and verified before this parent lands, then land the child.

Evidence

ACK 6d32972d295dd1eb2dacccf3ae9b3f889ccc7abb, tree 96d793758790101c921d15dbc1a6f32dd705a7fe, merges the qualified public ACK with pinned main 6d65c8b7f229641bf9b32e16da2c0fec1b64079f. The automatic merge is clean, with exact ordered additions/removals preserved across all 29 feature files. The previous ACK qualification remains attributed to its source: P2 clean and 77 intersection cases across three files passed in 119.50 seconds. Complete Terminal has separate reader review, targeted checks and compiled proof on its production-identical predecessor 0155; those complete-caller results are not a standalone ACK claim.

This PR qualifies worker-backed acknowledgment writes, not zero SQLite calls across the complete notification caller. Complete-caller Node/Bun measurements belong to the composed Terminal candidate; historical measurements retain their original source bindings. The complete Terminal candidate stays queued before ACK landing. Existing public history and the original two-PR dependency remain intact; hosted exact-union CI and native current-main admission remain pending.

@clawsweeper

clawsweeper Bot commented Sep 18, 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 size: XL maintainer Maintainer-authored PR labels Sep 18, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Sep 18, 2026
@clawsweeper

clawsweeper Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed September 21, 2026, 3:02 PM ET / 19:02 UTC (Revision 10).

ClawSweeper review

What this changes

Moves task-notification acknowledgment writes into the existing database worker while preserving the originating run, delivery watermark, and cleanup settlement.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep open: current main and the latest release still need this repair. Prior findings are resolved, and the reviewed diff has no new blocking correctness defect.

Priority: P2
Reviewed head: 6d32972d295dd1eb2dacccf3ae9b3f889ccc7abb

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent worker cutover with focused concurrency coverage and resolved prior findings; the recorded coordinated landing order remains applicable.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER association exempts this internal PR from the external-contributor proof gate. Its acknowledgment tests are supplemental; the child’s compiled complete-caller measurements remain bound to that child and are not standalone parent proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER association exempts this internal PR from the external-contributor proof gate. Its acknowledgment tests are supplemental; the child’s compiled complete-caller measurements remain bound to that child and are not standalone parent proof.
Evidence reviewed 10 items Pinned change ownership: Reviewed the introduced delta from 6d65c8b to the exact head. Raw head parents match the supplied original-head record. The supplied test merge is stale and was not used to infer removal of current-main behavior.
Current main still needs the repair: Current main accepts a task ID and synchronously acknowledges whichever task currently occupies that ID through delivery-state upsert and task update.
Latest-release comparison: The v2026.9.5 source also contains the synchronous acknowledgment helper and delivery-state upsert; this repair is not already present in the supplied latest release.
Findings None None.
Security None None.

How this fits together

The task registry turns background-task events into channel messages or queued session notifications. After delivery, acknowledgment records prevent repeated notifications and update the task’s activity timestamp.

flowchart TD
  A[Background task event] --> B[Capture task and event identity]
  B --> C[Prepare notification]
  C --> D[Channel send or session queue]
  D --> E[Database worker acknowledgment]
  E --> F[Recheck current ownership and task run]
  F --> G[Persist watermark and timestamp]
  G --> H[Publish committed task state]
Loading

Before merge

  • Complete next step (P2) - Preserve the recorded landing sequence: keep the verified complete Terminal child queued before merging this parent, then land the child.
Agent review details

Security

None.

PR surface

Source +342, Tests +732, Docs +10. Total +1084 across 29 files.

View PR surface stats
Area Files Added Removed Net
Source 16 546 204 +342
Tests 12 798 66 +732
Docs 1 10 0 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 29 1354 270 +1084

Review metrics

Metric Value Why it matters
Production versus test growth Production +342 net lines; tests and test support +731 Production growth implements worker dispatch and retained notification ownership; most added coverage exercises persistence and lifecycle interleavings.

Technical review

Best possible solution:

Use the existing worker and publication owners for acknowledgments, with the coordinated child completing notification preparation and terminal persistence.

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

Yes, from source: current main acknowledges by task ID after delivery waits, permitting a replacement run to receive the old acknowledgment, and performs those writes synchronously. No runtime reproduction was executed here.

Is this the best way to solve the issue?

Yes. Reusing the existing worker, admission, and publication owners is a focused repair, and the coordinated child explicitly owns the remaining synchronous notification work.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded task-notification reliability and Gateway responsiveness repair without evidence of an urgent widespread outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied MEMBER association exempts this internal PR from the external-contributor proof gate. Its acknowledgment tests are supplemental; the child’s compiled complete-caller measurements remain bound to that child and are not standalone parent proof.

Evidence

What I checked:

  • Pinned change ownership: Reviewed the introduced delta from 6d65c8b to the exact head. Raw head parents match the supplied original-head record. The supplied test merge is stale and was not used to infer removal of current-main behavior. (6d32972d295d)
  • Current main still needs the repair: Current main accepts a task ID and synchronously acknowledges whichever task currently occupies that ID through delivery-state upsert and task update. (src/tasks/task-registry-delivery.ts:551, b485dd0b988f)
  • Latest-release comparison: The v2026.9.5 source also contains the synchronous acknowledgment helper and delivery-state upsert; this repair is not already present in the supplied latest release. (src/tasks/task-registry-delivery.ts:547, ec9c1a13db89)
  • Worker acknowledgment invariants: Each acknowledgment stage rereads the task, checks the captured run scope, and checks current admission before writing. The watermark uses the maximum persisted/event value and preserves the current requester origin; watermark and timestamp transactions remain separately best effort. (src/tasks/task-notification.operation.ts:74, 6d32972d295d)
  • Retained ownership and settlement: The notification owner captures the existing database/store context, revalidates it after waits, registers pending acknowledgment custody before yielding, and joins already-started writes after preparation failure. The existing worker broker validates the operation and task before granting transaction admission. (src/tasks/task-notification-mutation.async.ts:26, 6d32972d295d)
  • Prior findings remain resolved: Production callers pass their producing task receipt, and the entry point captures task/event identity before preparation yields. Test fixtures join captured notification promises instead of polling global work counts. These files are unchanged from the previous reviewed head. (src/tasks/task-registry-delivery.test-support.ts:25, 6d32972d295d)

Likely related people:

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

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.

History

Review history (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-20T11:26:26.194Z sha cd0f00d :: needs real behavior proof before merge. :: [P2] Capture the producing task before waiting for acknowledgements
  • reviewed 2026-09-20T21:41:10.817Z sha 125d471 :: needs changes before merge. :: [P3] Join notification completion instead of polling global work counts
  • reviewed 2026-09-20T22:42:10.759Z sha 125d471 :: needs changes before merge. :: [P3] Join notification completion instead of polling global work counts
  • reviewed 2026-09-21T00:16:15.014Z sha 36fd2a9 :: needs changes before merge. :: [P3] Join notification completion instead of polling global work counts
  • reviewed 2026-09-21T00:44:45.128Z sha 32424a8 :: needs changes before merge. :: none
  • reviewed 2026-09-21T09:48:54.769Z sha 6c5ff27 :: needs changes before merge. :: none
  • reviewed 2026-09-21T11:06:43.683Z sha 6c5ff27 :: needs changes before merge. :: none
  • reviewed 2026-09-21T16:18:16.922Z sha 153b3a3 :: needs changes before merge. :: none

@steipete
steipete force-pushed the codex/task-active-terminal-20260918 branch from d5cdb89 to 057207f Compare September 20, 2026 10:29
Base automatically changed from codex/task-active-terminal-20260918 to main September 20, 2026 11:18
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime cli CLI command changes scripts Repository scripts agents Agent runtime and tooling labels Sep 20, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed 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. labels Sep 20, 2026
Retain the producing task identity through delivery and acknowledgement, preserve monotonic watermarks and requester origins, and settle queued acknowledgements through cleanup. Carry current registry batching and the canonical lineage fixture fence.

Private qualification checkpoint for #151815. Current main has an unresolved TS2345 in update-triage-resolution.ts; publication remains pending its canonical repair.
Preserve the reviewed acknowledgement patch and current task event preparation and publication owners. Include the canonical formatter arity repair from main; all three previously blocked type graphs now pass.
Preserve the acknowledgement feature unchanged while incorporating the landed identifier fixture correction and current filesystem dependency owner. Current core and affected test type graphs pass.
@steipete
steipete force-pushed the codex/task-state-notification-ack-20260918 branch from cd0f00d to 125d471 Compare September 20, 2026 21:25
@openclaw-barnacle openclaw-barnacle Bot removed app: web-ui App: web-ui gateway Gateway runtime cli CLI command changes scripts Repository scripts labels Sep 20, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the agents Agent runtime and tooling label Sep 20, 2026
@clawsweeper clawsweeper Bot added 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 rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 20, 2026
@steipete
steipete marked this pull request as ready for review September 20, 2026 22:35
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 21, 2026
@clawsweeper clawsweeper Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 21, 2026
@steipete steipete closed this Sep 21, 2026
@steipete steipete reopened this Sep 21, 2026
@steipete
steipete merged commit c88e73d into main Sep 21, 2026
214 checks passed
@steipete
steipete deleted the codex/task-state-notification-ack-20260918 branch September 21, 2026 20:50
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Sep 21, 2026
Join real task-delivery promises before the maintenance fixtures close SQLite. Observing queued system events does not imply worker-backed acknowledgements have settled; retain the existing delivery owner and propagate failures.

Repairs CI run 35661057519 job 106536622445 after #151815. All 48 maintenance, delivery-lifetime, and state-notification tests pass (44.21s wrapper); selected agents-other type graph, formatting, lint, and independent P2 review pass. The local baseline passed and does not erase the observed hosted race.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 22, 2026
…eway thread (openclaw#151815)

* fix(tasks): persist state notification acknowledgements in worker

Retain the producing task identity through delivery and acknowledgement, preserve monotonic watermarks and requester origins, and settle queued acknowledgements through cleanup. Carry current registry batching and the canonical lineage fixture fence.

Private qualification checkpoint for openclaw#151815. Current main has an unresolved TS2345 in update-triage-resolution.ts; publication remains pending its canonical repair.

* test(tasks): join event retirement before leak checks

* test(tasks): join native notification fixture deliveries
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 22, 2026
Join real task-delivery promises before the maintenance fixtures close SQLite. Observing queued system events does not imply worker-backed acknowledgements have settled; retain the existing delivery owner and propagate failures.

Repairs CI run 35661057519 job 106536622445 after openclaw#151815. All 48 maintenance, delivery-lifetime, and state-notification tests pass (44.21s wrapper); selected agents-other type graph, formatting, lint, and independent P2 review pass. The local baseline passed and does not erase the observed hosted race.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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.

1 participant