Skip to content

fix(mcp): preserve TOML multiline strings during removal - #564

Draft
Frankie-Xu wants to merge 5 commits into
trailhq:mainfrom
Frankie-Xu:fix/toml-multiline-strings-20261007
Draft

Frankie-Xu wants to merge 5 commits into
trailhq:mainfrom
Frankie-Xu:fix/toml-multiline-strings-20261007

Conversation

@Frankie-Xu

@Frankie-Xu Frankie-Xu commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Removing or rewriting a Graft TOML entry can mistake [mcp_servers.graft.env] inside another server's multiline string for an owned table. It then deletes the string's closing delimiter and following foreign settings, leaving invalid TOML. The removal scanner now tracks basic/literal string context, including comments, escapes and four/five-quote endings, and preserves foreign string content and newline delimiters.

This is a focused follow-up to #547. That PR is currently unmerged, so this branch retains its canonical parent/subtable cleanup commits; the additional commit e36ba64b8bdb7daa49fc7bd897fdcb770dc0a42c handles multiline-string preservation. It preserves orphan and noncontiguous canonical Graft-subtable cleanup and adds no runtime dependency or TOML reserialization.

A separate CI-only commit reuses the shared fix from e9649a4cda39f9bae7264e4f6d642e466dd46d0c to align CodeQL init with the existing analyze pin at v4.38.1. It changes one workflow line; functional source remains the independently reviewed commit above.

Validation:

  • The 11 new unit/writer regressions fail on the exact fix(mcp): remove graft TOML subtables on uninstall #547 head; all 26 pass with this change.
  • All 28 retract tests pass, including synthetic Codex config removal and the subsequent no-op.
  • An independent Python tomllib oracle passes 19 fixtures with valid output and preserved foreign values. Independent review adds 168 valid string-boundary probes, all passing.
  • npm run build passes locally. On exact published head 9e8878a, official clean-install prepare/build and full Ubuntu/Windows CI pass: 1,376 / 1,371 passed; 1 / 6 expected skips; zero failures. Node 24 WASM and CodeQL pass. The still-unstarted duplicate local host suite was canceled after these official substitutes passed.
  • git diff --check passes; independent code/spec review found no actionable issues.

Existing noncanonical-header/array-table matching and nested-array boundary limitations are outside this string-focused follow-up. The nested-array behavior was reproduced on upstream main and #547 as well as this branch. New Codex registration/retract fixtures use temporary synthetic homes; existing repo-only retraction fixtures disable global writes. Native dependency compilation encountered a local missing C++ header; the affected tests ran using an exact-version, verified read-only N-API cache copied into this isolated checkout.

AI-assisted implementation and review.

MachineGunLin and others added 4 commits October 4, 2026 13:18
stripTomlSection stopped at the next '[' header, orphaning
[mcp_servers.graft.*] subtables (e.g. .env) and breaking Codex CLI
config loads after uninstall. Dotted children of the graft table are
now consumed with it; foreign tables are untouched.

Fixes trailhq#546
Extend stripTomlSection to whole-file family removal: every
[mcp_servers.graft] and [mcp_servers.graft.*] table is dropped whether
contiguous or not, including orphaned subtables without a parent.
Foreign tables are preserved.
github-actions Bot added a commit that referenced this pull request Oct 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

🌱 graft blast radius

1 area changed → 1 area can be affected. 1 dependent symbol, depth 2.
Tests: no test reaches MCP Configuration.
Tag: @anirudhkumar-nanonets — MCP Configuration, Configuration Retraction · @shhdwi — MCP Configuration, Configuration Retraction

flowchart TB
  A0(("Configuration Retraction<br/>1 symbol"))
  classDef reached fill:#D9EDF3,stroke:#3AA7C9,stroke-width:1.5px,color:#0E313C;
  class A0 reached;
Loading
Can be affected Symbols Nearest hop Reached from
Configuration Retraction 1 src/hosts/retract.ts:L211-L221 removeTomlSection — calls, depth 2 MCP Configuration
Who knows this code — 2 people across 2 areas
Area Who knows it
MCP Configuration · changed @anirudhkumar-nanonets — 5 commits, last 2d ago · @shhdwi — 4 commits, last yesterday
Configuration Retraction · affected @anirudhkumar-nanonets — 5 commits, last today · @shhdwi — 1 commit, last yesterday

Ownership is git history over each area's own files, weighted towards recent work (120-day half-life). Merge commits and bots are dropped, and you are dropped from your own PR. A name with no @ has no GitHub handle in its commit email — tag them by hand, or add a .mailmap entry. A suggestion from history, not a CODEOWNERS rule.

All 1 dependent symbol, grouped by area

Configuration Retraction — 1 symbol in 1 file

  • src/hosts/retract.ts:L211-L221 — removeTomlSection (calls, depth 2)
Test signal per changed area — 1 ✗

Reached = a node under a test path has a resolved edge into the changed symbol. It undercounts anything called indirectly — through a CLI, a spawned process or a dynamic import — so read a low ratio as “look here”, never as a coverage gate.

  • ✗ MCP Configuration — 0 of 2 reached · no test file reaches it
    • not reached: nextTomlMultilineQuote, isFamilyHeader

graft blast · origin/main...HEAD · depth 2 · 3 changed files

Open the interactive graph → — click an area to see its dependent symbols at file:line.

github-actions Bot added a commit that referenced this pull request Oct 15, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants