Skip to content

fix(reconcile): supersede proven stale dead letters - #1148

Merged
steipete merged 4 commits into
mainfrom
steipete/head-mismatch-supersede
Aug 12, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/head-mismatch-supersede

Conversation

@steipete

@steipete steipete commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Production reconcile run 31648987909 at 2026-08-12T22:56Z was the first run with the skip taxonomy from openclaw/clawsweeper#1147. It reported 125 skipped targets, with head_mismatch: 121, blocked_alias: 3, active_work: 1, and zero recoveries. The open DLQ tail held 191 rows: 158 retry_exhausted, 31 tuple_protocol_invalid, and two workflow_cancelled.

These head mismatches are immutable publication artifacts for old pull-request heads. Replaying them would publish stale review state, but leaving every row open forever also leaves the DLQ without an endgame.

Why This Change Was Made

The existing HMAC-authenticated canonical record route is strong enough to prove supersession without adding a new endpoint: GET /internal/state/records/<repo-slug>/items/<number>. Its Durable Object envelope supplies canonical content, digest, monotonic revision, and update time; the report binds repository, item number, pull-request type, review status, and reviewed head.

The reconciler now resolves a head-mismatched row as superseded only when that digest-valid record identifies the same pull request, says the review is complete, and records the live GitHub head, which must differ from the dead-letter head. It then immediately re-reads GitHub and requires the same open node identity and head before mutation. Missing, malformed, failed, wrong-target, or wrong-head records leave the row open as head_mismatch_unproven; mutation-time drift leaves it open as head_mismatch_revalidation_changed.

The authenticated lifecycle audit inventory remains corroborating evidence only. It exposes completed/superseded lanes and canonical receipt outcomes, but deliberately omits source heads, so it cannot independently authorize this resolution.

User Impact

Each cycle checks at most ten head-mismatch targets and resolves at most 20 supported rows per proven target. Successful resolutions include the full newer head and exact canonical endpoint in the audit note, use the existing alias guard, and increment publication completed/superseded totals without counting a publish. Dry-run reports the plan without mutation.

tuple_protocol_invalid and workflow_cancelled rows are explicitly excluded. The stage never re-enqueues reviews and never resolves from absence of evidence.

Evidence

RED on fresh origin/main at 9a257905e50be2dff9bb99afecb6cde50f8417f9 retained 81 passing operator scenarios while the four new behavior scenarios failed at the missing contract. After a build, the dedicated Worker RED test also failed on the absent superseded metric accounting.

GREEN passes all 224 focused operator and queue-runtime scenarios. The complete pnpm run check gate passes 3,391 tests with nine platform skips and zero failures. Pre-commit and committed-branch Codex autoreviews report no accepted/actionable findings.

The first ClawSweeper verdict raised one accepted P1 finding: a pull request could advance after canonical evidence was read but before the Worker mutation. Fix round 1 adds the immediate same-open-node/same-head recheck and a B→C race fixture that proves zero resolution or recovery on drift. The full gate, autoreview, and container proof were refreshed for the new implementation head.

Real Behavior Proof

Proof status: sufficient.

Docker-backed Crabbox ran the real operator CLI and Durable Object route through loopback queue, GitHub, canonical-record, resolution, and metrics seams on committed implementation head 10b45760a0c0fe1adf156909e2df0d737d5fef6a.

  • Provider: local-container
  • Lease: cbx_a7a8d9e75f26 (brisk-shrimp-3201)
  • Image: node:24-bookworm
  • Result: 224 passed, 0 failed; exit 0, including the mutation-time B→C race
  • Cleanup: lease stopped automatically and is absent from the provider inventory
  • Receipt: docs/proof/head-mismatch-supersede/receipt.json
  • Contract: docs/proof/head-mismatch-supersede/behavior-contract.md
  • Source-blind result: docs/proof/head-mismatch-supersede/behavior-report.json

The refreshed proof artifacts were committed with fix round 1 in the same push. The branch head is e44f2bccdbd6da8058c9226e224c39ecd696d93f; the proof-only child commit does not change the executed code.

The proof uses deterministic loopback fixtures. It does not mutate the production queue, consume GitHub quota, or claim that any particular production row already has matching canonical evidence.

OpenClaw Bay

No Bay change is needed. This remains queue-owned observer-only state: existing aggregate metrics and the dynamic skip-reason map reflect the new outcome, while Bay gains no queue, workflow, GitHub, recovery, deploy, or rollback action.

@clawsweeper

clawsweeper Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. 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 Aug 12, 2026
@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 12, 2026, 7:29 PM ET / 23:29 UTC.

ClawSweeper review

What this changes

Adds a bounded exact-review reconciler path that marks stale publication dead letters as superseded only when a canonical completed review proves the same pull request has advanced to its current head.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This PR remains necessary: current main classifies head-mismatch skips but does not safely end proven stale publication dead letters. The prior P1 race finding is resolved by an immediate same-node/same-head recheck, with a focused B→C drift scenario and sufficient container proof on the current implementation content.

Priority: P2
Reviewed head: e44f2bccdbd6da8058c9226e224c39ecd696d93f

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Strong current-head-bound runtime proof and focused race coverage support a clean re-review after the earlier P1 fix.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body and committed receipt provide a Docker-backed local-container run of the real operator and queue route with 224 passing scenarios, including the after-fix head-drift recovery behavior.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body and committed receipt provide a Docker-backed local-container run of the real operator and queue route with 224 passing scenarios, including the after-fix head-drift recovery behavior.
Evidence reviewed 6 items Current-main gap: The checked-out main at 9a25790 does not contain the new canonical-supersession helper or mutation-time drift classification; its related merged work is the adjacent skip-taxonomy PR #1147.
Race guard: The proposed path obtains digest-valid canonical evidence, then immediately rereads GitHub and refuses resolution unless the pull request remains open with the same node identity and head used for that evidence.
Focused regression coverage: The B→C fixture verifies that a head advance after canonical evidence produces head_mismatch_revalidation_changed with neither resolution nor recovery mutation.
Findings None None.
Security None None.

How this fits together

The exact-review reconciler reads publication dead letters, live GitHub pull-request identity, and canonical review records to decide whether stale work can be resolved or must remain open. Its guarded queue mutation records the audit outcome and updates publication metrics without re-enqueuing a review.

flowchart LR
A[Publication dead letters] --> B[Reconcile operator]
B --> C[Live GitHub pull request]
B --> D[Canonical completed review record]
C --> E{Same open node and head?}
D --> E
E -->|proven| F[Guarded superseded resolution]
E -->|unproven or drifted| G[Leave row open]
F --> H[Queue audit and metrics]
Loading

Before merge

  • Resolve merge risk (P1) - Merging enables automatic resolution of production queue rows; it is deliberately fail-closed, but correctness depends on the existing authenticated canonical-record route and the immediate GitHub recheck continuing to represent the live pull-request state.
  • Complete next step (P2) - The prior actionable race finding is fixed and the PR has sufficient current implementation proof; no separate repair task is indicated.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production versus regression coverage production +236, tests +299 The reconciliation and Worker protocol change is accompanied by more focused regression coverage than production growth.
Proof scope 224 focused scenarios, 1 Docker-backed provider The proof exercises the operator CLI and queue route, including the mutation-time head-drift case.

Merge-risk options

Maintainer options:

  1. Accept the bounded reconciliation policy (recommended)
    Approve the guarded supersession behavior, which limits each run to ten proven targets and twenty rows per target while leaving any evidence or identity drift unresolved.
  2. Pause automatic supersession
    Keep stale rows open if maintainers do not want canonical completed reviews to authorize this queue-resolution outcome.

Technical review

Best possible solution:

Land the bounded, fail-closed reconciliation path so proven old-head publication artifacts stop accumulating while unproven, excluded, and drifted rows remain visible for later handling.

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

Yes. The committed proof establishes the stale-head, canonical-record, and post-evidence B→C drift scenarios through the real operator and queue boundary; this review did not rerun the container suite.

Is this the best way to solve the issue?

Yes. Reusing the authenticated canonical record plus a final live GitHub identity/head recheck is narrower and safer than replaying old publication work or resolving rows from head drift alone.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 9a257905e50b.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body and committed receipt provide a Docker-backed local-container run of the real operator and queue route with 224 passing scenarios, including the after-fix head-drift recovery behavior.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded operational reliability improvement for dead-letter reconciliation rather than an immediate user-facing outage.
  • merge-risk: 🚨 automation: The PR changes automated exact-review queue resolution and aggregate publication accounting.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body and committed receipt provide a Docker-backed local-container run of the real operator and queue route with 224 passing scenarios, including the after-fix head-drift recovery behavior.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body and committed receipt provide a Docker-backed local-container run of the real operator and queue route with 224 passing scenarios, including the after-fix head-drift recovery behavior.

Evidence

What I checked:

Likely related people:

  • steipete: Peter Steinberger authored the current-main skip taxonomy and recovery-routing work that owns this operator path, as well as this focused revalidation change. (role: recent area contributor; confidence: high; commits: 9a257905e50b, c8a9737486d5, 10b45760a0c0; files: scripts/exact-review-dead-letter-operator.mjs, dashboard/exact-review-queue.ts, test/exact-review-dead-letter-operator.test.ts)

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-08-12T23:17:31.282Z sha 5ac6c51 :: needs changes before merge. :: [P1] Revalidate the pull head before resolving stale rows

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 12, 2026
@steipete
steipete merged commit ae36d60 into main Aug 12, 2026
19 checks passed
@steipete
steipete deleted the steipete/head-mismatch-supersede branch August 12, 2026 23:33
steipete added a commit that referenced this pull request Aug 13, 2026
…1149)

Fixes the 401s that blocked #1148's evidence-gated supersession (run 31651591787: all 10 canonical-record lookups rejected).

Root cause: the canonical-record GET route (/internal/state/records/<slug>/items/<n>) verified only CLAWSWEEPER_WEBHOOK_SECRET, while the reconcile operator signs with EXACT_REVIEW_OPERATOR_SECRET. #1148's tests stubbed the Worker with a single shared secret, hiding the two-secret production reality.

Fix (review-narrowed to least privilege): webhook auth is attempted first; the operator secret is accepted as fallback for the items collection ONLY - closed/plans/decision-packets remain webhook-only. 503 only when neither secret is configured. No operator/workflow changes; the webhook secret stays out of workflow environments.

Proof: real-Worker matrix with DISTINCT secrets - operator 200/401/401/401 across items/closed/plans/decision-packets, webhook 200 on all four, garbage 401 on all four; Crabbox local-container receipt committed in the same push (docs/proof/operator-record-read-auth/); full gate 3393/0. Verdict clean (Findings: None, Security: None) on 06561bd.
steipete added a commit that referenced this pull request Aug 13, 2026
…sede proven-stale tuple rows (#1152)

Root-causes and fixes the tuple_protocol_invalid dead-letter class (30 rows), closing the DLQ's last unexplained residue.

Fingerprint archaeology: the dominant 21-row class hashed to a generic invalid_direct_publication_plan opacity bucket - 19 rows are debris of the mixed-case slug bug already fixed in #1100 (steipete/CodexBar targets), two lost their pre-#1091 detail and stay honestly unclassified. The live 4-row class is "conflicting direct publication retry": guarded apply refreshes current_item_*/apply_checked_at after canonical acceptance, so publication retries see byte-conflicts against their own accepted plan (hit both pre- and post-#1143 items, including re_review command results - NOT a protocol-v2 command bug).

Live fix: an actively owned batch resumes from its terminal canonical receipt instead of conflicting with itself; strict direct-publication conflict and fence checks preserved. Stale tuple rows now pass through the #1148 six-way evidence-gated supersede (newer-head completed record required); current-head rows stay recoverable so they republish after this fix; workflow_cancelled remains excluded.

Proof: red reproduced the HTTP 400 conflict and the supersede exclusion; green 176/176 focused scenarios; full gate 3396/0; Crabbox local-container receipt at this head (docs/proof/tuple-protocol-rootcause/). Verdict clean (Findings: None, Security: None) on 5b67ae2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. 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