Repository navigation
refactor(sweep): simplify apply and review owners - #1407
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed September 4, 2026, 3:14 AM ET / 07:14 UTC. ClawSweeper reviewWhat this changesConsolidates repeated review-comment synchronization, review-start lease acquisition, and mutation bookkeeping, while removing obsolete comments and source-text assertions. Merge readiness⛔ Blocked before merge - 2 items remain This remains a useful, unmerged refactor with no actionable code findings. The added real workflow traces bypass the extracted synchronization and lease-acquisition paths, so the previous proof blocker remains. Priority: P3 Review scores
Verification
How this fits togetherClawSweeper turns GitHub item reviews into stored reports, then applies eligible comments, labels, and closures. Review leases coordinate workers, while freshness checks prevent older reports from overwriting newer decisions. flowchart TD
A[GitHub items and context] --> B[Review lease coordination]
B --> C[Review and stored report]
C --> D[Apply freshness checks]
A --> D
D --> E[Comment synchronization decision]
E --> F[Eligible GitHub updates]
D --> G[Skip stale report]
Before merge
Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep the shared calculations in their existing owners while preserving rewritten-report matching, freshness checks, and lease cleanup. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR proposes behavior-preserving cleanup rather than a reported runtime bug; source review found no concrete introduced failure. Is this the best way to solve the issue? Yes: consolidating these calculations within their existing owners is a narrow approach, and the inspected branches preserve the previous distinctions. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0bf6bf603a12. LabelsLabel changes:
Label justifications:
EvidenceWhat 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 (1 earlier review cycle)
|
…ginal commits (#1409) <details> <summary>Additional instructions</summary> **MUST:** Keep **Allow edits from maintainers** enabled for this PR so maintainers can help update the branch when needed. </details> ## What Problem This Solves Resolves a problem where a ClawSweeper review could attribute a GitHub test merge's main parent to the original PR commit. The [historical review of the Gateway PR](openclaw/openclaw#136998 (comment)), reviewed at `2026-09-04T01:20:32.984Z`, claimed that original head `15ca0925f5d164df5283783aea5f4a01ffe3924e` had current main as its recorded parent. The original raw commit proves otherwise. The [producer run](https://github.com/openclaw/clawsweeper/actions/runs/33825006229) ran code `8440386ebd92f39c5d6812d74cda3793a67530a3`. Its archived report (`exact-review-33825006229-1`, artifact ID `9919776836`, report SHA-256 `3db6dce3fe4050873ad4131159604ecd62b11432eed98a73fd962cba873772bb`) preserves the incorrect claim; the linked durable comment is mutable and now contains later reviews. The raw report is deliberately not reproduced here. | Object role | Exact commit | Raw recorded parents, in order | | --- | --- | --- | | Original PR head | `15ca0925f5d164df5283783aea5f4a01ffe3924e` | `cd8c74889d21ddcc9f3a2d47fe868224a0e44acb` | | Historical GitHub test merge | `782c712e2dad405a2e9010354b5291fb94d42fe6` | `3c0eb9fd822f8101dc3117ce40dbd2b0f5e01930`, `15ca0925f5d164df5283783aea5f4a01ffe3924e` | ## Why This Change Was Made The evidence generator supplied identities and test-merge parents but omitted the original head's raw parents, and the model's prose conflated those distinct identities. Reuse the hardened Git reader and canonical parent parser to provide typed, role-labeled `originalHead` and `checkout` records, and explicitly label `testMerge`. The prompt requires public ancestry claims to keep these roles separate. Exact object-type checks prevent tag peeling. Reads retain the existing five-second/1 MiB bounds and cap parent lists at eight; unavailable, malformed, or oversized reads return `parents: null`, while only an inspected root returns `[]`. The old scalar head/checkout aliases are removed. This is reviewer input, with no decision schema, dependency, configuration, routing, persistent-data, or publication-authority change and no prose scrubber. Source preparation materializes the pinned original head. There is no evidence that a historical rebase caused the bad claim, and an integration checkout cannot rewrite an existing original SHA's parent. ## User Impact Maintainers and contributors receive explicit original-commit ancestry in review evidence, reducing false provenance and ownership claims when the actual checkout, fetched main, merge base, or test merge differs. Unknown inspection remains visibly unknown. Raw parent records alone do not establish causal introduction, authorship, or parent-object availability. ## OpenClaw Bay Impact Bay is unaffected: the change only adds reviewer-input provenance. No observer data contract, lifecycle/publication authority, queue state, telemetry, routes, or controls change. ## Documentation Impact Updated the active implementation documentation in `docs/pr-review-comments.md`, section “PR Introduction Evidence,” and the owning reviewer prompt in `prompts/review-item.md`. ClawSweeper review maintainers own this contract; `src/pr-review-evidence.ts` is the source of truth. Verified against this PR's four-file patch; changes to record roles, raw-object bounds, unknown/root semantics, or source acquisition trigger a documentation update. Reviewed `CONTRIBUTING.md`, `docs/README.md`, `README.md`, and `VISION.md`; no other documentation changes are needed. Release-note context is preserved here without editing the changelog. ## Evidence - Before the production change, the new regressions failed: initial focused run 89 passed / 7 failed; additional boundary cases 2 failed; exact-object-type case 1 failed. With the patch, all four focused files passed, 98/98, under Node 24.20.0 and pnpm 11.10.0 with standard Git configuration. - Real Git fixtures cover synthetic merges, rebased checkouts, original heads with multiple commits, merge heads, replacement refs, legacy grafts, shallow history, missing objects, trees/tags, malformed raw parents, oversized objects, and genuine roots. Production prompt serialization is exercised, including preservation of introduced versus main-only changes. - Static checks, all builds, lint, and the existing changed-surface coverage gate passed (13/13). The original full local `pnpm run check` was interrupted under severe host load and did not pass. A representative agent-runner failure was reproduced: that command set `TMPDIR` inside the checkout, which the scanner correctly rejects as `unsafe_path`. The unchanged test passes with the default external temp directory. This diagnoses that local failure only. The full gate subsequently passed in [exact-head Linux CI](https://github.com/openclaw/clawsweeper/actions/runs/33845765111/job/100937182439) on `f1a20200c0b22ccd309d38939879b8ec66fb7a85`; the same run also passed Windows launcher and sparse repair build checks, with no retry. [CodeQL](https://github.com/openclaw/clawsweeper/actions/runs/33845765036) passed at the same head. The hosted scan smoke is dispatch-only and was correctly skipped. - Fresh isolated Codex reviews before commit and after rebase both passed with no actionable P0–P3 findings. On head `f1a20200c0b22ccd309d38939879b8ec66fb7a85` against base `b4f7d36406ed1e375dc8eac17abc00ff63a93f02`, the production build, exact historical-object probe, and selected rebase/unknown/type/size regression cases passed (3/3). The rebased four-file patch is byte-identical to the original 98/98-tested patch (SHA-256 `e0c149f62c70876b121df9dfb497ec23a6e72fb5cdaf9c8b8cbbfb7387188128`); upstream did not change its evidence or prompt-serialization owners. - The [initial ClawSweeper review](#1409 (comment)) found no actionable issues or rank-up requests and judged the proof sufficient. No code changes were needed in response; this body now includes the completed CI result. - Scope: four files, production TypeScript +40/-4 (net +36), prompt +15/-3 (net +12), tests +172/-3 (net +169), documentation +13/-4 (net +9). No other owner's files changed. The related [owner simplification PR](#1407) changes different files. ## Real Behavior Proof **Claim:** compiled production evidence generation preserves the exact original PR head's raw parents independently of the actual integration/rebased checkout and GitHub test merge, and production prompt assembly carries those roles to the reviewer. **Surface and scenarios:** `buildPullRequestReviewEvidence` and production `buildReviewPrompt` against real disposable Git histories; additionally, compiled evidence generation against the exact historical original and test-merge objects in a task-owned bare object store. Historical source objects and active PR checkouts were not modified. **Commands/environment:** local macOS, Node 24.20.0, pinned pnpm 11.10.0, standard Git configuration. Build and focused proof: ```sh pnpm run build TMPDIR="$PWD/.artifacts/original-commit-provenance/tmp" CLAWSWEEPER_PROVENANCE_PROOF_DIR="$PWD/.artifacts/original-commit-provenance" node --test test/pr-review-evidence.test.ts test/review-prompt-context.test.ts test/review-prompt-policy.test.ts test/review-provenance.test.ts ``` The post-rebase boundary rerun used the default external temp directory and passed all three selected cases: ```sh node --test --test-name-pattern='original head parents survive synthetic|unavailable raw commits|invalid or oversized raw parent' test/review-provenance.test.ts ``` The historical probe calls the compiled `buildPullRequestReviewEvidence` with `head.sha=15ca0925f5d164df5283783aea5f4a01ffe3924e`, `base.sha=3c0eb9fd822f8101dc3117ce40dbd2b0f5e01930`, `mergeCommitSha=782c712e2dad405a2e9010354b5291fb94d42fe6`, `mainSha` equal to that base, and the bare fixture's `HEAD` at the test merge. It first verifies both objects with `git --no-replace-objects cat-file -p <exact-sha>` and asserts the following production output: ```text originalHead: verified, role=original_pr_head sha=15ca0925f5d164df5283783aea5f4a01ffe3924e parents=[cd8c74889d21ddcc9f3a2d47fe868224a0e44acb] checkout: verified, role=actual_checkout sha=782c712e2dad405a2e9010354b5291fb94d42fe6 parents=[3c0eb9fd822f8101dc3117ce40dbd2b0f5e01930,15ca0925f5d164df5283783aea5f4a01ffe3924e] testMerge: verified, role=github_test_merge sha=782c712e2dad405a2e9010354b5291fb94d42fe6 parents=[3c0eb9fd822f8101dc3117ce40dbd2b0f5e01930,15ca0925f5d164df5283783aea5f4a01ffe3924e] mergeBase: verified, sha=cd8c74889d21ddcc9f3a2d47fe868224a0e44acb PASS: immutable original-head parentage is separate from integration ancestry. ``` **Artifact/trace:** bounded historical output above, the original producer/artifact identities above, and reproducible real-Git regression assertions in `test/review-provenance.test.ts`. Red/green logs, fixture JSON, and historical production JSON are retained locally; raw reports and agent transcripts are not published on this branch. **Limits:** this proves evidence generation and prompt assembly, not model compliance, a replay of the historical model session, or GitHub review publication. It does not guarantee that model prose never makes another provenance mistake. No Gateway PR or lifecycle session was changed.
|
@clawsweeper re-review Real after-fix workflow runs on this head are now in the PR body: the local read-only review lane executed a full Codex review of this PR through the changed review owner, and an apply-decisions dry-run read the live durable review tuple and correctly emitted skipped_stale_review_comment_sync through the refactored sync path. Head unchanged. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Landing with maintainer proof override ( |
What Problem This Solves
The apply owner repeated its durable-comment synchronization calculation four times, and the review owner duplicated normal PR/issue lease acquisition and error handling. Those copies obscure the freshness distinctions and make behavior-preserving maintenance harder.
Why This Change Was Made
The shared calculations stay in their existing owners and preserve evaluation order. Current reports retain their comment-hash upgrade matching and verification receipts; rewritten reports retain strict hash matching without those receipts. The removed stale-comment check was unreachable after the earlier stale/open-state exits. Fresh reads before mutation remain in place.
Normal review lease acquisition now shares one path, with revision lookup still inside its error boundary and the existing posted/held result union enforcing lease identity. Identical mutation bookkeeping is collapsed, and orphan comments and historical narration are removed from the runtime. All close-safety and marker tests, including the full provenance/paired-closeout matrix, remain intact. Two source-text assertions that required the removed duplicate bookkeeping branches are deleted from the direct apply-owner test; its other receipt checks remain.
User Impact
Behavior-neutral; no runtime contract, config, or workflow change. No new dependency or exported API. No changelog entry is needed because this introduces no user-visible behavior change.
Evidence
The pr-behavior-proof contract for this behavior-neutral refactor is the full
pnpm run checkrun plus the targeted suites, as specified in the work order.pnpm run build:all; the eight targeted suites below;pnpm run format;pnpm run check./tmp/deslop-owners-targeted.log,/tmp/deslop-owners-targeted-retry.log,/tmp/deslop-owners-crabbox-stdout.log,/tmp/deslop-owners-crabbox-stderr.log, and/tmp/autoreview-deslop-owners.md. Crabbox provideraws, leasecbx_e4bd31a0e523, typec7a.8xlarge, imageami-0461d919be7deb53c, regioneu-west-1. All four changed-file SHA-256 hashes matched before remote execution and match commit002ce5db42f4ba8d5c08902a7b48a43c109976a5.Operator-visible surfaces verified unchanged:
Targeted command:
The first full gate reported the obsolete branch-spelling assertions and an existing macOS lock timing failure at
test/action-ledger-runtime.test.ts:2459(Date.now() - deadStartedAt < 5_000). Its coverage floors passed (85.04% lines, 76.23% branches, 89.37% functions). After removing only the obsolete owner assertions, both affected cases passed under coverage with:node scripts/run-node-tests.mjs unit -- --test-name-pattern='apply receipts start per item|macOS import locks retain live V1 owners and recover dead V1 owners' --experimental-test-coverageThe lock test passed unchanged in 12.07 seconds total, including its required ten-second live-lock wait. No ledger implementation or timing threshold changed.
The Mac full rerun passed both earlier cases but hit two other existing fixture-admission/process-cleanup failures. The complete gate passed in an isolated AWS environment through the configured Crabbox provider. The Mac failures were a snapshot deadline in
test/agent-input-scan.test.ts:1120and a terminal cleanup watchdog intest/live-proof-review-environment.test.ts:790; those owners and thresholds remain unchanged. Crabbox's hydration interpreter could not handle the pinned pnpm setup action, so the successful setup path uses--no-hydrateandpnpm install --frozen-lockfile; no repository workflow was edited.Pass summaries (verbatim):
The full gate also passed the separate fix-prompt-builder coverage check: 13/13 tests, 100% lines, 88.61% branches, and 100% functions. OS/tool-dependent skips are the suite's existing conditions; no tests or thresholds were disabled. The AWS command completed in 3m49s; source hashes were identical to this candidate.
Independent Codex autoreview (
--mode local --base origin/main --max-priority P1) is scoped-clean: no accepted/actionable findings in the selected Git scope and priority. Both AWS leases used for validation are confirmed released.OpenClaw Bay not affected: no dashboard changes.
Update after ClawSweeper review (head 002ce5d, unchanged): real after-fix workflow runs
Both changed production owners were executed on this exact head against live GitHub state, read-only (no mutations), from a build of this branch (
pnpm run buildat002ce5db4), on macOS with the operator's Codex login (pnpm run codex:local:checkpassed, smoke 16.7s).1. Review owner (
src/clawsweeper-review-command-workflow.ts,src/clawsweeper-runtime.ts) via the documented local review lane:Real GitHub reads (item, context hydration; the webhook read model was degraded at the time and the workflow fell back to live polling as designed), real target checkout, real Codex review, report and cache artifacts written.
2. Apply owner (
src/clawsweeper-apply-decision-workflow.ts) via the AGENTS.md-sanctioned copied-report procedure (tempitems/,--dry-run,--skip-dashboard,--item-numbers, temp--closed-dir), feeding the report produced in step 1:The apply owner read the live durable review tuple on GitHub (the current ClawSweeper lease comment on this PR), evaluated the refactored durable-comment sync decision (
reviewCommentSyncStatein "current" mode plus the canonical-bound stale-review guard), and correctly refused to overwrite the newer live comment. That is the close-safety behaviorAGENTS.mdrequires ("snapshot orupdated_atdrift blocks apply unless the only change is the existing ClawSweeper review comment") observed against real GitHub state after the fix.Limits: no live close, label mutation, or comment write was performed (dry-run and local-only by design); the merged-state paths are covered by the fixture suites listed above.
Coverage correction and maintainer proof override (head 002ce5d)
Correction to the previous section: the local-only review run does not exercise the extracted
acquireReviewStartLeaseclosure (local mode skips start comments by design), and the apply dry-run exited at the pre-existing canonical-bound stale guard, before the extractedreviewCommentSyncStateclosure. Those runs prove the surrounding review and apply owners execute end to end on this head against real GitHub reads; they do not reach the two refactored closures.Maintainer disposition (
proof: override): reaching those closures for real requires either posting a ClawSweeper review-start lease comment with the App credentials (a mutation on a live item) or an authenticated Worker record export to feed apply with a lease-bearing record; both are disproportionate for two behavior-preserving extractions. Each extraction was verified line by line againstmainduring maintainer review:acquireReviewStartLease: PR and issue sites had identical bodies except the head-SHA source, now a parameter; the removed "returned no identity" throws were unreachable becauseReviewStartStatusCommentResulttypesleaseas non-null for every non-heldstatus; held/failed handling (coordinationHeldRetryAt, failure counters,continue) is unchanged.reviewCommentSyncState: the four inline recomputation sites map to"current"(withallowApplyCloseActionUpgrade,reviewCommentHashMatches,reviewCommentVerifiedAt,guardedReviewedAt, force flag as before) and"rewritten"(no match options, direct sha256 comparison, no verified/guarded receipts, force true), matching the originals field for field;isCloseProposalis read at call time as before.skipped_stale_review_comment_syncblock was unreachable: open items exit at the canonical-bound guard earlier in the loop and closed items exit in the archive branch (continue/break) before it.Fixture coverage: 388 targeted tests across the close-safety, marker, provenance, and paired-closeout suites plus the full gate (4,799 passed on Linux). Post-merge watch: the sweep executes both closures on every review start and every apply cycle; the maintainer is monitoring sweep, comment-router, and apply outcomes for the first hour after landing and will revert on any regression.