Repository navigation
fix(reconcile): supersede proven stale dead letters - #1148
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 12, 2026, 7:29 PM ET / 23:29 UTC. ClawSweeper reviewWhat this changesAdds 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 readinessThis 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 Review scores
Verification
How this fits togetherThe 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]
Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest 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. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
…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.
…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.
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: 158retry_exhausted, 31tuple_protocol_invalid, and twoworkflow_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 ashead_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_invalidandworkflow_cancelledrows are explicitly excluded. The stage never re-enqueues reviews and never resolves from absence of evidence.Evidence
RED on fresh
origin/mainat9a257905e50be2dff9bb99afecb6cde50f8417f9retained 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 checkgate 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.local-containercbx_a7a8d9e75f26(brisk-shrimp-3201)node:24-bookwormdocs/proof/head-mismatch-supersede/receipt.jsondocs/proof/head-mismatch-supersede/behavior-contract.mddocs/proof/head-mismatch-supersede/behavior-report.jsonThe 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.