Skip to content

feat(records): store the typed decision as a review_record front-matter line - #1838

Merged
obviyus merged 4 commits into
mainfrom
review-record-line
Oct 9, 2026
Merged

obviyus merged 4 commits into
mainfrom
review-record-line

Conversation

@obviyus

@obviyus obviyus commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

What

Slice S1 of the approved typed ReviewRecord design (row 2, Shape B). The review report now stores the full typed Decision as one compact-JSON front-matter line. The line is written last in the front matter:

review_record: {"version":1,"decision":{…}}
  • src/review-record.ts owns 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 suspected regressionProvenance, 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.
  • Invariant: a stored line always reads back. markdownFor writes the line only when the decision reads back unchanged. updateReviewRecordDecision removes 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.
  • The decision parser has a stored mode (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 existing createDecisionParser seam. Model parsing does not change.
  • Decision mutators keep the record current. upgradeNoDiffPullRequestReport, upgradePullRequestClosePromotionReport, applyAuthorPrBudgetStateToReport, applyPrCloseCoverageProofBlockedReport and applyClosedUnmergedCanonicalBlockedReport change the decision fields that they rewrite in the markdown. The markdown edits do not change. PullRequestClosePromotion.evidence is now Evidence[], rendered by hostEvidenceMarkdown to the same bytes as before.
  • Nothing reads the record yet (S3 starts that). No DO, worker, snapshot, tuple or hydration change.

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, exactly review_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 with wt switch -c r2-base-s1 --base origin/main). The branch is this PR (0f7ce02a1; the proofs ran on e720613ca, 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 holds review-permissions.toml as config.toml and a symlink to ~/.codex/auth.json. Exit 0; Codex took 180 s, context 167 s.

review_record lines: 1 (front-matter line 147, the last one)
readReviewRecord: record v1 parsed strictly: 62 decision fields; decision=keep_open closeReason=none
  owners=["raw_parent_line_v1"] localCheckoutAccess=verified
report bytes 30018, review_record line bytes 11011
stored decision vs the parsed raw model output (codex/167817.json): 60 of 62 fields equal;
  differ (runner-owned): likelyOwners, localCheckoutAccess
review comment identical with and without the line: true

2. Markdown bytes, main vs branch, shipped CLI. review --local-range on a throwaway repo with pinned commit dates. A fake CODEX_BIN returns 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.md is:

144a145
> review_record: {"version":1,"decision":{"decision":"keep_open","closeReason":"none",…

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 (driver apply-proof.ts):

== real review of openclaw/openclaw#167817, comment sync (--sync-comments-only)
apply-report.json identical: true   ["review_comment_synced"]
gh calls identical (sorted, root and uuid masked): true (66 calls)
review comment written: true; identical: true
report identical apart from review_record and timestamps: true

== stale F-rated PR promotion (upgradePullRequestClosePromotionReport)
apply-report.json identical: true   ["review_comment_synced","closed"]
gh calls identical: true (205 calls); review comment identical: true
report identical apart from review_record and timestamps: true
record after  (main): decision=keep_open closeReason=none … evidence=["implementation",…]          (stale)
record after(branch): decision=close closeReason=low_signal_unmergeable_pr … evidence=["stale F-rated PR","proof blocker","no human follow-up"]

== coverage proof keeps a duplicate close open (applyPrCloseCoverageProofBlockedReport)
apply-report.json identical: true   ["skipped_pr_close_coverage_proof"]
gh calls identical: true (78 calls); review comment identical: true
report identical apart from review_record and timestamps: true
record after  (main): decision=close closeReason=duplicate_or_superseded …                      (stale)
record after(branch): decision=keep_open closeReason=none … evidence=["PR close coverage proof",…] closeComment=""

4. render-comments. render-comments.mjs hashes, main dist vs branch dist, on the saved real reports:

prompt-rest 47de395bb746cc03 =  prompt-lean 18683b232d285be5 =  prompt-dump 579d1528f1c1dbe4 =
async-proof/base 1aa96df1d1d1a613 =  async-proof/branch 3896b24867f7dd36 =  retire-proof/166090 76c824a5e9a6ff76 =

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 (af6d025cb335be41 all three).

Tests. test/review-record.test.ts covers four things. (1) Model, runner-enriched, failed and oversized decisions round-trip through markdownFor unchanged. (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 lint and pnpm run format:check pass; 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

  • Door: one-way for the data it writes (new and re-reviewed reports gain one line), two-way for code. Older code ignores the key: parseReportFrontMatter keeps unknown keys, and the DO line parsers anchor on their own keys. Revert is safe, and the line stays inert.
  • Blast radius: every new report grows by the compact decision (11 KB on #167817, report 30 KB). That is far below the 1.5 MiB inline and 2 MiB ingest limits. The line is last, so the DO coverage inventory's 4 KiB head window still holds 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-implementation reportRevisionSha256 changes only for reports that change anyway. Apply mutators can now drop an invalid record (logged as [review-record] … removed); they never throw for it.

@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 9, 2026
@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

ClawSweeper stores each structured review decision alongside its Markdown report and keeps that copy synchronized with existing apply updates.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful staged refactor with shipped CLI evidence, compatible legacy behavior and no actionable findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): Copied terminal output shows the shipped review CLI writing and strictly reading the record after a real Codex review, with unchanged rendered comments. Source comparisons tie the storage implementation to the current head; recording-GitHub apply comparisons provide supplemental synchronization evidence. Legacy-reader inspection and byte comparisons establish additive compatibility without migration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes
User problem: Automated follow-up reconstructs review decisions from rendered reports, which can lose structured decision details.
Reason: Preserving decisions at the write boundary supports reliable downstream automation. The author has established merged ownership in this area, and this stage retains current output and defaults.

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
Reviewed head: 72970095d7b8a99bc758a3aa57d0747bc36da4e2

Before merge

None.

Findings

None.

Agent review details

How this fits together

ClawSweeper 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]
Loading

Technical review

Best 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

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current-main necessity: The pinned main report writer ends its front matter without a complete decision record, and main has no src/review-record.ts. GitHub searches for review_record and typed decision found no merged replacement for this storage change. (src/clawsweeper-report-document.ts:754, 65d743c0fe48)
  • Strict storage boundary: The writer validates the serialized decision before storing it; the reader rejects invalid versions, fields and noncanonical round trips. Updates retain backfill origin and remove invalid records without changing legacy report behavior. (src/review-record.ts:65, 72970095d7b8)
  • Real review CLI proof: The fully inspected PR body, captured as sourceRevision a99577f87d0767041211959dd22a1ff8eadbf1e89fe70902784f7f8914f8d942, records a shipped review CLI run after a real Codex review. Copied output shows one final front-matter record, strict parsing of 62 decision fields, expected runner enrichment and an unchanged public comment. (e720613cae14)
  • Proof revision correspondence: GitHub blob comparisons establish that the current record implementation, decision parser and types match the proof revision exactly. Differences in the other touched production files are dependency-import refactors, an equivalent profile argument and an unrelated existing helper; the latest branch commit changes test wiring only. (src/review-record.ts:1, 72970095d7b8)
  • Stored-data compatibility: The new field is additive and remains unused by existing decision consumers. Existing front-matter readers retain unknown keys, legacy reports remain supported, and copied CLI comparisons show unchanged report/comment bytes apart from the new line and volatile metadata. Apply comparisons use a recording GitHub stub and are supplemental. Bay's existing projections and coverage keys remain unchanged. (src/report-front-matter.ts:24, 72970095d7b8)
  • Preserved parser and close-path intent: fix(review): stop code from rewriting model findings, ratings and proof status #1773 preserves reviewer judgments while validating structure; fix(review): stop forged proof headings in model prose from flipping PR verdicts #1048 prevents forged report sections; fix(close): close automation reads typed fields and exact labels, not prose judges #1774 makes close automation use typed facts. The new stored mode leaves the model path and existing close decisions intact. (src/clawsweeper-decision-parser.ts:1206, 72970095d7b8)

Likely related people:

  • Ayaan Zaidi: Raw commit 4735291 adds src/clawsweeper-report-document.ts:37 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4735291534a4; files: src/clawsweeper-report-document.ts)
  • Peter Steinberger: Raw commit 3f368a3 adds src/clawsweeper-decision-parser.ts:120 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3f368a3e394d; files: src/clawsweeper-decision-parser.ts)

Review metrics

Metric Value Why it matters
Production and test changes Production +555/-92 lines; tests +376/-23 lines Production growth supports one versioned storage owner, strict validation and synchronization of existing apply updates.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded improvement to durable review records that preserves existing consumer behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-09T19:58:23.961Z sha 0f7ce02 :: needs maintainer review before merge. :: none

Reviewed October 9, 2026, 4:04 PM ET / 20:04 UTC (Revision 2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant