Skip to content

fix: resume queued user work after Gateway restart - #175845

Merged
steipete merged 1 commit into
openclaw:mainfrom
enki:fix/restart-recovery-queued-input-identity
Oct 19, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
enki:fix/restart-recovery-queued-input-identity

Conversation

@enki

@enki enki commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: queued user work can fail to resume after a Gateway restart with a transcript idempotency conflict.

User Impact

Accepted user input remains intact, and its restart continuation starts without conflicting with the original transcript row. No configuration, schema, or permission changes.

Why This Change Was Made

Queued work keeps its original user transcript key as the recovery source while execution can have a different run ID. Recovery mistook the original admission ID for an already reserved continuation ID and tried to append different content under the original input key.

Recognize the existing canonical user-key form when choosing a fresh continuation ID. Keep the original source correlation and the strict transcript guard. Actual continuation IDs remain stable across uncertain transport failures; prior-lifecycle admissions still rotate.

Evidence

  • The new regression uses the real user recorder, reply claim actor, shutdown marking, recovery dispatcher, and strict transcript append. On the original production source it fails with TranscriptTurnAdmissionConflictError for the original synthetic input key.
  • Fixed source: six focused cases pass, including the new queued-input recovery, both source identity forms through an uncertain dispatch retry, prior-lifecycle rotation, and completed-RPC reuse. The original user row remains singular and its source correlation is retained.
  • Runtime-value import cycles and Madge cycles: zero. Format and diff checks pass.
  • Fresh independent review: scoped-clean through P2 (patch-correct confidence 0.93).
  • Exact-head PR CI is green at 2e3a493d828185504fcf240dbaec31452da5b755, including production types, test types, lint, and the CI gate (run 39070159117). The earlier bounded local compiler checks were stopped under host memory pressure without diagnostics; no local typecheck pass is claimed.

Local activation: the equivalent recovery fix is built and deployed in the operator’s existing beta runtime. All six recovery cases pass against that local backport. The managed Node 24 Gateway passes deep status and health checks; the web UI and assets respond, and the final restart window contains no ERROR/FATAL entries. Existing voice and plugin changes were preserved. This is a combined local backport, not a claim that the exact public PR binary or an external-provider recovery turn was exercised.

The focused regression uses synthetic data and simulated Gateway RPC execution with real persistence/recovery/transcript owners. The separate shipped-runtime proof below uses a real isolated Gateway and native provider. No production Gateway or private user transcript is used.

Actual Gateway/native recovery proof

A fresh isolated shipped-runtime proof exercised explicit owner chat.send followup behind an active native turn. Its original user admission ID differed from the queued turn’s actual execution ID. After a canonical preserve suspension, zero-write-custody check, exact-task process handoff and helper stop/start, an actual native assistant final QUEUED_RECOVERY_DONE was recorded under a third, fresh recovery run ID. The canonical transcript retained exactly one original user row with unchanged content; recovery was internal-system work and added no new user row. This uses the built v18 combined backport: the recovery identity-selection block is byte-identical to this PR, while other owner context includes additional repairs. The fixture’s old-client history polling timed out; independent read-only task transcript/session readbacks qualify the final and identity assertions. No fresh active source-claim snapshot was captured, so source continuity is limited to the original claim/key and unchanged canonical row plus reviewed propagation code. Both attempts were cleaned up; no production Gateway or user session was used.

Synthetic queued-input restart readbacks
{
  "syntheticOnly": true,
  "publicPr": 175845,
  "publicSourceHead": "2e3a493d828185504fcf240dbaec31452da5b755",
  "runtimeContext": "Built v18 combined backport; not an exact public-PR runtime build.",
  "recoveryIdentitySelectionByteIdenticalToPublic": true,
  "recoveryIdentitySelectionSha256": "683d2a32f620000ae2ebc9f4a6988458d3de58cb9842eb39306ede59893c8c53",
  "fullOwnerByteIdenticalToPublic": false,
  "explicitFollowupOwnerInput": true,
  "originalAdmissionDiffersFromQueuedExecution": true,
  "canonicalHandoffCommitted": true,
  "writeCustodyCountsZeroBeforeCommit": true,
  "recoveryRunDiffersFromAdmissionAndQueuedExecution": true,
  "actualNativeAssistantFinal": "QUEUED_RECOVERY_DONE",
  "actualFinalRunMatchesFreshRecoveryRun": true,
  "originalCanonicalUserRowCount": 1,
  "originalUserContentUnchanged": true,
  "sourceClaimBeforeRestartMatchesOriginalUserKey": true,
  "freshRecoveryUserRowCount": 0,
  "limits": [
    "First plain scheduled restart produced no qualifying continuation before its bounded timeout; it was cleaned up. Corrected attempt uses canonical preserve/custody/exact-target handoff.",
    "The fixture post-restart chat.history polling timed out; independent read-only task SQLite transcript and session metadata qualify the actual final.",
    "The fresh active recovery source claim was not captured. Source preservation is proven before restart and by the unchanged original canonical user row; propagation additionally follows the reviewed owner code.",
    "Recovery is an internal-system continuation and added no fresh user row. No persisted fresh recovery user-key claim is made."
  ],
  "fixturePollingReportedFailure": true,
  "independentCanonicalReadbackQualified": true,
  "gatewayStopped": true,
  "copiedAuthAndTaskStateRemoved": true
}

