Repository navigation
fix(queue): preserve lifecycle state across replay failures - #1375
Conversation
Preserve authoritative endpoint terminal ordering while making router and terminal replays transactionally duplicate-safe. Co-authored-by: Peter Steinberger <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper re-review Please review exact head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: blocked before merge. Reviewed September 3, 2026, 9:39 AM ET / 13:39 UTC. ClawSweeper reviewWhat this changesThe PR makes lifecycle router and terminal callbacks idempotent across lost responses while rerunning Bay materialization and alarm scheduling after committed replays. Merge readiness⛔ Blocked before merge - 5 items remain Keep this PR open: its replay recovery approach is useful, but it removes a currently accepted durable ledger representation and lacks the Docker-backed Crabbox proof required by repository policy. Priority: P2 Review scores
Verification
How this fits togetherExact-review lifecycle callbacks persist queue state in a SQLite Durable Object. Those lifecycle facts drive terminal finalization, OpenClaw Bay telemetry, and subsequent queue scheduling. flowchart LR
A[Lifecycle callback] --> B[Exact-review queue route]
B --> C[SQLite lifecycle projection]
C --> D{Replay or new operation}
D --> E[Bay lifecycle telemetry]
D --> F[Queue alarm scheduling]
D --> G[Terminal finalization]
Decision needed
Why: The repository policy reserves that exception to Martin, while the available proof was run outside the required Crabbox environment. Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain a read-only compatibility decoder for legacy terminal-operation ledger entries, never write that form again, add an upgrade replay regression, and validate the repaired exact head in Docker-backed Crabbox. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: replay a persisted lifecycle row whose terminal-operation ledger uses the string or null-kind representation that current main decodes; this branch rejects that row before callback recovery. Is this the best way to solve the issue? No. Durable rows accepted by current main need a read compatibility path; stricter validation can apply to new writes after legacy values have been decoded. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 674841bcdc0a. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Maintainer disposition for the remaining rank-up move: Docker-backed Crabbox proof is deferred because Docker is unavailable on this host and both recorded AWS attempts failed before repository execution (Actions hydration incompatibility, then broker DNS/EOF). This is an optional rank-up, not a code finding; the exact-head review found no actionable defect and states real-behavior proof is not required for this maintainer-authored PR. The PR body retains the redacted Wrangler Worker + SQLite HTTP proof and the precise proof limits. |
|
Late compatibility finding resolved by deployment/source provenance: pre- |
Related: #1368
What Problem This Solves
Fixes an issue where a lost Worker response could replay a committed lifecycle operation, mutate canonical state twice, or fail to restore derived Bay and alarm state after the canonical transaction had already committed.
This is the server prerequisite only. It does not re-enable client-side post-effect retries.
Why This Change Was Made
Router receipts and terminal dispositions now use durable operation identity inside the lifecycle projection transaction. Same-identity replays skip canonical mutation but always rerun idempotent Bay materialization and scheduling; conflicting terminal operation kinds return HTTP 409.
The router endpoint preserves the deployed f7 ordering rule for a matching receipt followed by a newer or equal non-routed terminal, and additionally preserves any authoritative requeue when a delayed router request had not committed a receipt. This endpoint rule is intentionally narrower than the lifecycle store contract:
applyTerminalDispositionstill permits requeue-to-route transitions for other callers, as covered by queue-policy tests.Terminal operation IDs remain for the projection lifetime with no eviction. Old rows without the field load as an empty ledger; malformed or duplicate entries are rejected.
Peter Steinberger authored the original publication-retry work and is credited in the signed commit. This prerequisite is separated because the server behavior must differ from the source PR before post-effect retries can safely return.
User Impact
Operators get deterministic lifecycle recovery after ambiguous Worker failures: duplicate delivery cannot recreate canonical effects, overwrite a later requeue, or leave Bay/alarm projections stale.
There is no new public API or configuration surface.
OpenClaw Bay Impact
The public Bay projection and schema are unchanged. Duplicate router and terminal deliveries rerun the existing idempotent
syncBayLifecyclepath after the canonical transaction, so a post-commit materialization failure can recover without changing lifecycle facts.Documentation Impact
Reviewed
docs/live-dashboard.md. No documentation change is needed: post-effect requests remain deliberately one-shot, and this PR only repairs the Worker prerequisite needed before that availability tradeoff can be reconsidered.Evidence
ba3822b6cf179d98bcaf2444e6974deb6095e752674841bcdc0a826ff4555f945cc81f122db0d6c2+98/-80, net+18.+238/-87, net+151.CI=1 pnpm run check:static: passed.pnpm run build:all: passed.pnpm run lint: passed.pnpm run format: passed on 808 files.git diff --check: passed.Regression coverage includes:
Review precedence
Two local review suggestions were considered and rejected after direct source/history audit:
{ kind: null }entries are not deployed durable states. Before f7 the field did not exist; f7 introduced the field and writes only concrete{ operationId, kind }entries. The removed reader bridge covered an unmerged predecessor shape, not a shipped migration.Real Behavior Proof
Claim: the real Worker HTTP boundary preserves a requeue across delayed router delivery, makes completed router and terminal replays canonical no-ops, and rejects a conflicting terminal operation kind.
Surface: Wrangler 4.107 running the production Worker and SQLite Durable Object locally over HTTP loopback. GitHub App installation and repository metadata were served by an ephemeral local mock; no private endpoint, credential, or repository data was retained.
Command:
bash /tmp/clawsweeper-worker-replay-proof.sh "$PWD" 8796Observed result:
{"ok":true,"transport":"HTTP loopback","runtime":"Wrangler Worker with SQLite Durable Object","router":{"delayed_receipt_preserved_requeue":true,"duplicate_left_updated_at_unchanged":true},"terminal":{"duplicate_left_updated_at_unchanged":true,"conflicting_kind_status":409}}Limits: this proves the production Worker/SQLite/HTTP boundary locally. It does not claim deployment or a live queue mutation. Docker was unavailable. Two AWS Crabbox attempts failed before running repository commands: one because local Actions hydration did not support
pnpm/[email protected], and one on broker DNS/EOF plus cancel-create timeout. A local fullpnpm run checkfallback reached unrelated terminal proof/PTY infrastructure failures; the focused owner-boundary suites and all static/build/lint/format gates above are green.No deployment, queue dispatch, cancellation, retry, or other live operation was performed.