Skip to content

fix(exec): acknowledge polled completions - #138188

Merged
steipete merged 3 commits into
mainfrom
codex/automation-completion-cleanup
Sep 4, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/automation-completion-cleanup

Conversation

@steipete

@steipete steipete commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Terminal !poll and process.poll must acknowledge a completion only after their result has reached its owner. The chat command originally left the occurrence queued; its first repair removed it too early, before final delivery. The process tool had the same early-acknowledgement defect before transcript persistence. A cancelled send, transport error or failed append could therefore discard the pending notification.

This revision acknowledges the exact captured process receipt after successful final delivery or tool-result persistence. Cancellation, deferred finalization failure, untracked custom dispatchers and failed transcript appends retain it. Late notifications use the same acknowledgement owner, repeated polling remains harmless, and unrelated completions survive. It also removes redundant process routing fields and duplicate heartbeat settlement branches, retaining the shipped SDK option declarations.

Related: #135933. This is a prerequisite cleanup; full exec admission and heartbeat retirement remain separate.

Scope and risk

No database schema, migration, stored representation, configuration/default, or Gateway protocol change. Existing completion routing, cadence, retry, suppression and recovery policies are preserved. Private payload metadata carries the delivery acknowledgement; no callback is serialized on the wire.

Production +116/−148 = −32 lines. Tests +383/−23 = +360. Documentation is net zero.

Validation

  • The original exact-occurrence regressions fail on the unchanged base. New RED cases reproduce premature removal on cancelled/pre-send/transport failure, failed real SessionManager persistence, and late-arriving completion receipts.
  • The original cleanup passed 228 tests across 16 files. The delivery repair passed 141 owner/sibling cases, including 12 actual-child-process cases; its expanded 12-case command suite and final 24-case focused rerun also passed. Coverage includes deferred finalization, routed delivery, retry/repeated polling, missing exact dispatcher outcomes, and removed/same-ID successor process records.
  • Full changed-file gates passed for both the cleanup and final repair: production/test types, formatting, lint, dead exports, import cycles, schema/storage and ownership guards. Fresh independent Codex review is clean. The final test-only CI repairs also passed their owning type/lint checks and fresh independent reviews.
  • Earlier isolated live proof passed against source db18067: two real process effects occurred once, and direct polling preserved unrelated receipts. Real-provider Gateway exec/main-session cron/subagent flows passed on OpenClaw and Codex with periodic heartbeat disabled. That direct-handler cell did not exercise final delivery failure; it does not establish the revised acknowledgement boundary.
  • Corrected real-process/production-dispatch proof passed all five delivery outcomes. Successful delivery left one unrelated receipt; cancelled, pre-send-failed, transport-failed and deferred-failed delivery each retained both receipts. The probe used real child processes and production command gates/dispatch with a controlled transport, without a model or external recipient. Native snapshot1e3fa6a72ca2f1b299825cb40c02a5de474d7be0 passed the source guard and fresh qaRuntime build; all14 pinned source files are byte-identical to final PR headc56d468b0054069c3114dd3758c8f4672ae96591. The lease is stopped and independently verified completed. A post-run portal-bookkeeping timeout did not affect the successful workload. Final hosted CI passed.

The fresh ClawSweeper P1 is accepted and addressed by the delivery/persistence ownership repair above. Its requested failure-path proof now passes on the corrected production sources. The earlier direct-handler evidence is not substituted for this delivery proof.

Previous-head CI completed with 132 passed and 43 skipped. Its only failures were four npm advisory-service timeouts and the dependent aggregate. The existing maintainer waiver covers that availability failure only; it does not waive source findings or final-head validation.

Follow-up: QA reference resolution can find generated files in ancestor checkouts and hide a missing current-checkout reference. The earlier 58-case catalog red/green proof used an isolated checkout; repository-bound reference resolution remains separate work.

Final CI follow-through: four direct-poll fixtures now invoke the existing persisted-result acknowledgement and first assert that pending receipts survive until that point (38 tests passed, owning types/lint and independent review clean). Two inherited Code Mode/process-lifecycle fixture failures were independently reproduced and repaired during this work. Concurrent PR #138238 landed fixes at those same boundaries; their source and sibling coverage were inspected, and our duplicate test changes were dropped during rebase. The final PR retains main's fixes. All 14 live-pinned production files remain byte-identical. Final-head CI passed.

Final-head CI first attempt: 130 checks passed and 43 skipped. The only failure was an unchanged Doctor process case timing out at its 60-second child deadline, plus the dependent aggregate. The same case passed in the other PR's Linux run in 41.968 seconds, and all three subprocesses converged on the unchanged exact CI-parent baseline locally. The single failed-job rerun passed, and CI33871590210 completed successfully on attempt 2. No source, timeout, or assertion was changed.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Sep 4, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 4, 2026, 7:51 AM ET / 11:51 UTC.

ClawSweeper review

What this changes

This PR defers acknowledgement of completed background exec notices until !poll delivery or process.poll transcript persistence succeeds, and adds regression coverage for delivery failures and receipt races.

