Wires Claude Code to a didbot personal data server: hooks, a plugin, and the harness contract they rest on.

perf(plugin): start the hook faster, and keep every scan linear and bounded #104

Merged permadeath.com
targeting main
Merged opened by and assigned to permadeath.com
targeting main

The hook runs as a new Python process on every event, and the harness waits on it, twice per tool call. A typical invocation took about 55 ms, 30 ms of it in imports; traceback alone pulled in seventeen modules on Python 3.14. It is now imported only when the hook fails, which brings an invocation to about 33 ms against 15 ms for a bare python3, or about 65 ms per tool call instead of 115 ms. A daemon that accepted connections and never answered added 2 s to every event and left no trace; the hook now logs the timeout.

Two scans took time quadratic in their input. A page repeating /oauth/browser? stalled every browser tool call: 80 KB took 1.3 s, and about 160 KB hit the 5 s hook timeout. A log naming thousands of sign-ins, such as didbot's own server log, took 2.5 s for 16,000. Past about 1,400 it also pushed the report over the daemon's 64 KiB line, so the event was refused whole. Both scans are now linear, and a report carries at most the last 64 request_uri values. Tool output nested past Python's recursion limit used to drop the report; it is now read with a stack.

New tests run thirteen realistic interactions through the hook against a stub daemon: image, PDF and long file reads, build and server logs, a 200,000-path listing, nested MCP output, a large fetched page, a browser snapshot, a failed tool, a pasted prompt, and a subagent starting and stopping. Each must finish within 2 s with a report the daemon reads. Other tests bound the modules imported at start (a count, not a timing), check that every scan grows linearly, and check that a silent daemon is logged. Each new test fails against main's hook. The plugin version moves to 0.2.1.

🤖 Generated with Claude Code

This pull request has no versions submitted yet.