Repository navigation
Restate a worktree's registration in the container - #89
Merged
Merged
Conversation
A linked worktree's git dir records the checkout it belongs to by the path that checkout has on the host, and the guard mounts every git dir at its host path but never a checkout there. Git still finds the root by walking up from the cwd, so ordinary work is unaffected, but everything that reads the record answers with a directory the container does not have: `git worktree list` calls the worktree `prunable`, and a harness that resolves its project root from it -- Grok Build keys folder trust on that root -- finds the tree it was started in untrusted and gates off project instructions, skills, MCP and hooks. `--worktree-at` names the container path the session starts in, and the guard mounts a replacement record read-only over the workspace's own. The host's file is untouched: its own `git worktree list` and `git worktree prune` read it, where a container path would read as a worktree that has gone away. The replacement lives under the system temp dir at a name derived from the pair of paths it stands for, since the guard exits before the container starts and a fresh name each run would leave a file nothing is left to remove. Only the workspace's own record is restated; the repository's other linked worktrees still read `prunable` inside the container.
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.
A linked worktree's git dir records its checkout in
gitdirby the checkout's host path. The guard mounts every git dir at its host path but never the checkout there, so inside the container that record names a directory that does not exist. Git still finds the root by walking up from the cwd, butgit worktree listcalls the worktreeprunable, and a harness that resolves its project root from the record gets nothing back. Grok Build keys folder trust on that root, so it treats the tree it was started in as untrusted and gates off project instructions, skills, MCP and hooks.git-guardtakes--worktree-at, the container path the session starts in:/workspace, or/repos/<slug>in repo-slug mode. The Makefile recipe passes it. The guard writes a replacement record naming<path>/.gitand mounts it read-only over the workspace's own record. The host's file is untouched, because the host'sgit worktree listandpruneread it.The replacement goes under the system temp dir, in a per-user directory that only that user can write. Its name is derived from the pair of paths, so a rerun overwrites its own file rather than adding another. The guard refuses when:
worktrees/is a symlink--worktree-atis not one of the--targets-vvalueEvery refusal comes before the write.
Tongs keep the host's record. Only the workspace's own registration is restated, so sibling worktrees still read
prunableinside the container.Docs:
docs/git-guard.md,docs/harnesses/grok.md,docs/tongs/definitions.md.