Skip to content

fix(claude-code): grep-guard liveness probe — block grep unless serve is down - #170

Closed
flupkede wants to merge 3 commits into
fix/watcher-reindex-tui-visibilityfrom
fix/grep-guard-liveness-probe
Closed

fix(claude-code): grep-guard liveness probe — block grep unless serve is down#170
flupkede wants to merge 3 commits into
fix/watcher-reindex-tui-visibilityfrom
fix/grep-guard-liveness-probe

Conversation

@flupkede

Copy link
Copy Markdown
Owner

What

Reworks the claude-code grep-guard hook so it blocks grep only when codesearch serve is reachable (liveness probe), instead of the previous pattern-extraction approach.

  • grep-guard.sh / grep-guard.ps1: probe the serve endpoint; allow grep through when serve is down (graceful fallback), block when it's up (so semantic search is used instead).
  • Drops the now-unused pattern-extraction code.
  • Docs: README + CHANGELOG entry.

Files

integrations/claude-code/hooks/grep-guard.sh, integrations/claude-code/hooks/grep-guard.ps1, integrations/claude-code/README.md, CHANGELOG.md

Validation

  • bash -n grep-guard.sh ✅ (syntax valid)
  • pwsh parser check grep-guard.ps1 ✅ (syntax valid)
  • No Rust changes → no cargo impact.

Notes

Test User and others added 3 commits July 28, 2026 18:15
Replace the blind 5-minute retry-cache auto-unblock with an active
/healthz liveness probe. A low-confidence or empty codesearch result is a
successful call ("reformulate"), not a dead server, so it no longer leaks
grep. Grep on an indexed internal path is now allowed ONLY when the
codesearch serve hub is genuinely unreachable.

- grep-guard.ps1: Invoke-WebRequest probe to {base}/healthz (2s timeout)
- grep-guard.sh: curl probe (no -o /dev/null — Git-Bash exit-23 quirk);
  requires curl
- base URL: CODESEARCH_SERVER > 127.0.0.1:$CODESEARCH_SERVE_PORT > :39725
- rewrote deny message to forbid grep-on-low-confidence and steer to
  find/explore/single-term reformulation
- README: documented liveness-probe behavior, dropped 5-min retry text

web-guard hooks intentionally left unchanged (different tool, no liveness
endpoint) — tracked as a follow-up.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The deny message became a generic template, so the Grep pattern is no
longer interpolated. Remove the dead pattern/$pattern extraction from
both hooks (path is still used by the internal-path gate). Flagged by
code review; no behavior change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant