Skip to content

fix(queue): keep legacy lifecycle projections replay-safe - #1376

Closed
vincentkoc wants to merge 1 commit into
mainfrom
fix/lifecycle-ledger-compat
Closed

vincentkoc wants to merge 1 commit into
mainfrom
fix/lifecycle-ledger-compat

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

Related: #1375

What Problem This Solves

Fixes an upgrade issue where a lifecycle projection written before #1375 could be rejected when its terminal-operation ledger still used a string operation ID or a null-kind operation entry.

Why This Change Was Made

Read-time normalization converts legacy string IDs to { operationId, kind: null }. A legacy null-kind ID remains an idempotent duplicate for any replayed terminal kind, matching the earlier deployed behavior; concrete different-kind reuse still returns 409. New writes continue to store concrete kinds, the ledger remains unbounded for the projection lifetime, and malformed or duplicate IDs remain invalid.

This is the narrow compatibility follow-up required because #1375 merged before its replacing exact-head ClawSweeper review tuple completed. It does not revert #1375 and does not change queue, workflow, schema, configuration, capacity, cadence, or live operations.

User Impact

Maintainers can upgrade without legacy terminal-operation rows becoming unreadable or replaying a previously applied terminal mutation. Current-format rows retain strict conflicting-kind protection.

OpenClaw Bay Impact

Bay lifecycle behavior is unchanged. A real local Wrangler Worker with its SQLite Durable Object accepted the existing router and terminal flows: delayed router replay preserved requeue, duplicate replay left the durable timestamp unchanged, and concrete conflicting-kind reuse returned 409.

Documentation Impact

No documentation change. This restores read compatibility for deployed durable rows without changing the documented queue or lifecycle contract.

Evidence

  • Signed head: 98a2e67789544319e149db762d16cb6eb0ed2f14
  • Production delta: +23/-14 (net +9)
  • Test delta: +35/-6 (net +29)
  • node --test test/dashboard-worker-publication-lifecycle.test.ts: 81 passed
  • TypeScript builds: tsconfig.json, tsconfig.repair.json, and tsconfig.dashboard.json passed
  • Static checks: active surface, dashboard queue boundary, dashboard strict, docs, and limits passed
  • Targeted oxfmt --check, oxlint, and git diff --check passed
  • Focused upgrade coverage proves legacy string IDs and null-kind objects normalize and replay without mutation, concrete different-kind reuse conflicts, and malformed or duplicate ledgers remain rejected.

The repository's broad Bay proof started the real Wrangler runtime but its public-visibility fixture returned 503 target_visibility_unverified; that fixture failure is unrelated to this read-compatibility change and is not counted as passing proof.

Real Behavior Proof

  • Claim: the compatibility read path does not regress the repaired router/terminal replay boundary.
  • Surface: signed lifecycle HTTP routes through the compiled dashboard Worker and real SQLite Durable Object.
  • Scenario: enqueue a disposable public target, record a requeue, deliver and replay a delayed router receipt, then record/replay a terminal operation and reuse its concrete ID with a different kind.
  • Environment: local Wrangler 4.107.0, loopback mock GitHub API, disposable local persistence, no production credentials or endpoints.
  • Observed result: router replay preserved requeue and left updated_at unchanged; terminal replay left updated_at unchanged; conflicting concrete kind returned HTTP 409.
  • Trace:
{"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: legacy persisted shapes are injected and verified in the focused Durable Object storage tests; the public HTTP API does not expose raw projection-row mutation. No production queue action, dispatch, retry, cancellation, or deployment was performed.

@clawsweeper

clawsweeper Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head 98a2e67789544319e149db762d16cb6eb0ed2f14 and the current proof package. This is the narrow read-compatibility follow-up to #1375; no queue, workflow, schema, configuration, or live-operation surface changed.

@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. 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 3, 2026
@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 3, 2026, 10:01 AM ET / 14:01 UTC.

ClawSweeper review

What this changes

The PR accepts string and null-kind terminal-operation ledger entries when loading lifecycle projections, normalizes them to a null kind, and adds focused storage tests.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep this PR open: the unchanged prior P1 finding still applies. Its new wildcard treatment of an unknown terminal kind silently accepts a same-ID replay with a different disposition where current main returns HTTP 409; no durable-row provenance establishes that this semantic downgrade is required.

Priority: P2
Reviewed head: 98a2e67789544319e149db762d16cb6eb0ed2f14

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch is narrowly scoped but has a high-priority correctness regression in the terminal replay conflict invariant.
Proof confidence 🌊 off-meta tidepool Not applicable: The author is a repository member, so the external-contributor proof gate does not apply. The supplied Wrangler/SQLite trace covers current-format replay behavior but does not resolve the introduced unknown-kind conflict defect.
Patch quality 🧂 unranked krab (1/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The author is a repository member, so the external-contributor proof gate does not apply. The supplied Wrangler/SQLite trace covers current-format replay behavior but does not resolve the introduced unknown-kind conflict defect.
Evidence reviewed 4 items Introduced wildcard conflict bypass: The introduced duplicate branch returns success whenever a matching operation ID has kind null, regardless of the incoming terminal kind. This changes current-main strict conflict behavior into a no-op for legacy-shaped rows.
Regression test encodes the conflicting replay: The new cases replace an existing concrete kind with a legacy string or null-kind entry, then replay that same ID as requeue and assert the projection is unchanged. That is precisely the conflicting replay current main rejects.
Merged lifecycle-ledger provenance: Current main's immediately preceding merge is the lifecycle replay work in #1375. The related merged PR states that the field did not exist before that work and that it writes concrete operation kinds; the submitted PR supplies no contrary deployed-row provenance.
Findings 1 actionable finding [P1] Reject unknown terminal kinds on reused operation IDs
Security None None.

How this fits together

The dashboard Worker records exact-review lifecycle state in a SQLite Durable Object. Terminal operation identities make replayed requests idempotent while rejecting a reused identity whose terminal outcome conflicts, before queue cleanup and Bay projection updates occur.

flowchart LR
A[Signed terminal request] --> B[Dashboard Worker]
B --> C[Lifecycle projection store]
C --> D[Terminal operation ledger]
D --> E{Duplicate or conflict check}
E -->|new operation| F[Lifecycle and queue state]
E -->|duplicate| G[Idempotent response]
F --> H[Bay projection and scheduling]
Loading

Before merge

  • Reject unknown terminal kinds on reused operation IDs (P1) - A string or kind: null row is normalized to a null kind, and this branch then treats any same-ID terminal request as a duplicate. A replay with a different terminal kind therefore returns success rather than the current-main 409, silently suppressing a conflicting lifecycle mutation. The prior review identified this unchanged behavior; retain strict rejection unless deployed durable-row evidence defines a safe compatibility rule.
  • Resolve merge risk (P1) - If a persisted null-kind or string ledger entry shares an operation ID with a later different terminal disposition, merging this PR suppresses that disposition instead of returning 409, leaving lifecycle state, queue cleanup, and Bay scheduling at the prior outcome.
  • Complete next step (P2) - Restore strict conflicting-kind rejection for string and null-kind ledger entries, or provide deployed durable-row provenance and a conflict-preserving compatibility design before merge.
  • Improve patch quality - Restore strict conflicting-kind handling for legacy-shaped operation IDs, or provide durable deployed-row provenance and safe conflict-preserving behavior.

Findings

  • [P1] Reject unknown terminal kinds on reused operation IDs — dashboard/exact-review-lifecycle.ts:589-592
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Diff scope 2 files affected; production +9 net, tests +29 net The patch is narrowly focused on Durable Object lifecycle-row parsing and replay behavior.

Merge-risk options

Maintainer options:

  1. Retain strict terminal-ID conflict handling (recommended)
    Remove string and null-kind wildcard acceptance so a reused operation ID with a different terminal kind continues to return HTTP 409.
  2. Accept a proven legacy contract
    Only retain the bridge if durable deployed-row evidence establishes the legacy representation and a safe way to preserve conflicting-kind detection.

Technical review

Best possible solution:

Preserve strict conflicting-kind rejection and keep the existing missing-ledger compatibility path; add a legacy bridge only after deployed-row provenance establishes how an unknown historical operation kind can be validated safely.

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

Yes, source-reproducible at this PR head: the focused test injects each legacy representation and then reuses its operation ID with a different requeue kind, which the introduced duplicate branch accepts rather than conflicts.

Is this the best way to solve the issue?

No: permissively treating an unknown historical kind as every possible terminal kind weakens the established replay invariant. Restoring strict validation is the narrowest safe repair unless durable provenance proves a different contract.

Full review comments:

  • [P1] Reject unknown terminal kinds on reused operation IDs — dashboard/exact-review-lifecycle.ts:589-592
    A string or kind: null row is normalized to a null kind, and this branch then treats any same-ID terminal request as a duplicate. A replay with a different terminal kind therefore returns success rather than the current-main 409, silently suppressing a conflicting lifecycle mutation. The prior review identified this unchanged behavior; retain strict rejection unless deployed durable-row evidence defines a safe compatibility rule.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 69ec53b00f11.

Labels

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🌊 off-meta tidepool and patch quality is 🧂 unranked krab.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🧂 unranked krab, so this older rating label is no longer current.

Label justifications:

  • P2: The patch affects upgrade and lifecycle replay compatibility, but no active service outage is evidenced.
  • merge-risk: 🚨 compatibility: The PR changes the interpretation of persisted terminal-operation identities and weakens the existing conflict response for legacy-shaped rows.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🌊 off-meta tidepool and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The author is a repository member, so the external-contributor proof gate does not apply. The supplied Wrangler/SQLite trace covers current-format replay behavior but does not resolve the introduced unknown-kind conflict defect.

Evidence

Acceptance criteria:

  • [P1] node --test test/dashboard-worker-publication-lifecycle.test.ts.
  • [P1] pnpm run check.

What I checked:

Likely related people:

  • vincentkoc: 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 (1 earlier review cycle)
  • reviewed 2026-09-03T13:56:35.450Z sha 98a2e67 :: blocked before merge. :: [P1] Keep unknown terminal kinds from bypassing conflict detection

@vincentkoc

Copy link
Copy Markdown
Member Author

Closing unmerged after deployment/source provenance resolved the premise.

Pre-f7c9afb15584b1837893877fdb3eca64f321b8bd source had no terminalOperationIds field, so those rows load as []. The deployed f7c9afb code only wrote concrete { operationId, kind } entries. Dashboard history shows successful deploys for f7c9afb (run 33712345842) and #1375's 69ec53b00f118593cf878d21d2975c8a52a84e3c (run 33762545402), with no deployment of the intermediate ce24cc9/29f171d3 heads that motivated the hypothetical string/null shapes.

Therefore no deployed row needs this decoder, while accepting null-kind IDs would weaken concrete-kind conflict detection. Hosted pnpm check passed on this branch, but the change is intentionally not landing.

@vincentkoc vincentkoc closed this Sep 3, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant