Skip to content

refactor(labels): read label decision fields from the typed review record - #1861

Merged
obviyus merged 1 commit into
mainfrom
review-record-s4-comment-labels
Oct 10, 2026
Merged

obviyus merged 1 commit into
mainfrom
review-record-s4-comment-labels

Conversation

@obviyus

@obviyus obviyus commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

What

Row 2 slice S4a (typed ReviewRecord): labels that the review selects outside PR merge readiness read the reviewed decision from the report's review_record line. Follows #1848 (S3, merged); rebased on main 20875f757.

  • New src/report-review-decision.ts: reportReviewDecision(markdown) returns the label fields of the decision (Pick<Decision, …>). With a record, the fields come from the record. A report without the line gets the same values from the same report readers as before. A line that does not read throws ReviewRecordFormatError: it gets no fallback.
    • It calls readReviewRecord directly. readReviewRecordOrLegacy needs a full Decision from the legacy reader, and no full legacy reader gives the same label values: reportDecision() sets decision: close and drops PR impact labels, and legacyReviewDecision() throws on 155 stored reports (dry run 37998508324).
  • Typed now:
    • apply label sync: priority, impact, maturity, merge-risk (clawsweeper-apply-report-labels.ts), Telegram proof (clawsweeper-apply-pull-request-labels.ts), issue advisory state (issueAdvisoryLabelState(markdown, decision, options); type and work_status stay host fields).
    • review comment: "Label changes" and "Label justifications" (clawsweeper-label-presentation.ts), and the triage priority in Merge readiness.
    • selectedLabelJustifications (report-parser) holds the "one justification for each selected label" rule for the record and for the report.
  • A line that does not read: apply already skips the item before this step (S3). The keep-open comment render now throws, so no comment is posted from such a report (live-proof attach, local review history). Apply also renders other items' reports, so two apply sites check the record first: the same-author pair counterpart does not start (clawsweeper-apply-close-guards.ts), and the paired durable comment check returns no proof (clawsweeper-apply-decision-workflow.ts).
  • Not in this PR (S4b): proof labels and the proof policy, PR rating label, feature showcase label, PR status label and merge readiness, the comment body fields, and the renderer close/keep-open choice. PR status reads merge readiness, which reads proof, rating, findings, security and product review. These must move together. A first attempt moved proof and rating only, and codex review found real disagreement cases between the labels and the status.

Why

Design review-record-design.md §6 step 4. Labels stop rebuilding decision fields from markdown.

Proof

Real entry points, main 314018ccc build (before S3) vs branch build (S3 + S4a; the proof ran before the rebase on 20875f757, and the rebase had no conflicts):

  • Comment bytes: render-comments.mjs <dist> <dir> (renders renderReviewCommentFromReport(report, "none")).
  • Labels and apply: node dist/clawsweeper.js apply-decisions --sync-comments-only --item-numbers N with the repo's recording gh stub (promotionGhMock). gh calls are sorted with paths and uuids masked. Markdown is compared with apply timestamps and the run-dir decision packet path masked.

Corpus: 73 saved real review reports (59 PR reports from /tmp/judgesb-reports, 9 saved production reports, 5 real issue reports). Variants: no record, backfilled record (legacyReviewDecision + reviewRecordFrontMatterLine), the real record of #167817 from a real review, and a corrupt record (review_record: {broken…).

variant reports comment bytes identical render failed main / branch
backfill-not-possible 2 2/2 0 / 0
backfilled-record 71 71/71 0 / 0
corrupt-record 12 0/12 0 / 12
no-record 73 73/73 0 / 0
real-record 1 1/1 0 / 0

apply-decisions runs: 147/159 identical (apply result, gh calls, comments, markdown). For every no-record, backfilled-record and real-record run, label calls, gh calls, comments and markdown are the same on both builds (label calls: 0 to 4 for each run). The 12 runs that are not identical are all corrupt-record runs: main syncs the comment (and labels); branch records skipped_changed_since_review / review_record: the value is not JSON; fresh review required, makes 0 gh calls, and posts no comment (S3 gate). Issue #156814 stops in the gh stub on both builds (cannot acquire a review lease without the current item revision) for the readable variants.

The corrupt-record comment render: 0/12 identical, because the branch render stops with ReviewRecordFormatError (**Render failed:** in the driver output) where main renders from the report text. Full per-run table: proof-table.md in the proof handoff.

Checks run: pnpm run build:all, focused tests (60 files that touch labels, comment rendering, proof policy, readiness, apply and records: 1511 pass, 0 fail, 22 skipped), pnpm run lint, pnpm run format:check.

Codex dispositions

codex review --base origin/review-record-s3-apply-close (the S3 head), three runs:

  1. P2: proof labels read the record but PR status read the report. Fixed in round 2 by moving proof policy.
  2. P2 ×2: authority-chain requirement and rating in readiness still read the report. Disposition: proof, rating, showcase and status labels go back to the report readers; they move with readiness in S4b.
  3. No findings.

Merge Danger

Low. For a report with a readable record or no record, labels and comments are the same (proof above). The changed behavior is for a report whose review_record does not read: outside apply, the keep-open comment render stops with ReviewRecordFormatError instead of a comment. Nothing stored changes. Rollback is a plain revert.

@clawsweeper

clawsweeper Bot commented Oct 10, 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 P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 10, 2026
@clawsweeper

clawsweeper Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

ClawSweeper reads selected labels and their explanations from the saved structured review decision, preserves older reports, and rejects unreadable records during comment rendering.

Example: A review report says P1 while its saved decision selects P2.

  • Before: The review comment proposes adding P1 using the report text.
  • After: The review comment proposes adding P2 using the saved decision.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A useful, coherent cutover with no actionable findings, supported by runtime comparisons whose GitHub boundary is mocked.
Proof confidence 🦐 gold shrimp (3/6) Verified collaborator authorship exempts this PR from the external-contributor gate. Supplied saved-report rendering and apply CLI comparisons exercise the changed readers, including corrupt-record rejection, but GitHub transport is stubbed. Existing records and legacy reports remain compatible without a format or migration change.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes
User problem: Maintainers need labels and label explanations to reflect the saved review decision.
Reason: The approved structured-record design gives reviewed fields one durable source. This bounded cutover preserves legacy reports and deliberately keeps readiness-dependent fields together.

Merge readiness

✅ Ready for maintainer review

This PR remains necessary: current main still reconstructs these label decisions from report text. The cutover follows the approved record design, and no actionable introduced defect was found.

Priority: P3
Reviewed head: b90d8a2d804a2089dc44b71bc57b7503739e6677

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied apply CLI comparison uses a recording GitHub stub and predates the rebase; it does not show current-head real-transport label synchronization.
Agent review details

How this fits together

ClawSweeper stores review decisions in reports that its apply workflow uses to publish GitHub comments and synchronize labels. This change selects the saved decision data while retaining existing freshness, lease, and publication safeguards.

flowchart TD
  A[Saved review report] --> B{Structured record present?}
  B -->|No| C[Read legacy report fields]
  B -->|Yes| D[Strictly read saved decision]
  D -->|Unreadable| E[Stop rendering or skip apply]
  D -->|Readable| F[Select labels and explanations]
  C --> F
  F --> G[Render review comment]
  F --> H[Guarded GitHub label sync]
Loading

Technical review

Best possible solution:

Keep the strict stored-decision reader and temporary legacy fallback, then move readiness-dependent fields together in the planned follow-up.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this is a refactor rather than a reported production bug; the added disagreement fixtures demonstrate which decision source each consumer reads.

Is this the best way to solve the issue?

Yes: the adapter reuses the existing strict record reader and preserves exact legacy readers, while leaving proof, rating, and status together with their current readiness owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 20875f75782f.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current-main necessity: The live main branch remains 20875f7. Its label-sync code still calls triagePriorityFromReport, impactLabelsFromReport, maturityLabelsFromReport, and mergeRiskLabelsFromReport; the merged close-reader work does not implement this label cutover. (src/clawsweeper-apply-report-labels.ts:175, 20875f75782f)
  • Strict reader and legacy compatibility: The adapter uses readReviewRecord and falls back only when the record is absent. Its legacy branch retains the same label and advisory readers used before this PR. (src/report-review-decision.ts:49, b90d8a2d804a)
  • Corrupt-record safeguards: Apply already checks record readability before promotion or label synchronization. The new counterpart checks prevent rendering unreadable paired reports, and keep-open rendering now invokes the strict reader. (src/clawsweeper-report-comment-presentation.ts:241, b90d8a2d804a)
  • Approved design and prior cutover: feat(records): store the typed decision as a review_record front-matter line #1838 records maintainer approval of the structured record format and synchronization of decision mutators. refactor(apply): read the apply close decision from the typed review record #1848 implements the close-reader cutover and early corrupt-record gate; this PR extends that design to labels. (src/review-record.ts:106, 410f120f8b9a)
  • Proof scope and identity: The complete supplied body, captured as sourceRevision 0886650b011e544020e206cc62387819d119961d6132fb71498b12993ecc230b and inspected through REST, reports shipped apply-decisions CLI comparisons and production comment rendering over saved reports. Readable variants retain matching outputs; corrupt-record rendering rejects all 12 variants. GitHub calls use promotionGhMock, and the comparison predates the rebase, so this is limited runtime evidence rather than real-transport proof. (b90d8a2d804a)
  • Maintainer scope: Although the REST author association says CONTRIBUTOR, the repository permission endpoint verifies obviyus has write permission, supporting collaborator treatment and the maintainer-authored proof exemption.

Review metrics

Metric Value Why it matters
Production and test changes Production +189/-79 lines; tests +160/-2 lines Production growth provides one shared record adapter with a temporary compatibility branch and replaces label-reader call sites.

Labels

Label changes:

  • add P3: This is an internal reader cutover with preserved normal behavior and no established urgent production incident.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This is an internal reader cutover with preserved normal behavior and no established urgent production incident.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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.

Reviewed October 9, 2026, 8:23 PM ET / October 10, 2026, 00:23 UTC.

@obviyus
obviyus merged commit 27ed20b into main Oct 10, 2026
30 of 31 checks passed
@obviyus
obviyus deleted the review-record-s4-comment-labels branch October 10, 2026 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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