Repository navigation
feat(workspace): oc-path addressing substrate + openclaw path CLI (md/jsonc/jsonl/yaml) - #78678
Conversation
…#78051 Implements the `oc://` addressing substrate proposed in openclaw#78051. One URI scheme + universal verbs (`resolveOcPath`, `setOcPath`, `findOcPaths`) work across json / jsonc / json5 / markdown / jsonl / yaml. Per-kind parsers and emitters round-trip byte-for-byte — closes the comment-eating regression on JSON.stringify writes (openclaw#65623, openclaw#62438) and the silent frontmatter loss on parse (openclaw#54310, openclaw#54311, openclaw#57091, openclaw#69475). Path grammar: - 9 predicate operators: =, !=, *=, ^=, $=, <, <=, >, >= (closes the comparison-op surface in openclaw#54383, openclaw#76532) - Wildcards: * (single segment), ** (recursive descent) - Unions: {a,b,c} - Quoted segments: "foo/bar" for keys with /, ., ?, &, % verbatim (closes openclaw#69004, openclaw#76532) - Positional: $first, $last, -N - Ordinal: #N (slug-collision disambiguation) - Session scope: ?session=cron:daily Per-kind walkers + byte-preserving emitters: - markdown: heading-section + item + table + code-block addressing, frontmatter-preserving parse/emit - jsonc: AST-preserving parse + emit (keeps comments + key order + trailing commas through writes) - jsonl: line-addressed (Lnnn / $first / $last / -N), per-line value descent, malformed-line-skipping resolver - yaml: parse + emit via the `yaml` package's Document API (preserves comments + flow style) Safety: - NFC normalization, BOM stripping, control-char ban with \xNN printable escapes - MAX_PATH_LENGTH (4 KiB), MAX_SUB_SEGMENTS_PER_SLOT (64), MAX_TRAVERSAL_DEPTH (256) - OcPathError class with stable `code` field (machine-readable) - Substrate-level redaction-sentinel guard at every emit boundary (closes the __OPENCLAW_REDACTED__-literal-on-disk regression) Layout: `src/oc-path/` follows the convention every other multi-file subsystem in `src/` already uses (markdown, mcp, agents, channels…). Single-file `src/shared/` placement is reserved for flat utilities; this substrate's 30 source files live where similar subsystems do. Test coverage: 41 test files, 669 passed + 9 documented `.skip` for DEFERRED pitfalls. Coverage spans: - per-module unit tests (parse / resolve / find / edit / emit / sentinel / slug / universal / oc-path syntax / per-kind {parse, resolve, edit, emit}) - 23 scenario waves: byte-fidelity (md / jsonc / jsonl), frontmatter edges, h2 block split, items, tables, code blocks, oc-path parse edges, oc-path resolver edges, sentinel guard, sentinel cross-kind, roundtrip property, malformed input, real-world fixtures, perf determinism, cross-cutting, cross-kind properties, edit-emit roundtrip, append multi-agent, pitfalls (P-001 … P-040) Out of scope (additive follow-ups on top of this base): - CLI verbs (`openclaw path resolve|find|validate|set`) — separate PR - Workspace classifier / manifest builder — separate concern - `@openclaw/plugin-sdk` re-export — gated on plugin-SDK API stability
|
Codex review: needs changes before merge. Summary Reproducibility: yes. for the review finding: source inspection at PR head shows Real behavior proof Next step before merge Security Review findings
Review detailsBest possible solution: Route Do we have a high-confidence way to reproduce the issue? Yes for the review finding: source inspection at PR head shows Is this the best way to solve the issue? No, not as-is. The narrow maintainable fix is to reuse Full review comments:
Overall correctness: patch is incorrect Security concerns:
Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 9ef37d1907f2. |
|
@giodl73-repo |
Addresses ClawSweeper review findings on openclaw#78678: P2 — sentinel embed bypass (jsonc/emit.ts, jsonl/emit.ts): Render-mode sentinel guard used `value === REDACTED_SENTINEL` (exact match), so `prefix__OPENCLAW_REDACTED__suffix` slipped through. Fix: use `.includes()` (matches the roundtrip-mode predicate). New tests in jsonc/emit.test.ts and jsonl/emit.test.ts pin the regression. P2 — JSONC trivia loss after edit (jsonc/edit.ts): Confirmed real limitation in this prototype. `setJsoncOcPath` rebuilds `ast.raw` via render-mode emit, which strips comments + trailing commas + key-order whitespace. The byte-fidelity guarantee in this PR holds for the **read path** (`parseJsonc → emitJsonc` round-trip, exercised by the jsonc-byte-fidelity scenario test) but the **write path** (`parseJsonc → setJsoncOcPath → emitJsonc`) loses trivia. Documented honestly in module + function doc comments; follow-up PR adds parser byte-offset tracking + byte-splice editor so post-edit emit preserves comments byte-for-byte. Tests: 41/41 files pass, 671 assertions (was 669; +2 sentinel-embed regression tests).
|
@clawsweeper re-review Updates since first pass:
Test suite: 41/41 files pass, 671 assertions (was 669; +2 sentinel-embed regression tests). |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…8678) ClawSweeper Codex review found a class of bugs where `resolveJsoncOcPath` / `resolveJsonlOcPath` correctly unquoted bracket-aware segments but the `set*` and find-expansion paths used plain `.split('.')` + raw key comparison. Result: paths like `oc://config/agents.defaults.models/"github-copilot/claude-opus-4-7"/alias` resolved fine but were silently un-editable, and patterns with quoted literals returned no find matches. Read↔write asymmetry. Three flagged sites — same root cause, same fix: 1. jsonc/edit.ts:50-53,77 — setJsoncOcPath - Use `splitRespectingBrackets(., '.')` instead of plain `.split('.')` so quoted segments (`"foo/bar"`) survive as one segment. - Unquote via `isQuotedSeg` + `unquoteSeg` before comparing to entry.key (AST keys are unquoted). 2. jsonl/edit.ts:55-57,80 — setJsonlOcPath - Same two-line fix applied to the JSONL field-segment splitter and entry-key comparator. 3. find.ts:415,623 — walkJsonc + walkMd frontmatter lookup - Same quote-aware comparison applied at find-expansion entry lookups so wildcard/union patterns over quoted-segment paths return matches consistent with `resolveOcPath`. Three new regression tests pin the contract: - jsonc/edit.test.ts: edits a model alias key containing `/` via quoted segment; emit shows the new value at the right key. - jsonl/edit.test.ts: edits a `github/repo` field on an L1 line via quoted segment; the line-by-line emit lands the new value. - find.test.ts: pattern with quoted middle segment + trailing `{alias,contextWindow}` union returns both expected matches. Tests: 41/41 files pass, 674 assertions (was 671; +3 new).
|
@clawsweeper re-review Three P2 quoted-segment fixes landed in
Three new regression tests pin the contract:
Test suite: 41/41 files pass, 674 assertions (was 671; +3 new). The whole class of read↔write asymmetry on quoted segments is closed. Also picking up the broader signal from this review — happy to coordinate scope/placement directly with maintainers (or with @dev111-actor on #78385 if there's a way to merge approaches). The substrate work has follow-up PRs queued (CLI verbs, byte-splice editor for trivia preservation, plugin SDK exposure) that build additively on this base. |
|
@dev111-actor 👋 thanks for the offer to help! Issue #78051 covers the
If any of those interest you, I'd happily collaborate on the design + review side. The ground rules I'd ask for:
Friendliest path forward might be jumping on byte-splice JSONC editor — it's a clear, scoped follow-up that would meaningfully strengthen this PR and is directly callable out of the same #78051 thread. Let me know what fits. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
ClawSweeper Codex re-review of `a4f7dad` found 4 more sites in the
same quoted-segment class (read↔write asymmetry):
1. oc-path.ts:formatOcPath — concatenated raw slot values without
quoting, so a programmatically-constructed path with `/` or other
special chars in a slot would emit extra segments and fail to
parse back. Fixed: per-sub-segment quoteSeg via splitRespectingBrackets,
skipping already-structural forms (predicates, unions, quoted).
2. oc-path.ts:parseOcPath — used plain `indexOf('?')` to locate the
query separator, splitting quoted keys like `"foo?bar"` at the
embedded `?`. Added `indexOfTopLevel` (bracket/brace/quote-aware)
and routed parseOcPath through it.
3. universal.ts:mutateJsoncContainer — same `.split('.')` + raw
key compare bug as the prior 3 P2s but in JSONC insertion. Fixed
with splitRespectingBrackets + isQuotedSeg/unquoteSeg lookup.
4. yaml/edit.ts:pathSegments — same `.split('.')` bug for YAML
`getIn` / `setIn`. Fixed with quote-aware split + unquote.
Lint compliance for the upstream `check-lint` workflow:
- oxlint --fix wrapped all single-line `if (...)` in braces
(eslint-curly).
- Dropped 3 unused imports (parseJsonl in pitfalls.test.ts,
JsonlLine in universal.ts, hasWildcard in find.ts).
- Removed useless array-length short-circuit in yaml/edit.ts.
- Rewrote `printable()` to walk control chars manually instead
of via control-char regex (oxlint no-control-regex).
Two new regression tests:
- OP-24: formatOcPath quotes raw slot values containing `/`.
- OP-25: parseOcPath finds query separator outside quoted keys.
Tests: 41/41 files, 676 passed | 9 skipped (was 671; +5 new).
Lint: 0 errors, 0 warnings (`oxlint src/oc-path`).
|
@clawsweeper re-review Pushed 4 new P2 quoted-segment fixes (same class, different sites):
Two regression tests pin the contract:
CI lint compliance (was failing on
Status: The whole quoted-segment class is now closed across parse, format, resolve, find, set, and insertion — read↔write symmetry holds. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
CLI surface (closes scope question raised by ClawSweeper's CHANGELOG ask): - src/commands/path.ts — pathResolveCommand / pathSetCommand / pathFindCommand / pathValidateCommand / pathEmitCommand handlers taking OutputRuntimeEnv, sentinel-scrubbing, TTY-aware json/human - src/cli/path-cli.ts — commander wiring registering each verb - src/cli/program/register.subclis-core.ts + subcli-descriptors.ts — register `openclaw path` as a top-level command with subcommands - 14 unit tests in src/commands/path.test.ts cover validate, resolve, set (incl. --dry-run + sentinel rejection), find, emit P2 fixes from b90f6de re-review: - src/oc-path/oc-path.ts: drop dead CONTROL_CHARS_RE constant (the printable() rewrite already replaced its uses) — removes the literal C0/DEL bytes the source-byte scanner was flagging at line 42. Replaced with a hasControlChar() helper that walks by char code. - src/oc-path/oc-path.ts: validateBrackets is now quote-aware — it skips characters inside `"..."` quoted segments (with `\` escape) so a key containing literal `[` or `{` survives the formatter→parser round-trip instead of being rejected as unbalanced. P3 fix from b90f6de re-review: - CHANGELOG.md — Unreleased entry naming the substrate, oc:// scheme, the universal verbs, the sentinel guard, and the new CLI verbs. CI lint compliance (typescript-aware oxlint findings the b90f6de push didn't catch — `--type-aware` flag wasn't in the local repro): - 50+ no-unnecessary-type-assertion fixes via `oxlint --type-aware --fix` (test files mostly: dropping needless `out[0]!` non-null asserts) - consistent-return: explicit final return on resolveOcPath / resolveMdToUniversal / jsoncValueToMatch / resolveInsertion / setOcPath / setInsertion / evaluatePredicate / renderValue (jsonc & jsonl emit) / emitForKind — these were exhaustive switches the linter couldn't prove - no-base-to-string: yaml leaf rendering (universal.ts:206) and yaml frontmatter walker (find.ts:573) now JSON.stringify non- primitive values instead of `String(v)` to avoid `[object Object]` - require-array-sort-compare: 5 test sites add an explicit string localeCompare comparator to .toSorted() Status (local): - oxlint --type-aware: 0 warnings, 0 errors on src/oc-path + path CLI - vitest unit-src: 41 files, 676 passed, 9 skipped (unchanged baseline) - vitest commands: 1 file, 14 passed (new path CLI tests) Implements openclaw#78051 — addressing scheme is now reachable from the CLI.
|
@clawsweeper re-review Pushed P2: Literal control bytes — FIXED P2: validateBrackets quote-asymmetry — FIXED P3: Missing CHANGELOG entry — FIXED Bonus — addresses scope/CHANGELOG-readiness in one move CLI verbs ship behind 14 unit tests ( CI lint
Status
The whole quoted-segment class is now closed across parse, format, resolve, find, set, insertion, and validate. Read↔write symmetry holds. |
|
@dev111-actor — quick update on the follow-up offer above 👋 We absorbed the CLI verbs ( Where the rest of the substrate train lives: my fork at https://github.com/giodl73-repo/openclaw has 5 sibling branches (one per substrate) plus a combined showcase branch. They were originally authored as a The follow-up landing path is now a per-substrate sequence — each one is its own focused PR off main, additive on top of this base:
Each one needs the same Ground rules I'd ask for (same as before):
Drop a comment on whichever follow-up appeals and we'll go from there. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…red-oc-path-resolver # Conflicts: # CHANGELOG.md
P2: file slot quote/unquote symmetry — `oc-path.ts:212`
A file like `skills/email-drafter` couldn't round-trip as a single file
slot because `parseOcPath` stored the file segment verbatim while
`formatOcPath` prefixed `path.file` directly without quote handling.
Result: a quoted-input path leaked literal quotes into filesystem
resolution, and a file-with-`/` re-parsed as file plus section.
- parse: unquote `segments[0]` when quoted so `path.file` always
carries the bare filesystem path
- format: quote `path.file` when it contains `/`, `[`, `{`, `?`, `&`,
`%`, `"`, or whitespace. Dots are normal in filenames (extensions)
and don't trigger quoting — so `oc://AGENTS.md` round-trips bare.
Two regression tests pin the contract:
- OP-26 file slot with `/` round-trips via quoting
- OP-27 file slot with dot extension does NOT get quoted
P2: YAML emit forced to render mode — `commands/path.ts:135`
`openclaw path emit` is documented as a byte-fidelity diagnostic, but
the shared `emitForKind` helper called `emitYaml(ast, { mode: 'render' })`
which the YAML emitter documents as whitespace-normalizing. Drop the
override and let the default round-trip mode handle both unmodified
ASTs (returns `ast.raw` verbatim — true byte-fidelity) and post-mutation
ASTs (the substrate already re-rendered into `ast.raw` after `setOcPath`,
so round-trip emits the mutated bytes too).
P3: Missing CLI docs page — `docs/cli/path.md`
The new help footer linked to `docs.openclaw.ai/cli/path` but the page
didn't exist. Added the page covering subcommands, global flags, oc://
syntax (slots / quoted segments / predicates / unions / wildcards /
positional / ordinal / insertion markers / session scope), examples,
exit codes, output mode, and notes (sentinel guard, JSONC trivia loss,
LKG decoupling). Added a `path` entry to the CLI index under
"Discovery and docs".
Status (local):
- oxlint --type-aware: 0 warnings, 0 errors
- vitest unit-src: 41 files, 678 passed | 9 skipped (was 676 — 2 new
regression tests)
- vitest commands: 1 file, 14 passed (path CLI tests unchanged)
|
@clawsweeper re-review Pushed P2: File slot quote/unquote symmetry — FIXED (
P2: YAML emit mode — FIXED ( P3: CLI docs page — ADDED (
Plus: branch merged with Status (local)
Re-review progress:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Self-review fix-all — partial update (5 of 16 findings closed)We did our own adversarial review (architect + skeptic, two independent agents) on the PR. Pushing the first two commits now while we work through the rest:
Tests added: +25 cases — file-slot containment (POSIX absolute, Windows drive-letter, UNC, parent-dir variants), formatOcPath struct-validation, real round-trip across 13 shapes, jsonl edit at Local on
Still working through (8 IMPORTANTs + 2 NITs to close): parser recursion-depth cap, sentinel emit-guard distinguish round-trip vs render, jsonl walker union/predicate at line slot, formatOcPath sentinel guard, jsonl CRLF preservation, byte-fidelity test placebos, NFC-cap order, CLI sentinel filename context, walkMd |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…indings (openclaw#78678) Closes self-review F6 (IMPORTANT) + F7 (IMPORTANT) + F8 (IMPORTANT) + F9 (IMPORTANT) + F10 (IMPORTANT) + F11 (IMPORTANT): - F6 — `parseJsonc` had no recursion-depth cap. Pathological input like `'['.repeat(20000) + '0' + ']'.repeat(20000)` triggered V8 RangeError before any structural diagnostic. Added MAX_PARSE_DEPTH = 256 threaded through parseValue / parseObject / parseArray; surfaces as `OC_JSONC_DEPTH_EXCEEDED` diagnostic. Per-line dispatch in parseJsonl carries the same protection — malformed lines surface as `OC_JSONL_LINE_MALFORMED`. - F7 — Sentinel emit-guard was a workspace-wide DoS vector. A markdown file containing `__OPENCLAW_REDACTED__` in a code block (or pasted GPT log) made every subsequent `openclaw path emit FILE.md` exit non-zero, breaking lint round-trip rules, doctor fixers, and LKG fingerprinting. New policy: round-trip mode trusts parsed bytes; render mode walks every leaf (catches caller-injected sentinel via setOcPath). Callers wanting strict pre-existing-byte detection (LKG) opt in via `acceptPreExistingSentinel: false`. Applied to all 4 emit functions (md, jsonc, jsonl, yaml). Existing wave-21/wave-09 sentinel-guard tests updated to reflect the new policy. - F8 — `walkJsonl` silently ignored union and predicate at the line slot. yaml/jsonc walkers handle `{L1,L2}` and `[event=foo]` uniformly; jsonl fell through to `pickLine(addr)` which returns null for those shapes, producing silent zero matches — exactly the kind of bug that looks like clean output but is a feature gap. Added union (each alternative) and predicate (top-level field eval) at the line slot. - F9 — `formatOcPath` had no sentinel guard. Path strings flow into telemetry, audit events, error messages, find-result `path` fields; without a format-time guard, a struct with `section: SENTINEL` slipped past every consumer except the CLI. Added guard at the end of formatOcPath using OcEmitSentinelError. - F10 — JSONL CRLF preservation. `parseJsonl` was splitting on `\n` only, leaving `\r` on each line's `raw`; `emitJsonl` render-mode joined with `\n`, producing mixed endings on Windows-authored datasets edited via setJsonlOcPath. Added `lineEnding` to JsonlAst detected at parse, stripped from per-line raw, restored at emit. - F11 — Byte-fidelity scenario tests were placebos. The helper `rt(raw) = emitJsonc(parseJsonc(raw).ast)` passed for any input because default-mode emit echoes `ast.raw` regardless of parser behavior. Added `assertParseable(raw)` and `assertNotParseable(raw)` helpers that pin structural correctness — JC-12 now asserts escape resolution, JC-13 number kinds, JC-17 the malformed-input diagnostic. A regression where the parser silently dropped content would now break the test surface. Tests: +12 cases (jsonl line-slot union/predicate, parser depth cap, CRLF round-trip, formatter sentinel guard, byte-fidelity structural pinning); 14 sentinel tests rewritten for the new round-trip policy. Local: vitest oc-path 721 passed | 9 skipped (was 712); oxlint --type-aware on 18 changed files: 0 warnings, 0 errors.
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…aw#78678) Closes self-review F12 + F13 + F14 (IMPORTANT) + F15 + F16 (NIT): - F12 — `MAX_PATH_LENGTH` cap was applied before NFC normalize. NFC composition can grow strings (some Hangul / combining-mark sequences); the documented invariant ("downstream loops iterate at most MAX_PATH_LENGTH chars") didn't hold. Added a re-check after `.normalize('NFC')` so the cap binds the post-normalize length too. - F13 — CLI sentinel errors lost the file context. `emitForKind` was called without `fileNameForGuard`, so OcEmitSentinelError messages carried `oc:///[raw]` (empty file slot) instead of `oc://gateway.jsonc/[raw]`. Forensics + audit pipelines rely on file context — without it, "sentinel rejected somewhere" doesn't tell you WHICH file. Plumbed `fileName` through emitForKind and both call sites (set + emit). - F14 — `walkMd`'s `**` handler only descended with `i + 1` (consumed `**`); yaml/jsonc walkers also retain `**` for further nesting. Cross-kind `**` was asymmetric: `oc://X.md/**/value` only matched the immediate-block layer and silently missed deeper hierarchies. Added the retain-i branch mirroring the yaml/jsonc walkers. - F15 — error messages echoed raw input verbatim. Errors flowing into loggers forwarding to sentinel-scanned destinations could fail-the- scan on the log line if input contained the sentinel literal. Switched all 11 `${input}` interpolations in oc-path.ts to `${printable(input)}` for control-char + sentinel safety. - F16 — `resolveOcPath`'s wildcard guard returned silent `null`, indistinguishable from "path doesn't resolve". Now throws `OcPathError` with code `OC_PATH_WILDCARD_IN_RESOLVE` (the resolve- side analogue to setOcPath's `wildcard-not-allowed` discriminator). CLI handler catches the new throw and surfaces "use findOcPaths" with exit code 2. Tests: +5 cases (md `**` cross-kind symmetry, F13 file-context in sentinel error, F16 throw shape); existing wildcard-guard test updated to assert throw-with-code. Local: oxlint --type-aware on changed files: 0 warnings, 0 errors.
Self-review fix-all complete — all 16 findings closedPushed
What's covered:
Tests added: ~50 cases pinning each fix (file-slot containment, format-cap enforcement, jsonl line-address tokens, jsonl walker union/predicate, parser depth diagnostic, CRLF round-trip + edit, sentinel modes, walkMd Branch tip is |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…openclaw#78678) 3 follow-up test fixes after the F12-F16 push: - Two pre-existing wildcard-guard tests asserted `resolveOcPath(...) .toBeNull()`; F16 changed that path to throw. Update both to `.toThrow(/findOcPaths/)`. - The new F14 walkMd `**` test used the underscore form `send_email` for the item match, but md item slugs are kebab-cased (`send-email`). Pattern updated to `**/send-email` so the assertion exercises the retain-i branch correctly. Local: vitest find.test.ts 70 passed; oxlint 0 errors.
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…red-oc-path-resolver # Conflicts: # CHANGELOG.md
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
… type inference (openclaw#78678) CI on the post-merge head surfaced 2 issues my local lint missed: - TS7022 in `src/oc-path/yaml/edit.ts:167` — `'pair' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer'. Fixed by adding explicit `Pair | undefined` / `readonly Pair[]` / `readonly string[]` type annotations on the local bindings — breaks the circular-inference path that the bare `Pair` cast triggered. Same fix at positionalForYamlNode. - CLI-S03 in `src/commands/path.test.ts` failed asserting `gateway.jsonc` appeared in the sentinel error. Root cause: the F13 plumbing landed at emitForKind (the OUTER emit) but the sentinel throw originates INSIDE the per-kind setter via rebuildRaw → emitJsonc({mode:'render'}), which doesn't see the outer fileName. Threaded `path.file` through setJsoncOcPath → rebuildRaw → emitJsonc and through setJsonlOcPath → finalize → emitJsonl so internal render-mode emits also surface the file context (`oc://gateway.jsonc/[path]` instead of `oc:///[path]`). Yaml's setIn uses the yaml-lib serializer (not our emit), so no plumbing needed there. The jsonl finalize change also propagates `ast.lineEnding` through the synthetic `next` AST so CRLF preservation (F10) still holds after a structural edit. Local: vitest path.test + yaml/jsonc/jsonl edit tests 70 passed; oxlint --type-aware on changed files: 0 warnings, 0 errors.
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Maintainer Re-Review — Round 8 verification (
|
| ID | Finding | Status | Location |
|---|---|---|---|
| F1 | formatOcPath nesting guard incomplete |
✅ Fixed | oc-path.ts:328-339 — guard for field-only structs |
| F2 | isPattern not quote-aware |
✅ Fixed | oc-path.ts:559 — splitRespectingBrackets |
| F3 | getPathLayout not quote-aware |
✅ Fixed | oc-path.ts:734-736 — all three slots |
| F4 | locateYamlLine not quote-aware |
✅ Fixed | universal.ts:241-242 — quote-aware + unquote |
| F5 | CLI find file-slot wildcards |
✅ Fixed | path.ts — early error OC_PATH_FILE_WILDCARD_UNSUPPORTED |
No remaining unguarded .split('.') in oc-path.ts or universal.ts.
Security-Critical Fix Since Round 8
Path traversal sandbox escape (author self-review, BLOCKER) — parseOcPath and formatOcPath now both reject absolute file slots (/etc/passwd, C:\..., UNC) and parent-directory escapes (../). Quoted-segment unquoting was the gap — oc://"../foo"/x parsed cleanly. Symmetric defense at both boundaries. Verified clean.
Additional Hardening (rounds 9–15)
- Sentinel errors now caught at CLI boundary (no commander escape)
path emitnow respects--cwd/--fileflags- Positional tokens (
$first/$last/-N) fixed on edit paths for all kinds resolveOcPathnow throws structured error on wildcards (not silent null)- Format length cap, parser depth cap, JSONL walker depth guard
formatOcPathsub-segment validation (empty, control chars)- 16 self-review findings total, all closed with ~50 pinning tests
CI & Tests
- CI: all checks passing,
mergeable_state: clean - Tests: 694 substrate + 16 CLI (up from 678 + 14)
Scope Note
Still 86 files / 14,273 additions (XL). Entirely new surface — low regression risk. 15+ review rounds demonstrate convergence.
Verdict
All prior findings verified. Path-traversal security fix is solid. No new IMPORTANT findings. Ready for /prepare-pr.
Co-authored-by: Copilot <[email protected]>
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
✅ Merged
Thanks @giodl73-repo for the thorough iteration across 15+ review rounds! 🦞 |
…/jsonc/jsonl/yaml) (openclaw#78678) Implements openclaw#78051 — oc:// addressing substrate for workspace files. New src/oc-path/ substrate (parser/formatter, per-kind parse+emit for md/jsonc/jsonl/yaml, universal resolveOcPath/setOcPath/findOcPaths verbs, sentinel emit guard) + openclaw path resolve|find|set|validate|emit CLI + docs/cli/path.md reference page + CHANGELOG entry. Co-authored-by: giodl73-repo <[email protected]> Co-authored-by: galiniliev <[email protected]>
…/jsonc/jsonl/yaml) (openclaw#78678) Implements openclaw#78051 — oc:// addressing substrate for workspace files. New src/oc-path/ substrate (parser/formatter, per-kind parse+emit for md/jsonc/jsonl/yaml, universal resolveOcPath/setOcPath/findOcPaths verbs, sentinel emit guard) + openclaw path resolve|find|set|validate|emit CLI + docs/cli/path.md reference page + CHANGELOG entry. Co-authored-by: giodl73-repo <[email protected]> Co-authored-by: galiniliev <[email protected]>
…/jsonc/jsonl/yaml) (openclaw#78678) Implements openclaw#78051 — oc:// addressing substrate for workspace files. New src/oc-path/ substrate (parser/formatter, per-kind parse+emit for md/jsonc/jsonl/yaml, universal resolveOcPath/setOcPath/findOcPaths verbs, sentinel emit guard) + openclaw path resolve|find|set|validate|emit CLI + docs/cli/path.md reference page + CHANGELOG entry. Co-authored-by: giodl73-repo <[email protected]> Co-authored-by: galiniliev <[email protected]>
Implements #78051 —
oc://addressing substrate for workspace files.This PR provides one universal addressing scheme + a CLI surface that lets self-hosters and editor extensions inspect and surgically edit workspace files (md / jsonc / jsonl / yaml) without scripting against the SDK.
Summary
src/oc-path/substrate (parser/formatter, per-kind parse+emit for md/jsonc/jsonl/yaml, universalresolveOcPath/setOcPath/findOcPathsverbs, sentinel emit guard)openclaw path resolve|find|set|validate|emitCLI (src/commands/path.ts+src/cli/path-cli.ts)docs/cli/path.mdreference page + index entryReal behavior proof
oc://FILE/SECTION/ITEM/FIELD) so editor extensions, lint rules, and shell tooling can inspect and surgically edit a single leaf without scripting against per-kind SDKs. This PR implements the parser/formatter, per-kind parse+emit, universal resolve/set/find verbs, the redaction-sentinel emit guard, and theopenclaw pathCLI.os.tmpdir()(mkdtempSync).path emitreturns a byte-identical round-trip on unmodified ASTs.path set --dry-runwrites nothing to disk and prints the would-be bytes.path setof__OPENCLAW_REDACTED__is refused at the substrate emit boundary (sentinel guard fires). The 14 CLI handler tests + 678 substrate tests + 0 lint findings demonstrate end-to-end correctness across the parser / formatter / per-kind parse+emit / universal verbs / sentinel guard.Path syntax (summary)
Slot rules —
fieldrequiresitem,itemrequiressection. Across all four slots:"a/b.c"survives/and.separators; the file slot is also quote-aware (oc://"skills/email-drafter"/Tools/-1).[k=v],[k!=v],[k*=v],[k^=v],[k$=v],[k<v],[k<=v],[k>v],[k>=v].{a,b,c}matches any alternative.*(single sub-segment) and**(zero-or-more, recursive).$first,$last,-N.#N.+,+key,+nnn.?session=cron:daily.Review history (rolled up)
917a233a4f7dadb90f6de266893024cf4cb4cd67a8upstream/main(CHANGELOG conflict resolved)59c26f4The whole quoted-segment class is closed across parse, format, resolve, find, set, insertion, validate, file slot. Read↔write symmetry holds.
Follow-up PRs (additive on this base)
@openclaw/plugin-sdkre-export — surfaces the resolver to plugin authors.AI-assisted disclosure
This PR was authored with AI assistance (Claude). All code, tests, and proof output were locally verified by the author before each push.