Repository navigation
fix: finalize legacy command acknowledgements without webhook races - #1018
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 3, 2026, 4:38 AM ET / 08:38 UTC. ClawSweeper reviewWhat this changesThis PR binds legacy and modern command acknowledgements to exact GitHub comment versions, lifecycle revisions, and delivery identities across the repair router, GitHub workflows, Worker queue, and Bay telemetry. Merge readinessKeep this PR open: current Priority: P2 Review scores
Verification
How this fits togetherClawSweeper turns authorized GitHub command comments into repair or review workflows, then writes verified terminal status back to GitHub and durable Bay telemetry. This change hardens the identity carried between those inputs, the authoritative queue decision, status acknowledgements, and completion records. flowchart LR
A[GitHub command comment] --> B[Repair router]
B --> C[Workflow dispatch]
C --> D[Authoritative review queue]
D --> E[Verified status acknowledgement]
E --> F[Bay journey telemetry]
Before merge
Findings
Agent review detailsSecurityNeeds attention: The available diff changes authenticated webhook and signed receipt provenance, but unavailable current-head blobs prevent a complete final security pass. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the exact comment-version, lifecycle-fence, and delivery-identity approach, then obtain a fresh full-head review that verifies every workflow-to-Worker propagation path and preserves legacy compatibility before landing. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main records a terminal completion into Bay immediately after submitting it to the lifecycle queue, without checking whether that queue accepted the exact acknowledgement. The supplied PR body also contains redacted production outputs for the legacy stuck-finalization case, although no tests were run in this read-only review. Is this the best way to solve the issue? Unclear until the full current head is inspectable: exact immutable comment, revision, and delivery identities are a narrow and appropriate repair direction, but every workflow and durable-state propagation path needs review at the latest head. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e55de43cfc03. LabelsLabel changes:
Label justifications:
EvidenceSecurity concerns:
What 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 (6 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…penclaw#1018) * fix: finalize legacy command acknowledgements without webhook races * fix: recover fenced legacy command acknowledgements safely * fix: fence command receipts and deduplicate Bay completions * fix: fence terminal acknowledgements to original command delivery * fix: reuse fresh router comment snapshots after dispatch recovery --------- Co-authored-by: Peter Steinberger <[email protected]>
Summary
openclaw/openclaw#115286by recognizing its exact, action/head-bound legacy command marker in both the repair CLI and authoritative Worker.updated_at; unchanged legacy completions work without a webhook, modern webhook completions remain single-counted, and command edits keep their correct journey.gpt-5.6-sol/xhigh, and disabled OpenClaw automatic merging.Root cause and real production proof
The public exact-review queue repeatedly reported:
The real bot status comment
5150578737contains the original command marker for source comment5150571675, but predates canonicalclawsweeper-command-ackmarkers. Existing finalization updates the comment successfully but cannot verify its source receipt, leaving the publication permanently retryable.A fresh GitHub API fetch of that actual production comment, passed through the newly compiled production receipt parser, now proves:
The same production parser rejects the exact comment body when its comment ID is forged and still verifies authorized legacy commands that have only an exact status marker. Hosted Worker integration covers legacy and canonical acknowledgements across re-review, autofix, and automerge; the authoritative lifecycle rejects wrong IDs/markers without updating Bay telemetry, binds reused modern comments to the matching head marker, and preserves marker-only attempts. End-to-end repair CLI fixtures additionally recover legacy admissions whose advertised temporary comment was already deleted or whose advertised comment belongs to an older marker. Router workflow coverage proves the retained existing comment is selected before dispatch advertises its ID.
Executing the newly compiled production router dispatch function against a precreated-to-retained comment transition confirms the actual dispatched identity:
Executing the newly compiled production status-update CLI against the real comment body and two stale predeployment addresses produces verified terminal receipts in both cases:
The existing guarded dead-letter reconciler separately resolved 45 stale rows. Generated OpenClaw fix PRs remain create-only; both OpenClaw merge switches are disabled.
Review disposition
A fresh Codex review of the original committed head found two actionable P1 provenance gaps: a legacy webhook could acknowledge a different same-marker status comment, and the repair CLI could select a different same-marker status comment than the one requested. Legacy acknowledgements now carry a strict status-comment provenance flag through the authoritative queue, and the repair verifier honors the expected status-comment ID.
The first follow-up precommit review identified marker-only legacy commands and precreated fast acknowledgements that router convergence replaces with an older existing status comment. Both are preserved explicitly: marker-only attempts bind to the exact authorized marker, and dispatch resolves the retained comment before publishing its status-comment ID.
The next precommit review identified reused modern shared comments that could complete the wrong fence and pre-existing admissions that still pointed at a deleted/replaced status comment. Modern receipt matching now requires agreement when both markers exist. Legacy finalization securely rebinds only when the advertised comment no longer exists or demonstrably belongs to a different status marker; a still-valid same-marker advertised comment remains mandatory.
The latest fresh precommit review identified ID-only legacy admissions and Bay journeys completed through a signed direct receipt after a migrated webhook was rejected. Exact comment-ID matches now remain valid when the admission has no marker, and the authenticated lifecycle endpoint updates Bay only after the durable queue accepts a review/re-review receipt. All eight accepted findings have focused regression coverage.
A subsequent review identified double-counted normal review completions and parsing before signature verification. Signed receipts now carry their admitted status-comment ID; Bay repair runs only when that ID differs from the verified completion comment, and request JSON is parsed only after signature verification. All ten accepted findings have focused regression coverage.
The latest precommit review reproduced one additional P2 timestamp-provenance finding: synthesizing a migrated completion from receipt-processing time duplicated modern completions and could incorrectly complete a newer edit of the same source command. The repair CLI now extracts the verified GitHub comment's actual
updated_at(including the returned PATCH response), signs that exact timestamp into the workflow receipt, and reuses it for Bay repair. Focused regressions independently cover migrated modern deduplication and preserving an older completion when a newer command edit exists.The first committed-branch review reproduced a P1 cross-revision provenance gap and a P2 missed legacy completion: a migrated signed receipt could complete a newer same-head projection when its admitted comment ID was ignored, and unchanged legacy comments produced no new webhook. The authoritative queue now validates and forwards the signed admitted comment ID, lifecycle observation matches that exact authorized attempt, and every accepted signed review receipt completes its Bay journey using the verified GitHub timestamp.
A subsequent precommit review identified that replaying the same verified completion while another edit of the same source command remained pending could consume that unrelated edit. Bay merging now recognizes an exact existing completion identity before choosing another pending journey. End-to-end Worker regressions independently cover same-head cross-revision isolation, unchanged legacy receipt recovery, malformed admitted IDs, duplicate signed receipts, and webhook-plus-signed replay with multiple edits of the same source command.
The next committed-branch review reproduced an additional same-comment cross-revision collision. Terminal workflow receipts now sign the immutable lifecycle fence and revision, the authoritative queue requires that identity as an all-or-nothing pair, and the projection store matches the exact admitted revision. Its follow-up precommit review independently reproduced an unfenced GitHub webhook completing the wrong revision and a fenced older receipt completing a newer Bay journey. Ambiguous unfenced observations now fail closed without mutating either revision.
The following fresh review proved that lifecycle admission IDs (
router:.../publisher:...) are not GitHub webhook delivery IDs, and reproduced unidentified-webhook races, legacy records without delivery IDs, and same-second orphan collisions. The original authenticated GitHub delivery ID now travels end-to-end through the hosted webhook, router workflow and command, sweep intake decision, immutable lifecycle admission, verified finalization receipt, and Bay reducer. Webhook completions receive the same canonical delivery identity from the authoritative queue. The reducer repairs a previously misattributed unidentified completion, accepts unambiguous legacy journeys, and keys identified orphan completions by delivery. The compiled production router proof above verifies both retained status-comment identity and the unchanged original GitHub delivery ID.The next independent review found six additional production defects: both repository-dispatch hops exceeded GitHub's hard ten-property limit; edited comments could inherit an older delivery ID; scheduled recovery lost delivery provenance after a durable claim; identified completion orphans did not join legacy triggers; and a newer scoped receipt arriving before an older receipt left its journey permanently pending. The hosted webhook now omits redundant
source_eventonly when carrying delivery identity, while the router workflow infers its fixedissue_commentsource. Routed PR budgets share onereview_optionsfield, with backwards-compatible support for existing flat timeout fields. Delivery identity is accepted only for an authenticated matching comment timestamp and body digest, persisted in claimed/waiting durable ledger entries, and recovered only for that exact comment version. Bay accepts unambiguous mixed-version completion orphans and rejoins detached scoped receipts after correcting provisional matches. The real compiled PR dispatch proof above carries both adaptive timeouts, the original delivery identity, retained status-comment ID and command marker in exactly ten payload properties. All 120 possible trigger/webhook/scoped-receipt arrival permutations converge to two correctly attributed completed journeys.The latest independent precommit review reproduced one P1 and two P2 integration regressions: the nested review-budget variable was accidentally declared in an earlier, separate Node heredoc; replacing a queued command without a new delivery ID retained the previous command's provenance; and shared-marker revisions with distinct status-comment IDs incorrectly rejected a uniquely identifiable webhook. The actual workflow serializer now declares its own nested options, and an executable regression runs both isolated Node heredocs against a real nested PR payload. Queue merges clear delivery identity whenever the marker or status-comment changes without a replacement identity. Unfenced lifecycle observations now prefer a single exact status-comment match while continuing to reject genuinely ambiguous same-comment attempts. All three behaviors have focused production-path regressions.
A second fresh review found three remaining same-comment race conditions. Concurrent state-ledger publication could discard a verified delivery when a scheduled waiting entry outranked the authenticated claim; same-head replacements could reuse both marker and status-comment ID while inheriting the old delivery; and an untagged legacy journey could capture a later tagged completion and disappear after normalization. Concurrent ledger union now preserves delivery only when repository, comment ID, exact comment timestamp and SHA-256 body digest all match. Any explicit command replacement without its own identity clears inherited provenance, including same-marker/same-comment replacements. Tagged completions detach provisional legacy observations and prefer their exact delivery-matched trigger before source-less legacy fallbacks. Regression tests exercise both concurrent merge directions, edited-body rejection, same-head replacements, and normalization after mixed legacy/scoped receipt arrival.
A further independent review stress-tested concurrent delivery permutations and exposed two additional convergence failures: three independently published command snapshots could choose different authenticated delivery IDs depending on merge grouping, and a provisional anonymous completion could consume the only identified journey before its genuine fenced completion arrived. Ledger union now chooses one canonical authenticated delivery deterministically, permanently discards provenance after conflicting or partially missing exact-comment identities, and is proven commutative and associative across 46,656 three-way status/delivery/body combinations, including legacy commands without body fingerprints. Bay now moves misassigned anonymous completions back to their own orphan, prefers exact delivery-matched orphans over earlier anonymous completions, safely assigns anonymous receipts only when exactly one compatible journey remains, keeps the newest of repeated delivery-fenced receipts, and breaks same-second completion ties by canonical comment ID. All 600 exhaustive permutations across nine identified/legacy/repeated-completion scenarios converge to identical journeys. The corrected reducer also passed 30,000 randomized, mixed-order trigger/retry/webhook/fenced-receipt scenarios without a dropped or misattributed journey.
The latest completed independent precommit reviews identified two related actionable P2 gaps: durable
appendLedger()command advancement dropped the invalidated-delivery tombstone, and the router's in-memory prior-claim index discarded tombstones before an authenticated redelivery was dispatched. The authoritative ledger now preserves conflict tombstones across every status transition, suppresses all delivery IDs on conflicted commands, rejects malformed tombstones during durable loading, indexes conflicted pending commands even without a delivery ID, and rejects event delivery provenance whenever the matching prior command is tombstoned. Regressions advance a conflicted waiting command to executed with a forged replacement delivery and replay an authenticated exact-comment webhook; neither path restores delivery provenance.The first committed-branch review identified one actionable P2 throughput regression: comment-history pagination ran before durable dispatch deduplication and repeated again when the status reply was written. Existing dispatch claims now short-circuit before any status-comment lookup, and retained status-comment selection reuses the router's existing per-issue comment cache. A follow-up precommit review correctly noted that a reused cache must be invalidated after successful comment creation, update, or temporary-ack deletion; all three mutation paths now evict the affected issue. The real compiled retained-comment dispatch proof remains unchanged while source-level coverage verifies the deduplication order, absence of duplicate
ghPagedhistory scans, and all mutation invalidation paths.Validation
401after zero JSON parses.git diff --checkpassed.