Skip to content

OC Path: restore YAML support - #81436

Merged
giodl73-repo merged 16 commits into
openclaw:mainfrom
giodl73-repo:restore-oc-path-yaml
May 16, 2026
Merged

giodl73-repo merged 16 commits into
openclaw:mainfrom
giodl73-repo:restore-oc-path-yaml

Conversation

@giodl73-repo

@giodl73-repo giodl73-repo commented May 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Restores YAML support to the bundled oc-path extension so the same oc:// addressing model works across markdown, JSONC, JSONL, YAML/YML, and .lobster workflow files.

This PR:

  • adds a YAML adapter using the existing yaml package instead of a hand-rolled parser;
  • wires YAML into openclaw path resolve/find/set/emit and the universal substrate;
  • maps .yaml, .yml, and .lobster to the YAML kind;
  • adds $first positional addressing alongside the existing $last; and
  • updates the oc-path CLI/plugin docs with YAML examples and behavior notes.

Motivation

Community feedback around oc-path has specifically asked for uniform addressing across formats, including YAML:

Agents need a uniform addressing substrate because they can't intuit file formats. A path that works identically across md, jsonc, and yaml means the agent never has to choose jsonpath vs jq vs sed.

That matches the original oc-path goal: callers should not need separate parser/edit code for every workspace file kind just to read or update one leaf.

Real behavior proof

Behavior addressed: YAML files can be resolved and edited through the real openclaw path CLI, empty YAML sequences can be appended to, and YAML writes refuse the redaction sentinel before bytes are emitted.

Real environment tested: Local Windows source checkout at 33cf47b79f, using an isolated --profile ocpath-proof and a temporary workspace. The bundled oc-path plugin was enabled with pnpm openclaw --profile ocpath-proof plugins enable oc-path.

Exact steps or command run after this patch:

pnpm openclaw --profile ocpath-proof path resolve 'oc://workflow.yaml/steps/0/id' --cwd <temp-workspace> --json
pnpm openclaw --profile ocpath-proof path set 'oc://workflow.yaml/items/+' 'alpha' --cwd <temp-workspace> --human
pnpm openclaw --profile ocpath-proof path set 'oc://workflow.yaml/name' '__OPENCLAW_REDACTED__' --cwd <temp-workspace> --json
pnpm openclaw --profile ocpath-proof path set 'oc://workflow.yaml/config/+__OPENCLAW_REDACTED__' '2' --cwd <temp-workspace> --json
pnpm test extensions/oc-path/src/oc-path/tests/yaml/yaml-kind.test.ts -- --reporter=verbose

Evidence after fix:

$ pnpm openclaw --profile ocpath-proof path resolve 'oc://workflow.yaml/steps/0/id' --cwd <temp-workspace> --json
{
  "resolved": true,
  "ocPath": "oc://workflow.yaml/steps/0/id",
  "match": {
    "kind": "leaf",
    "valueText": "fetch",
    "leafType": "string",
    "line": 3
  }
}

$ pnpm openclaw --profile ocpath-proof path set 'oc://workflow.yaml/items/+' 'alpha' --cwd <temp-workspace> --human
wrote 74 bytes to <temp-workspace>/workflow.yaml

$ type workflow.yaml
name: inbox-triage
steps:
  - id: fetch
  - id: classify
items: [ alpha ]

$ pnpm openclaw --profile ocpath-proof path set 'oc://workflow.yaml/name' '__OPENCLAW_REDACTED__' --cwd <temp-workspace> --json
{"error":{"code":"OC_EMIT_SENTINEL","message":"set refused: emit refused to write \"[REDACTED]\" sentinel literal at oc://workflow.yaml/name"}}

$ pnpm openclaw --profile ocpath-proof path set 'oc://workflow.yaml/config/+__OPENCLAW_REDACTED__' '2' --cwd <temp-workspace> --json
{"error":{"code":"OC_EMIT_SENTINEL","message":"set refused: emit refused to write \"[REDACTED]\" sentinel literal at oc://workflow.yaml/config/+[REDACTED]"}}

Targeted regression output:

✓ setYamlOcPath — positional tokens > edits the first seq element via $first
✓ universal verbs — yaml insertion > appends to an empty yaml seq with `+`
✓ universal verbs — yaml insertion > rejects sentinel-bearing yaml replacements before raw emit
✓ universal verbs — yaml insertion > rejects sentinel-bearing yaml insertions before raw emit
✓ universal verbs — yaml insertion > rejects sentinel-bearing yaml insertion keys before raw emit

