The lifecycle hook now reads ignore_worktrees first and does nothing
else for it while the key is off; the project lookup is then the one
the hook did before the key existed.
- cbm_mcp_ignore_worktrees_runtime_enabled() replaces
cbm_mcp_server_attach_runtime_config(). It never attaches a store to
the server, which may be the daemon session server. A server with a
store answers from it. Otherwise the runtime store is opened only to
read this key, and only when it already exists, so a hook event never
creates _config.db.
- cwd canonicalization, the linked-worktree probe and the parent-graph
check moved into ha_resolve_project_ignoring_worktrees(), which runs
only when the key is on.
Test cli_hook_ignore_worktrees_default_off_does_no_worktree_work was red
on the previous head (a default-off event created _config.db). It also
pins, through a test-API counter, that neither an absent store nor a
store without the key reaches the worktree gate, and that the key on
reaches it once. mcp_ignore_worktrees_runtime_read_leaves_server_and_store_alone
replaces the test of the removed helper.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
The review of 2026-10-01 asked to split these out of the ignore_worktrees
change. Neither belongs to it, and both are already on main in another
form, so this restores the three files to the branch merge-base:
- Makefile.cbm: main links cbm-fuzz with -fsanitize-link-c++-runtime.
- src/cypher/cypher.c and tests/test_cypher.c: main frees a partially
parsed MATCH pattern since 70543ba82, with its own regression test
cypher_parse_error_frees_partial_pattern.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
The memory-core ratchet rejects another raw free() in the hook. Keep the
parent name until the existing free(project) and skip it when the match
is a different worktree.
Signed-off-by: Nohj <vitalnohj@gmail.com>
The ignore_linked initializer exceeded the formatter's assignment break.
Lint treats that as an error, so the line now matches .clang-format.
Signed-off-by: Nohj <vitalnohj@gmail.com>
A symlink into a linked worktree has no .git on its lexical path, so the
hook told the agent to run index_repository. That call canonicalizes first
and then refuses. Resolve the cwd before project lookup and the
ignore_worktrees checks.
Signed-off-by: Nohj <vitalnohj@gmail.com>
A 64-level walk missed a deep session path, and a relative gitdir joined
onto a symlink spelling no longer matched the real project root. Walk to
the filesystem root and compare canonical gitdirs. Drop the unused project
resolver that failed the macOS -Werror build.
Signed-off-by: Nohj <vitalnohj@gmail.com>
The parent-graph drop treated any linked worktree root as a match, so an
unindexed worktree nested inside an indexed one still inherited that
parent. Compare the gitdir of each path's own anchor and keep the project
only when both paths are that same linked worktree.
Signed-off-by: Nohj <vitalnohj@gmail.com>
ignore_worktrees checked the setting only after project resolution, so a
linked worktree nested in an indexed checkout was reported as that parent
project. Drop an ancestor match and keep an index whose root is the
worktree itself.
Signed-off-by: Nohj <vitalnohj@gmail.com>
ignore_worktrees only inspected <path>/.git, so a session or index path
inside a linked worktree still passed the gate. Walk ancestors until a
git anchor, and stop at a main checkout or a submodule.
Signed-off-by: Nohj <vitalnohj@gmail.com>
The production hook builds its server with cbm_mcp_server_new(NULL), so
ignore_worktrees stayed off and an unindexed linked worktree still told
the agent to run index_repository. Attach the runtime store for that
check, then drop it before return.
Signed-off-by: Nohj <vitalnohj@gmail.com>
A session queued while capacity was full could still be indexed after the
setting was turned on. Retry admission now applies the same linked-worktree
gate as the initial path.
Signed-off-by: Nohj <vitalnohj@gmail.com>