@clawsweeper

clawsweeper Bot commented Oct 17, 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 agents Agent runtime and tooling size: M labels Oct 17, 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. 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. 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 Oct 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Choose a fresh restart-continuation ID when the claimed ID belongs to the original queued user input.

Example: Input queued-human-input executes as queued-followup-execution before a Gateway restart.

  • Before: Recovery reuses queued-human-input and conflicts with the existing queued-human-input:user transcript row.
  • After: Recovery selects a fresh continuation ID while retaining queued-human-input:user as its source.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, focused repair with no findings, meaningful regression coverage, successful exact-head CI, and qualifying runtime readbacks whose combined-backport limits are explicit.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The new isolated Gateway/native-provider readbacks exercise queued followup with distinct admission and execution IDs, restart, a final under a fresh recovery ID, and one unchanged original user row, addressing the prior proof request; evidence uses a combined backport with the changed selection block reported byte-identical, and source propagation additionally relies on inspected code because no active recovery-source snapshot was captured.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Accepted queued work can fail to continue after restart because recovery collides with its original transcript identity.
Reason: The patch restores the existing accepted-work recovery contract without adding configuration, storage formats, permissions, or competing ownership.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current recovery identity collision with a focused change; no actionable patch defects remain.

Priority: P2
Reviewed head: 2e3a493d828185504fcf240dbaec31452da5b755

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway startup recovery reads durable session claims, selects a continuation identity, and dispatches accepted work through the existing agent runtime.

flowchart TD
A[Accepted queued input] --> B[Transcript and recovery claim]
B --> C[Gateway restart]
C --> D[Recovery identity selection]
D --> E[Agent runtime dispatch]
E --> F[Assistant final and settlement]
Loading

Technical review

Best possible solution:

Retain this focused identity-selection repair within the existing recovery owner.

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

The admission producer, canonical :user key builder, and current-main selection condition establish the failing path; the contributor reports the focused regression failing before the fix and passing afterward, without reviewer execution.

Is this the best way to solve the issue?

This is the smallest complete fix: recognize the existing source-key representation at identity selection while retaining strict transcript admission and established retry behavior.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Continuation identity selection keeps the original intent (bafabba: Durable accepted-turn recovery separates original source identity from a reserved continuation and preserves that continuation across ambiguous dispatch failures.)
  • Prior-lifecycle continuation rotation keeps the original intent (72ddf22: An already admitted continuation needs a fresh ID after restart to avoid colliding with its ancestor transcript entry.)
  • Recovery regression suite keeps the original intent (49c85e5: Consolidate fixture arrangements while retaining distinct persistence, delivery, and lifecycle contracts.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 72ddf22 adds src/agents/main-session-recovery/main-session-restart-dispatch.ts:367 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 72ddf22b9308; files: src/agents/main-session-recovery/main-session-restart-dispatch.ts)
  • RoboClaw: Raw commit e5e90fb adds src/agents/main-session-recovery/main-session-restart-recovery.test.ts:1627 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: e5e90fb6291a; files: src/agents/main-session-recovery/main-session-restart-recovery.test.ts)

PR surface

Source +5, Tests +104. Total +109 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 6 1 +5
Tests 1 160 56 +104
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 166 57 +109

Review metrics

Metric Value Why it matters
Production versus test LOC Production +6/-1; tests +160/-56 The small owner fix is supported by a distinct persistence-to-recovery regression and extension of an existing retry table.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: A limited restart-recovery path can strand accepted queued work through a transcript identity conflict.
  • 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 (1 earlier review cycle)
  • reviewed 2026-10-17T21:40:57.011Z sha 2e3a493 :: needs real behavior proof before merge. :: none

Reviewed October 17, 2026, 5:59 PM ET / 21:59 UTC (Revision 2).

@enki

enki commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor Author

@steipete: current head 2e3a493d828185504fcf240dbaec31452da5b755 is ready for human review. Exact-head CI passes; the current Claw review accepts the disclosed Gateway/native restart evidence and reports no remaining findings or before-merge items. Could you review the continuation-ID repair?

Added an inspectable synthetic shipped-Gateway/native-provider restart capture. Real owner input enters explicit followup with distinct admission and queued-execution IDs; canonical preserve/zero-custody/exact-task handoff and process restart produce an actual provider final under a third recovery ID, with exactly one unchanged original user row. The body records combined-backport scope, identity-block byte equality/full-owner nonidentity, polling timeout and independent canonical readback qualification, and source-capture limits. No RPC execution was mocked in this capture and no operator Gateway or real user data was used.

@clawsweeper

clawsweeper Bot commented Oct 17, 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-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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: 🧂 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. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
@steipete
steipete merged commit e044c3f into openclaw:main Oct 19, 2026
183 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

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

Labels

agents Agent runtime and tooling 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.

2 participants