Skip to content

fix(oc-path): preserve untouched Markdown during edits - #172124

Merged
steipete merged 7 commits into
openclaw:mainfrom
fhgffy:fix/path-markdown-frontmatter-20261014
Oct 15, 2026
Merged

steipete merged 7 commits into
openclaw:mainfrom
fhgffy:fix/path-markdown-frontmatter-20261014

Conversation

@fhgffy

@fhgffy fhgffy commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #172123

What Problem This Solves

Editing a Markdown body with openclaw path set can 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

  • Current-main defect confirmed by source/history at 9b2bc0ed7e135d7be69f7f9749684bf30032981c: the parser's addressing index omits YAML continuation lines/comments, while rebuildMdRaw reconstructs all frontmatter and body from that index.
  • PR CI is the test and typecheck gate per maintainer policy. It covers the registered CLI/file-I/O regressions, Markdown editing/insertion siblings, shared JSONL behavior, and repository checks. Passed CI run 38709776092 on exact head 8ef8f466cabc3851e74afc99b85ef55378180124: 24 successful jobs, no failures, and required openclaw/ci-gate checks 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.
  • Runtime evidence: 230 tests passed across 22 oc-path files, including Markdown, JSONL and registered CLI/file-I/O coverage. The runner reported 13.07 s; the job took 1m 52s including setup. All 16 new preservation cases passed in 7–29 ms each, 187 ms combined.
  • Regression: preserves unrelated Markdown bytes during %s covers 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. Existing keeps item positions and explicit values through multiline edits and insertion now crosses frontmatter line-count changes. preserves output and input AST when inserting a %s adds absent/empty-frontmatter cases with BOM.
  • Local static lint passed on changed TypeScript files using the installed oxlint and the current core rules. The nested checkout lacks its own install and the inherited dependencies lack the UI-only Solid lint plugin, so the external lint config omits only that inapplicable UI override. Pinned oxfmt 0.72.0 passed through the native precommit hook using the existing tooling owner; git diff --check passed. No dependency installation was performed.
  • Deslop removed the superseded renderer and contributor frontmatterRaw invalidation 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).
  • Live Gateway, Crabbox/Testbox, local tests, local typechecks, and negative-control execution were intentionally skipped per maintainer policy. No leases or Gateway processes were started. No local test timing or negative-control result is claimed; the CI timings above are the measured proof.
  • ClawSweeper comment 6168475871 reported no code findings. Its shipped-CLI/upgrade proof-only requests are superseded by the explicit maintainer proof policy; PR CI is the proof. There are no human review findings on the original revision.

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.

@clawsweeper

clawsweeper Bot commented Oct 14, 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.

@fhgffy
fhgffy marked this pull request as ready for review October 14, 2026 12:27
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: oc-path size: S labels Oct 14, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 14, 2026
@clawsweeper

clawsweeper Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This 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].

  • Before: The command succeeds but reduces the description to "|" and removes nested metadata.
  • After: Only command: old becomes command: new; unrelated metadata and formatting remain intact.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The source repair is coherent and exact-head CI is green, but the required shipped behavior and existing-state compatibility evidence are not supplied.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A successful Markdown edit can silently delete unrelated descriptions, nested metadata, comments, and authored formatting.
Reason: The patch addresses demonstrated data loss within the existing plugin and adds no configuration, dependency, or public API.

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
Reviewed head: 8ef8f466cabc3851e74afc99b85ef55378180124

Before merge

  • Add real behavior proof - The complete body and discussion supply exact-head CI exercising registered Commander handlers and real temporary-file I/O, but no after-fix shipped-CLI output for Markdown edits or insertions; the body expressly skips upgrade execution and asserts that CI supersedes the prior request, without a recorded proof override under this review's rules. Supply redacted terminal output or a terminal recording covering those mutations and an upgrade with existing workspace data intact, removing IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: Provide shipped-CLI evidence for Markdown field edits and insertions, including existing workspace data carried from v2026.10.3; the expanded regression cases have no supplied executed baseline comparison.
Agent review details

How this fits together

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

Technical review

Best 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

  • Plugin ownership and Markdown parsing keeps the original intent (refactor: replace core oc-path with bundled plugin #79328: Keep workspace addressing plugin-owned and use established parser dependencies.)
  • Whole-file Markdown reconstruction changes intended behavior with a stated reason (37aaf07: Consolidate reconstruction while preserving literal values and sentinel handling; the current PR explains why reconstruction from an incomplete index loses unrelated content.)
  • Addressing positions across repeated edits keeps the original intent (eb212b7: Keep ordinal and positional edits aligned without reparsing explicit multiline values into additional nodes.)
  • Frontmatter value formatting keeps the original intent (aaae1f0: Share one private serialization policy across frontmatter writes.)
  • JSONL source preservation keeps the original intent (a0c056b: Replace only selected tokens and retain unrelated numeric literals, comments, whitespace, and separators.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit aaae1f0 adds extensions/oc-path/src/oc-path/frontmatter-format.ts:1 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: aaae1f0c8d80; files: extensions/oc-path/src/oc-path/frontmatter-format.ts)

PR surface

Source +89, Tests +103, Docs +2. Total +194 across 12 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 8 228 139 +89
Tests 3 116 13 +103
Docs 1 8 6 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 352 158 +194

Review metrics

Metric Value Why it matters
Production versus test LOC Production +228/-139; tests +116/-13 The production growth replaces lossy rendering with source boundaries and position maintenance; the tests primarily verify complete-file preservation through registered commands.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #172123
Summary: This PR repairs the canonical Markdown preservation report; quoted-scalar interpretation and JSONL token preservation are related but distinct work.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The repair prevents silent loss of unrelated workspace metadata in an optional, explicitly invoked editing command.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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 execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-14T12:34:19.615Z sha 5d2222c :: needs real behavior proof before merge. :: none

Reviewed October 15, 2026, 5:23 AM ET / 09:23 UTC (Revision 2).

steipete and others added 6 commits October 15, 2026 01:16
# 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]>
@steipete steipete changed the title fix: preserve Markdown frontmatter during body edits fix(oc-path): preserve untouched Markdown during edits Oct 15, 2026
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete merged commit ab7cbee into openclaw:main Oct 15, 2026
114 of 116 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: oc-path P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

path set discards unrelated Markdown frontmatter during body edits

2 participants