Repository navigation
fix(apply): stop own acknowledgement edits from requeueing source drift - #1715
Conversation
Exact PR review marks ClawSweeper's acknowledgement comment
(clawsweeper-pr-ack) complete after the review snapshot and before direct
publication. GitHub moves the PR updated_at for that edit, so close
proposals failed apply freshness with skipped_changed_since_review
("updated_at changed", sourceDriftVerified) and requeued another
source_drift_requeue review, which repeated the same edit forever
(openclaw/openclaw#126549 reached revision 25 on one head; #158447 revision
160 escaped only through a stale item read).
Apply freshness now accepts that edit as automation-only when a
ClawSweeper-authored acknowledgement for this item carries the item's
latest updated_at and the review's complete source, timeline, PR head, and
review-activity receipt still matches. Human comments, title/body and
non-managed label edits, PR reviews, new heads, other bots' comment edits,
and tuple-less legacy reviews still block apply and requeue as before.
…eue-loop # Conflicts: # CHANGELOG.md
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 29, 2026, 11:41 PM ET / September 30, 2026, 03:41 UTC (Revision 2). ClawSweeper reviewWhat this changesThe branch lets apply accept a ClawSweeper-authored PR acknowledgement edit when the complete review activity receipt still matches, and adds regression tests, a transport proof harness, and operator documentation. Merge readiness✅ Ready for maintainer review Keep open. Current main still rejects the bot’s acknowledgement edit as source drift. The new final-effect evidence addresses the prior review’s proof request, and this review found no blocking patch defect. Priority: P1 Review scores
Verification
How this fits togetherExact review records a snapshot before ClawSweeper marks its acknowledgement complete. The apply lane compares that snapshot with live GitHub activity before publishing the durable review, syncing labels, or closing an item. flowchart LR
A[Exact review snapshot] --> B[Acknowledgement edit]
B --> C[Apply freshness check]
D[Live activity receipt] --> C
C -->|Matches| E[Publish review and eligible close]
C -->|Changed| F[Requeue review]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: An exact review should publish after ClawSweeper’s own acknowledgement edit while any changed human activity, title, or PR head still forces a fresh review. Do we have a high-confidence way to reproduce the issue? Yes. The PR documents a controlled current-main apply run in which an acknowledgement-only edit yields source drift and requeue, while the candidate proceeds to publication. Is this the best way to solve the issue? Yes. The exception is confined to a bot-authored acknowledgement with matching item identity, latest timestamp, and complete live receipt; the documented outside-activity cases remain rejected. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0f5162431a34. 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)
|
…eue-loop # Conflicts: # CHANGELOG.md
Drive the compiled non-dry-run apply-decisions CLI (exact-event publication arguments) and ClawSweeper's own update-review-status acknowledgement edits through native gh over http_unix_socket to a stateful synthetic GitHub API seeded from a captured PR and rewound to its exact-review snapshot. The API models updated_at and timeline effects of comment, label, title, push and close writes and traces every request, so each scenario records the final GitHub effects (close request, durable comment sync, label edits, lease writes) for a baseline and a candidate build without mutating GitHub.
…shness (#1734) * fix(apply): accept receipt-backed own writes in deferred re-apply freshness A close proposal that its exact-review producer kept open (durable comment synced, close gate kept_open) ends with the producer releasing its review lease, which deletes the lease comment and moves the PR updated_at. When direct publication was deferred, the batch publisher re-applied the same review, saw that bump as source drift, recorded skipped_changed_since_review, and requeued a full source_drift_requeue review about every 23 minutes (openclaw/openclaw#143911 runs 36671559049 -> 36672608523 -> 36673368897, openclaw/openclaw#139260 run 36673226845). Apply freshness now generalizes the acknowledgement witness from #1715 into one receipt check for ClawSweeper's own writes. An update after the review snapshot is automation-only when a ClawSweeper-recorded receipt for the item accounts for the latest updated_at: a live ClawSweeper item-marker comment or a ClawSweeper-actor timeline event (managed label edit) with exactly that time, or the review generation's own lease comment is gone while the durable review comment carries that generation's review-version marker (item, reviewed_at, source revision, lease owner, lease comment id), was synced after the snapshot, and the update follows the generation's last recorded write by at most the five-minute apply-lease hold. Every receipt also requires the complete source, timeline, head, and review-activity receipt to match and no non-automation comment, review comment, or timeline event after the snapshot. Human comments, title/body or label edits, PR reviews, and new heads still block and requeue. The real-transport e2e harness gains the #143911 producer-then-batch shape and external-change controls. * docs(changelog): add receipt-based freshness fragment * fix(apply): match every ClawSweeper item marker kind in freshness receipts * docs(proof): record receipt-based freshness batch re-apply proof * docs(agents): describe receipt-based apply drift allowance * test(e2e): restore the durable comment's snapshot body from its edit history * docs(proof): add #1715 regression rerun to receipt-based freshness proof
Summary
Close-proposal PRs were being re-reviewed forever. Every exact review ended with
skipped_changed_since_review("updated_at changed",sourceDriftVerified: true), which requeued a freshsource_drift_requeuereview that hit the same drift. openclaw/openclaw#126549 ran revisions 13 through 25 on one unchanged head (f96bfcce), and its durable review comment was last updated on 2026-09-22. openclaw/openclaw#158447 reached revision 160.The drift came from ClawSweeper itself. Apply freshness now treats ClawSweeper's own review-acknowledgement progress edit as automation-only activity, but only when the review's complete activity receipt proves nothing else changed. Real external changes still block apply and requeue, exactly as before.
Root cause
For PRs with an acknowledgement comment (
<!-- clawsweeper-pr-ack:… item=N -->), the exact-review workflow runsupdate-review-statustwice. It first marks the comment "reviewing", just before the review snapshot. It then marks it "complete" after Codex finishes, which is before the direct-publication apply. GitHub moves the PR'supdated_atwhen a comment is edited:updated_atequalled the ack comment'supdated_atat both 01:13:43Z and 01:17:50Z.updated_at=2026-09-28T00:13:40Z, which is the time of the "reviewing" edit. The "complete" edit landed at 00:18:10Z.The review therefore stores
item_updated_atas the time of the "reviewing" edit, and the "complete" edit always counts as post-snapshot activity.For close proposals and guarded actions,
createApplySourceFreshness().reviewedSourceFresh()accepts anupdated_atchange only through four automation witnesses:retry_pr_close_coverage_proofNone of these matches the acknowledgement comment, so apply reports source drift. The run then gets a
source_driftdisposition, the lifecycle requeues, and the loop starts again.Two details explain the pattern seen in production:
updated_atthat lagged the edit by 2 s. Replaying the edited state onmainshows it drifts too.Change
src/clawsweeper-apply-source-freshness.tsadds a fifth automation witness. It fires only when all of these hold:updated_atchanged since the review;clawsweeper-pr-ackmarker hasupdated_atequal to the item's latestupdated_at;earlyLeaseState.comments), so it adds no GitHub request.AGENTS.md,docs/scheduler.md, andCHANGELOG.mddescribe the narrowed allowance.scripts/e2e/apply-source-drift-final-effect.mjs(with its-server.cjs) is a reusable real-transport proof harness; it is test-only and changes no production code.Behavior proof
Real transport final-effect proof
Contract
Claim: On the production write path, with native
ghas the transport, origin/main turns ClawSweeper's own acknowledgement "complete" edit into source drift and requeues without publishing anything. This branch publishes instead: durable comment sync, label reconciliation, and, for a close-capable record, the close request. On both builds, a human comment, a new PR head, or a title edit after the snapshot is rejected before any close, durable-comment or label effect.Exercised surface:
apply-decisionsCLI in non-dry-run mode, with the exact argument set ofsrc/repair/publish-event-result.ts runApplyDecisions;dist/repair/update-review-status.js(--state reviewingbefore the snapshot,--state completeafter it), as the workflow does;exactEventApplyProof/eventApplyRequeueLatestExpectedfrom the same build, applied to the apply report to get the requeue decision.gh2.101.0 fromPATH, with noGH_BINoverride, no stand-in client and no production-code hook. gh reaches a stateful synthetic GitHub API over its documentedhttp_unix_socketoption, the same pattern asdocs/proof/paired-close-drift. Proxies point at an unreachable port.Fixture:
updated_atbumps and timeline events). A push is modelled as a head-SHA change plus ahead_ref_force_pushedevent. Every request is recorded with method, path, status, actor, GraphQL operation and effect.implemented_on_main);implemented_on_main);stalled_unproven_pr). Its live guards are all met by the captured state: rating D, needs-proof label since 2026-08-20, no head activity since 2026-08-20, no human engagement. This variant proves the fresh path reachesgh pr close, and that the stale scenarios never do.Sequence per scenario:
The scenario write uses the PR author's token, or a synthetic push. It comes before the ack "complete" edit, so the ClawSweeper edit is the latest update: exactly the case the new allowance must not mask.
Command and environment:
node scripts/e2e/apply-source-drift-final-effect.mjs capture --gh gh --out .artifacts/lane-a/real-transport/seeds.node scripts/e2e/apply-source-drift-final-effect.mjs run --seed-dir .artifacts/lane-a/real-transport/seeds --baseline <origin/main checkout> --candidate <branch checkout> --out .artifacts/lane-a/real-transport/run.0f5162431a(origin/main); candidatecaa9e1eb3e(this branch). HEAD2004c55feeadds only the harness, and its SHA-256 matchesrun.log.Artifacts: under
.artifacts/lane-a/real-transport/:run/summary.json;run/<item>-<record>-<scenario>-<build>/, containingrequests.tsv(every request: method, path, status, actor, GraphQL operation, effect),http-trace.jsonl,apply-report.json,apply.stdout.log/apply.stderr.log,report-before.md,report-after*.mdandfinal-state.json;run.log, which records the Node and gh versions, both heads, and the harness and seed SHA-256s.Observed final effects (apply phase, writes only)
0f5162431acaa9e1eb3eskipped_changed_since_review(updated_at changed), requeue. Writes: apply-lease create/delete only. 0 durable comment, 0 labels, 0 closePATCH …/comments/5351817173200, thenkept_openby the paired-closeout gate. 0 closeremoveLabelsFromLabelable[status: 👀 ready for maintainer look], durablePATCH …/comments/5841242718200,kept_open(paired closeout). This matches what production rev 160 did when its stale read avoided driftPATCH200, closeout notePOST201,gh pr close→ GraphQLPullRequestByNumber+PullRequestClose200 (1 close request), then leaseDELETEupdated_at changed), requeue. Lease create/delete only. 0 close, 0 durable, 0 labelslive PR head 3333… differs from reviewed head …), requeue. No writes at all: rejected before lease acquisitionupdated_at changed), requeue. Lease only. 0 close, 0 durable, 0 labelsAcross the 24 runs there was exactly one close request: the close-capable (a) scenario on the branch. For pull requests the production close path is
gh pr close, so the close request is the GraphQLclosePullRequestmutation, not a RESTPATCH state=closed. The server records both forms. The apply-lease comment create/delete is ClawSweeper's own coordination write, made before classification on both builds; this change does not touch it.Limits
updated_atand timeline effects. No real GitHub object is mutated. Transport is a Unix socket, not TLS.implemented_on_main, which the paired-closeout gate keeps open.publish-event-result's arguments. That wrapper's Worker record store and the sweep.yml Finalize requeue are not run; the requeue decision comes from the production proof functions.Offline replay (dry-run)
Contract
source_drift_requeue. A human comment, title edit, label edit, or new head in the same window still reports drift and requeues.apply-decisionsCLI, run with the argument set fromsrc/repair/publish-event-result.ts runApplyDecisionsplus--dry-run;exactEventApplyProof/eventApplyRequeueLatestExpectedapplied to its report to get the requeue decision.updated_at = T_complete, and the storeditem_updated_atisT_review.9e5dbde8…for #126549 and1240e8a6…for #158447 rev 160.ghrefuses all non-read calls, and in replay mode it refuses any unrecorded read.run-proof.sh <worktree> <dist@8d659e7cb9> <dist@c8aa82b6aa> <out>, run offline with Node v24.21.0 on macOS (local, no container)..artifacts/lane-a/proof/summary.json, per-runapply.log,gh-calls.jsonlandreport-before.md, plus the harness and fixture hashes in the handoff.Observed (22 runs, all exit 0, no missing recordings)
main8d659e7updated_atunchanged)updated_at changed)The
mainresult for the ack-only scenario matches the production apply output for #126549 in run 36361785207 exactly:skipped #126549: updated_at changed,sourceDriftVerified: true.Limits
ghHTTP transport.Validation
test/apply-source-freshness.test.ts(new) holds unit tests for the witness with its six negative cases, plus twoapply-decisionsCLI regressions in the real #126549 shape.skipped_changed_since_review/updated_at changed/sourceDriftVerified.PATH=/opt/homebrew/bin:$PATH CLAWSWEEPER_TEST_CONCURRENCY=6 pnpm run checkon2004c55fee, under Node v26.10.0 from that PATH and bash 5.3, on a host at load average 65–98 from parallel lanes:build:all, lint (includinglint:scripts) and changed coverage (13/13) pass..artifacts/lane-a/check3-isolated-rerun.log).c8aa82b6aa, the same families timed out under load and passed in isolation.OpenClaw Bay: not affected. The change narrows the apply-time source-drift classification. It adds no queue or lifecycle field, published schema, status value, route, or control. Bay continues to show the same lifecycle outcomes: after this change these items show up as publications instead of source-drift requeues.
Risks / rollback
updated_atbump. The trust boundary is the same one used by the existing durable-comment and owned-lease witnesses: GitHub-verified bot authorship and exactupdated_atequality. It also requires the complete source, timeline, head, and review-activity receipt to match, which is stricter than the lease witness's legacy fallback. Human edits to ClawSweeper-managed labels (status:,rating:,P*,proof:exceptproof: override) remain outside the receipt, as they already are for the existing witnesses.c8aa82b6aa; the harness commit is test-only. The loop behavior returns, but nothing is persisted differently.Live impact on 2026-09-30
The loop is still burning review capacity in production. Each item below receives a full exact review about every 8 minutes, and every one ends in
skipped #N: updated_at changed→requeue_latest=true→source_drift_requeue.These five items alone consume about 35 full reviews/hour, while seven-day coverage has fallen to 35.3%. After merge, the verification is that these items publish (
review_comment_syncedor their close proposal) and stop receivingsource_drift_requeuegenerations.Review
Codex
/review(autoreview, branch mode against currentorigin/main, P0–P1 threshold):72447ed127(0.88);2004c55feeafter the real-transport harness and main merge (0.86). It confirmed that the acknowledgement exception requires bot ownership, a matching latest-update timestamp and a complete matching activity receipt.ClawSweeper's P1 on
72447ed127(no final-effect proof) is addressed by the "Real transport final-effect proof" subsection above. The realghclient ran against a stateful synthetic GitHub API:The local full check timed out 14 load-sensitive tests in untouched files on an overloaded host (they pass 179/179 when rerun alone). CI on this head is the clean full-check gate.
Note: this PR also updates the
AGENTS.mdSafety Rules drift line, so the documented policy names the owned acknowledgement-progress edit, conditioned on a matching receipt.