Repository navigation
hook-augment: prove the hook's build identity without hashing the whole executable in every hook process #2683
Copy link
Copy link
Open
Labels
editor/integrationEditor compatibility and CLI integrationEditor compatibility and CLI integrationenhancementNew feature or requestNew feature or requestpriority/normalStandard review queue; useful PR with ordinary maintainer urgency.Standard review queue; useful PR with ordinary maintainer urgency.stability/performanceServer crashes, OOM, hangs, high CPU/memoryServer crashes, OOM, hangs, high CPU/memorywindowsWindows-specific issuesWindows-specific issues
Description
Problem
Before a hook-augment process can ask the daemon for graph context, it computes the SHA-256 of its own executable (about 300 MB) as its daemon build identity.
Since #2575 (e93e438, first released in v0.12.0) that hash runs on the CPU's SHA instructions where they exist. Measured on current main (354ccec), Apple arm64, over the 305 MB image:
| path | time per hash |
|---|---|
| hardware (ARMv8 SHA2) | 0.10 s |
| portable fallback | 0.95 s |
CPUs without SHA instructions take the portable path on every hook call. Reporters measured about 2.3 s of startup CPU on their machines (#1335, #1388, #2441), which is past the 2000 ms hook deadline, so the hook exits 0 with no output. Even when it stays under the deadline, every Grep/Glob/Bash call pays that latency.
Constraints
- The build identity is part of the version-cohort and activation contract (A live daemon that is not holding the version-cohort marker poisons every index worker it forks, for its entire lifetime — no self-heal, and the conflict log names a build that does not exist #2178, Linux 0.10.5: new MCP/CLI clients intermittently wait 15–30s or time out while healthy daemon serves existing clients #1955, fix(daemon): hash a verified peer image copy once, not on every HELLO (#1955) #2335). A hook process must not be able to pass as a different build.
- A cache keyed on file metadata (size, timestamps, file index) is not a stable identity on Windows for any file other than the running image, because the change time can be set through
SetFileInformationByHandle. This came up in the perf(daemon): hash the executable image once per process; announce missed hook deadlines #1767 review. - Hooks stay fail-open and never add noise to stdout.
Options to evaluate
- Daemon-side verification. The daemon verifies the connecting hook's image, as fix(daemon): hash a verified peer image copy once, not on every HELLO (#1955) #2335 does for peers with the verified handle held open, and the hook process does not hash itself.
- A read-only hook channel with a narrower identity requirement, since
hook-augmentonly reads the graph. - An install-time digest, recorded by the installer in an owner-only file and checked by the daemon against its own verification of the peer image.
Done when
- A hook process does no full-image hash on the hook path, asserted by a work counter (bytes hashed), never by wall time.
- The identity contract holds on macOS, Linux and Windows.
- Hooks on CPUs without SHA instructions return context at the default deadline.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
editor/integrationEditor compatibility and CLI integrationEditor compatibility and CLI integrationenhancementNew feature or requestNew feature or requestpriority/normalStandard review queue; useful PR with ordinary maintainer urgency.Standard review queue; useful PR with ordinary maintainer urgency.stability/performanceServer crashes, OOM, hangs, high CPU/memoryServer crashes, OOM, hangs, high CPU/memorywindowsWindows-specific issuesWindows-specific issues
Activity