Test Files  1 passed (1)
Tests  34 passed (34)

Observed result after fix: The real CLI resolves YAML leaves, appends to an empty YAML sequence, persists the expected YAML bytes, and rejects sentinel-bearing YAML values and insertion keys. The targeted regression suite passes all 30 YAML tests.

What was not tested: This proof used a local source checkout and isolated profile, not a packaged npm install or remote Gateway.

Tests

  • pnpm test extensions/oc-path/src/oc-path/tests/yaml/yaml-kind.test.ts -- --reporter=verbose
  • pnpm exec oxfmt --check --threads=1 extensions/oc-path/src/oc-path/yaml/edit.ts extensions/oc-path/src/oc-path/tests/yaml/yaml-kind.test.ts CHANGELOG.md docs/cli/path.md docs/plugins/oc-path.md
  • git diff --check

Notes

This PR intentionally does not add structured diff output for dry runs. That is split into a smaller companion PR.

Related

Refs #78051.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: oc-path size: XL maintainer Maintainer-authored PR labels May 13, 2026
@clawsweeper

clawsweeper Bot commented May 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Summary
The PR restores YAML/YML/.lobster support in the bundled OC Path plugin, adds $first positional addressing, updates docs/tests/changelog, adds a plugin-local yaml dependency, and refreshes one raw-fetch guard allowlist entry.

Reproducibility: not applicable. for a feature restoration PR. Current main source shows YAML is absent from OC Path dispatch, while the PR body provides after-fix terminal proof for YAML resolve/set/sentinel behavior.

Real behavior proof
Sufficient (terminal): The PR body includes terminal output from a real local Windows checkout showing YAML CLI resolve/set behavior, persisted bytes, and sentinel refusal after the patch.

Next step before merge
No repair-lane target remains; the next action is explicit maintainer/dependency approval for the protected feature PR and its small shared-check cleanup.

Security
Cleared: No concrete security or supply-chain regression found; [email protected] is plugin-local and the package metadata shows no install/postinstall/prepare script.

Review details

Best possible solution:

Land the YAML restoration after maintainer/dependency approval, keeping the implementation inside the bundled oc-path plugin and leaving dry-run structured diff work to the companion PR.

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

Not applicable for a feature restoration PR. Current main source shows YAML is absent from OC Path dispatch, while the PR body provides after-fix terminal proof for YAML resolve/set/sentinel behavior.

Is this the best way to solve the issue?

Mostly yes: the adapter stays inside the oc-path plugin boundary and uses the upstream YAML Document API with parse-error guards. The remaining decision is maintainer approval for the feature, dependency, and small shared-check cleanup.

Acceptance criteria:

  • node scripts/run-vitest.mjs --run extensions/oc-path/src/oc-path/tests/yaml/yaml-kind.test.ts extensions/oc-path/src/cli.test.ts
  • node scripts/check-no-raw-channel-fetch.mjs
  • git diff --check refs/remotes/openclaw/main...HEAD

What I checked:

Likely related people:

  • giodl73-repo: Prior merged history introduced the original oc-path substrate with YAML support and later removed YAML during scope tightening; this PR restores that same feature area. (role: feature-history owner and recent area contributor; confidence: high; commits: bc735f4fde6f, 6283c8247c9b; files: extensions/oc-path/src/oc-path, extensions/oc-path/src/cli.ts, docs/cli/path.md)
  • steipete: Merged history moved oc-path into the bundled plugin boundary and added the bundled plugin/docs surface this PR updates. (role: plugin refactor and docs area contributor; confidence: high; commits: e3b33a26cdb1, 52a319047edd; files: extensions/oc-path, docs/cli/path.md, docs/plugins/oc-path.md)
  • omarshahine: Reviewed the YAML adapter approach, identified the malformed-document blocker, and supplied targeted validation context in PR discussion. (role: reviewer; confidence: medium; files: extensions/oc-path/src/oc-path/yaml/edit.ts, extensions/oc-path/src/oc-path/tests/yaml/yaml-kind.test.ts)

Remaining risk / open question:

  • The protected maintainer label and plugin dependency change require explicit maintainer handling before merge.
  • The final diff still includes a raw-fetch allowlist line-number update outside OC Path; it appears to preserve current shared checks, but maintainers may want to confirm it belongs in this branch.

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

