Repository navigation
refactor: import label policy, selection and proof policy directly instead of building them in the runtime - #1814
Conversation
…stead of building them in the runtime
|
🦞👀 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. What this changesThis PR simplifies how ClawSweeper connects its label and proof rules, while retaining one shared instance for GitHub label writes. Review scores
ProductKind: Refactor · Worth it: Yes Merge readiness✅ Ready for maintainer review Keep this PR open: it provides distinct maintenance value that current main does not include, and the inspected changes introduce no actionable correctness regression. Priority: P3 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherClawSweeper turns saved review reports into public comments, readiness decisions, and GitHub labels. This subsystem selects labels and batches their writes through the existing GitHub execution layer. flowchart TD
A[Saved review reports] --> B[Proof and readiness rules]
A --> C[Label selection rules]
B --> C
B --> D[Public review comments]
C --> E[Shared label mutation instance]
D --> E
E --> F[GitHub execution layer]
F --> G[Updated comments and labels]
Technical reviewBest possible solution: Use direct imports for pure policy functions and retain one shared owner for label mutation state. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR proposes a behavior-preserving refactor rather than a reported runtime bug. Is this the best way to solve the issue? Yes: direct imports remove redundant policy construction while preserving the stateful mutation owner and existing decision rules. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d559d9e498e4. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Review metrics
LabelsLabel 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 Reviewed October 9, 2026, 6:10 AM ET / 10:10 UTC. |
What
Row 3, PR 2a of the dependency-lattice collapse: labels. The diff was larger than 2k lines, so the apply guards go in a separate PR 2b, which I open after this one lands.
pullRequestReviewReadinessFromReportmoves out of the report-comment-helpers factory with the same body. It is a module export now, as aresecuritySensitiveRepairAllowedand the privatepublicBeforeMergeItems/typedBlockerDetail. The pure text helpers that it reads (sentence,stripListMarker,reportRiskEntries,publicRealBehaviorProofLine, …) move to module scope inreview-presentation. That factory still returns them, so the rendering interfaces do not change here (cluster 3).proof-policy:reportRealBehaviorProofPolicyis a plain export.createRealBehaviorProofPolicyand its dependency interface are gone.label-policyandlabel-selectionare plain exports.createLabelPolicy,createLabelSelectionPolicyand thelabelPolicyobject are deleted.label-mutationskeeps one factory,createLabelMutationOperations({ ghJson, ghObservedMutationCommand }), because its pending batch and label-catalog cache are real state. The pure error classifiers (labelAlreadyExistsError,missingLabelError,labelCapacityError) are module exports.createLabelSyncOperations(mutations)builds on that instance, so the sync calls and the review-commentremoveIssueLabelshare one batch. The runtime builds the instance once, in place of the orchestration foundation.clawsweeper-label-sync.ts,clawsweeper-label-dependencies.ts, all 21 label*ForTesttwins, and the label, proof and readiness members of the report-orchestration, report-rendering, review-comment, apply and github-execution dependency interfaces. Also deleted: the runtime spreads (...labelPolicy,labelSynchronization) and 12 forward arrows ((...args) =>and friends).hasNormalizedLabel/normalizedLabelSetmove toitem-policy.test/pr-label-policy.test.tsthat injected fake readers now use real reports:pullRequestProofReportfixture. That fixture is the formerreportForfromtest/pr-proof-automation.test.ts, now intest/helpers.ts.test/label-mutation-batch.test.tspasses only the gh context.Why
The label cluster rebuilt pure functions through four factories, a 21-line dependency interface and a 61-line aggregator. The runtime then copied them back out with forward arrows. Callers now import what they use. Real dependency injection stays only where something varies: the gh shell for label writes.
Proof
pnpm run checkon8870d9d17: exit 0. 7005 tests, 6968 pass, 0 fail.7494c448a→ branch):*-dependencies.ts+*Dependenciesinterfaces)export function createXfactories*ForTestexportsclawsweeper-runtime.tslinesgit diff -w --shortstat)render-comments.mjs, main dist against branch dist: byte-identical for prompt-rest, prompt-lean, prompt-dump, async-proof/base, async-proof/branch and retire-proof/166090 (9 reports, 0 render failures).node dist/clawsweeper.js apply-decisions --target-repo openclaw/openclaw --apply-kind all --sync-comments-only --item-numbers <n>with the repo's recording gh stub (promotionGhMock, the fix(review): status label contradicts Before merge; regex classifiers add refuted blockers #1766 driver), on saved reports 167298, 167054 and 166090. The results are the same on both builds:labels.log) are identical and in the same order: 1, 2 and 4gh issue editcalls, for example the 166090 rating change🐚 platinum hermit→🦐 gold shrimpand the status👀 ready for maintainer look→⏳ waiting on author;status/check-runsreads, and the temporary artifact path.Codex dispositions
codex review --base origin/main: "No actionable regressions were found against the supplied merge base. The build and all 393 selected tests passed." No P0–P2 findings.Merge Danger
Low. This is a mechanical move: function bodies stay the same, and TypeScript checks every caller.
dist/clawsweeper.jsre-exports: the 21 label*ForTesttwins (featureShowcaseLabelsForTest,prStatusLabelsForTest,prStatusLabelSchemeForTest,priority/impact/maturity/mergeRisk/prRating LabelScheme/LabelsForTest,issueAdvisoryLabelsForTest,telegramVisibleProofLabelsForTest,realBehaviorProof{Media,Sufficient}LabelsForTest,isGitHubLabel{AlreadyExists,Capacity}ErrorForTest,isMissingGitHubLabelErrorForTest,syncBulkFilerLabelForTest). Repo tests import the owner modules now.label-sync-identity-determinismproof driver passes extra keys tocreateLabelMutationOperations. The factory ignores them, so the driver works on both sides of the cutover.