Repository navigation
fix(apply): accept receipt-backed own writes in deferred re-apply freshness - #1734
Conversation
…shness 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.
|
🦞👀 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 October 1, 2026, 3:05 AM ET / 07:05 UTC. ClawSweeper reviewWhat this changesClawSweeper's apply lane accepts its own receipt-backed updates during deferred publication, with regression coverage, transport traces, and updated safety documentation. Merge readiness✅ Ready for maintainer review This PR remains necessary: current main handles acknowledgement edits but still rejects the producer's released-lease update during deferred re-apply. The patch has no actionable correctness findings, and the recorded production-path proof supports the fix. Priority: P1 Review scores
Verification
How this fits togetherThe apply lane consumes completed review records and checks live GitHub activity before publishing comments, reconciling labels, or closing items. Its freshness checks must distinguish ClawSweeper's coordination writes from changes that invalidate a review. flowchart TD
A[Completed review record] --> C[Apply freshness checks]
B[Live GitHub activity] --> C
C --> D[Match source and activity receipt]
D --> E[Verify automation write]
E --> F[Publish through existing action gates]
D --> G[Reject drift and requeue]
E --> G
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Retain generation-bound automation receipts while preserving external-change rejection and the existing final action gates. Do we have a high-confidence way to reproduce the issue? Yes: current-main source and the recorded baseline production-path replay establish that producer lease deletion causes deferred re-apply to report source drift. This reviewer did not execute the harness. Is this the best way to solve the issue? Yes: the patch extends the existing freshness owner using complete review receipts and generation identity, without weakening publication immutability or duplicating queue ownership. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against cac974b3e1da. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Summary
A close proposal that its exact-review producer keeps open (durable comment synced, close gate
kept_open) ended in a ~23-minutesource_drift_requeueloop whenever its direct publication was deferred. Examples: openclaw/openclaw#143911 (runs 36671559049 -> 36672608523 -> 36673368897) and openclaw/openclaw#139260 (run 36673226845). The batch publisher re-applied the same review and treated the producer's own writes as source drift. Apply freshness now accepts anupdated_atmoved only by ClawSweeper-recorded writes. Real external changes still block and requeue.Root cause
The producer's last write is releasing its review lease, a
DELETEof the lease comment after the durable comment PATCH. The deletion moves the PRupdated_atand leaves no live comment to witness. The batch re-apply of the same pre-apply artifact therefore sawupdated_at changedand recordedskipped_changed_since_reviewwithsourceDriftVerified, which requeues a full review.The deferral itself (
invalid_direct_publication_plan: conflicting direct publication retry) is a separate queue defect and is not changed here. The ordinary-item revision allocator does not floor on directly published revisions, so a re-admitted item can reuse one, and the canonical tuple receipt correctly rejects the different bytes. That revision-reuse defect is tracked as a separate follow-up lane.Change
Freshness.
createApplySourceFreshnessgeneralizes fix(apply): stop own acknowledgement edits from requeueing source drift #1715's acknowledgement witness into one receipt check. A post-snapshot update is automation-only when either:updated_at; orclawsweeper-review-versionmarker (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 five minutes.Both paths also require a matching complete source/timeline/head/review-activity receipt, and no non-automation comment, review comment or timeline event after the snapshot.
Policy. The AGENTS.md "Safety Rules" drift line now says that drift blocks apply unless the only change is the existing ClawSweeper review comment, or a ClawSweeper-recorded write for the item (
docs/scheduler.md) while the complete source/timeline/head/activity receipt matches and no non-automation activity follows the review snapshot.docs/scheduler.mddocuments both receipt paths.Proof harness.
scripts/e2e/apply-source-drift-final-effect.mjsadds the #143911 producer-then-batch scenarios. Capture restores the durable comment's snapshot body from its read-only GraphQL edit history, and the seeded review lease stays live so the apply adopts it as production does.Behavior proof
scripts/e2e/apply-source-drift-final-effect.mjsdrives realghagainst a stateful synthetic GitHub API seeded from read-only captures. Builds: baselinecac974b3e1(origin/main), candidate349741921f.skipped_changed_since_reviewand requeues.review_comment_synced(metadata only) +kept_open, with no requeue, no durable PATCH and no close.recordedandclose-capable, #158447, all 4 scenarios, 24 runs). Baseline and candidate are identical, and match fix(apply): stop own acknowledgement edits from requeueing source drift #1715's recorded outcomes:kept_open.kept_open.Receipts, seed hashes and limits are in
docs/proof/receipt-based-freshness/README.md.Validation
node --test test/apply-source-freshness.test.ts: 9/9 pass. The new positive cases fail on origin/main.pnpm run checkon the merged code head606ffe5e65: exit 0 (7,133 tests, 0 fail).lint:scripts,check:docs,check:changelog,format:check. Main did not move, so the full check was not re-run.OpenClaw Bay: not affected. No queue, status, telemetry or dashboard data contract or public field changes.
Risks/rollback
fix(apply)commits and the AGENTS.md line. Freshness then returns to fix(apply): stop own acknowledgement edits from requeueing source drift #1715 behavior.Follow-up: the queue revision-reuse defect behind
conflicting direct publication retryis tracked as a separate lane.Review
Codex
/review(autoreview, branch mode againstorigin/main, P0–P1 threshold): clean on head53deda6319, "patch is correct" (0.86). It confirmed that the new freshness exceptions require a matching complete review receipt and no visible non-automation activity after the snapshot.Follow-up tracked separately: the "conflicting direct publication retry" deferral comes from exact-review revision reuse after direct publication. A re-admitted item can be allocated a revision it already published directly. That is a queue allocator defect with its own PR and proof; this PR intentionally does not loosen the direct-publication immutability check.