Skip to content

refactor: replace core oc-path with bundled plugin - #79328

Merged
steipete merged 16 commits into
mainfrom
refactor/oc-path-extension-replacement
May 9, 2026
Merged

steipete merged 16 commits into
mainfrom
refactor/oc-path-extension-replacement

Conversation

@steipete

@steipete steipete commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This is a replacement PR for #78678.

#78678 landed oc-path as a core workspace substrate. This PR deliberately replaces that shape by:

  • reverting the core src/oc-path implementation and core openclaw path command wiring
  • reintroducing the same openclaw path surface as a bundled oc-path plugin under extensions/oc-path
  • keeping the CLI registered through the plugin CLI registration API instead of core command registration
  • keeping parser dependencies plugin-local
  • updating docs and labeler ownership so path is described and triaged as plugin-owned surface

Discussion required (resolved)

  1. Bundled plugin vs core substrate — agreed; ships as bundled plugin under extensions/oc-path/.
  2. Plugin manifest / activation shape — accepted as drawn.
  3. Parser deps plugin-local — agreed. Final dep set: commander, jsonc-parser, markdown-it. All plugin-local.
  4. Replace remaining hand-rolled pieces with deps — done where it pays:
    • YAML kind dropped entirely (substrate is md / jsonc / jsonl only).
    • markdown-it replaces the hand-rolled MD parser in parse.ts.
    • jsonc-parser retained for jsonc parse + edit.
    • JSONL stays hand-rolled — line-oriented parsing is genuinely simpler than any dep, and the per-line jsonc parse goes through jsonc-parser.
    • OcPath grammar trimmed: dropped quoted-segment escape sequences (\"/\), CSS-style predicate ops (*=/^=/$=), $first literal, -N negative index. Kept: quoted segments themselves, union {a,b,c}, predicate [k=v]/[k!=v] + numeric </<=/>/>=, $last, wildcards */**.

ClawSweeper findings

  • [P2] parent help action: addressed. Inline equivalent at the end of registerPathCli — path.action() calls outputHelp() and sets process.exitCode = 0. Plugin SDK doesn't expose applyParentDefaultHelpAction, so the helper lives locally in the plugin.
  • [P3] plugin inventory regen: out of scope for this PR; the inventory generator runs as a separate doc/release task and would land in its own PR.

LoC

Stage Total Δ
Original draft (fe037ce) ~15,000 —
After yaml drop 13,199 -1,800
After markdown-it + grammar relax 12,793 -406
After consolidation + comment cleanup 10,570 -2,223
After YAGNI grammar cuts (final) 10,275 -295
Net -31.5%

src-only: 7,500 → 4,551 LoC (-39%). 634 tests pass.

Real behavior proof

  • Behavior addressed: The optional bundled oc-path plugin provides the openclaw path CLI after enablement, preserving the parent-help contract and the main validate, resolve, find, set, and emit verbs for markdown, JSONC, and JSONL workspace files.
  • Real environment tested: Local Windows OpenClaw checkout built from this PR head (reported as 16349b5c28 in the terminal capture) with the bundled oc-path plugin enabled.
  • Exact steps or command run after this patch: Enabled the plugin with openclaw plugins enable oc-path, then ran openclaw path, openclaw path validate, openclaw path resolve, and openclaw path find against real markdown, JSONC, and JSONL fixture files.
  • Evidence after fix: Terminal output from the real OpenClaw run:
$ openclaw plugins enable oc-path
Enabled plugin "oc-path". Restart the gateway to apply.

$ openclaw path
🦞 OpenClaw 2026.5.6 (16349b5) — ...
Usage: openclaw path [options] [command]

Inspect and edit workspace files via the oc:// addressing scheme

Options:
  -h, --help  Display help for command

Commands:
  emit        Round-trip a file through parse + emit
  find        Enumerate matches for a wildcard / predicate oc:// pattern
  resolve     Print the match at an oc:// path
  set         Write a leaf value at an oc:// path
  validate    Parse an oc:// path and print its slot structure

Docs: https://docs.openclaw.ai/cli/path

$ echo $?
0

$ openclaw path validate 'oc://AGENTS.md/tools/gh' --human
valid: oc://AGENTS.md/tools/gh
  file:    AGENTS.md
  section: tools
  item:    gh

$ openclaw path resolve 'oc://x.md/[frontmatter]/tier' --file frontmatter.md --human
leaf @ L4: "core" (string)

$ openclaw path resolve 'oc://x.md/tools/gh/gh' --file frontmatter.md --human
leaf @ L9: "GitHub CLI" (string)

$ openclaw path find 'oc://x.md/tools/*' --file frontmatter.md --human
3 matches for oc://x.md/tools/*:
  oc://x.md/tools/gh           →  node @ L9 [md-item]
  oc://x.md/tools/curl         →  node @ L10 [md-item]
  oc://x.md/tools/send-email   →  node @ L11 [md-item]

$ openclaw path resolve 'oc://config.jsonc/plugins/github/enabled' --file config.jsonc --human
leaf @ L4: "true" (boolean)

$ openclaw path find 'oc://session.jsonl/[event=action]/userId' --file session.jsonl --human
1 match for oc://session.jsonl/[event=action]/userId:
  oc://session.jsonl/L2/userId  →  leaf @ L2: "u1" (string)
  • Observed result after fix: Bare openclaw path printed help and exited 0 after enabling oc-path; markdown frontmatter/item lookup, JSONC leaf lookup, and JSONL predicate lookup all returned the expected matches.
  • What was not tested: No known gaps for the documented CLI behavior; local verification also covered tests/build/lint/install as listed below.

Fixtures used:

<!-- frontmatter.md -->
---
name: drafter
description: email drafting agent
tier: core
---
## Tools
- gh: GitHub CLI
- curl: HTTP client
- send_email: enabled
// config.jsonc
{
  "plugins": {
    "github": {"enabled": true, "role": "vcs"},
    "slack":  {"enabled": false, "role": "chat"}
  }
}
{"event":"start","userId":"u1","ts":1}
{"event":"action","userId":"u1","ts":2}
{"event":"end","userId":"u1","ts":3}

Verification

  • pnpm vitest extensions/oc-path/src — 39 files / 634 tests passing
  • pnpm build — green
  • pnpm lint — clean (oxlint, 0 warnings 0 errors on oc-path)
  • pnpm install --frozen-lockfile — passes (lockfile in sync after yaml dep removal)

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes size: XL maintainer Maintainer-authored PR labels May 8, 2026
@clawsweeper

clawsweeper Bot commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

Summary
This PR replaces the prior core oc-path shape with an optional bundled oc-path plugin that registers openclaw path via plugin CLI metadata and adds docs, tests, package metadata, labeler, lockfile, and one gateway test-mock adjustment.

Reproducibility: yes. Source inspection gives a high-confidence path: oc://config/items.$last/tags/+ can resolve as a JSONC insertion point, then mutateAt replays $last through Number(seg) and returns unresolved.

Real behavior proof
Sufficient (terminal): The PR body contains terminal output from a real Windows OpenClaw checkout after enabling the plugin and running the main CLI flows on real fixture files.

Next step before merge
A narrow repair remains in the PR branch: normalize JSONC insertion parents, add the missing regression test, and align the docs.

Security
Cleared: No concrete security or supply-chain regression found; new dependencies are plugin-local/locked, no lifecycle scripts or permissions are added, and path containment plus sentinel guards have coverage.

Review findings

  • [P2] Normalize JSONC insertion parent segments — extensions/oc-path/src/oc-path/universal.ts:454
  • [P3] Correct JSONC insertion preservation docs — docs/cli/path.md:326-327
Review details

Best possible solution:

Land the plugin-owned CLI after normalizing JSONC insertion parent paths through the same concrete path resolution used by lookup, with regression coverage and corrected JSONC edit-preservation docs.

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

Yes. Source inspection gives a high-confidence path: oc://config/items.$last/tags/+ can resolve as a JSONC insertion point, then mutateAt replays $last through Number(seg) and returns unresolved.

Is this the best way to solve the issue?

No. The bundled-plugin ownership is the right direction, but the current patch should not merge until JSONC insertion mutation consumes a concrete resolved parent path and the docs stop over-promising comment preservation for insertions.

Full review comments:

  • [P2] Normalize JSONC insertion parent segments — extensions/oc-path/src/oc-path/universal.ts:454
    resolveJsoncInsertion can accept an insertion parent reached through positional segments like items.$last.tags, but mutation then replays the raw parent path and array descent uses Number(seg). That lets a path report a valid insertion point and then fail during set; pass a concrete resolved parent path through or resolve positional segments inside mutateJsoncContainer.
    Confidence: 0.91
  • [P3] Correct JSONC insertion preservation docs — docs/cli/path.md:326-327
    The CLI docs say JSONC edits preserve comments and whitespace through jsonc-parser, but insertion paths rebuild via emitJsonc(..., { mode: "render" }), which drops comments and formatting. Either make insertions use the parser edit path or carve out insertion behavior in the docs.
    Confidence: 0.78

Overall correctness: patch is incorrect
Overall confidence: 0.9

Acceptance criteria:

  • pnpm test extensions/oc-path/src/oc-path/tests/universal.test.ts
  • pnpm test extensions/oc-path/src
  • pnpm build
  • pnpm lint
  • git diff --check

What I checked:

  • PR state: GitHub API shows this PR is open, non-draft, mergeable, at head 89ae6c6, with labels docs, gateway, maintainer, size: XL, and proof: sufficient. (89ae6c6e1221)
  • Current main lacks this implementation: The provided current-main SHA returns 404 for both extensions/oc-path/openclaw.plugin.json and src/oc-path/universal.ts, so this PR is not already implemented on main. (b34cf2f1a223)
  • Plugin boundary fit: VISION.md says core stays lean and optional capability should usually ship as plugins, while bundled optional plugins have a high bar. (VISION.md:54, 5fdef4c39e75)
  • Plugin CLI API fit: The SDK docs describe lazy CLI registration through api.registerCli(..., { descriptors }), and the PR registers path using that exact descriptor-backed shape. (extensions/oc-path/cli-registration.ts:4, 89ae6c6e1221)
  • Related implementation history: The related core oc-path PR was merged, and its author commented here that extension ownership is the right home for this surface. (bc735f4fde6f)
  • Blocking JSONC insertion mismatch: resolveJsoncInsertion accepts the parent via resolveJsoncOcPath, but setJsoncInsertion then passes the raw parent path into mutateJsoncContainer; mutateAt handles arrays with Number(seg), so a parent containing $last can resolve as an insertion point and then fail during mutation. (extensions/oc-path/src/oc-path/universal.ts:454, 89ae6c6e1221)

Likely related people:

  • giodl73-repo: Authored the merged core oc-path implementation in feat(workspace): oc-path addressing substrate + openclaw path CLI (md/jsonc/jsonl/yaml) #78678 and several current-PR follow-up commits that refactor and tighten the oc-path substrate; also commented agreement that extension ownership is appropriate. (role: introduced behavior and recent oc-path contributor; confidence: high; commits: bc735f4fde6f, d956fac6ef2c, 2f52c3465774; files: extensions/oc-path/src/oc-path/universal.ts, extensions/oc-path/src/oc-path/tests/universal.test.ts, docs/cli/path.md)
  • steipete: Authored the plugin replacement and docs commits on this branch, and current checkout blame shows Peter Steinberger on the plugin CLI documentation that this PR uses. (role: plugin replacement author and recent docs/plugin API maintainer; confidence: high; commits: a4c20debf1d3, 09dde24b3c92, 89ae6c6e1221; files: extensions/oc-path/cli-registration.ts, extensions/oc-path/openclaw.plugin.json, docs/plugins/sdk-overview.md)

Remaining risk / open question:

  • The PR has the protected maintainer label, so landing still needs explicit maintainer handling.
  • This read-only review did not execute the PR's test/build/lint commands; validation evidence comes from source inspection and the PR's posted proof.

Codex review notes: model gpt-5.5, reasoning high; reviewed against b34cf2f1a223.

@omarshahine
omarshahine requested a review from giodl73-repo May 8, 2026 11:49
@giodl73-repo

giodl73-repo commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

Author of #78678 here — happy to align on the extension shape. Quick takes on the 4 discussion points:

  1. Bundled plugin vs core substrate — agree. oc-path is opinionated tooling for a workspace pattern; it doesn't need core's release cadence. Extension is the right home.

  2. Plugin manifest / activation shape — accepting your contract (openclaw.plugin.json + cli-registration.ts + the cli-metadata split) as drawn. Nothing about the surface needs to be load-bearing on core.

  3. Parser deps plugin-local — agree. Keeping jsonc-parser plugin-local is correct scope; we can promote to shared later if a second consumer appears.

  4. Replace remaining hand-rolled pieces — agree in principle; suggest landing the current shape now and iterating. The OcPath grammar is a custom URI scheme so it's likely irreducible. The md / jsonl pieces could probably be replaced with remark / line-iter deps as follow-ups, but they have ~700 tests of behavior pinned and the substrate works as-is. I'd rather not block this PR on that swap.

Otherwise: ship it as-is from my end. Thanks for the cleanup.

@giodl73-repo giodl73-repo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@giodl73-repo
giodl73-repo force-pushed the refactor/oc-path-extension-replacement branch from fe037ce to 23f965e Compare May 9, 2026 01:14
@openclaw-barnacle openclaw-barnacle Bot added the commands Command implementations label May 9, 2026
@giodl73-repo

giodl73-repo commented May 9, 2026 •

Copy link
Copy Markdown
Contributor

Pushed fe037ce8e2 → 23f965e673 (force-with-lease). Rolling up the work since your draft + addressing the discussion-required points and ClawSweeper findings.

Final commit shape (5 commits on top of your 3)

23f965e673 refactor(oc-path): drop YAGNI grammar features
ca6a709d62 refactor(oc-path): consolidate dispatch and trim comment surface
cd48b63f63 refactor(oc-path): markdown-it tokenizer + grammar relaxation
bbe4e9f1b3 refactor(oc-path): drop YAML kind from substrate
772a9bdf7a fix(oc-path): three followup fixes (sentinel guard, byte cap, walker parity)
4e718b6f41 refactor: move oc-path into plugin            ← your commit
d20d02fe54 revert: remove oc-path implementation         ← your commit
b93c82a033 revert: remove oc-path workspace substrate    ← your commit

Discussion points → resolution

  1. Bundled plugin vs core substrate — agreed; ships as bundled plugin under extensions/oc-path/.
  2. Plugin manifest / activation shape — accepting your contract as drawn. CLI registered through registerPathCli(program) from the plugin entry, no core wiring.
  3. Parser deps plugin-local — agreed. Final dep set: commander, jsonc-parser, markdown-it (added — see point 4). All plugin-local.
  4. Replace remaining hand-rolled pieces with deps — done where it pays:
    • YAML kind dropped entirely (-1,467 LoC). Substrate is md / jsonc / jsonl only. The yaml use cases pivoted to the other kinds in real workspaces.
    • markdown-it replaces the hand-rolled MD parser in parse.ts. Tokenization is delegated; this module owns only the H2-block walker and the frontmatter detector. AST is also slimmed: tables and codeBlocks dropped (substrate doesn't address into them; markdown-it's tokenizer already excludes them from heading/item misparse).
    • jsonc-parser retained for jsonc parse + edit (your call from PR refactor: replace core oc-path with bundled plugin #79328 stands).
    • JSONL stays hand-rolled — line-oriented parsing is genuinely simpler than any dep, and the per-line jsonc parse goes through jsonc-parser already.
    • OcPath grammar trimmed rather than swapped. Removed YAGNI features: quoted-segment escape sequences (\"/\), CSS-style predicate ops (*=/^=/$=), \$first literal, -N negative index, #N ordinal addressing. Kept: quoted segments themselves, union {a,b,c}, predicate [k=v]/[k!=v] + numeric </<=/>/>=, \$last, wildcards */**.

ClawSweeper findings

  • [P2] parent help action: addressed. Inline equivalent at the end of registerPathCli — path.action() calls outputHelp() and sets process.exitCode = 0. Plugin SDK doesn't expose applyParentDefaultHelpAction, so the helper lives locally in the plugin.
  • [P3] plugin inventory regen: out of scope for this PR; the inventory generator runs as a separate doc/release task and would land in its own PR.

LoC

Stage Total Δ
Your draft (fe037ce) ~15,000 —
After yaml drop 13,199 -1,800
After markdown-it + grammar relax 12,793 -406
After consolidation + comment cleanup 10,570 -2,223
After YAGNI grammar cuts (final) 10,275 -295
Net -31.5%

src-only: 7,500 → 4,551 LoC (-39%). 634 tests pass.

Behavior proof

$ openclaw path
🦞 OpenClaw 2026.5.6 (23f965e) — ...
Usage: openclaw path [options] [command]
Inspect and edit workspace files via the oc:// addressing scheme
Options:
  -h, --help  Display help for command
Commands:
  emit        Round-trip a file through parse + emit
  find        Enumerate matches for a wildcard / predicate oc:// pattern
  resolve     Print the match at an oc:// path
  set         Write a leaf value at an oc:// path
  validate    Parse an oc:// path and print its slot structure
$ echo $?
0

$ openclaw path validate 'oc://AGENTS.md/tools/gh' --human
valid: oc://AGENTS.md/tools/gh
  file:    AGENTS.md
  section: tools
  item:    gh

$ openclaw path resolve 'oc://x.md/[frontmatter]/tier' --file frontmatter.md --human
leaf @ L4: "core" (string)

$ openclaw path resolve 'oc://x.md/tools/gh/gh' --file frontmatter.md --human
leaf @ L9: "GitHub CLI" (string)

$ openclaw path find 'oc://x.md/tools/*' --file frontmatter.md --human
3 matches for oc://x.md/tools/*:
  oc://x.md/tools/gh           →  node @ L9 [md-item]
  oc://x.md/tools/curl         →  node @ L10 [md-item]
  oc://x.md/tools/send-email   →  node @ L11 [md-item]

$ openclaw path resolve 'oc://config.jsonc/plugins/github/enabled' --file config.jsonc --human
leaf @ L4: "true" (boolean)

$ openclaw path find 'oc://session.jsonl/[event=action]/userId' --file session.jsonl --human
1 match for oc://session.jsonl/[event=action]/userId:
  oc://session.jsonl/L2/userId  →  leaf @ L2: "u1" (string)

Verification

pnpm vitest extensions/oc-path/src   →  39 files, 634 tests passing
pnpm build                            →  ok (full repo)
git diff --check                      →  clean

Ready for re-review when you have a chance.

Re-review progress:

@giodl73-repo
giodl73-repo marked this pull request as ready for review May 9, 2026 01:15
@giodl73-repo
giodl73-repo force-pushed the refactor/oc-path-extension-replacement branch from 23f965e to b7f77aa Compare May 9, 2026 01:27
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 9, 2026
@giodl73-repo
giodl73-repo force-pushed the refactor/oc-path-extension-replacement branch 2 times, most recently from e97cb26 to 16349b5 Compare May 9, 2026 01:53
steipete and others added 8 commits May 8, 2026 19:56
…parity)

Closes three load-bearing gaps in the substrate's defenses:

- **md sentinel defense-in-depth (I2)**: `setJsoncOcPath` and the jsonl
  finalize-via-render path both refuse sentinel-bearing values before
  they reach the AST. The md path was deferring entirely to round-trip
  echo through `emitMd`, which `acceptPreExistingSentinel` skips by
  default. Closes the cross-kind asymmetry.

- **jsonc byte-length cap (N3)**: pre-parse cap on input length, symmetric
  with the existing post-parse depth cap at `nodeToJsoncValue`. Without
  this, `parseTree` allocates the full tree before our walker notices.

- **md walker union + predicate parity (I3)**: jsonc walkers dispatched
  union and predicate at every slot; md dispatched only on
  wildcard/ordinal/positional/literal, so `oc://X.md/{Boundaries,Limits}/...`
  matched zero items where the same shape on jsonc would match both.
  Pins the parity.
The YAML AST/parser/emitter/edit-resolve module is removed. The
substrate now supports md / jsonc / jsonl. Walker, universal verbs,
CLI, and tests are stripped of yaml-kind branches; the `yaml` package
dependency is dropped.

Why: YAML editing was the most complex per-kind module (~750 LoC of
parse/emit/resolve plus walker scaffold) for the smallest surface area
in real-world usage — substrate consumers (lkg, gateway config, agent
metadata) all pivoted to jsonc / md / jsonl. Carrying yaml support
indefinitely was net cost.

Walker depth-cap test that previously relied on YAML's lack of a
parser-level depth cap is rewritten to construct a synthetic JSONC AST
chain by hand, exercising the walker's MAX_TRAVERSAL_DEPTH defense in
isolation from the parser's MAX_PARSE_DEPTH.

Net: -1467 LoC across substrate + tests.
The hand-rolled MD parser is replaced with a markdown-it token-stream
walker. AstTable and AstCodeBlock are dropped from the AST — the
substrate doesn't address into table rows or fence content, and
markdown-it's tokenizer already handles "##/- inside fenced code
should not be a heading/item" correctly without first-class AST
modeling.

Grammar opinions move from parser to lint:
  - Indented `## foo` (1-3 spaces) is now a heading
  - Empty `## ` is a heading with empty slug
  - Ordered lists (`1. step`) become items
  - Nested sub-bullets become items at flat level

Each was previously a silent parser refusal — now they are recognized
shapes. Lint rules can flag them (`OC_HEADING_INDENTED`,
`OC_HEADING_EMPTY`, etc.) where authoring conventions require the
narrower shape.

Net: parse.ts drops 301 → 207 LoC; tables/code-blocks scenario tests
removed wholesale (-251 LoC of test surface that pinned dead AST
fields).
Substrate simplifications and broad comment cleanup:

**Walker collapse (find.ts)**: three near-parallel walkers
(walkJsonc, walkJsonl + walkJsonlInsideLine, walkMd + walkMdInsideBlock
+ walkMdInsideItem) shared the same segment-shape dispatch — union /
predicate / `*` / `**` / positional / literal — with different child
types. Extracted as a single `dispatchSeg<T>(ops, ...)` that takes a
per-kind `WalkOps<T>` table; each walker is a thin wrapper. The three
md walkers fold into one `walkMd(level, ...)` polymorphic on a
`MdLevel` discriminated union. JSONL routes the post-line-slot
descent through walkJsonc via a WeakMap-tagged ast holder.

**CLI (cli.ts)**: each command duplicated four times the same
try/catch/emit/exit dance — missing-arg check, parseOcPath try/catch,
OcEmitSentinelError catch. Extracted as `requireArg`, `tryParse`,
`catchSentinel`. Folded `RawPathOptions` into `PathCommandOptions`
(identical shape) and collapsed `.option(...)` chains via
`withCommonOpts`.

**universal.ts**: setJsoncLeaf and setJsonlLeaf were near-identical
(resolve, refuse root, coerce, set, wrap). Extracted as
`setStructuredLeaf<A, M>` with optional `onLine` for jsonl's
whole-line replacement. Inlined setMdLeaf (7-line passthrough) into
setOcPath. Dropped four `throw new Error("unreachable")` statements
TS exhaustive checking already covers.

**oc-path.ts**: 35 `throw new OcPathError(...)` sites compress through
a `fail()` helper. File-slot containment check (absolute, parent-dir,
control chars) extracted as `validateFileSlot` so parse + format share
the same defense. Three structural-nesting throws in formatOcPath
collapse into two. Three near-parallel string scanners
(`indexOfTopLevel`, `splitRespectingBrackets`, `validateBrackets`) fold
through one `scanBracketAware(s, onChar, onUnbalanced)` helper.

**jsonl/edit.ts**: pickLineIndex compressed; line-address dispatch
shares the value-line filter as a small helper.

**Internal review codes stripped**: P-NNN, F-NN, I-NN, H2-NN, OP-NN,
R-NN, T-NN, S-NN, BFJ-NN, RJC-NN, RJL-NN, FM-NN, A-NN, B-NN, CC-NN,
wave-NN — these were review-process artifacts (sprint identifiers,
finding IDs, pitfall taxonomy IDs) that mean nothing to a reader who
didn't participate in the originating review. Test names rewritten
human-readable; comments lose their P-NNN bookmarks; describe blocks
drop the wave-NN prefix.

**Pitfalls test consolidated**: `tests/scenarios/pitfalls.test.ts`
(637 LoC, organized by P-NNN) replaced by `security-and-limits.test.ts`
(288 LoC) — unique coverage migrates over with descriptive names;
duplicates of OP-/R-/etc. tests are dropped.

**Comment cleanup**: per CLAUDE.md "default to writing no comments;
add one only when the WHY is non-obvious", trimmed multi-paragraph
WHY-prose on every public export, running prose inside function
bodies that restated what the next line of code said, section-divider
comments in test files, and module-level doc-comments that paraphrased
the file name. Kept load-bearing context: NFC re-check after grow,
quote-aware split symmetry, multi-char operator precedence, sentinel
guard catch routes, WeakMap holder rationale.

**MdAst slimmed**: `tables` and `codeBlocks` fields removed — substrate
addressing doesn't go inside them, and markdown-it's tokenizer
already excludes them from heading/item misparse without
first-class AST modeling.

Net reduction across the 10 consolidation/cleanup commits: ~3,800 LoC.
Removes four path-syntax features that added complexity without
enough real-world use:

- **Quoted-segment escape sequences**: kept quoted segments themselves
  (still needed for keys with `/` or `.`) but dropped `\"` and `\`
  escapes. Quoted content is now byte-literal, refused if it contains
  `"` or `\`. Simplifies scanBracketAware (drops the `escaped` state),
  unquoteSeg (no decode loop), quoteSeg (no escape encoding).

- **CSS-style predicate operators**: removed `*=` (substring), `^=`
  (prefix), `$=` (suffix). Predicate set is now `=`, `!=`, and the
  numeric `<` / `<=` / `>` / `>=`. Lint rules needing substring
  matching can use `findOcPaths(*)` + JS filter.

- **`$first` positional**: alias for index 0 (or first-declared key).
  Use the literal `0` instead.

- **`-N` negative index**: rarely useful beyond `-1`, which is already
  covered by `$last`. The "negative numeric key on object" case
  (Telegram supergroup IDs) still works — non-indexable containers
  fall through to literal-key lookup.

Behavior loss: zero in observed real workspace files. Tests for the
dropped features removed (15 tests).

Net: -22 LoC src + 15 fewer tests. Total package: 10,570 → 10,275 LoC.
@giodl73-repo
giodl73-repo force-pushed the refactor/oc-path-extension-replacement branch from bba887f to 750497f Compare May 9, 2026 02:57
@openclaw-barnacle openclaw-barnacle Bot removed cli CLI command changes commands Command implementations labels May 9, 2026
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 gateway Gateway runtime maintainer Maintainer-authored PR proof: sufficient ClawSweeper judged the real behavior proof convincing. size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants