Skip to content

fix(oc-path): keep quoted positional keys literal - #172382

Merged
steipete merged 4 commits into
openclaw:mainfrom
fhgffy:fix/oc-path-quoted-positional-keys-20261014
Oct 15, 2026
Merged

steipete merged 4 commits into
openclaw:mainfrom
fhgffy:fix/oc-path-quoted-positional-keys-20261014

Conversation

@fhgffy

@fhgffy fhgffy commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #172375

What Problem This Solves

Fixes path resolve, find, and set treating quoted $first / $last keys as positional selectors, which can overwrite a neighboring JSONC/YAML entry or give a JSONL value the wrong type.

User Impact

Quoted special keys remain literal across JSONC, JSONL, and YAML. Unquoted $first / $last keep selecting the first or last entry. Returned find paths retain literal token identity, including wildcard, ordinal, insertion, union, and predicate-shaped keys. Quoted segments support escaped quotes (\") and backslashes (\\); other escapes remain rejected. No migration or configuration change is required.

Why This Change Was Made

The shared parser now preserves quote spelling through selector dispatch and owns literal decoding and quoting. JSONL writes reuse the JSONC resolver's typed key/index path instead of maintaining a second traversal, while retaining the exact source-token edit from #172410. Positional find results quote raw object/map keys before lookup so a key containing literal quotes is not decoded twice.

Original fix by @fhgffy; maintainer cleanup extends the literal/escape contract, consolidates JSONL traversal, and preserves the sibling's byte-preservation fix. Contributor commit 051bf809653f5bd90e799502d963e04a95edfc83 remains in branch history.

Evidence

  • Defect confirmed by source and history on main 3d6a3dc1d820802f05769d285d30dd5a244672d9: splitOcPathSlots strips quotes before JSONC/YAML positional dispatch. Commit 4d06fa489bab6e90315cd6608d896da57a32326a introduced that shared splitter; this is provenance for the splitter, not a claim about the defect's original introduction.
  • PR CI is the test gate per maintainer policy. Exact head 3b03f7ac58ebc303399c825880325149209175ef: CI run 38686615207 finished with all selected static checks passing (production/test types, lint, docs, guards, architecture, source contracts, and baseline ratchets). The eight Node test jobs failed before checkout; the aggregate gate is red and unit behavior remains unverified on this head.
  • Regression: keeps quoted special and escaped keys literal in %s CLI reads, writes, and find runs for JSONC, JSONL, and YAML. It checks numeric types, untouched siblings, dry-run byte preservation, persisted writes, wildcard traversal/emission, and ordinary selectors selecting literal token or quote-bearing keys. Parser coverage extends round-trip canonical forms and adds rejects invalid quoted escapes: %s; the existing Windows path containment test now checks the decoded absolute-path rejection.
  • Local changed-file oxfmt 0.71.0 passed through the native tooling-owner route. Static oxlint passed nine TypeScript files with 231 rules and zero diagnostics. The shared install lacks the UI-only Solid plugin, so the temporary core lint configuration omitted only the ui/**/*.tsx override and retained every applicable rule; no dependency installation or tracked configuration change.
  • Deslop removes the duplicate JSONL edit traversal and the positional-find rewrite. Independent Codex autoreview passed before commit and again in prescribed branch mode against merge base 54691736d026cba16ee8623bb3729f8c2c4c5af7: scoped-clean, no actionable P0–P2 findings. Both were source-only reviews.
  • Live Gateway/CLI proof, leases, local tests, negative controls, and local typechecks were intentionally skipped per maintainer policy. ClawSweeper comment 6175031582 reports no code findings; its live-proof-only request is superseded by the explicit policy that PR CI provides proof. No human review findings were present.
  • Test cost: one existing three-format CLI table extended, plus three tiny parser rejection rows; no new sleeps, timers, polling, servers, or processes. Local test wall time was not measured because execution was intentionally skipped; CI did not reach the test processes, so no current-head unit timing is available.
  • Exact diff versus main: production +45/-91 (net -46), tests +133/-3 (net +130), docs +5/-3 (net +2). No detached/background/deferred side effects were added or changed.

Remaining CI blocker

All eight failed Node jobs hit the same setup error before checking out this patch: An action could not be found for actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e. Examples: PR changed-tests job 116263180110 and PR small-4 job 116263180106. The same signature is present in the newest scheduled main run 38687324602, job 116265300311, at main head c58d6181af08cbd56ad42466d03295145d94068b: inherited infrastructure failure. The PR failure classifier compared the previous scheduled run, so its new/unknown rows predate this matching main evidence.

The affected PR jobs are checks-node-changed, checks-node-changed-boundary, checks-node-changed-compact-large-13, checks-node-changed-extensions-config, and checks-node-compact-small-1 through -4. Their logs were inspected individually. Planned unit coverage includes the oc-path CLI regressions and existing JSONL byte-preservation tests, but none of these jobs reached tests. The action archive still returned HTTP 404 at 05:34 UTC; no blind rerun, workflow pin change, or proof-policy bypass was attempted. Restore action-download availability, then rerun the failed jobs on this exact head before declaring it land-ready. No merge was performed.

@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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: oc-path size: S labels Oct 14, 2026
@fhgffy
fhgffy marked this pull request as ready for review October 14, 2026 17:48
@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

Preserves quoted keys as literals across JSONC, JSONL, and YAML reads, writes, and emitted find paths.

Example: Run path set 'oc://config.jsonc/"$first"' 42 on {"head":"keep-first","$first":7,"tail":"keep-last"}.

  • Before: The command changes head to string "42" and leaves $first unchanged.
  • After: The command changes only $first to numeric 42.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused implementation has no actionable findings and exact-head CI passes, but required shipped-entry-point evidence is absent.
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 path edit can overwrite a neighboring entry or silently change a literal key's value type.
Reason: The documented quoted-key contract is broken on main, and the focused repair restores it while reducing production duplication.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this PR repairs a current wrong-target and wrong-type editing bug, preserves the separate JSONL byte-preservation fix, and has no actionable code findings.

Priority: P2
Reviewed head: 3b03f7ac58ebc303399c825880325149209175ef

Before merge

  • Add real behavior proof - The JSONC, JSONL, and YAML owners have registered-Commander regression coverage and successful exact-head CI, but the body and discussion supply no after-fix run through the actual OpenClaw CLI; the prior proof request remains applicable under this review's explicit policy despite the body's CI-only assertion. Provide terminal screenshots, logs, or live output showing literal-key reads, dry runs and persisted writes, sibling preservation, reusable find results, and unchanged unquoted selectors across the three formats, with IPs, API keys, phone numbers, and non-public endpoints redacted. 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.

Findings

None.

Tests

  • Missing end-to-end proof: Missing a recorded shipped-CLI resolve/find/set demonstration of the changed literal-key behavior; no base-fail/head-pass execution of the expanded regression was supplied.
Agent review details

How this fits together

The bundled oc-path plugin parses CLI addresses and workspace files, resolves format-specific targets, and returns matches, previews, or updated file bytes.

flowchart LR
 A[Path CLI] --> B[Address parser]
 B --> C[Literal and selector dispatch]
 D[Workspace file] --> E[Format adapter]
 C --> E
 E --> F[Matches or edited bytes]
Loading

Technical review

Best possible solution:

Keep literal decoding in the shared parser and use the existing format resolvers consistently for reads, mutation targeting, and concrete-path emission.

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

Source confirms quote loss before positional interpretation and traces the incorrectly selected value into type coercion and mutation; this read-only review executed no target code.

Is this the best way to solve the issue?

The patch fixes the owning boundary, removes duplicate JSONL traversal, and preserves the earlier concrete-path quoting and source-byte preservation contracts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 520302d8ee63.

Provenance checked

  • Shared slot splitting changes intended behavior with a stated reason (4d06fa4: Consolidate repeated plugin flows while preserving behavior; this identifies the shared splitter's history rather than the defect's original introduction.)
  • Quoted escape grammar changes intended behavior with a stated reason (ac9418d: Escapes were deliberately removed to reduce complexity without observed workspace use; this PR restores them to represent quote-bearing keys and preserve literal identity in returned paths.)
  • Concrete positional find paths keeps the original intent (d36d90b: Quote object-key substitutions so emitted positional paths resolve back to the matched value, retaining numeric array positions.)
  • JSONL mutation ownership keeps the original intent (a0c056b: Replace only selected source tokens to preserve untouched numbers, comments, whitespace, and line separators.)
  • YAML positional addressing keeps the original intent (0b708a2: Restore uniform YAML addressing and first/last positional selection through the YAML adapter.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source -46, Tests +130, Docs +2. Total +86 across 10 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 45 91 -46
Tests 4 133 3 +130
Docs 1 5 3 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 183 97 +86

Review metrics

Metric Value Why it matters
Production versus test LOC Production +45/-91; tests +133/-3 Production shrinks by sharing JSONL traversal; added coverage verifies persisted values and untouched siblings across three format adapters.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Repairs silent wrong-target or wrong-type writes for a narrow class of keys in an advanced CLI workflow.
  • 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.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Supply the actual-CLI demonstration described in the behavior-proof assessment.

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-14T18:06:12.433Z sha 051bf80 :: needs real behavior proof before merge. :: none

Reviewed October 15, 2026, 2:12 AM ET / 06:12 UTC (Revision 2).

steipete and others added 3 commits October 14, 2026 22:19
Keep quote and escape handling in the shared path parser. Reuse the JSONC value resolver for JSONL writes, preserving source-token edits and removing duplicate traversal. Cover special tokens and escaped keys through registered CLI reads, dry runs, writes, and find across JSONC, JSONL, and YAML.

Fixes openclaw#172375

Co-authored-by: fhgffy <[email protected]>
@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 ae55909 into openclaw:main Oct 15, 2026
161 of 172 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(oc-path): keep quoted positional keys literal

* fix(oc-path): preserve literal special keys through reads and writes

Keep quote and escape handling in the shared path parser. Reuse the JSONC value resolver for JSONL writes, preserving source-token edits and removing duplicate traversal. Cover special tokens and escaped keys through registered CLI reads, dry runs, writes, and find across JSONC, JSONL, and YAML.

Fixes openclaw#172375

Co-authored-by: fhgffy <[email protected]>

---------

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 changes the wrong key for quoted $first/$last paths

2 participants