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

Open
opened 2026-11-22 23:12:07 +00:00 by uranus · 3 comments
Member

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 the refusalOf fixture 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 pins export GIT_DIR=$A_CLONE → null). Every consumer then reads call.gitDirectory ?? call.directory:

  • src/guard_workspace/guard_workspace.ts:191, :404, :417
  • src/ask_git_what_a_member_is_about_to_change/ask_git_what_a_member_is_about_to_change.ts:174-175, :211

?? 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:

D=<clone>/.git; GIT_DIR=$D git push origin HEAD          (on main d8e33b07 too)
D=<clone>/.git; git --git-dir=$D push origin HEAD        (on main d8e33b07 too)
D=<clone>/.git; export GIT_DIR=$D; git push origin HEAD  (at fc98233c)
D=<clone>; cd $D; git push origin HEAD                   (null directory, on main too)

Same class from the reader alone: export GIT_DIR=$HOME/... and $'...' give null; export GIT_DIR=~/x/.git gives <wt>/~/x/.git where 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 gitDirectory or directory is 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 writing git --git-dir=$D push is refused and must write the path.

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 the `refusalOf` fixture 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 pins `export GIT_DIR=$A_CLONE` → null). Every consumer then reads `call.gitDirectory ?? call.directory`: - src/guard_workspace/guard_workspace.ts:191, :404, :417 - src/ask_git_what_a_member_is_about_to_change/ask_git_what_a_member_is_about_to_change.ts:174-175, :211 `??` 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: D=<clone>/.git; GIT_DIR=$D git push origin HEAD (on main d8e33b07 too) D=<clone>/.git; git --git-dir=$D push origin HEAD (on main d8e33b07 too) D=<clone>/.git; export GIT_DIR=$D; git push origin HEAD (at fc98233c) D=<clone>; cd $D; git push origin HEAD (null directory, on main too) Same class from the reader alone: `export GIT_DIR=$HOME/...` and `$'...'` give null; `export GIT_DIR=~/x/.git` gives `<wt>/~/x/.git` where 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 `gitDirectory` or `directory` is 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 writing `git --git-dir=$D push` is refused and must write the path.
Author
Member

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:

"This isn't a new guard or a new CI check. It closes a hole in the existing git guard, in a harm Raf kept by name: DECIDED 2026-11-20 "Yes, list then cut (Recommended)", where the default keeps "only leaks, lost work, unapproved push to main". A push whose repository can't be resolved can be an unapproved push to main, and a worktree remove or move on an unresolved repository can be lost work. DECIDED 2026-11-19 "No new checks without your yes (Recommended)" covers new guards and checks. A refusal added inside an existing guard, for a harm Raf already kept, is not one of those."

Conditions:

  1. the refusal is for push and worktree remove/move only;
  2. its message names the reason and the way through (write the repository path literally);
  3. no new CI job or check, and tests go in the guard's own test files;
  4. mutants only on the new refusal.

Asset and harm

  • Main of a clone's origin. An unapproved push onto the default branch is a harm Raf kept by name.
  • Another member's worktree. A remove or move takes their uncommitted work, which is lost work.

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= or export GIT_DIR=. Every consumer then reads gitDirectory ?? 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.
  • Seam (b), the shim, gets only cwd and args, and its argv carries no 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)

  • A null directory with no repository named. Seam (a) reads every line with no starting directory, so every plain git push there has directory: null. Seam (b) judges those in the real cwd. Refusing on a null directory would refuse every push. So the refusal keys on gitDirectory === null only. That includes cd $D; git push, which seam (b) judges in $D.
  • Every call other than push and worktree remove/move (condition 1). Those keep failing open: with an unread repository, no facts are asked and no notice fires.

