Skip to content

feat(workspace): add internal oc-path resolver - #78385

Closed
WT-WSL wants to merge 1 commit into
openclaw:mainfrom
WT-WSL:feat/workspace-oc-path-resolver
Closed

WT-WSL wants to merge 1 commit into
openclaw:mainfrom
WT-WSL:feat/workspace-oc-path-resolver

Conversation

@WT-WSL

@WT-WSL WT-WSL commented May 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Problem: Workspace file handling proposals in Workspace oc:// addressing substrate — feedback wanted #78051 need a small shared addressing foundation before larger lint, doctor, rollback, or policy work can be reviewed safely.
  • Why it matters: Without a common resolver, future workspace tooling would keep reimplementing ad hoc JSONC and markdown traversal logic.
  • What changed: Added an internal read-only oc:// resolver for JSON/JSONC/JSON5 values and markdown heading sections, with focused unit coverage.
  • What did NOT change (scope boundary): No CLI commands, public plugin SDK APIs, doctor integration, write/edit support, LKG rollback, or policy IR behavior were added.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Real behavior proof (required for external PRs)

  • Behavior or issue addressed: Internal workspace addressing can now resolve supported oc:// paths over JSONC and markdown content without introducing broader runtime behavior.

  • Real environment tested: Local OpenClaw checkout on Linux.

  • Exact steps or command run after this patch:

    • node --import tsx - <<'NODE' ... NODE
  • Evidence after fix: copied console output from the live local OpenClaw checkout:

    {
      "jsoncPredicate": {
        "kind": "value",
        "path": "oc://policy.jsonc/tools/[id=send-email]/sensitivity",
        "value": "restricted"
      },
      "jsoncWildcard": [
        "send-email",
        "calendar"
      ],
      "markdownSection": {
        "kind": "markdown-section",
        "path": "oc://AGENTS.md/Tools/send-email",
        "heading": "send-email",
        "line": 5,
        "valueText": "Email body."
      }
    }
  • Observed result after fix: The resolver returned the expected JSONC predicate value, wildcard JSONC values, and markdown section content from a real local module import.

  • What was not tested: CLI usage, doctor integration, plugin registration, write/edit operations, and live runtime use, because this PR intentionally does not add those surfaces.

  • Before evidence: Current main has no parseOcPath, resolveOcPath, findOcPaths, registerLintRule, OcPathFixerSpec, PolicyIR, or generalized LKG substrate.

Root Cause (if applicable)

N/A

Regression Test Plan (if applicable)

N/A

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/shared/oc-path.test.ts
  • Scenario the test should lock in: oc:// parsing and read-only resolution for JSONC values, array indexes, predicates, wildcards, and markdown heading sections.
  • Why this is the smallest reliable guardrail: The new behavior is a pure internal resolver with no runtime side effects.
  • Existing test that already covers this (if any): None.
  • If no new test is added, why not: New focused tests were added.

User-visible / Behavior Changes

None.

Diagram (if applicable)

Before:
[workspace file content] -> [feature-specific parser]

