Repository navigation
feat(plugin): check the plugin's folder before each copilot - #35
Merged
Merged
Conversation
A role runs as the user, so it could change the hooks in a plugin folder in baton's cache and turn the guard off for the panes that start after it (risk 12). Write now uses a folder only if its files hash to the plugin's, and it is a real folder; else it writes the plugin under the next name, up to seven more, and never replaces a folder that a copilot may be loading. A role's pane checks again after its wait, and the guard denies a role's create and edit in baton's cache (decision 53).
|
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.



Step
plugin-check(docs/plan.md §0): baton checks the plugin's folder before eachcopilotstarts, so that a role can't turn the guard off for the panes that start after it (risk 12). It follows the orchestrator's trust-gap note on #34:plugin.writereused an existingplugin-<hash>folder without looking at its files.What it does
Decision 53:
plugin.Writeuses a folder that has the plugin's name only if it is a real folder (not a symlink to one) and its files hash to the plugin's: paths in the folder and contents, as the binary's are hashed. A folder with a changed, extra or missing file, or with anything but folders and regular files (a symlink, say), and anything else under the name, stays as it is.plugin-<hash>-1up to-7; with all eight taken, the pane fails and says why. baton never replaces a folder (Go'sos.Renamerefuses to), so a startingcopilotnever finds the folder missing and goes on without hooks and with the default agent (risk 10). Panes that start at once converge on the same new name.copilot. A failure there leaves the work picked up, as acopilotthat fails to start does (decision 38).baton hook guarddenies a role'screateandeditin baton's cache folder, as in baton's folder, and fails when it can't find the user's cache folder.The hash format changed (paths relative to the folder, regular files only), so the plugin's folder name changes once.
Checks
changed_test.go(8 kinds of change, each giving-1and keeping the changed folder as the role left it, and many panes at once after a change), the keep test (same folder, same inode), recrafted hash pairs, refusal rows (a symlink in the tree, a name too long for the disk, a file at each of the 8 names); the guard's cache rows × create/edit and its failure without a cache folder; the pane's re-check after the wait and its failure.internal/plugin100%,internal/cli99.8%, total 99.3%.copilot, no tmux: the first pane getsplugin-<hash>; after a change tohooks.json,-1, and-1again; the changed folder stays as it was; the guard denies an edit of-1'shooks.jsonwith the cache reason, says nothing for a repo file, and fails without HOME.Known gaps
bashcan still change the plugin's files after a pane's check, while itscopilotstarts or runs, or through a hard link (risk 2, forbelt). Changed folders stay in the cache. A Finder.DS_Storein a folder costs one more folder.Decision 53 is a lead's call, flagged for the end review.