Regression provenance

Possible regression — probable (reviewed change; known regression link). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

The prior P1 is addressed: both polling paths now retain the exact completion notice until their real delivery owner succeeds. This active maintainer PR remains necessary because current main still acknowledges before construction/delivery, while exact-head checks are in progress.

Priority: P1
Reviewed head: 3b0285a33ae80f36fabac757832c2711042308bf

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-negative production repair with substantive delivery and persistence fault-path coverage; no blocking source finding was identified.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its supplied corrected real-process production-dispatch run is supplemental to the source and boundary-test review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its supplied corrected real-process production-dispatch run is supplemental to the source and boundary-test review.
Evidence reviewed 5 items Current-main defect: Current main acknowledges the finished process before preparing the tool result, leaving a failed later persistence path unable to retain the completion notice.
Process-poll repair: The PR attaches one acknowledgement callback that clears both staged poll output and the exact completion receipt only after the result owner acknowledges it.
Chat-delivery repair: The final-dispatch owner registers the completion callback against the dispatcher outcome and invokes it only for a delivered result; direct routed delivery requires a confirmed delivered count.
Findings None None.
Security None None.

How this fits together

Background exec jobs place completion notices in a session queue. Chat polling and agent process polling consume the matching notice only after their final reply is delivered or durably recorded, so failed delivery leaves it recoverable.

flowchart LR
  A[Background exec job] --> B[Completion notice queue]
  B --> C[Chat poll or process poll]
  C --> D[Final reply delivery or transcript persistence]
  D -->|success| E[Acknowledge exact notice]
  D -->|failure or suppression| F[Retain notice]
  E --> G[Unrelated notices remain queued]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -32, Tests +346, Docs 0, Other 0. Total +314 across 24 files.

View PR surface stats
Area Files Added Removed Net
Source 15 116 148 -32
Tests 7 359 13 +346
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 24 477 163 +314

Review metrics

Metric Value Why it matters
Production versus test delta production +116/-148 (net -32); tests +359/-13 (net +346); docs and QA net 0 The repair adds boundary-level regression coverage while reducing production code overall.

Technical review

Best possible solution:

Keep the exact receipt owned by the process record and acknowledge it only from confirmed chat delivery or durable tool-result persistence, as this revision does.

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

Yes, source-reproducible: current main calls acknowledgement before constructing the finished poll result, while the revised owner paths defer it until delivery or persistence succeeds.

Is this the best way to solve the issue?

Yes: acknowledgement belongs at the final delivery or persistence boundary, which preserves retryability without widening configuration or adding a parallel delivery path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 79930b846762.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its supplied corrected real-process production-dispatch run is supplemental to the source and boundary-test review.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 message-delivery: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: Current main can silently discard a completed background exec notice when a poll result later fails delivery or persistence.
  • 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: This MEMBER-authored PR is exempt from the external-contributor proof gate; its supplied corrected real-process production-dispatch run is supplemental to the source and boundary-test review.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • rick-stevens-ai: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • xin zhuang: 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 (2 earlier review cycles)
  • reviewed 2026-09-04T10:55:36.241Z sha 300c382 :: blocked before merge. :: [P1] Defer acknowledgement until final reply delivery
  • reviewed 2026-09-04T11:10:38.698Z sha 300c382 :: blocked before merge. :: [P1] Defer acknowledgement until final reply delivery

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 4, 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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 4, 2026
@steipete
steipete force-pushed the codex/automation-completion-cleanup branch from 3b0285a to 6a2f15d Compare September 4, 2026 12:09

@sylvesterkaczmarek sylvesterkaczmarek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledging only after final delivery or transcript persistence is the correct boundary. Keeping the exact removal handle also preserves unrelated completion receipts. Looks sound.

Terminal !poll now consumes the exact process-owned completion receipt,
matching process.poll while preserving other pending occurrences.

Consolidate captured event routing and heartbeat settlement without changing
cadence, readiness retries, suppressed-send retention, or persisted state.
Keep the shipped coding-tool SDK declarations accepted and document the
acknowledgment behavior. Production code shrinks by 49 lines.

Related: #135933
@steipete
steipete force-pushed the codex/automation-completion-cleanup branch from 6a2f15d to c56d468 Compare September 4, 2026 12:12
@steipete
steipete merged commit c3f394f into main Sep 4, 2026
310 of 312 checks passed
@steipete
steipete deleted the codex/automation-completion-cleanup branch September 4, 2026 12:34
@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 5, 2026
* fix(exec): acknowledge polled completions

Terminal !poll now consumes the exact process-owned completion receipt,
matching process.poll while preserving other pending occurrences.

Consolidate captured event routing and heartbeat settlement without changing
cadence, readiness retries, suppressed-send retention, or persisted state.
Keep the shipped coding-tool SDK declarations accepted and document the
acknowledgment behavior. Production code shrinks by 49 lines.

Related: openclaw#135933

* fix(exec): settle poll acknowledgements after delivery

* test(exec): acknowledge persisted poll results in fixtures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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