Skip to content

fix: restore recovery notices to history after a Gateway crash - #198139

Merged
vincentkoc merged 5 commits into
mainfrom
test/postgres-notice-ack-crash-20261113
Nov 13, 2026
Merged

vincentkoc merged 5 commits into
mainfrom
test/postgres-notice-ack-crash-20261113

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes a delivered recovery notice disappearing from conversation history after the Gateway dies between committing its queue acknowledgement and recording the notice in its originating session.

Maintainer PostgreSQL qualification follow-up to #197780.

User Impact

Restart can record the already delivered notice and acknowledge its existing debt without sending it again. Ordinary suppressed notices without a completed receipt retain their existing behavior. No schema, schema-version, DDL, migration, persisted-format, config, retention, or durability-policy changes.

Why This Change Was Made

The queue correctly suppresses reuse of a completed stable intent. The pending-notice owner treated that suppression as non-delivery, even though it already reconciled the same completed receipt after a send error. Both outcomes now use the existing receipt before appending the transcript and acknowledging debt. This removes the suppression-only branch at the existing owner; session, revision, intent, and acknowledgement-precedence checks remain intact. No new abstraction, send path, or async transaction work.

The PostgreSQL fixture withholds the notice ACK's successful worker reply after commit, independently reads PostgreSQL, kills the real Gateway, and restarts it against a synthetic HTTP sink. The previous three answer-delivery crash cases remain covered.

Evidence

  • Before-fix d4bb8e6aa825: channel regression failed at the intended missing-transcript assertion, with 830 other channel assertions passing. Its PostgreSQL case stopped before the crash on an incorrect undefined-property expectation; pre-fix process proof at the intended assertion is unavailable.
  • Behavior candidate 460ff0a791a: PostgreSQL shard 1 passed, including all four Gateway crash windows. The new ACK-reply-loss case passed in 46.4s: completed notice receipt survives SIGKILL, restart acknowledges debt, records exactly one notice in the original transcript, finalizes the original failure, and sends no duplicate notice or answer. Shard 2 and shard 3 also passed.
  • Final-head PR merge checkout b89c5f85aaed (head 085d3432dfd, base 6c57f13ade83) passed all three PG17 conformance shards and PG16 Gateway smoke. PG17 shard 1 passed all four crash windows, including notice ACK-reply loss in 79.0s. PG16 independently passed the new window in 46.2s and all 11 Gateway database tests.
  • The same behavior run passed the complete build/artifact job, production types, and all five core test-type lanes. All 831 channel assertions passed, including the previously red notice test and its routing/revision/concurrency siblings. Final head 085d3432dfd differs by a justified one-line lint directive preserving JSON serialization semantics and its explicit allowlist entry. The targeted rule and used-directive check passed locally. Final-head PR CI attempt 2 passed: 42 jobs successful, 28 intentionally skipped, no failures. This includes the runtime suppression guard (all 14 cases), changed-channel tests, production and test types, lint, browser and baseline checks; no behavior assertion was removed.
  • Local autoreview through 94259259a62, plus independent review of the fixture serialization correction: both scoped-clean at P0–P2. Local ClawSweeper was unavailable because its checkout was ambiguous. Final-head ClawSweeper review at 085d3432dfd found no actionable issues, no before-merge items, and sufficient process proof. The exact suppression allowlist entry also has separate independent review; no coverage was weakened.
  • Formatting, commit guards, and git diff --check passed. Production +6/-4 (net +2); tests/support +254/-70 (net +184), including relocation of the existing anchor reader to keep the test module within its line cap.
  • Broad manual CI has locale-baseline, dead-code, declaration-fixture, and lint failures; it is not green. The fixture's unbound-method error was fixed with arrow functions. Its intentional JSON normalization lint error is fixed by the directive. The first ready-head CI correctly required the matching suppression allowlist entry; that two-line entry is now included, with exact key, count, ordering, formatting and all 14 runtime suppression checks verified. Other failures are not claimed inherited without comparison. The superseded repair run was cancelled. The queued Testbox was stopped before execution; local product dependencies are unqualified.
  • Final-head CI infrastructure recovery: all registered Boat and Boat-large runners were offline. After all PostgreSQL jobs passed and no jobs remained active, cancelled the stalled queue and retried failed/cancelled jobs once. Attempt 2 moved the 16 stalled checks to ubuntu-24.04 and completed successfully; successful PostgreSQL results preserve their original execution times. No runner configuration or CI source change was made for the outage. Final-head security-fast and all five Security High lanes passed.
  • No real Telegram or exactly-once external-delivery claim.

Next bounded qualification: crash after the notice transcript commits but before debt acknowledgement; test existing keyed transcript deduplication without changing storage or policy.

@clawsweeper

clawsweeper Bot commented Nov 13, 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.

@vincentkoc vincentkoc self-assigned this Nov 13, 2026
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M labels Nov 13, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 13, 2026
@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR restores an already delivered recovery notice to conversation history when a Gateway crash interrupts its acknowledgement.

