Repository navigation
refactor(apply): read the apply close decision from the typed review record - #1848
Conversation
|
🦞👀 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 changesClawSweeper reads close-validation fields from the stored structured review decision, retains support for older reports, and skips reports with unreadable records. Example: Apply processes a stale PR report containing
Review scores
ProductKind: Refactor · Worth it: Yes Merge readiness✅ Ready for maintainer review This PR remains necessary: current main stores typed review records but still reconstructs close decisions from report text. No merged replacement or actionable introduced defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherClawSweeper saves reviews as reports that its apply workflow reads before publishing comments or closing GitHub items. This change selects the reviewed decision data while retaining the existing live eligibility and freshness checks. flowchart TD
A[Saved review report] --> B{Structured record present?}
B -->|No| C[Read legacy report text]
B -->|Yes| D[Strictly read structured decision]
D -->|Unreadable| E[Skip and request fresh review]
D -->|Readable| F[Existing close validation]
C --> F
F --> G[Live eligibility and freshness checks]
G --> H[Close or keep open]
Technical reviewBest possible solution: Keep one strict record reader as the close-validation source, with the temporary legacy fallback and existing live closeout safeguards. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a reader cutover rather than a reported production bug. Source inspection and the supplied CLI comparisons establish the corrupt-record fallback path on the base. Is this the best way to solve the issue? Yes: the adapter reuses the strict stored-record reader and existing close validator, replacing the old validation path without adding a competing policy owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 314018ccc4e3. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
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:13 PM ET / 22:13 UTC. |
What
Row 2 slice S3 (typed ReviewRecord): the apply close path reads the reviewed decision from the report's
review_recordline.src/clawsweeper-apply-close-decision.ts:validateReportClose(dependencies, item, markdown, closeReason, options)validates the close that apply will do. The reviewed fields come from the record (readReviewRecordOrLegacy). The host gives what the record cannot hold: the apply's close reason (withdecision: close,confidence: high, as before), the close comment that apply posts (the report's Close Comment section), and a maintainerproof: overridelabel on the current labels. A record that does not read returnsskipped_changed_since_reviewwithreview_record: …; fresh review required. No close.unreadableReviewRecordReason(markdown): the apply loop checks it once for each item, next to the reconciliation skip, and before any promotion can start. A promotion callsupdateReviewRecordDecision, which removes a record that does not read. Without this early check, a promoted item with a corrupt record would close through the legacy fallback.src/review-record.ts:readReviewRecordOrLegacy(markdown, legacyDecision). A report without the line gets its decision fromreportDecision()until the backfill shows 0 missing. A line that does not read gets no fallback.reportDecisionis not deleted.reportDecision()call sites in apply:clawsweeper-apply-close-execution.ts: the current-report validation before the close →validateReportClosevalidateReportClosevalidateReportCloseclawsweeper-apply-close-guards.ts:currentCloseGatesPassed(same-author pair start) →validateReportClosevalidateReportCloseclawsweeper-apply-decision-workflow.ts: pre-sync duplicate validation →validateReportClosepairedIssueDurableReviewCommentUpdatedAtusedreportDecision(md, "implemented_on_main").closeReason, which only gives back its argument. It is now the constant.test/apply-close-decision.test.ts(record wins over the report text, legacy fallback, corrupt line, proof override), e2e apply tests for a record-driven block and a corrupt record (apply-stale-version-bug-policy,apply-pr-promotion). The author-budget fixture record now holds the same proof and rating as its report text (before, the fixture record was the generic issue decision; with the record as the source the close was correctly blocked).Why
Design
review-record-design.md§6 step 3: the close path stops rebuilding a Decision from markdown. A corrupt record fails closed (fresh review) instead of being filled by the report parsers (audit Finding 4).Proof
apply-decisionsCLI, main314018cccbuild vs branch build, the repo's recording gh stub (promotionGhMock),withMockCodexProof. Driver reused from the S1 proof (/tmp/r2proof/s3/apply-proof.ts). gh calls are sorted with paths and uuids masked; markdown compared with apply timestamps masked.branch: skipped_changed_since_review (review_record: the value is not JSON; fresh r…)
branch: skipped_changed_since_review (review_record: the value is not JSON; fresh r…)
branch: skipped_changed_since_review (review_record: the value is not JSON; fresh r…)
branch: skipped_changed_since_review (review_record: the value is not JSON; fresh r…)
Notes:
legacyReviewDecision, and without). They are keep-open, so comment sync runs, as in the S1 proof.skipped_changed_since_review/review_record: the value is not JSON; fresh review required, makes 0 gh calls, keeps the report initems/with the line unchanged andaction_taken: skipped_changed_since_review, and writes no comment. (Row 15 is a dry run, so neither build writes the report.) That action is in thereview_refreshbucket, so the item gets a fresh review.Checks run:
pnpm run build:all, focused tests (alltest/apply-*.test.tsplus close-reasons, oversized-pr-close, review-close-policy, clawsweeper, action-ledger, work-plan-artifacts, review-record, review-record-backfill: 510 pass, 0 fail),pnpm run lint,pnpm run format:check.Codex dispositions
codex review --base origin/main, two runs (after each commit): no findings. The first run noted format errors in a full check; fixed with oxfmt.Merge Danger
Low. Reports with a readable record or no record behave the same (proof rows above, and the existing apply suite). The only behavior change is for a report whose
review_recordline does not read: apply now skips it for a fresh review instead of comment sync, promotion or close. S1 stores only records that read back, so such reports should be rare. Rollback is a plain revert; nothing stored changes.