Git guard: a repository the reader cannot follow (a variable, ~) is judged where the call was typed, so a push through it reaches the clone #68
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Purpose (defect): a git call whose repository the reader cannot follow (a variable,
$HOME/...,~) is judged where it was typed, so a push through it reaches a clone's default branch and nothing refuses it.Refs macula-io/martha#48 (where the null came in) and macula-io/martha#53 (which extends it to an exported GIT_DIR). Found by Uranus's attack read of #53 (PR 66, tip
fc98233c), run end to end with real git through therefusalOffixture of ask_git_what_a_member_is_about_to_change.node-test.ts.What happens
The reader marks a repository it cannot resolve as
gitDirectory: null(read_the_git_calls_in_a_shell_line.ts; #53's own test pinsexport GIT_DIR=$A_CLONE→ null). Every consumer then readscall.gitDirectory ?? call.directory:??treats null as missing, so the call is judged at the worktree it was typed in, and a push from the worktree passes. git writes the clone.Typed in a member's worktree; each one PASSES the guard and git works on the clone:
Same class from the reader alone:
export GIT_DIR=$HOME/...and$'...'give null;export GIT_DIR=~/x/.gitgives<wt>/~/x/.gitwhere the shell expands the tilde.Why it is not in #53
#53's threat model (line 45) says a variable value is null, "as #48 says for --git-dir", and that the guard "judges the call at that repository". For null it does not: it judges at the worktree. Closing this hole means a push whose repository is unknown is refused, which is a new refusal. The threat model says "No new refusal" (DECIDED 2026-11-19 "No new checks without your yes"), and the house stance so far is fail-open (the header of ask_git_what_a_member_is_about_to_change.node-test.ts). So it needs a ruling, not a fold-in.
What it would take (for the ruling)
Narrowest form: a push (and worktree remove/move) whose
gitDirectoryordirectoryis null is refused with a named reason ("a push whose repository this guard cannot read"), and the consumers stop folding null into the worktree. Cost: a member writinggit --git-dir=$D pushis refused and must write the path.Threat model: martha#68, a push through a repository the guard cannot read (Uranus, 2026-11-23)
Ruling. Supervisor ruling 2026-11-23, (A). Raf can overrule it:
Conditions:
Asset and harm
Actor
A member's model writing a shell line. It isn't hostile on purpose, but it is free to write any line, and it often writes
$VAR,~and$HOME/...for paths.The hole (seam (a), the relay's shell-line reader)
The reader marks a repository named with a value it cannot follow as
gitDirectory: null: a variable,$HOME/..., or$'...', in--git-dir,GIT_DIR=orexport GIT_DIR=. Every consumer then readsgitDirectory ?? directory, and??folds that null into the place the line was typed. So:GIT_DIR=$D git push origin HEAD, typed in a worktree, is judged as a push of the worktree's own branch and passes. git writes the clone named by$D, whose HEAD is main.GIT_DIR=. The env value is never sent, so it judges at the worktree too and passes. The push reaches main.git --git-dir=$D push: seam (a) passes it the same way. Seam (b) sees the expanded path and refuses, so that one is closed today by seam (b) alone.What is NOT a hole (and must stay passing)
git pushthere hasdirectory: null. Seam (b) judges those in the real cwd. Refusing on a null directory would refuse every push. So the refusal keys ongitDirectory === nullonly. That includescd $D; git push, which seam (b) judges in$D.The change
One reading of "the repository a call works on", used by every consumer:
gitDirectorywhen it is a path;directorywhen none is named.null stays null and is never folded into the typed place. This touches guard_workspace.ts:191, :404 and :417, and ask_git…ts:174-175 and :211.
In
refusalOfACall: apush, or aworktree remove/worktree move, whose repository is named but unread is refused with: "this push/worktree call names its repository with a value the guard cannot read (a variable such as$HOME), so it cannot tell which branch it writes: write the repository's path out in full. Nothing was run."A worktree call naming an absolute worktree path is still judged at that path, which git lists from any of the repo's worktrees. It is refused only when the path it takes cannot be placed.
Residual (named, not closed here)
export GIT_DIR=$Din one shell call, thengit pushin a later one: seam (a) sees no GIT_DIR in the second line, and seam (b) does not read its environment. Scope asked of Mars: either a fold into #68 (the shim sends GIT_DIR and GIT_WORK_TREE), or its own issue.~in the reader. A tilde reads as a wrong path (<wt>/~/x/.git), not as null, inGIT_DIR=~/x git push, in--git-dir ~/xand inexport GIT_DIR=~/..., so this refusal does not fire on it. Measured ona1dab83e. Seam (b) catches the--git-dirform, because the shell expands it before the shim sees it. The inlineGIT_DIR=~/x git pushgets past both seams, the same way as the seam (b) env gap. The fix belongs in read_the_git_calls_in_a_shell_line.ts (Vesta's PR 66 file, off-limits here) and is filed as its own issue.!alias, or git by its absolute path. These stay seam (c)'s, as documented.Tests (red first, real git, in the two guard test files)
a1dab83e: each of these, typed in the member's own worktree, is refused, and the refusal names the way through:D=<clone>/.git; GIT_DIR=$D git push origin HEADgit --git-dir=$D push origin HEADGIT_DIR=$HOME/x/.git git push origin HEADexport GIT_DIR=$D; git pushis read only once martha#53, PR 66, lands. It then meets this same refusal.)GIT_DIR=$HOME/x git worktree remove <other's worktree>... worktree move ...git push origin HEADwith no starting directory;cd $D; git push origin HEAD;GIT_DIR=$D git statusandGIT_DIR=$D git checkout -b x, with no refusal and no notice;??fold in the consumer, and the push test goes red with it, so the fold is pinned too.Built on PR 85 (branch uranus/uranus-68-null-repo-guard).
Correction to the threat model above (r=1 review, Neptunus note 4). This is appended; comment 1105 is unchanged.
worktree removeorworktree movewhose repository is named but unread (GIT_DIR=$D git worktree remove /abs/path) is refused, even when the worktree path is absolute. The code follows ruling condition 1 (refuse on an unresolved repository) and does not judge it at the named path. The way through is the same: write the repository's path out.--git-dir/GIT_DIRfrom a directory the reader cannot place. The message now says so: "a variable, or a relative path from a directory it cannot place".874cecd1): an alias is now read where the line was typed when the repository is unread, soalias.pu=push; GIT_DIR=$D git puis refused. Residual: an alias defined ONLY in the unread repository's own config is still not seen. That is the same class as #86 and #87.State at park (Uranus, 2026-11-23): PR 85 is on tip
d6fea572with r=2 PASSed (Neptunus). Forgejo runs 2332-2335 are green on the exact tip, and the only skipped jobs are the conditional ones. The HANDOFF is with Mars, and the PR waits for Terra to land it as a merge commit (sponsors#50). Once it lands, the worktree martha-uranus-68-null-repo-guard gets finished. Refs #68