Skip to content

family.py bump and remove have no rollback: when a git step after write_members fails (a holder pre-commit hook that exits 1, a held index.lock), they exit 2 with REFUSED a git or gh command failed and leave family.yaml rewritten, the member checked out at --to (or deinitialised and removed), and the change staged or half-staged, without a word about any of it, where add puts the holder back and names what it put back #365

Closed

Description

@brettheap

Lane: openreposhape-4 (openRepoShape-4)

Named out of scope by the writer of #242's replay (PR #308, head 15c080c): "cmd_bump leaves family.yaml modified if a git step after write_members fails". Seen twice by this lane's adversarial reviews, each time through a trigger since fixed:

The triggers were fixed. The missing rollback was not, and _commit_one's docstring now records it ("bump and remove leaving the pin or the unmount staged with no rollback"). Re-verified on main c7c02fa and on a scratch merge of #318's head 0f2a0dd (which carries c7c02fa) with #317's head c23e2b0, with two triggers that need no defect at all: a holder pre-commit hook that exits 1, and an index.lock held during the run. Local bare remotes, an empty global git config, GIT_ALLOW_PROTOCOL=file and a gh that exits 97 (never called). Not claimed: Windows (the hook is a plain sh hook, which git for Windows runs, as tests/test_family_member_path.py's hook test does; not run here).

What is wrong. cmd_bump (scripts/family.py:1829 at c7c02fa) fetches in the member and checks it out at --to. It then rewrites family.yaml (write_members), re-stages the gitlink (force_stage), asks _nothing_to_record and commits (_commit_one: force_stage again, then git commit). cmd_remove (:1926) runs git submodule deinit -f, then git rm -r -f, then write_members, then _commit_one. A CommandFailed from any step after the checkout, or after deinit, goes straight to main, which prints REFUSED a git or gh command failed and returns 2:

U=<openRepoShape checkout>   # a clean checkout at c7c02fa
# Runs from a clean checkout of openRepoShape, in bash, on Linux (GNU coreutils). Nothing leaves the machine: members and
# holder live in local bare repositories under $R, git reads an empty global config, GIT_ALLOW_PROTOCOL=file makes any
# accidental https/ssh clone fail, and a `gh` that exits 97 stands first on PATH.
R=$(mktemp -d); mkdir $R/bin; printf '#!/bin/sh\nexit 97\n' > $R/bin/gh; chmod +x $R/bin/gh; touch $R/gitconfig
export PATH=$R/bin:$PATH GIT_CONFIG_GLOBAL=$R/gitconfig GIT_CONFIG_NOSYSTEM=1 GIT_ALLOW_PROTOCOL=file \
       GIT_AUTHOR_NAME=t [email protected] GIT_COMMITTER_NAME=t [email protected]
for P in Atlas Nova Zed; do
  python3 $U/scaffold-project.py --org testorg --project $P --elected-by 'Test Human' --elected-on 2026-10-12 \
      --local-remote-dir $R/remotes --work-dir $R/work >/dev/null
done
python3 $U/scripts/family.py init --org testorg --family Fam --created-by 'Test Human' --created-on 2026-10-12 \
    --local-remote-dir $R/fam --work-dir $R/h >/dev/null 2>&1
H=$R/h/Fam; cd $H
add() { python3 $U/scripts/family.py add --family-root $H --member "$1" --local-remote-dir $R/remotes; }
add testorg/Atlas >/dev/null; add testorg/Nova >/dev/null
(cd $R/work/Atlas && echo moved > NOTES.md && git add NOTES.md && git commit -qm 'moved on' && git push -q origin main)
TIP=$(git -C $R/work/Atlas rev-parse HEAD)
printf '#!/bin/sh\necho "pre-commit: refused" >&2\nexit 1\n' > .git/hooks/pre-commit; chmod +x .git/hooks/pre-commit
cp -a $H $R/h/Fam2                  # the same holder, hook included, for `remove`
python3 $U/scripts/family.py bump --family-root $H --member Atlas --to $TIP 2>&1 | grep -E '^REFUSED|^pre-commit'
echo "bump: exit ${PIPESTATUS[0]}"
git status --porcelain
grep -A6 'project: Atlas' family.yaml | grep 'commit:'
echo "member checked out at: $(git -C members/Atlas rev-parse HEAD) (--to $TIP)"
cd $R/h/Fam2
python3 $U/scripts/family.py remove --family-root $R/h/Fam2 --member Nova 2>&1 | grep -E '^REFUSED|^pre-commit'
echo "remove: exit ${PIPESTATUS[0]}"
git status --porcelain
echo "rows: $(grep -c '^  - project:' family.yaml); files left in members/Nova: $(ls -A members/Nova 2>/dev/null | wc -l)"

Output at c7c02fa (the merge of #318 and #317 prints the same, commit ids aside):

REFUSED a git or gh command failed. THE EXACT COMMAND WAS:
pre-commit: refused
bump: exit 2
M  family.yaml
M  members/Atlas
      commit: "0375f29f6647c54269b2d2a02645ee5550e08555"
member checked out at: 0375f29f6647c54269b2d2a02645ee5550e08555 (--to 0375f29f6647c54269b2d2a02645ee5550e08555)
REFUSED a git or gh command failed. THE EXACT COMMAND WAS:
pre-commit: refused
remove: exit 2
M  .gitmodules
M  family.yaml
D  members/Nova
rows: 1; files left in members/Nova: 0

With an index.lock held instead of the hook, bump fails at its first force_stage. It leaves family.yaml rewritten but unstaged and the member checked out at --to, and validate-family.py then reports member-gitlink-mismatch (exit 1), because the index still records the old gitlink while the manifest pins the new one. That run was probed the same way on both trees, and is not in the block above.

In none of these runs does the output say what was left. add, given the same failure, puts back every step and ends with a sentence naming each one (MountRollback.undo). remove's state is the hardest to put back by hand: deinit -f has already removed the member's working tree.

Why. add runs inside MountRollback (#203, #236), which records the holder before the first write and undoes each step on any failure. bump and remove were written before it and never got one. The standard's other pin-moving tools do roll back: bump-leg.py (#253 is about the cases it still misses) and update-shape.py apply. In this file's own convention, add's, a REFUSED line means the holder is as it was. Here it is not, and the line does not say so. A holder hook that rejects the commit (a linter over family.yaml, say) is the likeliest way to meet this, and nothing about it is wrong.

What it should do. A refused bump or remove leaves the holder as it found it, or says exactly what it left and how to finish or undo it. The decisions are the author's:

  1. bump. Either a rollback: record family.yaml's bytes, the index records for members/<P> and family.yaml, and the member's HEAD before the checkout, then put each back on any failure (git -C members/<P> checkout -q <was>, update-index --index-info, the bytes) and end with add's kind of sentence. Or no rollback, and a closing sentence naming each leftover with the two exits: the git commit -- <paths> that finishes it, and the commands that undo it.
  2. remove. deinit -f and git rm are not cheap to reverse: the store git rm keeps lets git submodule update --init -- members/<P> restore the work tree. So either that rollback, or an honest sentence, or a reordering that checks what can be checked (a writable index, say) before the first destructive step.
  3. family.py bump (and add, remove) take no --dry-run, though the file's exit-code paragraph says a dry run prints and exits 0 and bump-leg.py has one, so the only way to see what a bump would pin is to run it: fetch, check the member out at --to and rewrite family.yaml #326 (bump --dry-run, held by lane 4) changes the same function. Whether the two land together, or this one first.
  4. The exit stays 2, and the git line stays quoted as it is now.

How to test. For bump and for remove, a pre-commit hook that exits 1, and separately a held index.lock (its path from git rev-parse --git-path index.lock, as #242's lock test does). Under a rollback, assert that the holder's snapshot before and after is identical: HEAD, ls-files -s, status --porcelain, family.yaml's bytes, the member's HEAD and .git/config's submodule.* keys. Under decision 1's second branch, assert that the sentence names each leftover.

Verified at main c7c02fa and at the scratch merge of #318's head 0f2a0dd with #317's head c23e2b0 (scripts/family.py sha256 8339041e…); neither #317 nor #318 touches cmd_bump or cmd_remove, and the finding survives the merge.

Related: #203 and #236 (MountRollback, the model), #253 (bump-leg.py's rollback gaps), #210 (bump's nothing-to-record), #326 (bump --dry-run), #242 / PR #308 and #299 / PR #315 (the two earlier triggers).

Activity

  1. brettheap commented on Oct 12, 2026

    @brettheap
    ContributorAuthor

    CLAIMED — lane openRepoShape-4, session e7cd5391-c790-49b0-a88f-a97d34b22582@Eagle, 2026-10-12T15:22:14Z, for #365

    Logged in lanes/log/openRepoShape-4.md at fc545cc98cf5b84033527e23489285568c126cfc.

    The three reads (lane-collision-protocol Rule 1):

    1. existing `CLAIMED —` comments on opensoft/openRepoShape#365:
       none
    2. `gh pr list --repo opensoft/openRepoShape --state all --search "#365"`, kept where the row or its body names `#365`:
       none
    3. `git ls-remote --heads [email protected]:opensoft/openRepoShape` branches naming `365` as a whole token:
       none
    
  2. added this to the v1.0.0 milestone on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions