Skip to content

v0.7.0 install/update wires the legacy blocking PreToolUse gate, not hook_augment (regresses #214) #409

Closed

Description

@cryptomaltese

Summary

On a clean v0.7.0 install -y --standard (and update), the Claude Code PreToolUse hook written to ~/.claude/hooks/cbm-code-discovery-gate is the old blocking shell gate (exit 2, gate file keyed on bare $PPID) — not the non-blocking augmenter shipped in the binary (src/cli/hook_augment.c, commit c29e6d5). So the exact symptom of #214 returns on every install/update, even though #214 is marked fixed in v0.7.0.

Why it misbehaves (same root as #214)

$PPID is the shell spawned for each hook invocation, so it rotates per tool call. The gate file /tmp/cbm-code-discovery-gate-$PPID therefore never matches a prior one → the "first call per session" check is always true → every Grep/Glob/Read is blocked with exit 2, not just the first.

The installed hook (v0.7.0):

#!/bin/bash
# Gate hook: nudges Claude toward codebase-memory-mcp for code discovery.
# First Grep/Glob/Read/Search per session -> block. Subsequent -> allow.
# PPID = Claude Code process PID, unique per session.
GATE=/tmp/cbm-code-discovery-gate-$PPID
...
touch "$GATE"
echo 'BLOCKED: ...' >&2
exit 2

Repro

  1. codebase-memory-mcp install -y --standard (or update) on v0.7.0, Linux, Claude Code.
  2. In a session, issue several Read/Grep calls.
  3. Each is blocked by the gate (not nudged once) — the claude process reads the hook fresh each call and $PPID differs every time.

Expected

install/update should wire the non-blocking augmenter (the hook_augment path that's already in the binary), so Read is no longer gated and the nudge is emitted at most once per session — the behaviour #214 was closed as delivering.

Note

The binary genuinely has the fix; this is a packaging/install gap — the install template still emits the legacy blocking script. A session_id-keyed (from the PreToolUse stdin JSON) non-blocking augmenter that exit 0s avoids both the $PPID rotation and any ps/process-name assumptions.

Environment

  • v0.7.0, Linux (cgroup v2), Claude Code, standard stdio variant.

Activity

  1. added
    bugSomething isn't working
    editor/integrationEditor compatibility and CLI integration
    on Jun 6, 2026
  2. DeusData commented on Jun 6, 2026

    @DeusData
    Owner

    Thanks for the detailed write-up — the $PPID analysis is spot-on for the old gate.

    I'm having trouble reproducing this on a clean v0.7.0. On main (and in v0.7.0, which already contains the augmenter fix c29e6d5), both install and update write ~/.claude/hooks/cbm-code-discovery-gate as the non-blocking augmenter shim, not the old gate:

    #!/bin/bash
    # codebase-memory-mcp search augmenter (Claude Code PreToolUse).
    BIN="<path>"
    [ -x "$BIN" ] || exit 0
    "$BIN" hook-augment 2>/dev/null
    exit 0

    No $PPID, no exit 2; settings.json's PreToolUse command points at that script; the file is written with fopen(..., "w") (truncate, so it overwrites any older gate); and a regression test guards it (cli_hook_gate_script_no_predictable_tmp_issue384 — asserts no PPID, delegates to hook-augment).

    To pin down what's different in your environment, could you share:

    1. The verbatim contents of your installed ~/.claude/hooks/cbm-code-discovery-gate.
    2. codebase-memory-mcp --version.
    3. The PreToolUse block (matcher + command) from ~/.claude/settings.json.
    4. Was this a fresh install or an upgrade from a pre-v0.7.0 version (roughly which)?

    Leading suspicion: a stale PreToolUse entry in settings.json from an older install still pointing at an inline/$PPID gate rather than the rewritten shim — (3) + (4) would confirm it.

  3. added
    awaiting-reporterWaiting on the reporter for info/repro; stale bot will warn then close
    on Jun 23, 2026
  4. DeusData commented on Jun 26, 2026

    @DeusData
    Owner

    This is fixed. The installer now wires the non-blocking hook-augment shim rather than the legacy blocking PreToolUse gate, and the gate-script writer truncates and rewrites the non-blocking content on upgrade (so a stale blocking script from a pre-0.7.0 install is replaced). We've added a regression guard for the upgrade/overwrite path specifically.

    Closing as fixed — reopen if a fresh install or upgrade still wires a blocking gate for you. Thanks!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting-reporterWaiting on the reporter for info/repro; stale bot will warn then closebugSomething isn't workingeditor/integrationEditor compatibility and CLI integration

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions