Repository navigation
fix(oc-path): preserve untouched Markdown during edits - #172124
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 real behavior proof before merge. What this changesThis PR replaces Markdown reconstruction with targeted source edits that preserve unrelated frontmatter and body bytes. Example: Run openclaw path set 'oc://SKILL.md/tools/command/command' new on a file containing a multiline description and metadata.openclaw.requires.bins: [gh].
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain Keep this PR open: it repairs a concrete current-main data-loss path, has maintainer engagement, and contains useful work that the adjacent quoted-scalar PR does not replace. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe optional oc-path plugin reads workspace files, builds an addressing index, applies a selected mutation, and returns bytes for the CLI to preview or write. flowchart LR
A[CLI path set] --> B[Read workspace file]
B --> C[Parse addressing index]
C --> D[Resolve selected mutation]
D --> E[Patch original source]
E --> F[Preview or write file]
Technical reviewBest possible solution: Keep the source-range repair in the existing plugin owner and complete the required behavior and existing-data validation before landing. Do we have a high-confidence way to reproduce the issue? The linked reproduction matches the current-main parser, whole-file renderer, mutation dispatch, and CLI write boundary; this read-only review executed no target code. Is this the best way to solve the issue? Targeted replacement fixes the lossy reconstruction at its owner, removes the superseded renderer, preserves literal multiline addressing, and reuses existing YAML and serialization contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b4b89d404ca4. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +89, Tests +103, Docs +2. Total +194 across 12 files. Added test files: 0. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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 15, 2026, 5:23 AM ET / 09:23 UTC (Revision 2). |
# Conflicts: # extensions/oc-path/src/cli.test.ts
Patch only selected source ranges while retaining the addressing index for explicit multiline values. Preserve frontmatter and body bytes in both directions, including CRLF and missing final newlines. Co-authored-by: fhgffy <[email protected]>
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
* fix: preserve Markdown frontmatter during body edits * fix(oc-path): preserve Markdown bytes across edits Patch only selected source ranges while retaining the addressing index for explicit multiline values. Preserve frontmatter and body bytes in both directions, including CRLF and missing final newlines. Co-authored-by: fhgffy <[email protected]> * fix(oc-path): preserve YAML anchors during value edits * fix(oc-path): separate inserted values from empty YAML anchors * fix(oc-path): retain scalar readback after frontmatter replacement --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: fhgffy <[email protected]>
Fixes #172123
What Problem This Solves
Editing a Markdown body with
openclaw path setcan silently discard unrelated multiline descriptions, nested metadata, and comments while reporting success. Frontmatter edits also re-render the body and change its bytes.User Impact
Body edits and item/section insertions retain the original frontmatter. Frontmatter edits and insertions retain the body. Untouched source keeps its comments, quoting, key order, blank lines, BOM, LF/CRLF, and final-newline convention. No migration or configuration change is required. Markdown frontmatter remains
----delimited;+++remains ordinary body text.Why This Change Was Made
Replace the lossy whole-file Markdown renderer with source-range edits, using shared line offsets and newline selection extracted from the JSONL preservation fix in #172410. The existing YAML parser identifies the selected frontmatter value's extent without serializing unrelated metadata or removing anchors still referenced by aliases. Preserve the in-memory addressing index across edits: reparsing a literal multiline value as Markdown would create unintended addressable items.
Original fix by @fhgffy; maintainer cleanup completes preservation in both directions, removes the renderer and source-cache invalidation path, strengthens complete-file regressions, and incorporates the merged JSONL and quoted-positional-key repairs.
Evidence
9b2bc0ed7e135d7be69f7f9749684bf30032981c: the parser's addressing index omits YAML continuation lines/comments, whilerebuildMdRawreconstructs all frontmatter and body from that index.8ef8f466cabc3851e74afc99b85ef55378180124: 24 successful jobs, no failures, and requiredopenclaw/ci-gatechecks green. Production/test typechecks, affected-extension lint, docs, boundaries, baseline ratchets, and selected runtime tests all passed. Fresh main was merged immediately before pushing, with all reviewed files unchanged.preserves unrelated Markdown bytes during %scovers body field edit, item insertion, section insertion, frontmatter edit/insertion, empty anchored values, block-scalar replacement, and nested-metadata replacement with CLI readback; each uses LF with a final newline and CRLF without one. Existingkeeps item positions and explicit values through multiline edits and insertionnow crosses frontmatter line-count changes.preserves output and input AST when inserting a %sadds absent/empty-frontmatter cases with BOM.git diff --checkpassed. No dependency installation was performed.frontmatterRawinvalidation path. Precommit Codex autoreview found the contributor index version’s frontmatter-loss path (removed by this rewrite) and a stale CRLF diff expectation (corrected to preview an actual value change). A subsequent P2 anchor-preservation finding was fixed by retaining the selected node’s anchor while replacing its string content; the existing byte-preservation fixture now includes an anchor/alias pair. Final committed-branch Codex autoreview: scoped-clean, no accepted/actionable P0–P2 findings (exit 0).Exact numstat against the integrated main base: production +228/−139 (net +89), tests +116/−13 (net +103), docs +8/−6 (net +2). The production-LOC exception pays for exact source ranges, YAML value boundaries, and position maintenance that preserves the existing in-memory multiline-value contract; no unrelated cleanup is included. No new detached, background, cleanup, or deferred side effects were introduced.