Skip to content

fix(outbound): retain delivered receipts after heartbeat renewal fails - #190318

Merged
vincentkoc merged 4 commits into
mainfrom
fix-lifecycle-custody-20261101
Nov 2, 2026
Merged

vincentkoc merged 4 commits into
mainfrom
fix-lifecycle-custody-20261101

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

A failed producer heartbeat can discard an accepted outbound receipt and leave
delivery unresolved even when its original queue claim survives. This cleanup
also removes parallel mailbox summary state and clarifies lifecycle ownership.

User Impact

Already-started sends can settle their unchanged claim after heartbeat failure.
Cancellation blocks later sends, replacement claims remain protected, and partial
batches retain recovery custody. Mailbox and UI behavior are preserved.

Why This Change Was Made

Keep receipt settlement in the existing exact-claim delivery owner. Pair mailbox
sources with summary text and remove the derived elision count. Document existing
mailbox, subagent, plugin, reload, update, transcript and UI ownership without a
state-machine framework or public API, config, dependency, schema or protocol change.

During CI qualification, the restart fixture also gained failure-only gate/Gateway
diagnostics through raw stderr, which the silent E2E runner retains. Its closure
assertion now selects the first successful seal for the actual physical session
store, preserving strict marker ordering and the no-late-backfill check.

Evidence

  • The accepted-receipt regression fails on audited base ba51135a5962 and passes
    with the fix; paired cases protect replacement claims and partial-batch custody.
    The original production snapshot passed 380 selected tests across 16 files.
    Queue proof uses controlled external adapters; no live transport-client recovery
    trace is claimed.
  • Targeted original Gateway/messaging types, lint, format, docs/MDX/links, test-line
    checks and hooks passed. The final fixture passed its owning test-root-other
    type graph, lint, format, diff and test-line checks without a new allocation.
  • The predecessor's CI attempt
    timed out in the blocked-store:false restart case at 180 seconds. A
    paired Linux replay
    passed 212/212 tests on its exact CI merge dd1398ab7753 and 212/212 on main base
    d2710e1efaa7, using the original four-file shard order and matching observed
    resources/runtime. This predates the fixture-only follow-up and did not reproduce
    or attribute the timeout. Main's original run had zero jobs; no inherited-failure
    or successful-repair claim is made.
  • At fixture commit c07d1e19bad, both original-budget restart cases passed.
    A controlled missing gate verified visible context under the silent runner.
    Injected interim/unrelated receipts were ignored, while an early matching
    successful seal still failed the strict ordering assertion. All probe-only
    changes were restored; committed bytes match the tested candidate. A prior
    generic-receipt ordering failure remains documented in native review evidence.
  • Local autoreview covered the original production change against ba51135a5962
    through P2. Hosted ClawSweeper
    found no actionable findings at production head 2d6d636b5097. Fresh local
    autoreview covered the complete fixture delta from that head to c07d1e19bad,
    with the full fixture and owners supplied: scoped-clean through P2, zero
    actionable findings.
  • Current-head CI
    passed for c07d1e19bad. GitHub completed the normal gated squash merge.

Keep cancellation on send initiation while concrete receipts settle through the existing exact claim. Protect replacement claims and partial batches with production queue regressions.
Replace parallel mailbox summary arrays and the derived elision count with paired entries. Preserve original-to-compact source identity, active custody, approved text, and routing through enqueue, drain, cancellation, and compaction.
Clarify mailbox admission versus settlement, subagent compensation, transcript drain budgets, plugin health, reload receipts, managed handoff custody, and the UI save slot. Keep existing owners and behavior.
@vincentkoc vincentkoc self-assigned this Nov 1, 2026
@clawsweeper

clawsweeper Bot commented Nov 1, 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 docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling size: M labels Nov 1, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 1, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review November 1, 2026 12:46
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 1, 2026
@clawsweeper

clawsweeper Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR retains accepted delivery receipts after producer-heartbeat failure, pairs mailbox summary sources with their text, and documents lifecycle ownership.

Example: Matrix returns messageId accepted-message after the producer heartbeat fails.

  • Before: The aborted lease prevents settlement even when the original queue claim survives.
  • After: The receipt settles the unchanged claim; a replacement claim remains protected and another payload cannot start.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The source supports the repair and its focused regression boundaries, while validation remains limited by adapter-based proof and unresolved CI attribution.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its supplied evidence exercises the production queue and SQLite settlement through controlled adapters, with no live-channel claim.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A message accepted by the channel can remain unresolved after a producer-heartbeat failure despite its original claim surviving.
Reason: Retaining confirmed delivery evidence has clear user value, and the maintainer-authored direction preserves existing cancellation, routing, and recovery contracts.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it addresses a current delivery-settlement defect, preserves exact-claim fencing, and has no concrete introduced correctness finding; CI remains blocked by an unattributed restart-resume timeout.

Priority: P2
Reviewed head: 2d6d636b5097ed4d28444e84d13a5e0672976900

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied heartbeat-failure evidence uses a synthetic Matrix adapter rather than a real transport-client recovery trace.
Agent review details

How this fits together

The outbound queue receives prepared channel payloads, holds durable send custody, invokes channel adapters, and settles receipts or retains uncertain deliveries for recovery.

flowchart TD
A[Prepared payloads] --> B[Durable queue claim]
B --> C[Producer lease]
C --> D[Channel send]
D --> E[Platform receipt]
E --> F[Exact claim settlement]
F --> G[Completion or recovery]
Loading

Technical review

Best possible solution:

Keep receipt settlement in the existing exact-claim queue owner while retaining cancellation checks before every subsequent send.

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

Current-main source shows the aborted producer lease rejecting settlement after an accepted receipt; the PR reports a base-failing regression, but this read-only review executed no target code.

Is this the best way to solve the issue?

The repair uses the existing queue owner and transactional claim check, preserves send cancellation, and removes the superseded mailbox representations without adding competing machinery.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Producer-lease rejection and outbound receipt settlement changes intended behavior with a stated reason (371c03c: Renewable ownership prevented recovery from sending concurrently with an active producer; later shared-custody work retained confirmed output and conservative recovery.)
  • Mailbox overflow summary representation keeps the original intent (36e277d: The session controller became the single owner of ordered inputs, collection, cancellation, and summary custody; paired entries preserve those responsibilities.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +42, Tests +72, Docs +9, Other +2. Total +125 across 25 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 14 113 71 +42
Tests 8 107 35 +72
Docs 2 9 0 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 25 231 106 +125

Labels

Label changes:

  • add P2: Heartbeat-renewal failure can leave an accepted send unresolved, but the evidence establishes a bounded delivery-settlement defect rather than a widespread outage.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Heartbeat-renewal failure can leave an accepted send unresolved, but the evidence establishes a bounded delivery-settlement defect rather than a widespread outage.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

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

  • Establish whether the restart-resume CI timeout is caused by this diff before landing.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 1, 2026, 8:04 AM ET / 13:04 UTC.

Require a written seal for the fixture physical store while preserving marker ordering and the no-backfill check. Emit bounded Gateway context for rejected provider gates through raw stderr so the silent E2E runner retains it.
@vincentkoc
vincentkoc enabled auto-merge (squash) November 2, 2026 06:03
@vincentkoc
vincentkoc merged commit e41e6d5 into main Nov 2, 2026
141 checks passed
@vincentkoc
vincentkoc deleted the fix-lifecycle-custody-20261101 branch November 2, 2026 06:20
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash auto-merge.

vincentkoc added a commit that referenced this pull request Nov 2, 2026
Remove the obsolete provider-phase rejection case: an expired lease still settles a concrete receipt through its exact durable claim, as intended by #190318. The unchanged cancellation suite already proves same-owner receipt acceptance, replacement-claim preservation, partial-batch fencing and no replay.

Keep both pre-dispatch ownership-loss cases and the stable-intent renewal/completion checks. The original fixture reproduces one failure; the remaining lease and cancellation suites pass all 25 cases on Node and Bun. Scoped types, typed lint, format and the staged line ratchet pass. Production code is unchanged; test code shrinks by forty lines.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 3, 2026
openclaw#190318)

* fix(outbound): preserve accepted receipts after lease renewal fails

Keep cancellation on send initiation while concrete receipts settle through the existing exact claim. Protect replacement claims and partial batches with production queue regressions.

* refactor(sessions): pair overflow summary sources with their text

Replace parallel mailbox summary arrays and the derived elision count with paired entries. Preserve original-to-compact source identity, active custody, approved text, and routing through enqueue, drain, cancellation, and compaction.

* docs(runtime): clarify lifecycle custody and settlement boundaries

Clarify mailbox admission versus settlement, subagent compensation, transcript drain budgets, plugin health, reload receipts, managed handoff custody, and the UI save slot. Keep existing owners and behavior.

* test(gateway): qualify restart receipts and report gate failures

Require a written seal for the fixture physical store while preserving marker ordering and the no-backfill check. Emit bounded Gateway context for rejected provider gates through raw stderr so the silent E2E runner retains it.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 3, 2026
Remove the obsolete provider-phase rejection case: an expired lease still settles a concrete receipt through its exact durable claim, as intended by openclaw#190318. The unchanged cancellation suite already proves same-owner receipt acceptance, replacement-claim preservation, partial-batch fencing and no replay.

Keep both pre-dispatch ownership-loss cases and the stable-intent renewal/completion checks. The original fixture reproduces one failure; the remaining lease and cancellation suites pass all 25 cases on Node and Bun. Scoped types, typed lint, format and the staged line ratchet pass. Production code is unchanged; test code shrinks by forty lines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M 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