Skip to content

S08-03 - Pushes

Purpose: Where the guest’s pushes land, the settings receive-pack runs with, which refs a push may write, and the push at session end.

Each project has a bare repository in Wraith Box’s state directory, projects/<id>/landing.git. The guest pushes there, never to the user’s repository.

landing.git borrows objects from the same project’s export.git. At each session start wb-hostd rewrites its alternates file to exactly that one entry. A push then sends only new objects.

The guest pushes to landing.git through the same transport as its fetches (S08-01-into-the-guestS08-01-into-the-guest: Into the GuestHow the project's code reaches the guest: the clone, its transport, its remotes, and the uncommitted changes carried in at session start.).

wb-hostd runs git receive-pack with these settings:

Git reads a GIT_ALLOC_LIMIT of 0 as no limit. So the value is never computed from a setting that can be zero. The environment builder in wb-hostd has a unit test that pins the value (C08-gitC08-git: GitThe test cases for the git round trip: the transport, the pack scanner and the pre-receive check, git's own limits behind them, and the data scope of what a session gets from the host repository.).

A filter in wb-hostd reads the push’s command list before receive-pack sees any of it. It refuses the whole push unless every ref is under refs/heads/wb/<session-id>/, where <session-id> is:

A push to an ended or discarded session’s branch is refused and logged with the rule (SEC06-repo-writesSEC06-repo-writes: Repository-scoped writesGit pushes and repository-mutating API calls are allowed only for the repositories of the projects that have a session in the VM.). So is a push to another project’s or another VM’s branch.

The filter also checks the form of each command:

  • Below the prefix, ref components use only A-Z, a-z, 0-9, -, _ and ..
  • A component doesn’t start with ., doesn’t end with . or .lock, and holds no ...
  • A component is at most 255 bytes, and a ref at most 1024.
  • Object IDs must have the length of the landing repository’s hash.
  • shallow lines are refused.
  • The first command must ask for side-band-64k. Git then sends its messages, and those of index-pack and the pre-receive check, to the guest inside the protocol, not on its own standard error.

The filter reads no byte past the flush that ends the command list. The pack scanner then gets the pack from its first byte (S08-04-push-checksS08-04-push-checks: Push ChecksThe checks that bound the memory and work of a push before git unpacks it: git's allocation limit, the pack scanner, and the pre-receive check.).

The filter is a parser of guest bytes, so it has a fuzz target (C08-gitC08-git: GitThe test cases for the git round trip: the transport, the pack scanner and the pre-receive check, git's own limits behind them, and the data scope of what a session gets from the host repository.). It logs each ref it allows or refuses with the rule.

receive.hideRefs restricts the same refs inside git as a second layer, and hides other sessions’ branches.

With side-band-64k, receive-pack sends the messages of index-pack and the hook to the guest inside the protocol. wb-hostd passes them on without reading them.

What receive-pack still writes to its own standard error reaches wb-hostd, such as a fatal: line. Its text depends on the pack, for example an fsck message that quotes a tag name or a .gitmodules value. So wb-hostd treats it as guest input:

If the worktree has uncommitted changes, wb-guestd commits them to the session branch as a WIP commit marked as such, then pushes. wb can also push mid-session.

When the commit or the push fails:

A later wb claude --continue starts from the host’s HEAD (S08-01-into-the-guestS08-01-into-the-guest: Into the GuestHow the project's code reaches the guest: the clone, its transport, its remotes, and the uncommitted changes carried in at session start.). The old session’s uncommitted files reach a new session only after the user lands its WIP commit and merges it, or carries the files in by hand (FR04-carry-inFR04-carry-in: Uncommitted changes carried inUncommitted host changes (staged, unstaged, untracked-not-ignored) are carried into the session at start.).

receive.unpackLimit=1 sends every push through index-pack, never unpack-objects.

A hangup ends the session like an exit of claude. The same WIP commit and push follow.

Status: Draft