osfd runs git in a worktree as itself: a hook an agent plants runs outside the sandbox #493

Closed
opened 2026-11-11 17:44:38 -05:00 by cmoriarty · 1 comment
Owner

What happens
osfd commits, checkpoints and diffs in a run's worktree, whose .git the agent writes. A post-commit hook runs through git commit --no-verify, and core.fsmonitor runs on git add (measured for braid#203's first draft). Both run as osfd, outside the fence and the sandboxes. A push also reads the worktree's own git configuration while it carries the forge token.

Fix
The first draft's design: every git command osfd runs in a worktree goes through that worktree's sandbox, and a push takes the run's commits as a bundle into a repository osfd owns, so no configuration an agent wrote is read with the token in reach.

Done when
A test plants a hook and an fsmonitor that copy a token file set up outside: both run and neither finds the file; and a worktree carrying url.<forge>.insteadOf still lands its commit on the forge.

Split from braid#203 by the owner's decision, 2026-11-11.

**What happens** osfd commits, checkpoints and diffs in a run's worktree, whose `.git` the agent writes. A `post-commit` hook runs through `git commit --no-verify`, and `core.fsmonitor` runs on `git add` (measured for braid#203's first draft). Both run as osfd, outside the fence and the sandboxes. A push also reads the worktree's own git configuration while it carries the forge token. **Fix** The first draft's design: every git command osfd runs in a worktree goes through that worktree's sandbox, and a push takes the run's commits as a bundle into a repository osfd owns, so no configuration an agent wrote is read with the token in reach. **Done when** A test plants a hook and an fsmonitor that copy a token file set up outside: both run and neither finds the file; and a worktree carrying `url.<forge>.insteadOf` still lands its commit on the forge. _Split from braid#203 by the owner's decision, 2026-11-11._
Author
Owner

Shipped in pull request 566 (change sandbox-edges-493-532).

  • osfd's git in a run's folder runs in a sandbox of its own. With sandboxes on, osfd puts a git wrapper first on its own PATH. Each git command whose directory, repository, worktree or index is in a run's folder runs in a one-off bubblewrap: the run's worktrees and .git read-write, its repository copy read-only, the image less Braid's program, no network. A forge address or a token there is refused.
  • The forge is reached from osfd's own copy. Pushes, the base sync, the archive and git-flow run in a repository outside the run that borrows its objects, so the token never meets the run's configuration or hooks.
  • Braid's interpreter never imports from the directory it runs in: OSF_PYTHON is a launcher with -P.

Evidence: in the image, a planted post-commit hook and core.fsmonitor both ran during osfd's add and commit, and both failed to read a token file set up outside the run (No such file or directory); the commit was made. A medium test shows a worktree with url.<forge>.insteadOf and a pre-push hook landing its commit on the forge with the hook never run. The wrapper costs about 28 ms a git command.

On production since 19a75bd: osfd installed its git wrapper at boot, and the deploy's self-check passed its 6 simulated runs (git-flow among them) in the image, fenced. Archived in pull request 568.

Shipped in pull request 566 (change `sandbox-edges-493-532`). - **osfd's git in a run's folder runs in a sandbox of its own.** With sandboxes on, osfd puts a `git` wrapper first on its own `PATH`. Each git command whose directory, repository, worktree or index is in a run's folder runs in a one-off bubblewrap: the run's worktrees and `.git` read-write, its repository copy read-only, the image less Braid's program, no network. A forge address or a token there is refused. - **The forge is reached from osfd's own copy.** Pushes, the base sync, the archive and git-flow run in a repository outside the run that borrows its objects, so the token never meets the run's configuration or hooks. - **Braid's interpreter never imports from the directory it runs in**: `OSF_PYTHON` is a launcher with `-P`. **Evidence:** in the image, a planted `post-commit` hook and `core.fsmonitor` both ran during osfd's add and commit, and both failed to read a token file set up outside the run (`No such file or directory`); the commit was made. A medium test shows a worktree with `url.<forge>.insteadOf` and a `pre-push` hook landing its commit on the forge with the hook never run. The wrapper costs about 28 ms a git command. On production since 19a75bd: osfd installed its git wrapper at boot, and the deploy's self-check passed its 6 simulated runs (git-flow among them) in the image, fenced. Archived in pull request 568.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
cmoriarty/braid#493
No description provided.