Repository navigation
refactor: one owner for report front matter, sections and escapeRegExp - #1788
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 changesThe branch centralizes Markdown report headers and sections, preserves dollar characters in stored text, and excludes fenced examples from review coverage counts. Example: An operator checks coverage for one report containing completion metadata only in a fenced example.
Review scores
ProductKind: Refactor · Worth it: Yes Merge readiness✅ Ready for maintainer review This PR contributes useful work still absent from current main. Inspection found no actionable introduced defect, and the earlier CRLF concern is addressed. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherClawSweeper stores review decisions in Markdown reports with a leading metadata header. Review, repair, apply, and dashboard consumers read these reports to display results and select permitted work. flowchart TD
A[Review decisions and text] --> B[Stored Markdown reports]
B --> C[Shared header and section helpers]
C --> D[Metadata ambiguity checks]
D --> E[Review and repair consumers]
D --> F[Apply safety checks]
C --> G[Coverage summaries and comments]
Technical reviewBest possible solution: Keep one shared report owner that preserves structural ambiguity checks and writes stored text literally. Do we have a high-confidence way to reproduce the issue? Yes: current main's replacement-string writers establish the dollar-expansion failure, and its unrestricted coverage regex accepts fenced metadata. The PR supplies failing-base and passing-head consumer observations; this review did not execute a reproduction. Is this the best way to solve the issue? Yes: routing callers through the existing structural owner removes competing implementations and repairs literal writes without introducing another parsing layer or stored format. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7b0c589b7335. Provenance checked
TestingProof path: in-process harness. 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 HistoryReviewed October 9, 2026, 3:12 AM ET / 07:12 UTC (Revision 3). |
e8b9033 to
56dd14a
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
56dd14a to
0b9a2e9
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
What
There is now one owner for each part of report front-matter and section parsing:
src/report-front-matter.tsownsfrontMatterField,frontMatterValue,frontMatterStringArray(plusparseFrontMatterStringArrayfor value-level reads),frontMatterJsonArray,frontMatterBoolean,replaceFrontMatterValue,sectionValue,replaceSectionValueandappendSectionValue.src/clawsweeper-markdown.tsownsescapeRegExp. The repair router now usesmarkdownTopLevelSection, so itsextractMarkdownSectioncopy is gone.clawsweeper-record-metadata.ts: the factory methods.decision-packets.ts:replaceFrontMatterValue.repair/workflow-utils.ts:frontMatterField,frontMatterValue,jsonArrayFrontMatterandsectionValue.repair/create-job.ts:frontMatterValue,frontMatterArrayandsectionValue.repair/target-fanout.ts: its regex-onlyfrontMatterField.repair/issue-implementation-intake.ts:frontMatterStringArray.repair/comment-router-core.ts:extractMarkdownSectionand its private fence helpers.escapeRegExpinclawsweeper-text.tsandrepair/text-utils.ts, plus four inline escape regexes....recordMetadatawiring for these names inclawsweeper-runtime.ts;withRunnerPreflightProvenance,localExactBootstrapReviewCommentBody, thelive-proof/attach.tsidentity helpers andcreateApplyChangedSinceReviewMarker);test/clawsweeper-record-metadata.test.tsis renamed totest/report-front-matter.test.tsbecause it now tests only the owner.Why
These audits found the duplicates:
$substitution bug.extractMarkdownSectionandescapeRegExpare copied between the repair and top-level code.The copies already disagreed on fences, quotes and
$replacement patterns.Behavior changes (every caller whose behavior changes)
When copies differed, the shared reader's semantics won, with one stricter choice (item 7).
decision-packets.tssyncDecisionPacketRecord. It usedmarkdown.replace(pattern, line), so$&,$`and$'in a packet path were expanded. They are now written literally (replacer function). New test:decision packet sync writes packet pointers literally and keeps CRLF headers. It fails on main (actual: false).replaceSectionValue/appendSectionValue. The record-metadata copy used`$1${value}`as the replacement string, so model text with$1/$&(shell snippets, for example) corrupted the section. Callers:promotion-facts,coverage-proof,apply-close-execution,failed-review-retry,live-proof/attach. The text is now written literally. The section heading is now regex-escaped; no shipped heading contains a metacharacter other than.. New test:section writes keep replacement patterns in model text literal. On main this returns"Run \echo"`.repair/target-fanout.tssummarizeFleetReviewCoverage. The old regex readreview_status:/reviewed_at:from anywhere in the file, including fenced samples, and stripped single quotes. It now uses the fence- and ambiguity-aware reader. New test (added first):target fanout coverage ignores review metadata inside a fenced report sample. It fails on main with1 !== 0.repair/workflow-utils.tsandrepair/create-job.ts. Quote stripping changed from removing a leading and a trailing"separately to removing one matched pair. Absent values still read as""at each call site (?? ""). Callers: apply-candidate selection, close-promotion signals, stale comment-sync selection,applyCheckedAtForItem, andcreate-jobparseClawSweeperReport. A named variant was not needed, because no writer emits unpaired quotes.repair/create-job.tslist fields (work_cluster_refs,work_validation,work_likely_files). A valid JSON non-array (for example42) now reads as["42"]instead of[], which matches the sharedfrontMatterStringArray.repair/comment-router(-core).ts:reviewSummaryFromCommentBody,reviewFollowupFromCommentBody,beforeMergeReason/decisionNeededReason/trustedHumanReviewReasonand the router'smarkdownSectionnow usemarkdownTopLevelSection. These forms are no longer read:Heading:colon-style headings;Label:lines as section boundaries.Null results are kept with
|| null. The test that pinned the colon form now assertsnull.Quoted-empty values (
key: "") are nowambiguous(fail closed) in the shared reader. Before, record-metadata read them as an empty value and the repair copy read them as ambiguous. The repair promotion test (workflow empty and quoted-empty ratings remain ambiguous) pins the fail-closed behavior. In the main lane, an empty value was already invalid for every enum reader, so it still fails closed.CRLF packet insertion. The shared writer inserts a new key after
---\r?\nand uses the same line ending, so CRLF reports keep their packet pointers (Codex P2).Proof
pnpm run checkexits 0 on this head after rebasing onto main 3ef195d (refactor: own stringOrUndefined helpers in value-coerce #1782, refactor: own ISO timestamp helpers in iso-time #1786 and refactor: route sha256 hex digests through content-hash #1790). Both coverage runs reportℹ fail 0. When I resolved the conflicts, I dropped every dependency-interface and destructure line that either side deleted.frontMatterField3 → 1,frontMatterValue3 → 1,frontMatterStringArray2 → 1;replaceFrontMatterValue2 → 1,sectionValue3 → 1;extractMarkdownSection1 → 0 (it uses the existingmarkdownTopLevelSection),escapeRegExp2 → 1;/tmp/h2-consumer-proof.mjs(fixture script, not committed) runs the real consumers from each dist:createApplyRecordOperations(...).writeReportMarkdownis the apply path that persists a report and syncs its decision packet. The fixture uses a record root namedteam$&-$'-$`.decision_packet_path: team---→ FAIL.decision_packet_path: team$&-$'-$`/openclaw-openclaw/decision-packets/321.json→ PASS.summarizeFleetReviewCoverageis the function thattarget-fanout coveragecalls. The fixture report hasreview_status: complete/reviewed_atonly inside a fenced YAML sample.scanned=1 percent=100→ FAIL.scanned=0 percent=0→ PASS.target-fanout coverageCLI itself. Before it calls this function, it loads eligible repositories and live open counts from GitHub.render-comments.mjs: prompt-rest, prompt-lean, prompt-dump, async-proof/{base,branch}, retire-proof/166090, /tmp/rules-slice/{reports,reports-leased,run-144991,run-167362}. That is 15 reports in 10 directories. All 10 outputs are byte-identical.extractMarkdownSectionwith the branch'smarkdownTopLevelSection(...) || nullfor the 10 router headings. The bodies were 618 real ClawSweeper comments from openclaw/openclaw (issues/comments, newest 1000) and the 15 rendered comments. Result: 6330 lookups, 1008 sections found, 0 differences.sectionValueand the escaped repairsectionValueagainst the owner, for every key and##heading. Result: 5150 reads, 0 differences.Codex review dispositions
docs/proof/record-front-matter-literal-writeto the shared exports: declined. That directory is a frozen proof for an already merged PR. Its before/after harness compiles the module at that PR's merge base, so it cannot be re-run on current main with or without this change.Not in this PR
repair/issue-implementation-intake.tsstill parses its ownRecord<string,string>front matter and has a case-insensitivesection()helper. Only its string-list decoder moved to the owner.commit-sweeper.tsandcomment-router-core.tsjob-file writers edit a different document type (commit records and repair jobs), so they are not changed.Merge Danger
Door: two-way. This is a pure refactor plus the fixes listed above. Revert is clean.
Blast radius:
Shared-file hunks in
clawsweeper-runtime.tsand the*-dependencies.tsfiles only remove members, so they may conflict on nearby lines with the parallel asRecord/stringOrUndefined slice.