Repository navigation
fix(oc-path): use last duplicate JSON key to match runtime parsing - #189855
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesMakes named JSON, JSONC, and JSONL reads, searches, and edits select the last duplicate key. Example: Run openclaw path set oc://config.json/port 5 on {"port":1,"port":2}.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR fixes a current wrong-value editing bug, has convincing shipped-CLI proof, and has no actionable findings; exact-head CI remains pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe optional bundled oc-path plugin translates CLI addresses into format-specific reads and edits, returning matches or updated workspace-file bytes. flowchart LR
A[Path CLI] --> B[Address and format dispatch]
B --> C[JSONC and JSONL resolver]
B --> D[Finder]
C --> E[Effective source node selection]
E --> F[Format specific editor]
F --> G[Workspace file]
D --> H[Resolved matches]
Technical reviewBest possible solution: Land the consistent last-occurrence repair through the existing plugin owners once required CI passes. Do we have a high-confidence way to reproduce the issue? Current-main source and the pinned dependency establish first-occurrence reads and writes; supplied built-CLI traces demonstrate the failure and correction, while this read-only review executed no target code. Is this the best way to solve the issue? The patch fixes selection at the existing resolver, finder, and editor boundaries, shares the necessary token walk, and retains format-specific byte handling without unnecessary machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ffbaf04726a5. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +48, Tests 0, Docs +6. Total +54 across 10 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
Reviewed October 31, 2026, 8:38 PM ET / November 1, 2026, 00:38 UTC (Revision 4). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Independent built CLI proof — effective duplicate JSON keysCandidate Independently installed and built both source snapshots with the canonical runtime build in secretless Linux Each file starts with Candidate edits the effective last occurrence while retaining the earlier shadowed copy. Exact source-byte checks retain JSONC comments/formatting and JSONL BOM, CRLF, and an untouched Ordinary no-duplicate reads and real writes are unchanged in all four runs; their resulting bytes have the same SHA-256: P3 recovery guidance is factualThe live contributor follow-up already supplied this error detail; I retained it rather than introducing a wording policy. Actual Both refusals preserve the file. Following that advice—consolidating the duplicate parent while retaining its effective Committed regressions without growthConsolidated the standalone duplicate-key test into existing JSONC resolve/edit, JSONL edit, and finder fixtures. All existing assertions remain; duplicate inputs strengthen their effective-value coverage, including empty keys, predicate fields, nested objects, and arrays. No new test lines or allocation. Same final fixtures on frozen main: 7 intended failures / 106 passes. Candidate: 113 pass across 4 files. Targeted lint reports zero warnings/errors; formatting passes. Production is unchanged from the live contributor head: +68/-15; tests +12/-12 (net0); docs +6. Limits: named-key semantics only; positional object selectors still count source entries, including shadowed copies. No new grammar, parser dependency, schema, authority, or configuration contract. The existing safe insertion refusal is preserved. Production source hashes match the final candidate and built artifact inputs. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Current-main integration proofExact candidate: Fresh secretless Linux Docker / Node 24.22.1 canonical runtime builds, then real shipped
The earlier two independently built main/candidate repetitions remain documented in the original evidence. The new pair reruns nested duplicate parents, predicates, winning scalar shapes, insertion refusal, actual human recovery and successful retry, JSONC comment/format preservation, and JSONL BOM/CRLF/untouched literal preservation. Combined adjacent-file control: one workspace contains YAML anchors/aliases/a self-cycle and duplicate-key JSON. Both fresh refs find two YAML alias ports, resolve the scalar alias to Final exact-source build/proof task succeeded. Focused suites: 153 passed /5 files, including YAML-kind coverage. Targeted oxlint:0 errors/warnings; formatting:12 files passed. Test delta remains net zero. An intermediate attempted lint compaction increased AST getter reads and was rejected by the existing expansion-budget regression; the final source restores the single cached access, passes that regression, and compacts the equivalent null return instead. Host and built-container source SHA256 agree: finder |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in 7f593b6. Thanks @jerome-queck. CLI path tools now use the effective last key when a key is repeated. |
…ed-backup-search-exports-20261101 * commit 'cde4bfe4f10ce470ded7264c68d9a72ae03594cc': fix(ci): keep backup and chat search internals private (#189894) fix(codex): recover unused native threads without dropping history (#189900) fix(oc-path): use last duplicate JSON key to match runtime parsing (#189855) perf(test): parse the Mantis resolver workflow once (#189801) fix(agents): revert default hard context admission (#189891) refactor(test): use canonical tracked temp paths (#189800) chore(ui): refresh control ui locales (#189898) improve: show gateway commit and build time on About refactor(test): share SDK export fixture JSON writes (#189799) fix: restore Files navigation from unavailable previews (#189879) refactor(test): share raw ratchet fixture writes (#189798) fix(ai): honor Model Studio compatible-mode output limits (#189870) fix: hold queued messages through inline edits (#189869) perf(test): reuse the baseline fixture Node resolver (#189790) test(qa): correlate handoff replies by run identity (#189885) fix(ui): normalize canonical Unicode in local search comparisons (#189874) fix(ui): explain unsupported browsers without module scripts (#189883) # Conflicts: # ui/src/pages/chat/components/chat-search-highlight.browser.test.ts
…penclaw#189855) fix(cli): use the effective last key when a JSON file repeats a key Fixes openclaw#189835. When a JSON, JSONC or JSONL object repeated a key, CLI path resolve, find and set used the first occurrence. Runtime parsing takes the last one, so set reported success while the value OpenClaw actually used stayed the same. Path tools now select and rewrite the effective last key and keep the shadowed copies. Files without duplicates produce byte-identical output. JSONC comments and formatting, and JSONL BOM, CRLF and literal tokens, are preserved. The human-readable recovery text points to consolidating the duplicates. This works together with YAML alias resolution from openclaw#189784. Evidence: built CLI in secretless Node 24.22.1 Docker on real JSON, JSONC and JSONL files, rebuilt after merging current main. Main selected the first key and reported writes that didn't change the effective value; with this change the effective last key was selected and actually rewritten. A combined YAML and JSON workspace kept aliases, scalar aliases, finite cycle traversal and unchanged YAML bytes across actual JSON writes. Details: openclaw#189855 (comment) and openclaw#189855 (comment). Thanks @jerome-queck. Co-authored-by: Ayaan Zaidi <[email protected]>
Backport of 7f593b6 (#189855). Preserve shadowed source copies while resolving and editing the runtime-effective last key. Targeted baseline: 7 failed, 104 passed; fixed: 111 passed. Scoped self-review retained existing parser and edit ownership. Co-authored-by: Ayaan Zaidi <[email protected]> Co-authored-by: RomneyDa <[email protected]>
Fixes #189835
What Problem This Solves
For named duplicate keys in JSON, JSONC, and JSONL,
path resolveandfindselect the first occurrence even though runtime parsing uses the last.path setcan report success after changing only that shadowed first occurrence, leaving the effective configuration unchanged.User Impact
Named-key reads, searches, predicates, and replacements now use the effective last occurrence. Real edits preserve earlier shadowed copies and unrelated source bytes. Insertion beneath a duplicated parent remains safely refused rather than editing the wrong copy.
Why This Change Was Made
Use last-key selection in the existing AST resolver/finder. Share a last-effective
jsonc-parsernode walk between JSONC and JSONL editors so edits target the correct source token, while retaining range formatting and source-preservation owners. No new grammar, dependency, public API, schema, authority, or configuration option.Both commits by @jerome-queck are preserved. The live head fetched for takeover already included
a4a0460bdb29, addressing the review's P3 recovery text. Its guidance was retained and verified through actual human CLI output and a successful retry after preserving the effective parent value—not replaced with a wording policy.The follow-up consolidates the standalone regression file into existing JSONC resolve/edit, JSONL edit, and finder fixtures. All existing assertions remain; fixture data now discriminates first-versus-effective duplicate selection. Tests remain net zero lines. Current main was merged without rewriting contributor history, retaining the YAML alias fix from #189784 alongside last-wins JSON addressing. The merged finder retains its AST-access budget and stays within the existing lint ceiling.
Evidence
Independent built CLI and actual-write proof: secretless Linux Docker, Node 24.22.1, real files, independently built base/candidate CLI artifacts. In all three formats, main reads/finds1 twice and reports successful edits while runtime parsing still sees2. Candidate reads/finds2 twice and real
set ... 5makes runtime parsing see5, retaining the earlier1. JSONC comments/formatting, JSONL BOM/CRLF/literal tokens, nested duplicate parents, predicates, and winning scalar shapes are checked.No-duplicate controls produce identical bytes on both refs. Candidate duplicate-parent insertion refusal leaves the file unchanged and prints actionable
--humanrecovery text. Consolidating that parent while retaining its effective value, then retrying, succeeds.After merging main
85ae35910a6e6f903fbe885eda88e7e343c3e09d, fresh builds and an additional main/candidate pair reproduce the same JSON/JSONC/JSONL contrast. A combined workspace proof interleaves YAML alias reads, actual duplicate-JSON writes, and YAML alias/cycle reads again: both refs retain two alias matches, scalar aliases, finite cycle traversal, and identical unchanged YAML bytes; only the candidate updates the runtime-effective JSON key. Candidate:153 passed across5 focused files, including YAML-kind coverage. Targeted lint and formatting pass. This is shipped CLI proof, not helper-only or dry-run-only edit evidence.Merge Danger
Two-way door: reverting restores first-occurrence behavior; no migration. Explicit
setwrites workspace files, so preserve normal backups/review practices. Blast radius is named JSON/JSONC/JSONL object addressing and source-token replacement. Positional object selectors still count source entries, including shadowed copies; their semantics are not changed here. Safe insertion refusal and ordinary-file behavior remain intact.