Example: The Gateway crashes after committing the delivery ACK for notice intent-1 to chat-1, before recording its transcript entry.

  • Before: Restart suppresses another send but leaves the delivered notice absent from history.
  • After: Restart uses the completed receipt to record one transcript notice and acknowledge its debt without another send.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with production-process crash coverage and no identified defects; required final-head CI is still running.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (linked_artifact): The supplied successful PostgreSQL run exercises the changed notice owner through a real Gateway CLI process, real workers, and HTTP transport: after committed-ACK reply loss and SIGKILL, restart records exactly one notice, acknowledges debt, and sends no duplicate. Subsequent changes are lint-only; blocked raw-log access is a reviewer limitation.
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 recovery notice can reach the chat but remain missing from conversation history after a Gateway crash.
Reason: This maintainer-authored repair restores the existing history contract while preserving duplicate-send suppression and ordinary suppression behavior.

Merge readiness

✅ Ready for maintainer review

This PR fixes a receipt-reconciliation gap still present on main. No actionable patch defects were found; final-head CI remains pending.

Priority: P2
Reviewed head: 085d3432dfd9aee3802870da63fe783d5deaa2c7

Before merge

None.

Findings

None.

Agent review details

How this fits together

The pending-notice owner receives unresolved delivery debt during recovery or an inbound turn, sends through the lifecycle runtime, and records the outcome through the existing transcript and session owners.

flowchart TD
  A[Recovery or inbound turn] --> B[Pending notice owner]
  B --> C[Lifecycle sender]
  C --> D[Durable delivery queue]
  D -->|Suppression and receipt| B
  B --> E[Transcript owner]
  E --> F[Session notice acknowledgement]
Loading

Technical review

Best possible solution:

Use the existing completed receipt to reconcile suppressed notice sends before the guarded transcript append and debt acknowledgement.

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

Current-main source deterministically skips transcript recording for a suppressed completed intent; the supplied channel regression reports the intended red/green result, while the pre-fix process run stopped during fixture setup.

Is this the best way to solve the issue?

The patch is the smallest complete repair: it extends existing receipt reconciliation to suppression, retains session, revision, route, and intent checks, and adds no competing recovery path.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit 91efeca adds src/channels/turn/pending-delivery-notice.ts:89 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 91efecab22e5; files: src/channels/turn/pending-delivery-notice.ts)
  • Peter Steinberger: Raw commit bc9433b adds src/channels/turn/pending-delivery-notice.ts:46 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: bc9433b48ae1; files: src/channels/turn/pending-delivery-notice.ts)
  • Hana Chang: Raw commit f6f7252 adds src/channels/turn/pending-delivery-notice.ts:68 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: f6f7252001c1; files: src/channels/turn/pending-delivery-notice.ts)

PR surface

Source +2, Tests +184. Total +186 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 6 4 +2
Tests 4 254 70 +184
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 260 74 +186

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test change Production +6/-4; tests/support +254/-70 The small owner repair is supported by a distinct whole-Gateway crash scenario and independent database assertions; part of the test growth relocates an existing anchor reader.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: A narrow crash window loses a delivered recovery notice from conversation history without losing the underlying answer or requiring a new capability.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-13T06:39:20.296Z sha d4bb8e6 :: needs changes before merge. :: [P2] Include the notice-owner repair with the new regression
  • reviewed 2026-11-13T07:22:11.719Z sha b6eb25f :: needs maintainer review before merge. :: none

Reviewed November 13, 2026, 2:43 AM ET / 07:43 UTC (Revision 3).

@vincentkoc vincentkoc changed the title fix: preserve recovery notice acknowledgement after a Gateway crash fix: restore recovery notices to history after a Gateway crash Nov 13, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review November 13, 2026 07:16
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 13, 2026
@clawsweeper clawsweeper Bot added the status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. label Nov 13, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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 13, 2026
@vincentkoc
vincentkoc enabled auto-merge (squash) November 13, 2026 08:00
@vincentkoc
vincentkoc merged commit 71b8719 into main Nov 13, 2026
223 of 243 checks passed
@vincentkoc
vincentkoc deleted the test/postgres-notice-ack-crash-20261113 branch November 13, 2026 08:09
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash auto-merge.

obviyus added a commit that referenced this pull request Nov 13, 2026
…ted final resend

Main now delivers the unconfirmed-delivery notice when recovery settles (#195400, #198139), so this branch drops its agent-hint notice redesign and keeps the routed final text resend, the channel opt-in, and the proxy reset control.

Co-authored-by: obviyus <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 14, 2026
…law#198139)

* test(postgres): reproduce notice acknowledgement reply loss

* fix: record delivered recovery notices after a crash

* test(postgres): match serialized recovery checkpoint metadata

* test(postgres): preserve JSON checkpoint normalization in lint

* test(postgres): register checkpoint serialization lint exception
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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