Lost lease-completion callbacks drop the owed source-drift follow-up review and misclassify completion-failure runs
Summary
When the Complete exact-review queue lease callback cannot reach the durable queue (outage, repeated 5xx, a non-whitelisted conflict), the aftermath is wrong on both of the run's possible conclusions:
- Direct publication accepted: the run stays green by design and the workflow_run reconciler heals the still-leased item from the run conclusion alone. That bare-outcome heal deletes the item, silently discarding the source-drift follow-up review that the completion payload's
direct_lifecycle_requeue: truewould have created. An item whose source drifted during publication, exactly the item that most needs a fresh review, never gets one. - Direct publication not accepted (durable-queue lane): the run goes red, and the only operator-facing annotation blames
classification=codex_or_content_failureeven though its own fields showreview_outcome=successand the actual failure was queue connectivity.
Environment
- Commit: a958131e8846d0e07673655fb1db2795971e4c12 (origin/main at time of filing)
- Surfaces:
.github/workflows/sweep.ymlevent-review-applyjob (completion step and fail gate),dashboard/exact-review-queue.ts/reconcileand/completehandlers,.github/workflows/exact-review-reconcile.ymloutcome mapping
Steps to reproduce
Defect 1 (lost source-drift follow-up):
- Lease a review item and deliver a direct publication receipt whose lifecycle is
{ kind: "requeue" }through the real signed ingress route/internal/exact-review/publication-results(source drift detected during publication, follow-up owed). - Control: deliver the completion callback with
direct_lifecycle_requeue: true. The item is requeued as a freshsource_drift_requeuerevision. - Defect path: the completion POST fails all 3 in-step attempts. The run concludes green (the fail gate's first clause requires
steps.direct-exact-review-publication.outputs.accepted != 'true', sweep.yml:2073). The reconciler then posts the run's green conclusion to/internal/exact-review/reconcileexactly asexact-review-reconcile.ymlmaps it. The item is deleted instead of requeued.
Defect 2 (misclassified red run):
- Same completion-callback failure in the durable-queue publication lane (
accepted != 'true', review generated and publication queued successfully, generation resultoutcome=success). - The fail gate's first clause fires on the completion failure and the step's
runblock emits its hardcoded annotation.
Expected
- A completion callback loss after an accepted direct publication should not erase the owed source-drift follow-up review. The lifecycle projection already holds the
requeueterminal fact at heal time, so the information survives the lost callback; only the reconciler's bare-outcome completion discards it. - A red run caused by a completion-callback failure should say so.
classification=codex_or_content_failureshould be reserved for runs where the review itself failed.
Actual
/reconcilecompletes the leased item withfinishExactReviewQueueItem(state, item, now, run.outcome, 0, false, undefined, this.random)(dashboard/exact-review-queue.ts:3477), a bare outcome with no lifecycle consultation. For a green run this takes thedelete state.items[item.key]path (dashboard/exact-review-queue.ts:12056). Thesource_drift_requeuerevision that/completewould have created viarequeueDirectLifecyclePublicationSync(dashboard/exact-review-queue.ts:2269, 7866) never exists, and with the item deleted the 130-minute lease-expiry backstop can no longer fire either. The drifted head goes unreviewed until some unrelated future event re-enqueues the item.- The fail gate's annotation is a single hardcoded string for every trigger path (sweep.yml:2091):
echo "::error::Exact review generation failed: classification=codex_or_content_failure reservation=$RESERVATION_STATUS review_outcome=$REVIEW_OUTCOME review_exit=$REVIEW_EXIT_CODE"
Nothing else in the repository emits or parses that string, so it is the only classification an operator sees. The same mislabel covers the held-reservation deferral whose completion failed (reservation=held, review skipped). The completion step's real HTTP error is only buried log text of a continue-on-error: true step.
Root cause (if known)
The completion callback is the only carrier of the completion metadata (direct_lifecycle_requeue, requeue_latest, completion_kind, reason_code), and both fallback paths that engage when it is lost ignore that metadata: the reconciler substitutes a bare run-conclusion outcome, and the fail gate substitutes a fixed classification.
Fix direction constraint worth recording: making the producer run red on a completion failure after an accepted publication is not a viable fix. The reconciler maps a red run to a failure completion for the still-leased item, which requeues a complete duplicate review of an already-published item, burns reviewFailureAttempts toward review_retry_exhausted, and contradicts the documented contract at dashboard/exact-review-queue.ts:2224 that an auxiliary-step failure must not make the reconciler requeue review work that already succeeded. A queue-side option: /reconcile could consult the lifecycle projection (which already records terminalDisposition.kind === "requeue" for the fenced revision) before finishing a leased review item with a bare success.
Sibling surfaces
- https://github.com/openclaw/clawsweeper/issues/894 covered the inverse false-red on benign completion conflicts; its fix (https://github.com/openclaw/clawsweeper/pull/895) whitelists
lease_superseded409s inside the completion step and is untouched by this report. Genuine completion failures (outage, 5xx, unexpected conflicts) still take the paths above. - https://github.com/openclaw/clawsweeper/pull/966 fixed a different path that wrongly burned failures as
codex_or_content_failure(head-drift reservations), showing this classification is treated as meaningful; the completion-failure trigger path still hardcodes it. - The publish job's
Fail unsuccessful exact review publicationguard and the terminal-acknowledgement job surface completion failures by reddening their runs; those jobs' items are publication or acknowledgement leases whose red-run reconciliation is the intended retry, so they do not have defect 1.
Real behavior proof
Behavior addressed: a lost lease-completion callback after an accepted direct publication silently deletes the owed source-drift follow-up review, and the same loss in the durable-queue lane produces a red run blamed on codex_or_content_failure.
Real environment tested: the production Cloudflare worker and ExactReviewQueue Durable Object code at commit a958131e8846, driven end to end through the real signed ingress route /internal/exact-review/publication-results, the real /internal/exact-review/reconcile route with the exact payload shape exact-review-reconcile.yml sends for a green run, and the real /complete handler; storage substituted in memory at the Durable Object storage seam, everything else real. The fail gate's production if-expression was evaluated by GitHub's own Actions expressions engine and its run block executed verbatim with the scenario's step results.
Exact steps or command run after this patch: node repro-drift.ts and node repro-annotation.mjs from /tmp/openclaw-bug-repros/clawsweeper-completion-metadata, against the workflow file and dashboard sources at a958131e8846.
Evidence after fix:
[completion-delivered] direct publication receipt (source drift detected, follow-up requeue owed): HTTP 202 {"ok":true,"accepted":true,"deduped":false,"superseded":false,"superseded_revisions":[],"canonical_target_key":"openclaw/openclaw#703","fence_key":"openclaw/openclaw#703","state_commit_sha":"do-revision:4"}
[completion-delivered] completion callback delivered: {"ok":true,"requeued":true}
[completion-delivered] queue item afterwards: {"state":"pending","revision":5,"sourceAction":"source_drift_requeue"}
[completion-unreachable-green-run] direct publication receipt (source drift detected, follow-up requeue owed): HTTP 202 {"ok":true,"accepted":true,"deduped":false,"superseded":false,"superseded_revisions":[],"canonical_target_key":"openclaw/openclaw#703","fence_key":"openclaw/openclaw#703","state_commit_sha":"do-revision:4"}
[completion-unreachable-green-run] completion callback: POST /internal/exact-review/complete unreachable for all 3 attempts; workflow run stays green (fail gate first clause requires accepted != 'true'), item still leased
[completion-unreachable-green-run] reconciler heals green run: HTTP 200 {"ok":true,"reconciled":1,"requeued":0,"completed":1}
[completion-unreachable-green-run] queue item afterwards: DELETED - no source-drift follow-up review remains anywhere
scenario: durable-queue publication lane (direct publication not accepted), review generated and
published fine, only the lease completion callback failed (queue outage, 3 attempts)
guard step if-expression evaluates: true -> step runs, job goes red
guard step run block executed verbatim, exit code 1, sole annotation emitted:
::error::Exact review generation failed: classification=codex_or_content_failure reservation=posted review_outcome=success review_exit=0
Observed result after fix: on identical inputs the delivered callback requeues the item as a fresh source_drift_requeue revision, while the green-run reconcile heal deletes it outright, and the red-lane annotation blames codex_or_content_failure while reporting review_outcome=success.
What was not tested: no live Cloudflare Durable Object or live sweep run was driven; the Durable Object storage API was substituted in memory while all queue, route, signature, and workflow logic stayed real; the reconciler's GitHub run lookup was not exercised, its documented conclusion-to-outcome mapping was applied to construct the reconcile payload.
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed August 30, 2026, 5:57 PM ET / 21:57 UTC.
Summary Keep open: current main still drops the persisted direct-lifecycle requeue during reconciliation, and the formally linked open fixing PR is the appropriate owner of the repair.
Reproducibility: yes. —current main source provides a high-confidence path: persist an accepted direct lifecycle requeue, lose completion, then reconcile a successful run through the generic completion helper. No target code was executed during this read-only review.
Regression provenance Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.
Root-cause cluster
Relationship: canonical
Canonical: https://github.com/openclaw/clawsweeper/issues/1245
Summary: This issue is the canonical report for the lost completion-metadata recovery path; the open linked PR is its candidate fix.
Members:
fixed_by_candidate: https://github.com/openclaw/clawsweeper/pull/1251 - It formally links to this issue and implements the described reconciler and workflow changes.adjacent_distinct: https://github.com/openclaw/clawsweeper/issues/894 - It addressed benign completion conflicts, whereas this issue concerns genuine callback loss and lifecycle metadata recovery.adjacent_distinct: https://github.com/openclaw/clawsweeper/pull/966 - It handles head-drift reservation classification, not a lost completion callback after direct publication.
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.
Next step https://github.com/openclaw/clawsweeper/pull/1251 already owns this bounded fix; avoid a duplicate repair PR and review it after its merge conflict is resolved.
Review details
Best possible solution:
Land a narrow reconciler recovery that requeues only accepted or deduplicated direct lifecycle plans, preserve superseded-receipt completion behavior, and identify queue-completion failures separately in the workflow annotation.
Do we have a high-confidence way to reproduce the issue?
Yes—current main source provides a high-confidence path: persist an accepted direct lifecycle requeue, lose completion, then reconcile a successful run through the generic completion helper. No target code was executed during this read-only review.
Is this the best way to solve the issue?
Yes—the linked PR's queue-side recovery is the narrow boundary because the lease retains the lifecycle fact that the bare run conclusion cannot convey.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
- The linked fixing PR was marked merge-conflicted in the captured context, so its proof and review must be refreshed after resolving base drift.
Codex review notes: model internal, reasoning high; reviewed against 99fa19072766.
Label changes
Label changes:
- add
clawsweeper:linked-pr-open: Current issue advisory state selects this label. - add
clawsweeper:no-new-fix-pr: Current issue advisory state selects this label. - remove
clawsweeper:queueable-fix: Current issue advisory state no longer selects this label. - remove
clawsweeper:fix-shape-clear: Current issue advisory state no longer selects this label.
Label justifications:
P1: A lost completion callback can leave a source-drifted item without the fresh review that the queue owes it.impact:other: The issue affects review-automation correctness and operator diagnosis rather than a more specific owned impact category.
Evidence reviewed
What I checked:
- Current reconciliation omits lifecycle-aware recovery: The current /reconcile handler matches a leased run and calls the generic completion helper with only the run outcome; it does not inspect the direct-publication lifecycle persisted on the lease. (
dashboard/exact-review-queue.ts:3508, 99fa19072766) - The missing recovery fact is durable: Accepted direct-publication receipts persist both the lifecycle plan and receipt outcome onto the lease decision, so reconciliation can distinguish an owed requeue from a superseded receipt. (
dashboard/exact-review-queue.ts:3087, 99fa19072766) - Successful generic completion deletes the lease: The generic queue completion path deletes an item when it is not requeued; a successful reconciled run therefore cannot preserve the source-drift follow-up by itself. (
dashboard/exact-review-queue.ts:12095, 99fa19072766) - Workflow annotation remains misclassified: The failure gate has a completion-failure clause but emits a fixed codex_or_content_failure annotation for every triggering path. (
.github/workflows/sweep.yml:1967, 99fa19072766) - Open fixing PR owns the implementation: The supplied GitHub context formally links https://github.com/openclaw/clawsweeper/pull/1251 to this issue and shows a focused lifecycle and workflow fix with recorded proof.
- Current-main check: Current main is 99fa19072766106fdf1586196d450b613bf2b09e and its recent history does not include the linked open PR; the inspected source still has the reported behavior. (
dashboard/exact-review-queue.ts:3508, 99fa19072766)
Likely related people:
- Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
How this review workflow works
- 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-reviewcomments, 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-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only. - Maintainers can also comment
@clawsweeper reviewto 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 explainto ask for more context, or@clawsweeper stopto stop active automation.
Landed in https://github.com/openclaw/clawsweeper/pull/1251 at https://github.com/openclaw/clawsweeper/commit/9f343df8bfd7e852a7e10601a6a9ea7345af6f60, with the contributor's authorship preserved.
The before/after Worker proof reproduced the lost callback on main: reconciliation deleted the accepted receipt's owed source-drift review. The fixed branch and merged main each preserved exactly one pending revision with its requeue terminal fact. A superseded receipt still completed without another review. The merged-main replay passed all 16 runtime assertions on AWS Crabbox cbx_7031f88109bf, run run_f60f73a3ce28, using real local workerd/SQLite and signed production routes. Initial lease setup and inspection were controlled proof seams; no production outage was induced.
Validation: pnpm run check passed with 4,140 tests passing and 8 skipped. Both independent Codex reviews passed at P0 scope. Current-head CI passed: https://github.com/openclaw/clawsweeper/actions/runs/33344206454. The current-head/body ClawSweeper review found no actionable defects and accepted the proof: https://github.com/openclaw/clawsweeper/pull/1251#issuecomment-5420682900.
Production deployment passed: https://github.com/openclaw/clawsweeper/actions/runs/33344651901. /api/health reports the merged SHA. The live reconciliation check passed: https://github.com/openclaw/clawsweeper/actions/runs/33344721744, reporting checked=21 terminal=0 reconciled=0 unavailable=0; it also checked 120 review placeholders with no orphaned entries, errors, or failed actions. This verifies deployed service health and real GitHub lookup, while the controlled runtime proof establishes the lost-callback behavior.
The update adds no new retry loop. Consolidated regression setup and retained immutable proof drivers reduced the proposed change by 823 lines. The isolated checkout ended clean on main, and the AWS lease has been released.