After:
[workspace file content] -> [internal oc:// resolver] -> [matched JSONC value or markdown section]

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any Yes, explain risk + mitigation: N/A

Repro + Verification

Environment

  • OS: Linux
  • Runtime/container: Local Node/pnpm workspace
  • Model/provider: N/A
  • Integration/channel (if any): N/A
  • Relevant config (redacted): N/A

Steps

  1. Run pnpm test src/shared/oc-path.test.ts.
  2. Run pnpm exec oxfmt --check --threads=1 src/shared/oc-path.ts src/shared/oc-path.test.ts.
  3. Run git diff --cached --check.
  4. Run the local node --import tsx smoke shown in the real behavior proof section.

Expected

  • Focused unit tests pass.
  • Targeted formatting check passes.
  • Staged diff has no whitespace errors.
  • Live resolver smoke prints the expected JSONC and markdown matches.

Actual

  • Focused unit tests passed.
  • Targeted formatting check passed.
  • Staged diff check passed.
  • Live resolver smoke printed the expected JSONC and markdown matches.

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

  • Verified scenarios: Live local module smoke for JSONC predicate, JSONC wildcard, and markdown section resolution; focused tests for supported oc:// parsing, invalid/unsupported paths, JSONC object/array/negative-index/predicate/wildcard paths, and markdown heading/wildcard paths.
  • Edge cases checked: URL-decoded path segments, missing predicate match, missing markdown heading, markdown under an H1 wrapper.
  • What you did not verify: CLI, doctor, plugin SDK, write/edit operations, LKG rollback, or policy IR behavior.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

@openclaw-barnacle openclaw-barnacle Bot added size: L triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. labels May 6, 2026
@clawsweeper

clawsweeper Bot commented May 6, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close as superseded: #78678 merged the canonical oc-path substrate, CLI, docs, and tests, and current main now carries that implementation. This narrower read-only resolver branch also still has the known slash-bearing returned-path bug.

So I’m closing this here and keeping the remaining discussion on the canonical linked item.

Review details

Best possible solution:

Keep the merged opt-in oc-path plugin as the canonical surface and route any remaining follow-up work to that implementation rather than this narrower src/shared resolver branch.

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

Not applicable as a current-main bug: this is a feature PR. The remaining patch-specific defect is source-reproducible from buildResolvedPath joining decoded path segments with /.

Is this the best way to solve the issue?

No: this branch is no longer the best implementation path because the merged opt-in plugin provides the broader resolver, formatter, find/set verbs, CLI, docs, and round-trip coverage on current main.

Security review:

Security review cleared: The diff adds pure in-memory resolver code and tests using an existing dependency, with no concrete security or supply-chain concern found.

What I checked:

Likely related people:

  • giodl73-repo: Authored the merged canonical oc-path substrate PR that supersedes this narrower branch and participated in the discussion offering to reconcile useful pieces. (role: canonical feature author; confidence: high; commits: bc735f4fde6f, 1448fe1727f5; files: extensions/oc-path/src/oc-path/index.ts, extensions/oc-path/src/cli.ts, docs/cli/path.md)
  • galiniliev: Live PR metadata shows this account merged the canonical oc-path implementation, and related discussion assigned maintainer follow-up around the substrate and CLI scope. (role: merger and reviewer; confidence: high; commits: bc735f4fde6f, 1448fe1727f5; files: CHANGELOG.md, extensions/oc-path/src/oc-path/index.ts, docs/cli/path.md)
  • Peter Steinberger: Local blame for the current oc-path source and docs in this checkout points to 731c8843ff, making this a useful routing signal for the current-main file state even though the original feature provenance is the merged canonical PR. (role: recent area contributor; confidence: medium; commits: 731c8843ff2a; files: extensions/oc-path/src/oc-path/oc-path.ts, extensions/oc-path/src/cli.ts, docs/plugins/oc-path.md)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 42b95a9eb1eb; fix evidence: commit bc735f4fde6f, main fix timestamp 2026-05-08T05:26:29Z.

@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. labels May 6, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 6, 2026
@WT-WSL

WT-WSL commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper

@WT-WSL
WT-WSL marked this pull request as draft May 6, 2026 17:01
@WT-WSL
WT-WSL marked this pull request as ready for review May 6, 2026 17:01
@giodl73-repo

Copy link
Copy Markdown
Contributor

Hi @dev111-actor — heads up that I've opened #78678 which addresses the full scope of #78051 (the issue this PR closes).

I've narrowed #78051 to focus specifically on oc:// addressing. #78678 ships the validated implementation from giodl73-repo/openclaw that includes:

  • byte-preserving emit chain (md / jsonc / jsonl / yaml) — the round-trip guarantee Workspace oc:// addressing substrate — feedback wanted #78051 explicitly asks for
  • 9 predicate operators (=, !=, *=, ^=, $=, <, <=, >, >=)
  • recursive ** wildcard, {a,b,c} unions, "quoted" segments, $first/$last/-N positional, #N ordinal, ?session= scope
  • setOcPath + per-kind emitXxx for writes (not just read-only)
  • jsonl line addressing (Lnnn) and yaml multi-doc support
  • substrate-level redaction-sentinel guard, NFC/BOM/safety caps
  • OcPathError class with stable error codes
  • 669 passing test assertions across 41 files (per-module unit + 23 wave-style scenarios + adversarial coverage)

Happy to defer to the maintainers on which approach lands. If #78678 is preferred, this PR can be closed; if there are pieces of your read-only resolver design they prefer, I'd welcome feedback to reconcile. Either way, appreciate you picking up the issue quickly.

@WT-WSL

WT-WSL commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed heads-up. I agree #78678 appears to cover the broader substrate shape that #78051 was originally pointing toward, especially the write path, byte-preserving emit chain, richer oc:// addressing semantics, and the adversarial/round-trip coverage.

My PR was intentionally narrower and focused on a read-only resolver slice, so I’m happy to defer if maintainers prefer #78678 as the canonical implementation path. The main areas I’d still like to compare are:

I’ll hold off on pushing this further until maintainers weigh in. If #78678 is selected, I’m fine closing this PR and helping reconcile any useful pieces from the read-only design into that branch.
I would like to contribute for Openclaw as much as possible...
Thanks!

@clawsweeper clawsweeper Bot closed this May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Workspace oc:// addressing substrate — feedback wanted

2 participants