Repository navigation
fix(queue): keep explicit requests answerable across deferred publication - #1984
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
a530111 to
4c60cc8
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4c60cc8c24
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const continuesHeldRequest = | ||
| verifiedSourceDriftRequeue && | ||
| this.continuesHeldCommandPublicationSync(state, decision, activeBatchItemKeys, now); |
There was a problem hiding this comment.
Merge held-request requeues into an existing review item
When an ordinary webhook revision is already queued for the item while the deferred publisher still holds the explicit request's publication, current is truthy, so this continuation check is never reached; the earlier existing-item path classifies every source_drift_requeue as an ignored low-priority recovery and returns a successful admission without merging its verified command context. The ordinary review can then run without authorization or command acknowledgement, leaving the explicit request unanswered even though the publisher still owns its newest publication. Apply the held-publication checks when an existing non-command item is present and merge the command obligation into that item.
AGENTS.md reference: AGENTS.md:L38-L46
Useful? React with 👍 / 👎.
|
@clawsweeper review Requested once for landing. Proof, before/after results, Codex review dispositions, and validation for head 4c60cc8 are in the PR body. This stacked follow-up also carries the reserved continuation-prefix guard that #1981 latest review asks for. |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesThis PR preserves explicit review requests through deferred publication, protects queued commands during refresh, and prevents finished commands from reaching organic successors. Example: Producer run 7100, attempt 1, requeues an explicit request while its deferred publication remains held.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: current main still needs these fixes, and the reviewed head resolves the earlier producer-authority finding without a new actionable defect. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Worker’s exact-review queue accepts command and publisher decisions, persists their lifecycle, and hands authorized decisions to review and publication workflows. flowchart LR
A[Explicit request] --> B[Exact review queue]
B --> C[Review worker]
C --> D[Deferred publication]
D --> E[Producer bound continuation]
E --> B
B --> F[Apply and status owners]
Technical reviewBest possible solution: Preserve the producer-bound continuation and command lifecycle fixes here, with the existing queued-review collision handled by #1989. Do we have a high-confidence way to reproduce the issue? Current-main source exposes the verification drop and command overwrite paths, and the supplied before/after scenarios exercise them; this read-only review ran no target code. Is this the best way to solve the issue? The patch repairs the existing queue, lifecycle, and shared publisher payload owners without introducing another authority store or configuration option. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8ae8cba03403. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed October 14, 2026, 4:47 AM ET / 08:47 UTC (Revision 3). |
4c60cc8 to
014bde0
Compare
|
@clawsweeper re-review Addressed the review on 4c60cc8 for head 014bde0: the held-publication continuation is now followed through the real apply owner to its final GitHub writes, with finished, lease-lost, replaced, and newer-publication controls making no write; an upgrade run reopens rows persisted by origin/main; and the branch is rebased onto the parent's current head. Proof tables, artifacts (docs/proof/deferred-request-continuation), and the finding dispositions are in the PR body. |
|
🦞👀 Re-review progress:
|
… requeues (#1981) An explicit `@clawsweeper re-review` on a maintainer-authored PR was silently lost when the PR changed while the review ran (on #1969 and again on this PR, another bot's PR review moved the review-activity cursor). Apply skipped publication for source drift, the queue requeued the generation in place as `source_drift_requeue`, and claim admission skipped that retry as an automatic maintainer review, leaving the command status at "Review in progress" and its review lease held for about an hour. - `isExplicitReviewRequest` now accepts a `source_drift_requeue` that still carries the request's command status and verified command fields, so the queue's fenced in-place requeue continues the same request through claim admission and the hosted publication gate. - The queue keeps request verification on a `source_drift_requeue` only when it requeued the generation in place (`direct-lifecycle-requeue:` admission provenance). The rule runs in the load-time normalizer and on `/enqueue`, so a finished or replaced request re-enqueued by a publisher, including rows persisted by the previous release, keeps its status but cannot authorize another review. `/enqueue` rejects caller delivery ids that use the queue-owned prefix (`reserved_delivery_id`). - AGENTS.md, docs/scheduler.md, README, and a changelog fragment state the contract; deferred publications (batch publisher requeues) still need a new request and are tracked in the stacked #1984. Proof: replay of #1969's real rev 2/rev 3 claim decisions through the compiled `live-item` admission step, real queue Durable Object lifetime and upgrade tests, final effects through the real apply owner on an owner-authored oversized PR (continuation writes; finished-request requeue zero writes), and a cross-version run where main persists an orphaned verified requeue and this change claims those bytes as non-explicit.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 014bde0ba9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| !item.terminalFinalization && | ||
| publication?.itemKey === key && | ||
| revision !== null && | ||
| exactReviewSameVerifiedCommand(publication.producerDecision, decision) && |
There was a problem hiding this comment.
Bind the continuation to its originating publication
When two deferred publications for the same explicit request overlap at different source revisions, this search can authorize the older publisher’s requeue using the newer publisher’s held item: the command metadata matches, and the newer candidate satisfies the publication-head test, but nothing ties the candidate’s producerRunId/attempt to the incoming publisher-source-drift:<run>:<attempt> delivery. If the newer publisher then completes and answers the request, the stale queued continuation retains verified authority and may run the request again; require the held publication lineage to match the requeuing publisher.
AGENTS.md reference: AGENTS.md:L42-L46
Useful? React with 👍 / 👎.
…tion Follow-ups to #1981, each of which left a command request unanswered: - A deferred publisher's source-drift requeue keeps the request's verification while the publisher still holds the request's newest publication and no other command reached the item since. The admitted item carries a queue-owned `held-publication-requeue:` delivery prefix that the load-time verification rule honors; `/enqueue` rejects caller delivery ids with either continuation prefix. Any other orphan requeue still drops it. - The batch publisher builds its requeue with the shared `enqueue source-drift` CLI, so both publishers send one delivery id per review generation (`publisher-source-drift:<producer run>:<attempt>`). - Command-bearing recovery is no longer shed by backpressure or a GitHub throttle window. - An artifact refresh leaves a queued command intact. A different, older producer command is answered as superseded instead of overwriting it. - An organic successor of a pending terminal finalizer no longer inherits the finalized command. The `--refuse-terminal-state` report is intended behavior (#1675) and is unchanged.
…nd upgrade ClawSweeper asked for the held-publication continuation to be followed to the final GitHub effects and through an upgrade. - test/exact-review-deferred-publication-fixture.ts drives the real queue from a verified request through a held deferred publication to the publisher's source-drift requeue and returns the decision the review job claims. The source-drift tests now share it. - test/oversized-pr-close.test.ts feeds those claimed decisions to the real apply owner on the OWNER-authored oversized PR: the open continuation syncs the durable review and closes; finished, lease-lost, replaced, and newer-publication continuations stop at skipped_maintainer_authored with no write. - docs/proof/deferred-request-continuation/upgrade.mjs reopens rows that origin/main persisted (held and refreshable publications, queued commands, a pending finalizer) with another release; the README and JSON artifacts record both the final effects and the upgrade.
014bde0 to
37101de
Compare
|
@clawsweeper re-review The previous request was lost, not answered. Its review (https://github.com/openclaw/clawsweeper/actions/runs/38522067648) was superseded at 06:28Z when #1981 merged and GitHub retargeted this PR's base to main. The next generation (https://github.com/openclaw/clawsweeper/actions/runs/38523668129) carried no command and was skipped as automatic. Its status still held review coordination until 07:29:53Z. Requesting once more for head 37101de: the same two reviewed commits, rebased onto main after #1981 landed ( |
|
🦞👀 Re-review progress:
|
ClawSweeper and the Codex connector noted that the held-publication check accepted any held publication with the same verified command. An older producer's late source-drift requeue could therefore borrow a newer publication's authority, and keep it after that publication answered the request. The requeue's delivery id (publisher-source-drift:<producer run>:<attempt>, shared by both publishers) names its producer, so the queue now looks up exactly that publication and applies the held, newest, and no-other-command checks to it alone. The shared fixture gains the overlapping-publication scenario, which the queue tests and the apply-owner final-effects tests both run; with the previous scan it fails.
Same-lineage publication deduplication keeps a retained queue key while refreshing the item's producer to a newer run or attempt. The publisher then requeues under the refreshed producer's delivery id, so a lookup by a constructed queue key wrongly rejected that legitimate continuation. The held-publication check now matches the publication's itemKey and producer run and attempt, and keeps the held, newest, and no-other-command checks. A regression test refreshes a deferred publication's producer under its retained key; the key lookup fails it.
The "no other command since the producer" check matched the review fence key case-sensitively, but queue keys keep repository casing verbatim. A newer request admitted as OpenClaw/OpenClaw#N and answered without a publication was invisible to an openclaw/openclaw#N continuation, which then kept its verification. Every casing of an item shares one revision counter, so the check now compares fence keys case-insensitively. It reads through the existing repository index (LOWER(repo), canonical_target_key, fence_key, revision), which EXPLAIN QUERY PLAN confirms as an indexed search scoped to one repository. The shared fixture gains the casing-alias scenario; the exact match fails it.
|
@clawsweeper re-review Addressed the review on 37101de for head 635a9df:
New scenarios are older-producer-borrows-newer-publication, newer-command-answered-under-other-casing, and a refreshed-provenance continuation. They run through the real queue and the real apply owner, and each fails under the previous code. Dispositions for the review findings and both inline Codex comments, with the updated proof tables, are in the PR body. |
|
🦞👀 Re-review progress:
|
After #1984 landed, the held-continuation check matches the publication by the producer named in the requeue's publisher-source-drift delivery id. The queued-review handoff passes that delivery id too, so only the producer that still holds its own publication can hand its request to a pending review.
…iew (#1989) An explicit @clawsweeper re-review could still stay at "Review in progress" when its review's publication was deferred and an ordinary review was already queued for the item: the publisher's source-drift requeue was ignored as low-priority recovery, nothing carried the request, and the publication still recorded lifecycle requeue. - A verified source_drift_requeue that meets a pending, request-less, non-publication review hands the still-current request to that review (new command revision, admission held-publication-requeue:<delivery id>), keeping the review's newer source. Currency comes from #1984's producer-bound continuesHeldCommandPublicationSync (the requeue's delivery id must name the producer that still holds its own newest publication, and no other command reached the item). - A deferred publication's lifecycle requeue stands only if a review at the item admitted the same request after the producer revision (sameCommandAdmittedAfter, sharing #1984's casing-aware scan); otherwise the queue records superseded so the request gets a terminal answer, in /complete and idempotently in the batch post-effect. Direct-lifecycle receipts are excluded. - Rebased onto main after #1981/#1984: the handoff passes the requeue's delivery id (producer binding), with a test that a requeue naming another producer leaves the pending review untouched. Proof: real queue Durable Object scenarios; the transferred decision through the real apply owner on an owner-authored oversized PR (a current request publishes and closes; finished, lease-lost, replaced under either casing, older-producer, and wrong-producer requeues make zero writes); the real finalizer status CLI leaves a status comment reused by a newer request untouched. Live: #1981's in-place continuation was exercised in production on this PR (drift injected mid-review; the requeued revision was admitted, published, and the command status reached Complete).
Follow-up to #1981, which landed as
9ac67f94(its head131383c7). This branch is rebased ontomain;git range-diffshows both commits unchanged from the reviewed stacked version.What Problem This Solves
Follow-ups found while reviewing #1981. Each one leaves an explicit command request without an answer: its status sticks at "Review in progress" or "Queued", or the wrong request gets answered. Five reported items were verified against the code; four are real and fixed here.
main. Fixed.main. Fixed.main. Fixed.--refuse-terminal-statelets "Failed" through1. Deferred publication. When a review's publication is deferred, the publisher (
sweep.yml"Queue fresh review after source drift", or the batch publisher) re-enqueues the claimed decision assource_drift_requeuewhile it still holds the publication itemrepo#N@publish:<run>:<attempt>. Nothing is queued atrepo#N, so #1981's lifetime rule dropssourceCommentVerified, and a maintainer's open request is then skipped as automatic. The two publishers also used different delivery ids for the same producer generation:publisher-source-drift:<producer run>:<attempt>(sweep) andpublisher-source-drift:<publication key>:<publication revision>(batch). A batch run that requeued and then lost its membership, or a re-claim by the other publisher, admitted a second requeue of the same generation.2. Publication refresh.
refreshExactReviewPublicationItemmerged the refreshed producer decision into a pending or parked item atrepo#Nwith{...current, ...next}. An older producer's command fields andartifact_retention_recoveryoverwrote a newer queuedre_reviewwithouttransitionCommandRevision. The newer request lost its status marker and its explicitness, and the older request was revived in its place.3. Pending terminal finalizer. The
/enqueuemerge base for a pending finalizer atrepo#Nwas the finalized producer decision. An organic successor (an issue edit, a push) inherited the finalized command's marker, status comment, and verified fields. That contradicts the comment above it, skips the debounce, reopens the old status comment, and admits the organic review as command-originated.4. Shed continuations. A source-drift requeue that still carries command context is low-priority by source action, so it was shed under backpressure (
EXACT_REVIEW_PENDING_SOFT_LIMIT) or during a GitHub throttle window. Both publishers accept.shed == trueand record lifecyclerequeue, which hands the status to a successor that never exists.docs/limits.mdalready promised that commands stay admitted, and the loop breaker already exempted command context.5. Not a bug. "Failed" stays non-terminal for the fence on purpose (#1675: failed, interrupted, and waiting states stay retryable). The review-failure ladder and dead-letter recover-fresh rely on it to finish the original command. On maintainer items,
artifact_retention_recoveryis not an explicit request, so recover-fresh stops at admission and the status stays "Failed".Why This Change Was Made
Held-publication continuation (
continuesHeldCommandPublicationSync). Asource_drift_requeuethat finds no queued item keeps its verification only when all of these hold:publisher-source-drift:<producer run>:<attempt>names the producer, and the queue holds that producer's own publication under a live lease or an active batch lease. The publication is matched by its producer run and attempt, not by queue key, because same-lineage deduplication keeps a retained key while refreshing its producer. An older producer's requeue therefore cannot borrow a newer publication's authority;otherCommandAdmittedAfter). Every casing of an item shares one revision counter, and the query reads through the existing repository index (EXPLAIN QUERY PLAN:SEARCH … USING INDEX exact_review_lifecycle_projection_bay_repository_journey).Every other orphan requeue still loses verification, as in fix(review): keep explicit maintainer re-reviews through source-drift requeues #1981. A finished request (publication completed), a lost publisher lease, a newer answered request, and a newer publication all fail closed.
fix(review): keep explicit maintainer re-reviews through source-drift requeues #1981 strips verification whenever the queue loads an item, unless
admissionDeliveryIdcarries the in-place requeue prefix (3ce7e49d). An item admitted through this check is stamped with a second queue-owned prefix,held-publication-requeue:<delivery id>, which that load-time rule also honors. fix(review): keep explicit maintainer re-reviews through source-drift requeues #1981's131383c7reserves the in-place prefix at/enqueue. This PR extends that check to both queue-owned continuation prefixes (reserved_delivery_id), so a caller-chosen delivery id cannot keep a stale requeue's verification through either one.One delivery id per review generation. The batch publisher now builds its body with the same
enqueue source-driftCLI as the direct publisher, so both sendpublisher-source-drift:<producer run id>:<attempt>. This also removes the batch workflow's duplicated jq copy of the kept-action rule.Refresh keeps a queued command. A pending or parked item that carries command context is left untouched, matching
/enqueue, where a recovery never replaces queued work. When the refreshed producer's command differs, completion records lifecyclesupersededinstead ofrequeuein both/completeand batch completion. That command then gets its terminal answer ("A newer review tuple already exists"), instead of an orphaned "Review in progress".Finalizer merge base. For a publication-shaped pending finalizer, the merge base drops command-scoped fields (
exactReviewDecisionWithoutCommand). A non-publication finalizer decision can be a still-pending follow-up command, so it is kept as before.Shedding. The new
isSheddableExactReviewRecoveryexempts command context from both shed paths: backpressure and the throttle token check.User Impact
@clawsweeper re-reviewnow also gets answered when its publication was deferred and the item changed before publication.Automatic and scheduled work keeps its existing opt-in and shedding behavior.
Documentation Impact
docs/scheduler.md(maintainer opt-in paragraph): describes the held-publication continuation and removes fix(review): keep explicit maintainer re-reviews through source-drift requeues #1981's "batch publisher needs a new request" limitation.docs/limits.md:AGENTS.md: the canonical request-lifetime line now names the deferred publisher's requeue next to the in-place one.Changelog fragment:
changelog.d/command-continuation-followups.md.Real Behavior Proof
ExactReviewQueue) through/enqueue,alarm,/claim, and/complete(review, publication, and refresh completions), plus/publication-batches/claimand/publication-batches/complete..github/workflows/exact-review-batch-publish.yml, run in bash with realjqand the realsrc/repair/exact-review-queue-request.ts enqueue source-driftCLI. Onlypnpm(the post-effect HTTP call) is stubbed, to capture the body.publisher:<run>:1), and a publisher run claims it.sourceDriftRequeuebody: as-is; after the publication finished; after its lease expired; after a newer request was answered; after a newer publication was admitted./completeand batch completion.editedevent.3ce7e49d(detached worktree with only the new tests copied in; the same results held on the earlier heada92b6dcb).3ce7e49d)held-publication-requeue:publisher-source-drift:<run>:1); claimed decision explicit after the load-time rule/enqueuewith a caller delivery idheld-publication-requeue:…ordirect-lifecycle-requeue:…400 reserved_delivery_id7100attempt 1publisher-source-drift:openclaw/openclaw#710@publish:7100:1:3publisher-source-drift:7100:1, byte-identical to the direct publisher's body{"ok":true,"shed":true,"reason":"backpressure"}queued: true, item pendingscheduled_ratequeued: true, item pending/completewith a queued newerre_reviewartifact_retention_recovery; lifecyclerequeuesuperseded; finalization driver for the older marker;terminal_finalization: truere_reviewdowngraded toartifact_retention_recoveryre_review; lifecyclerequeuesupersededfinalizereditedafter a pending finalizercommandOriginated: false; driver keeps the old markerFinal effects (authority chain through the real apply owner)
The decision the real queue hands the review job (
deferredContinuationClaimintest/exact-review-deferred-publication-fixture.ts) goes through the real apply owner. The owner runs with--exact-event-publicationon #1981's OWNER-authored oversized pull request fixture,openclaw/openclaw#141913(test/oversized-pr-close.test.ts), with a recordinggh. Artifact:docs/proof/deferred-request-continuation/final-effects.json.131383c7)skipped_maintainer_authored, no write (the scenario fails)review_comment_synced,closedPOST issues/141913/comments(durable review),pr close 141913,PATCH issues/comments/150913(close notice)skipped_maintainer_authoredskipped_maintainer_authoredskipped_maintainer_authoredskipped_maintainer_authoredskipped_maintainer_authoredskipped_maintainer_authoredOpenClaw/OpenClaw#N)skipped_maintainer_authored(131383c7has no held path)skipped_maintainer_authoredskipped_maintainer_authoredskipped_maintainer_authoredskipped_maintainer_authored(131383c7has no held path). The previous head37101de2kept the borrowed verification, and the queue claim was explicit (mutation check).skipped_maintainer_authoredUpgrade from the deployed release (data-model compatibility)
docs/proof/deferred-request-continuation/upgrade.mjs:origin/mainbc3ae1d960persists real queue rows to file-backed SQLite through the real routes. Two releases then reopen those exact files: #1981's head131383c7and this branch. Artifact:upgrade-result.json.publisher-source-drift:…, verification dropped; claim not explicitheld-publication-requeue:publisher-source-drift:…, verified; claim explicitrefresh_requiredwith a newer request queuedartifact_retention_recoverywith the older marker; lifecyclerequeue; newer request not explicitre_reviewunchanged and explicit; refreshed commandsupersededwith a terminal finalizationeditedEvery persisted row loads on both releases, and
/statsanswers 200. No schema or table changes: the only new persisted value is theheld-publication-requeue:prefix onadmissionDeliveryId, written only by the queue.main, so this PR's own review does not exercise the change.Evidence
test/exact-review-source-drift-loop.test.ts,test/dashboard-worker-publication-lifecycle.test.ts,test/exact-review-publication-batches.test.ts,test/repair/exact-review-batch-workflow.test.ts. On3ce7e49d, every new positive test fails, and the guard tests pass both ways.pnpm run test:unit: 4741 tests, 0 failures, 18 skipped. This ran before the two review fixes below; the affected files were rerun on the final code.node scripts/run-node-tests.mjs repair: 896 tests, 0 failures, 12 skipped.source_drift_requeuein the batch workflow source, which now comes from the shared CLI) was updated to assert the shared CLI call.pnpm run check:fastpasses: static, docs, changelog, limits, format, three builds, lint.sameCommandStatusAddress: any conflicting part of the address means a different command.a92b6dcbis scoped-clean.3ce7e49d, the committed branch against3ce7e49dis scoped-clean. The rebase changed only the integration with the load-time rule.6af7d5ce(docs-only) and131383c7merged the scheduler paragraph and folded fix(review): keep explicit maintainer re-reviews through source-drift requeues #1981's in-place prefix reservation into this PR's prefix list. After the last rebase, the source-drift suite (17 tests) andcheck:fastpass.ClawSweeper review dispositions (head
37101de2)older-producer-borrows-newer-publication:skipped_maintainer_authoredwith zero writes.actual: true).newer-command-answered-under-other-casing; the exact match fails it.a deferred continuation follows a publication refreshed under its retained key) covers it, and the key-lookup version fails it.ignoredRecoverygap listed under Follow-up, and the PR does not change that path. Carrying a command onto a queued organic item changes/enqueuemerge semantics for every recovery, so it is being fixed and proven separately.ClawSweeper review dispositions (head
4c60cc8c)skipped_maintainer_authoredwith zero writes.131383c7. That commit reserves the in-place prefix itself; this PR's reservation list now covers both prefixes.Follow-up (not in this PR)
When an organic item is already queued at
repo#N, a command-bearingsource_drift_requeueis still dropped as low-priority recovery (ignoredRecovery), so that command's status can orphan. Fixing it changes/enqueuemerge semantics and needs its own review.