Repository navigation
Hand the cached kb-guard over to the code clone - #54
Merged
Merged
Conversation
Claude Code and Codex run the hooks from their per-version plugin cache. bin/kb already hands over to the code clone ("code" in the config) when it runs from a */plugins/cache/* path. bin/kb-guard had no hand-over, so a guard fix reached users only with a new version.
Now the cached bin/kb-guard runs the clone's bin/kb-guard with /bin/sh, before it reads stdin, so the event passes through. With no config, no "code" key, no bin/kb-guard in the clone, or a "code" that is itself under */plugins/cache/* (an exec loop), it uses its own logic.
drive.py hook gets --cached: it loads a copy of the plugin from <dir>/plugins/cache/, so /verify can drive the hand-over.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hata-8f4a35 # Conflicts: # docs/development.mdx
main is at 0.11.3 now (#53), and its test wants a new version when bin/ changes. The merge also gave tests/test_plugin.py two CACHED constants: the second one, a path string, replaced the list of the version test. The cache path is now CACHE_DIR. The bump rule in CODING_STANDARDS.md and the test comment now say that bin/kb and bin/kb-guard hand over to the code clone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Make the cached
bin/kb-guardrun the code clone's guard, likebin/kbdoes. Then a guard fix reaches users withkb update, and does not wait for a new plugin version.Drift
drive.py hook --cached. Before,/verifyloaded the plugin from the checkout, so it could not reach the new hand-over. Now it loads a copy from<sandbox>/plugins/cache/.mainwent to 0.11.3 in Raise the plugin version so the guard fix of #49 reaches the cache #53 while this branch was open.main: both sides added aCACHEDconstant totests/test_plugin.py. The second one (a path string) replaced the list of the version test. The cache path is nowCACHE_DIR.Decisions
INPUT=$(cat), so the event on stdin goes to the clone's guard unchanged."code"key, nobin/kb-guardin the clone, or a"code"under*/plugins/cache/*. The last case prevents anexecloop.exec /bin/sh, notexec sh: ifshis not onPATH, theexecfails with 127 and the guard does not block the command.bin/kb: if the clone is older than the cache, the older guard runs.kb updatefixes it.bin/kb-guard.Evidence
The same fake code clone for both runs. Its
bin/kb-guardonly prints a deny with the reasonFAKE CLONE GUARD ran. Each guard runs from a cache-shaped path, with the event ofecho hello:Before (
main, cached 0.11.3): the cached guard uses its own logic and letsecho hellogo through.After (this branch, cached 0.11.4): the cached guard runs the clone's guard.
Live headless Claude Code (Haiku) with
drive.py hook --cached, plugin loaded from the sandbox cache:"code"= the fake clone,echo hello→PreToolUse:Bash hook error: FAKE CLONE GUARD ran."code"= this checkout,kb decide accept s-000002 --yes→ denied with "retroagent: only the user answerskb decidequestions…". Thenecho allowed-by-guard→allowed-by-guard.pluginLog:PreToolUse:Bash [".../ra-verify-xp5c9o_g/plugins/cache/retroagent/retroagent/0.11.3/bin/kb-guard"] (plugin retroagent@inline) finished with status 0 (171ms), then(114ms). The same hook from the checkout: 96 ms and 101 ms. The hook timeout is 5 s. (This live run was before the merge ofmain, so the path shows 0.11.3.)Reading map
Tests changed or deleted:
tests/test_plugin.py:_assert_guardgets aguard=parameter; 5 new tests (hand-over, no config, no key, missing clone, cache loop);CACHED→CACHE_DIRfor the path.Config:
.claude-plugin/plugin.json,.codex-plugin/plugin.json: 0.11.3 → 0.11.4.Error handling:
bin/kb-guard:15-26: the newexecpath, and its fallback to the local logic.Stack
Step 1/2. Previous: none. Next: #55 (stacked on this PR; merge this one first, then set the base of #55 to
main).🤖 Generated with Claude Code