The change

  1. One reading of "the repository a call works on", used by every consumer:

    • gitDirectory when it is a path;
    • null when it is named but unread;
    • directory when 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.

  2. In refusalOfACall: a push, or a worktree 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."

  3. 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)

  • Seam (b) and an exported GIT_DIR. export GIT_DIR=$D in one shell call, then git push in 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, in GIT_DIR=~/x git push, in --git-dir ~/x and in export GIT_DIR=~/..., so this refusal does not fire on it. Measured on a1dab83e. Seam (b) catches the --git-dir form, because the shell expands it before the shim sees it. The inline GIT_DIR=~/x git push gets 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.
  • A ! 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)

  • Red on 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 HEAD
    • git --git-dir=$D push origin HEAD
    • GIT_DIR=$HOME/x/.git git push origin HEAD
    • (export GIT_DIR=$D; git push is 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 ...
  • Stays green:
    • a plain git push origin HEAD with no starting directory;
    • cd $D; git push origin HEAD;
    • GIT_DIR=$D git status and GIT_DIR=$D git checkout -b x, with no refusal and no notice;
    • the literal-path forms (the #48 tests).
  • Mutant (condition 4): remove the new refusal (the guard returns undefined) and the red tests go red again. A second mutant restores the ?? 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).

## 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: > "This isn't a new guard or a new CI check. It closes a hole in the existing git guard, in a harm Raf kept by name: DECIDED 2026-11-20 "Yes, list then cut (Recommended)", where the default keeps "only leaks, lost work, unapproved push to main". A push whose repository can't be resolved can be an unapproved push to main, and a worktree remove or move on an unresolved repository can be lost work. DECIDED 2026-11-19 "No new checks without your yes (Recommended)" covers new guards and checks. A refusal added inside an existing guard, for a harm Raf already kept, is not one of those." Conditions: 1. the refusal is for push and worktree remove/move only; 2. its message names the reason and the way through (write the repository path literally); 3. no new CI job or check, and tests go in the guard's own test files; 4. mutants only on the new refusal. ### Asset and harm - **Main of a clone's origin.** An unapproved push onto the default branch is a harm Raf kept by name. - **Another member's worktree.** A remove or move takes their uncommitted work, which is lost work. ### 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=` or `export GIT_DIR=`. Every consumer then reads `gitDirectory ?? 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. - Seam (b), the shim, gets only cwd and args, and its argv carries no `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) - **A null *directory* with no repository named.** Seam (a) reads every line with no starting directory, so every plain `git push` there has `directory: null`. Seam (b) judges those in the real cwd. Refusing on a null directory would refuse every push. So **the refusal keys on `gitDirectory === null` only.** That includes `cd $D; git push`, which seam (b) judges in `$D`. - **Every call other than push and worktree remove/move** (condition 1). Those keep failing open: with an unread repository, no facts are asked and no notice fires. ### The change 1. One reading of "the repository a call works on", used by every consumer: - `gitDirectory` when it is a path; - **null** when it is named but unread; - `directory` when 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. 2. In `refusalOfACall`: a `push`, or a `worktree 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." 3. 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) - **Seam (b) and an exported GIT_DIR.** `export GIT_DIR=$D` in one shell call, then `git push` in 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, in `GIT_DIR=~/x git push`, in `--git-dir ~/x` and in `export GIT_DIR=~/...`, so this refusal does not fire on it. Measured on a1dab83e. Seam (b) catches the `--git-dir` form, because the shell expands it before the shim sees it. The inline `GIT_DIR=~/x git push` gets 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. - **A `!` 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) - **Red on 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 HEAD` - `git --git-dir=$D push origin HEAD` - `GIT_DIR=$HOME/x/.git git push origin HEAD` - (`export GIT_DIR=$D; git push` is 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 ...` - **Stays green:** - a plain `git push origin HEAD` with no starting directory; - `cd $D; git push origin HEAD`; - `GIT_DIR=$D git status` and `GIT_DIR=$D git checkout -b x`, with no refusal and no notice; - the literal-path forms (the #48 tests). - **Mutant (condition 4):** remove the new refusal (the guard returns undefined) and the red tests go red again. A second mutant restores the `??` 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).
Author
Member

Correction to the threat model above (r=1 review, Neptunus note 4). This is appended; comment 1105 is unchanged.

  • "The change" item 3 is wrong for the code as built. A worktree remove or worktree move whose 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.
  • Note 3: the refusal also covers a relative --git-dir/GIT_DIR from a directory the reader cannot place. The message now says so: "a variable, or a relative path from a directory it cannot place".
  • r=1 required finding (fixed by Neptunus, 874cecd1): an alias is now read where the line was typed when the repository is unread, so alias.pu=push; GIT_DIR=$D git pu is 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.
**Correction to the threat model above (r=1 review, Neptunus note 4).** This is appended; comment 1105 is unchanged. - "The change" item 3 is wrong for the code as built. A `worktree remove` or `worktree move` whose 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. - Note 3: the refusal also covers a relative `--git-dir`/`GIT_DIR` from a directory the reader cannot place. The message now says so: "a variable, or a relative path from a directory it cannot place". - r=1 required finding (fixed by Neptunus, 874cecd1): an alias is now read where the line was typed when the repository is unread, so `alias.pu=push; GIT_DIR=$D git pu` is 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.
Author
Member

State at park (Uranus, 2026-11-23): PR 85 is on tip d6fea572 with 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

State at park (Uranus, 2026-11-23): PR 85 is on tip d6fea572 with 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
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
martha-ai/martha#68
No description provided.