Skip to content

fix(hooks): route file-indexed probe through daemon socket so hard-de…#193

Merged
zzet merged 1 commit into
zzet:mainfrom
vitaliyslion:fix/hook-deny-daemon-socket
Jun 29, 2026
Merged

fix(hooks): route file-indexed probe through daemon socket so hard-de…#193
zzet merged 1 commit into
zzet:mainfrom
vitaliyslion:fix/hook-deny-daemon-socket

Conversation

@vitaliyslion

Copy link
Copy Markdown
Contributor

Summary

The PreToolUse hook is meant to hard-deny whole-file Read/cat/Edit/Write
of indexed source and redirect to graph tools. Commit 7208e77a ("server: drop
--web, salvage /v1/graph + /v1/events, delete internal/web", 2026-04-18) deleted
the internal/web server, removing the /api/graph/file endpoint the hook
probed. Since then queryFileIndexed always returned (false, 0), so the deny
silently degraded to soft guidance for every agent. Masked because the tests
mocked the endpoint and the fallback still printed advice.

This re-points the file-indexed probe at the daemon's MCP socket
(get_file_summary) - the always-present, authoritative graph owner.

⚠️ Intentionally hook-local and minimal, not a complete fix. The deeper
path-resolution work is left as inline TODOs for a maintainer to direct; I'm
happy to add follow-up commits once the direction is decided.

Changes

  • Replace the dead /api/graph/file HTTP probe with a daemon socket call to
    get_file_summary, behind a fileIndexedFn test seam.
  • Thread cwd (from HookInput.CWD) through enrich -> enrichRead/enrichBash/ enrichEdit/enrichWrite -> queryFileIndexed so the probe scopes to the workspace
    and resolves the repo-relative graph key.
  • Memoize the daemon status fetch (5s TTL) so a wide postGlob makes ~one
    control-status round-trip instead of one per file.
  • Migrate the HTTP-mock hook tests to stub the new seam.
  • TODOs left for maintainer review (documented inline): route the path
    through the server's existing resolveFilePath (abs -> repo-relative + symlink
    confinement) instead of hand-rolling root resolution; reuse one MCP connection
    per batch / count-only probe. Note: the file-callers + symbol-at probes in
    posttooluse.go were never served — out of scope here.

Testing

  • All tests pass (go test -race ./...)
  • New tests added for new functionality
  • Benchmarks run if performance-relevant

Checklist

  • Code follows existing patterns in the codebase
  • No unnecessary abstractions added
  • Language extractor includes Meta["methods"] for interfaces (if applicable)
  • Methods have EdgeMemberOf edges to their containing type (if applicable)

@zzet zzet merged commit 0ec489c into zzet:main Jun 29, 2026
10 checks passed
@zzet

zzet commented Jun 29, 2026

Copy link
Copy Markdown
Owner

@vitaliyslion thank you for your contribution!

I'll take a look at TODOs performance references later

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.

2 participants