Repository navigation
fix(setup): edit the duplicate JSON member that clients read - #4957
Merged
Merged
Conversation
JSON.parse, JSONC parse, and native Claude Code keep the last duplicate object member, and parseClientConfiguration therefore validates the last one. The shared setup/uninstall serializer instead edited text through jsonc-parser's modify and findNodeAtLocation, which select the first matching member, so setup and uninstall on configurations with repeated server tables or rea members wrote into a shadowed member and failed readback. Locate every JSON text edit by the effective (last) member in one place, replacing the first-member modify path. Removing an effective member that shadows an earlier duplicate would activate that duplicate, whatever its ownership, so the serializer now returns a tagged shadowed_member failure and setup and uninstall refuse before writing a backup or the configuration. Fixes #4952 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
[Critical impact] The reviewed changes appear safe to merge; no blocking issue was found. SummarySetup and uninstall now edit the last matching JSON member, which is the member clients read.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Build desired configuration] --> B[Locate last matching JSON member]
B --> C{Would deletion reveal a duplicate?}
C -->|Yes| D[Return failure without backup or write]
C -->|No| E[Finish serialization]
E --> F[Preserve original backup]
F --> G[Publish and check configuration]
Reviews (2) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile |
2 tasks done
Geetesh72
added a commit
to Geetesh72/rea
that referenced
this pull request
Oct 18, 2026
fix(setup): edit the duplicate JSON member that clients read (morluto#4957)
This was referenced Oct 18, 2026
NikeGunn
added a commit
to NikeGunn/rea
that referenced
this pull request
Oct 18, 2026
Deleting repeats one at a time still copied the whole document once per member, so tens of thousands of repeats in a large file cost k x n work. All removal spans now come from one syntax tree and the text is rebuilt once. A separator stays only between members that remain, plus a JSONC trailing separator while any member remains, and comments outside the removed members keep their bytes. The single-member deletion from morluto#4957 is unchanged. Removing 20,000 repeats drops from 35.8 s to 0.46 s. Co-Authored-By: Claude Opus 5.5 <[email protected]>
daffafikri19
pushed a commit
to daffafikri19/rea
that referenced
this pull request
Oct 23, 2026
daffafikri19
pushed a commit
to daffafikri19/rea
that referenced
this pull request
Oct 27, 2026
daffafikri19
pushed a commit
to daffafikri19/rea
that referenced
this pull request
Nov 7, 2026
daffafikri19
pushed a commit
to daffafikri19/rea
that referenced
this pull request
Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4952. Setup and uninstall now edit the duplicate JSON member that the parsed document and JSON clients read (the last one), and they refuse an uninstall that would make an earlier shadowed duplicate active.
Problem and expected behavior
parseClientConfigurationreads JSON/JSONC with last-member semantics, the same asJSON.parseand native Claude Code. The shared serializer edited text through jsonc-parser'smodifyandfindNodeAtLocation, and both of those pick the first matching property. As a result, setup on{"mcpServers": {...}, "mcpServers": {...}}, or on a repeatedrealeaf, wrote into a member nobody reads, and the run ended inneeds_humanwithfailed/readback. Uninstall from a repeated parent table failed the same way. In every case the original file was restored.Expected: edit the member the client reads, and leave shadowed duplicates and comments as they are. If removing the effective owned
reawould make an earlierreaactive (owned, foreign or unresolved), keep the configuration unchanged and say why.Change and scope
ClientConfigurationDocument.tsnow owns a single last-member locator (effectiveJsonProperty), and every JSON text edit goes througheditJsonMember. The first-membermodifypath is gone. Formatting followsmodify's own rule: jsonc-parserformatruns over the touched lines.serializeClientConfigurationreturnsResult<string, ClientConfigurationShadowedMember>. Deleting an effective member that has an earlier same-key sibling returns{ kind: "shadowed_member", path }.shadowed_memberit reportsfailedwith a specific explanation and writes nothing, not even a backup.mcp.reabeside V2. That case now maps to a newshadowed_memberfailure reason with its own message.Contract and boundary impact
Semantic owner and earliest changed stage:
ClientConfigurationDocumentJSON text-edit boundary.Contribution scope fit and linked maintainer decision: not applicable (bug fix inside existing setup/uninstall authority).
CLI and MCP/tool-catalog contract: setup client results gain
failed/shadowed_memberwithpath. Uninstall keepsfailedand adds a new detail text. Tool catalog unchanged.Provider, bridge, target-format, or platform compatibility: JSON/JSONC client formats only.
Evidence, artifact, provenance, or reconstruction contract: none.
Target selection, authority, upstream behavior, and cleanup details: shadowed members are never deleted or activated. A refused uninstall leaves the configuration untouched and creates no backup.
Generated metadata, package, or installation impact: none.
Read existing files or captured data.
Change process memory, registers, files, or configuration.
Evidence and regression coverage
Tests added or updated: new
tests/acceptance/setup/duplicateJsonMemberSetup.test.ts, which runs the public CLI:realeaf succeeds. The shadowed member stays byte-for-byte, the backup matches the original, and a second setup plans nothing and leaves the file unchanged.reafollowed by an ownedreais refused. The file is unchanged and no backup is created.Existing serializer callers in
ClientConfigurationDocument.capacity.test.tsandclientConfigurationEnvironment.test.tswere updated to theResultreturn.Base reproduction: on
origin/main(2c4338db1) the issue's CLI repro gave exit 1 withfailed/readbackfor duplicate-parent setup and duplicate-leaf setup, and a failed uninstall (original restored) for duplicate-parent and foreign-then-owned. With this branch the same script gave exit 0configuredfor both setups, exit 0removedfor duplicate-parent uninstall, and exit 1failedfor foreign-then-owned, with the file unchanged. All 5 new tests fail when run againstorigin/mainsources.User-visible output for the refused uninstall:
Configuration repeats the member at ["mcpServers","rea"]; removing the registration the client reads would activate an earlier duplicate, so no change was made. Remove the duplicate members manually, then rerun uninstall.Remaining proof gaps: native Claude Code and other native clients were not run for this change; the issue's native last-member observation is the only native evidence. Not run: Windows/Linux, and the OpenCode legacy
shadowed_membersetup path (source-derived only, no dedicated test).Validation performed
npm run build:cached— passedHOME/CLAUDE_CONFIG_DIR) on main and on this branch — results as abovenpm run test:focused -- tests/acceptance/setup/duplicateJsonMemberSetup.test.tsonorigin/mainsources — 5 failed (expected)npm run test:focused --the related setup and client-configuration tests (44 files intests/acceptance/setupandtests/boundary/filesystem, plussrc/application/ClientConfigurationDocument.{capacity,shape}.test.tsandsrc/application/Setup.{configuration,recovery,planning,initialSnapshot}.test.ts) — 50 files, 738 passed, 2 skippednpm run check:fast— passednpx oxfmt --checkon changed files — clean after formattingCompatibility, safety, and release
Author readiness
Human owner:
Before merge
type(scope): outcome.🤖 Generated with Claude Code