Repository navigation
feat(records): store the typed decision as a review_record front-matter line - #1838
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 stores each structured review decision alongside its Markdown report and keeps that copy synchronized with existing apply updates. Review scores
ProductKind: Refactor · Worth it: Yes Merge readiness✅ Ready for maintainer review This PR remains necessary: current main does not preserve the complete typed review decision, and no merged replacement owns this work. No actionable introduced defect was found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherClawSweeper saves review decisions as Markdown reports consumed by publication and apply workflows. This change preserves structured decision data alongside those reports while existing consumers continue using their current fields. flowchart TD
A[Reviewer decision and runner facts] --> B[Report writer]
B --> C[Validate structured decision]
C --> D[Report with optional JSON record]
E[Apply promotion or coverage block] --> F[Update report and stored decision]
D --> F
D --> G[Existing report readers]
F --> G
G --> H[Comments and apply outcomes]
Technical reviewBest possible solution: Keep storage, backfill and reader cutover as separate stages so each transition can preserve and verify existing report contracts. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a staged storage refactor rather than a reported runtime bug; current-main inspection confirms that complete typed decisions are not stored. Is this the best way to solve the issue? Yes: a single versioned record owner reuses existing field parsers and synchronizes existing mutation paths without prematurely switching consumers. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 65d743c0fe48. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
Review metrics
LabelsLabel changes: No label 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 HistoryReview history (1 earlier review cycle)
Reviewed October 9, 2026, 4:04 PM ET / 20:04 UTC (Revision 2). |
0f7ce02 to
7297009
Compare
What
Slice S1 of the approved typed ReviewRecord design (row 2, Shape B). The review report now stores the full typed
Decisionas one compact-JSON front-matter line. The line is written last in the front matter:src/review-record.tsowns the format: the writer (reviewRecordFrontMatterLine), the strict reader (readReviewRecord) and the decision updater (updateReviewRecordDecision). The reader rejects all of these: non-JSON, an unknown version, origin or key, any field that the schema parsers reject, and runner-owned fields (localCheckoutAccess,fixedPullRequest, verified or suspectedregressionProvenance,oversizedPullRequest[Source],likelyOwners[].attributionSource) that their own readers reject. The stored decision must also be a fixed point: if parsing changes any field (a default, a normalization, an unknown key), the record is invalid, and the error names the field."origin":"backfill"is accepted and kept on update, so S2 is safe to roll back.markdownForwrites the line only when the decision reads back unchanged.updateReviewRecordDecisionremoves a line that is invalid before or after the update and logs why. In either case the report reads like a report from before review_record existed. The S2 backfill covers those, and its dry run counts them.parseStoredDecisionFields, the same field parsers). Host-built decisions (failed and oversized reviews, apply promotions) may omit the optional fields and name no owner. They also skip the model-only consistency rules (merge-risk options, maintainer owner, label justifications). An invalid root-cause cluster fails; it does not fall back to the empty cluster. Stored text is record data, so the stored instance uses identity text adapters, the second adapter of the existingcreateDecisionParserseam. Model parsing does not change.upgradeNoDiffPullRequestReport,upgradePullRequestClosePromotionReport,applyAuthorPrBudgetStateToReport,applyPrCloseCoverageProofBlockedReportandapplyClosedUnmergedCanonicalBlockedReportchange the decision fields that they rewrite in the markdown. The markdown edits do not change.PullRequestClosePromotion.evidenceis nowEvidence[], rendered byhostEvidenceMarkdownto the same bytes as before.Why
Audit agent://SlopDataModel/report, Findings 1, 2 and 4: the typed Decision is destroyed at the write boundary, and apply rebuilds it from its own markdown with about 30 regex section parsers (
reportDecision) that fall back silently. The maintainer approved this format (design: local://review-record-design.md): Shape B, exactlyreview_record: {"version":1,"decision":{…}},"origin":"backfill"for backfilled files, and host lifecycle fields kept as front-matter scalars.Proof
Main is
271574b75(built in its own worktree withwt switch -c r2-base-s1 --base origin/main). The branch is this PR (0f7ce02a1; the proofs ran one720613ca, and the later commit only adds an author-budget test assertion). Drivers and outputs are saved in~/Developer/.agents/handoffs/clawsweeper-review-record/s1/.1. Real review, shipped CLI.
CODEX_HOME=$T/codex-home pnpm run review -- --local-only --target-repo openclaw/openclaw --item-number 167817 --codex-model gpt-6.1-sol --codex-sandbox clawsweeper-review --output-retention debug --artifact-dir $T/run-167817. CODEX_HOME holdsreview-permissions.tomlasconfig.tomland a symlink to~/.codex/auth.json. Exit 0; Codex took 180 s, context 167 s.2. Markdown bytes, main vs branch, shipped CLI.
review --local-rangeon a throwaway repo with pinned commit dates. A fakeCODEX_BINreturns one fixed decision. After masking wall-clock fields (reviewed_at,last_full_review_at, elapsed ms, prompt chars from the temp path),diff main/0.md branch/0.mdis:The failed-review path (a fake Codex that exits 1 after printing host-like failure text) gives the same one-line diff. Its record reads back: 64 fields,
localCheckoutAccess=unverified.This run found two real gaps, and both are fixed here. (a) The runner adds
likelyOwners[].attributionSource, which the model schema rejects. The record was left out and the reason was logged, as designed. (b) A local-range review uses item number 0.3. apply-decisions CLI, main vs branch. The repo's recording gh stub (
promotionGhMock) runs from each build on the same input reports (driverapply-proof.ts):4. render-comments.
render-comments.mjshashes, main dist vs branch dist, on the saved real reports:On the four branch-written reports (real, local-range, both apply outputs), the comment is byte-identical for: the reports with the line, the same reports without it, and main's renderer (
af6d025cb335be41all three).Tests.
test/review-record.test.tscovers four things. (1) Model, runner-enriched, failed and oversized decisions round-trip throughmarkdownForunchanged. (2) U+2028 and U+2029 stay on one line. (3) Eight kinds of outside change are rejected, and the updater removes the line for each. (4) A decision that would not read back is not stored. Apply e2e tests (low-signal promotion, closed-unmerged canonical, coverage keep_open, author budget) now give their fixture a record and check that it agrees with the markdown after apply. Local (per the new process, no full local check):pnpm run build:all,pnpm run lintandpnpm run format:checkpass; 16 focused test files (review-record, apply promotion/duplicate-proof/author-budget/supersession, decision-parser, codex-review-runner, regression-provenance, close-reasons, pr-proof-automation, review-activity-cursor, review-comment-rendering, compatibility-proof, local-range-review, review-command-workflow, clawsweeper): 434 tests, 0 fail. Full suite runs in CI.Codex dispositions
codex review --base origin/main: "No actionable defects were found against the supplied merge base." Nothing to fix.Merge Danger
parseReportFrontMatterkeeps unknown keys, and the DO line parsers anchor on their own keys. Revert is safe, and the line stays inert.repository/reviewed_at/review_status/labels. Prompts, comments, jobs and work plans never embed raw front matter (checked: create-job, issue-implementation intake, related context, work plans, review prompt). Issue-implementationreportRevisionSha256changes only for reports that change anyway. Apply mutators can now drop an invalid record (logged as[review-record] … removed); they never throw for it.