Repository navigation
Commit 98e58ac
committed
fix(install): keep foreign tables between the managed TOML markers (DeusData#2228)
cbm_toml_upsert_managed_block and cbm_toml_remove_managed_block treated
everything between the "# >>> codebase-memory-mcp MCP >>>" markers as
ours: install replaced the whole span with the fresh block, uninstall
deleted it, and the conflict check skipped that same span. When our block
ended ~/.codex/config.toml, Codex Desktop appended its own tables below it
while the closing marker stayed the last line, so [mcp_servers.node_repl],
[desktop] and the [marketplaces.*] tables sat inside the markers. The
0.10.4 -> 0.11.0 upgrade deleted all of them, together with the
startup_timeout_sec the user had added to our own table.
The span is now read as TOML sections, each classified against the tables
the block declares:
- owned: a declared table (the k-th [[element]] of a declared array). The
keys the block writes are replaced; every other key, comment and blank
line in it stays in the table.
- attached: a sub-table of a declared table, such as
[mcp_servers.codebase-memory-mcp.env]. It is part of our server entry
and stays with it; outside the markers it would collide with the next
install.
- foreign: any other table, moved byte for byte and in order to just after
the closing marker, so from then on the markers bracket only our entry
and later appends land outside them.
- lead: lines above the span's first table, moved above the opening
marker, where they keep the table they belong to.
Uninstall of the Codex, Grok and Kimi blocks goes through the new
cbm_toml_remove_managed_block_owned with the header each block declares:
it removes our table with its keys and sub-tables and leaves everything
else in place. cbm_toml_remove_managed_block keeps the historical
whole-span contract.
Content whose ownership cannot be decided fails closed with the file
untouched: a second copy of a declared table, an undeclared extra
[[element]] of a declared array, a child of a declared array element, an
unparsable line in an owned table, a user key colliding with one the block
writes, a move that would hand the keys below the block to another table,
and a rewritten file whose tables conflict with the block.
Preserving was chosen over failing closed on every foreign table because
Codex keeps appending below a closing marker that ends the file. A
refusing installer would block every later install and uninstall until
the user hand-edits the TOML, and a hand edit is itself the likeliest way
to lose those tables. Moving whole sections keeps every byte and every
key's table, and the shapes that cannot be attributed still refuse.
Without foreign content the output is byte-identical to the old rewrite.
Fixes DeusData#2228
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>1 parent 9d65f4c commit 98e58ac
5 files changed
Lines changed: 751 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3793 | 3793 | | |
3794 | 3794 | | |
3795 | 3795 | | |
| 3796 | + | |
| 3797 | + | |
3796 | 3798 | | |
3797 | | - | |
| 3799 | + | |
| 3800 | + | |
3798 | 3801 | | |
3799 | 3802 | | |
3800 | 3803 | | |
| |||
4418 | 4421 | | |
4419 | 4422 | | |
4420 | 4423 | | |
4421 | | - | |
| 4424 | + | |
| 4425 | + | |
4422 | 4426 | | |
4423 | 4427 | | |
4424 | 4428 | | |
| |||
4984 | 4988 | | |
4985 | 4989 | | |
4986 | 4990 | | |
4987 | | - | |
| 4991 | + | |
| 4992 | + | |
4988 | 4993 | | |
4989 | 4994 | | |
4990 | 4995 | | |
| |||
0 commit comments