Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

Merge pull request #2467 from DeusData/fix/issue-2228-toml-foreign-tables

Martin Vogel8c12de9b165e
diff --cc src/cli/config_toml_edit.h
index 1b0ef137f,616ed3e1d..6b944ee19
--- a/src/cli/config_toml_edit.h
+++ b/src/cli/config_toml_edit.h
@@@ -24,21 -24,28 +24,31 @@@ int cbm_toml_escape_basic_string(const
*
* Insert or replace one managed, line-delimited block. block is the body
* between the two marker lines. Duplicate or unbalanced markers are rejected
- * without changing the file. */
+ * without changing the file. An existing span keeps what is not ours (#2228):
+ * keys and comments the block does not write stay in the tables it declares,
+ * with those tables' sub-tables; lines before the span's first table move
+ * above the block and any other table moves, byte for byte and in order, to
+ * just after it. Content whose ownership is ambiguous fails closed. */
int cbm_toml_upsert_managed_block(const char *file_path, const char *begin_marker,
const char *end_marker, const char *block);
+ /* Removes the whole span between the markers. */
int cbm_toml_remove_managed_block(const char *file_path, const char *begin_marker,
const char *end_marker);
+ /* Removes the markers and only the tables owned_tables declares (e.g. the
+ * block's header lines), with their keys and sub-tables; every other line of
+ * the span stays in place. Ambiguous ownership fails closed (#2228). */
+ int cbm_toml_remove_managed_block_owned(const char *file_path, const char *begin_marker,
+ const char *end_marker, const char *owned_tables);
/* Remove one pre-marker codebase-memory-mcp table only when it has the known
- * historical schema: one owned command basename, optional empty args, and no
- * unknown assignments or descendant tables. Returns 1 for a syntactically
- * valid same-name foreign table and leaves it byte-identical, 0 for removed or
- * absent owned state, and -1 for malformed input or I/O failure. A supplied
- * managed-marker pair makes this a successful no-op. */
+ * historical schema: one owned command basename, optional empty args, optional
+ * env_vars naming only CBM_CACHE_DIR/CBM_RUNTIME_DIR, and no unknown
+ * assignments or descendant tables. A lone orphaned managed marker (left when
+ * a client rewrote the table and dropped its comments, #1720) is dropped in
+ * the same write. Returns 1 for a syntactically valid same-name foreign table
+ * and leaves the file byte-identical, 0 for removed or absent owned state, and
+ * -1 for malformed input or I/O failure. A supplied managed-marker pair makes
+ * this a successful no-op. */
int cbm_toml_remove_legacy_table(const char *file_path, const char *table_name,
const char *begin_marker, const char *end_marker);