@giodl73-repo
giodl73-repo force-pushed the restore-oc-path-yaml branch from 59e4ac4 to 5cb1c71 Compare May 13, 2026 15:33
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 13, 2026
@giodl73-repo

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@giodl73-repo
giodl73-repo marked this pull request as ready for review May 13, 2026 21:20
@github-actions github-actions Bot added the dependencies-changed PR changes dependency-related files label May 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Changes Detected

This PR changes dependency-related files. Maintainers should confirm these changes are intentional.

Changed files:

  • extensions/oc-path/package.json
  • pnpm-lock.yaml

Maintainer follow-up:

  • Review whether the dependency changes are intentional.
  • Inspect resolved package deltas when lockfile or workspace dependency policy changes are present.
  • Run pnpm deps:changes:report -- --base-ref origin/main --markdown /tmp/dependency-changes.md --json /tmp/dependency-changes.json locally for detailed release-style evidence.

@giodl73-repo
giodl73-repo force-pushed the restore-oc-path-yaml branch 2 times, most recently from 5bcb324 to 451f207 Compare May 14, 2026 14:08
@omarshahine

omarshahine commented May 16, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed at 451f207c2b. Approach is sound — adapter pattern mirrors JSONC/JSONL, stays inside the extensions/oc-path boundary, and the sentinel guard now covers nested keys recursively.

One blocker matches ClawSweeper's P2: setYamlOcPath / insertYamlOcPath (extensions/oc-path/src/oc-path/yaml/edit.ts:50,74) call cloneDoc → parseDocument(doc.toString(), …) before any error gate, and [email protected] Document.toString() throws Error: Document with errors cannot be stringified when errors.length > 0 (verified against node_modules/yaml/dist/doc/Document.js:320-322).

Repro:

parseYaml("key: value\n  bad indent: oops\n")
// → doc.errors.length === 2, ast still returned
// → any path set against that file crashes instead of returning
//   { ok: false, reason: "parse-error" }

Fix is ~10 LOC: gate ast.doc.errors.length > 0 at the top of both functions, return { ok: false, reason: "parse-error" }. YamlEditResult.reason already includes parse-error, so no type changes. Add one yaml-kind.test.ts unit case and one cli.test.ts regression case covering malformed input.

Optional nits (none blocking):

  • coerceYamlValue (universal.ts:687-711) only special-cases number/boolean/null. YAML Date / bigint scalars silently rewrite as string on edit. Find/resolve already handle them via yamlScalarToText. Worth a follow-up or a doc note.
  • emitYaml default acceptPreExistingSentinel: true in roundtrip mode passes through a sentinel literal already in the source. CLI compensates via scrubSentinel; programmatic callers don't.
  • .lobster ⇒ yaml in dispatch.ts:30-32 commits the substrate to "lobster = YAML." Tested and documented; flagging only as a directional note.

Targeted suites locally on 451f207c2b:

node scripts/run-vitest.mjs --run extensions/oc-path/src/oc-path/tests/yaml/yaml-kind.test.ts
→ Test Files 1 passed, Tests 34/34

node scripts/run-vitest.mjs --run extensions/oc-path/src/oc-path/tests/find.test.ts extensions/oc-path/src/cli.test.ts
→ Test Files 2 passed, Tests 74/74

After the malformed-input gate lands, rebase past the CHANGELOG.md conflict on main (only file conflicting) and this is ready to merge.

#81436

Re-review progress:

@giodl73-repo
giodl73-repo force-pushed the restore-oc-path-yaml branch from 451f207 to bff6be1 Compare May 16, 2026 04:28
@giodl73-repo

Copy link
Copy Markdown
Contributor Author

Addressed the malformed YAML blocker from @omarshahine.

Changes:

  • setYamlOcPath and insertYamlOcPath now return { ok: false, reason: parse-error } before cloning/stringifying documents that already have YAML parse errors.
  • The universal YAML set/insert path also gates malformed parsed documents before resolve/coercion so CLI callers get the structured parse-error instead of not-writable or a thrown Document.toString() error.
  • Added direct YAML edit regressions for malformed set/insert and a CLI regression that verifies openclaw path set leaves the malformed file untouched and returns structured parse-error.
  • Rebased onto current origin/main and resolved the CHANGELOG.md conflict, preserving the YAML entry once.

Validation:

  • node node_modules\\vitest\\vitest.mjs run extensions\\oc-path\\src\\oc-path\\tests\\yaml\\yaml-kind.test.ts extensions\\oc-path\\src\\cli.test.ts → 55 tests passed
  • git diff --check

Note: the local Windows shell still fails to launch oxfmt with spawn EPERM, so I could not run the formatter check locally in this environment.

@giodl73-repo

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@giodl73-repo

Copy link
Copy Markdown
Contributor Author

Follow-up docs update for the YAML support PR:

  • docs/cli/path.md now explicitly calls out .yaml, .yml, and .lobster as supported YAML-backed file kinds.
  • The mutation contract now documents that malformed YAML with parser errors is refused before mutation with parse-error.

Validation after rebasing onto current origin/main:

node node_modules\vitest\vitest.mjs run extensions\oc-path\src\oc-path\tests\yaml\yaml-kind.test.ts extensions\oc-path\src\cli.test.ts
# Test Files 2 passed (2), Tests 55 passed (55)

git diff --check
# passed

@clawsweeper re-review

@giodl73-repo
giodl73-repo force-pushed the restore-oc-path-yaml branch from bff6be1 to 6d2634d Compare May 16, 2026 04:46
@clawsweeper

clawsweeper Bot commented May 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@giodl73-repo
giodl73-repo force-pushed the restore-oc-path-yaml branch 8 times, most recently from 6883648 to 623a1a4 Compare May 16, 2026 13:37
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
* OC Path: restore YAML support
* fix(oc-path): guard yaml writes and empty sequences
* fix(oc-path): guard yaml insertion keys
* fix(oc-path): guard yaml object key
* fix(oc-path): classify yaml root insertions
* style(oc-path): format yaml branch after rebase
* fix(oc-path): reject malformed yaml edits
* docs(oc-path): clarify yaml file support
* fix(ci): refresh yaml branch after rebase
* fix(ci): clean shared blockers for yaml path PR
* fix(changelog): keep yaml path note scoped
* fix(ci): preserve current shared contracts


---------

Co-authored-by: Gio Della-Libera <[email protected]
galiniliev pushed a commit to galiniliev/openclaw that referenced this pull request May 25, 2026
* OC Path: restore YAML support
* fix(oc-path): guard yaml writes and empty sequences
* fix(oc-path): guard yaml insertion keys
* fix(oc-path): guard yaml object key
* fix(oc-path): classify yaml root insertions
* style(oc-path): format yaml branch after rebase
* fix(oc-path): reject malformed yaml edits
* docs(oc-path): clarify yaml file support
* fix(ci): refresh yaml branch after rebase
* fix(ci): clean shared blockers for yaml path PR
* fix(changelog): keep yaml path note scoped
* fix(ci): preserve current shared contracts


---------

Co-authored-by: Gio Della-Libera <[email protected]
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
* OC Path: restore YAML support
* fix(oc-path): guard yaml writes and empty sequences
* fix(oc-path): guard yaml insertion keys
* fix(oc-path): guard yaml object key
* fix(oc-path): classify yaml root insertions
* style(oc-path): format yaml branch after rebase
* fix(oc-path): reject malformed yaml edits
* docs(oc-path): clarify yaml file support
* fix(ci): refresh yaml branch after rebase
* fix(ci): clean shared blockers for yaml path PR
* fix(changelog): keep yaml path note scoped
* fix(ci): preserve current shared contracts


---------

Co-authored-by: Gio Della-Libera <[email protected]
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
* OC Path: restore YAML support
* fix(oc-path): guard yaml writes and empty sequences
* fix(oc-path): guard yaml insertion keys
* fix(oc-path): guard yaml object key
* fix(oc-path): classify yaml root insertions
* style(oc-path): format yaml branch after rebase
* fix(oc-path): reject malformed yaml edits
* docs(oc-path): clarify yaml file support
* fix(ci): refresh yaml branch after rebase
* fix(ci): clean shared blockers for yaml path PR
* fix(changelog): keep yaml path note scoped
* fix(ci): preserve current shared contracts


---------

Co-authored-by: Gio Della-Libera <[email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies-changed PR changes dependency-related files docs Improvements or additions to documentation extensions: oc-path maintainer Maintainer-authored PR proof: sufficient ClawSweeper judged the real behavior proof convincing. scripts Repository scripts size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants