Repository navigation
Description
Problem
templates/family-root/scripts/validate-family.py reads the sections a recursive clone reads from HEAD's .gitmodules alone (_head_gitmodules, member-gitmodules-absent, #407's decision 3), so "a .gitmodules staged and not committed counts for nothing until it is committed". A staged deletion of the file is such a staged-and-not-committed change, and nothing names it:
- With
git rm --cached -- .gitmodulesand the work tree's file left on disk, HEAD still holds the file, the work tree's file is clean, and every check passes:family ok, exit 0, in every mode. - A plain
git committhen records the deletion. HEAD holds no.gitmodules, a recursive clone checks out nothing at any member's gitlink, and the next run givesmember-gitmodules-absentfor every member (exit 1).
The gate names the same hazard one level down: member-gitlink-removal-staged says a gitlink whose removal is staged and not committed will be un-registered by the next commit, and puts it back. .gitmodules has no such finding.
With a value only the work tree's file gives, the one finding the gate prints has no stage line (its staged is not present or (name, key) in in_index, and the index holds no file), so its lines, typed in order and committed with a plain git commit, drop the file the same way. #1227's M3 row (test_a_value_here_and_in_head_ends_staging_it_with_no_index_s_file) covers only a value HEAD's file gives, where the finding ends with the stage line.
This is older than #1227 and unchanged by it: main's script behaves the same in both states below (measured). Found by rv1227c as P6 and P6b.
Evidence
rv1227c's probes test_p6_* and test_p6b_* (scratch file work/rv1227c/probes/test_rv1227c_probe.py in lane 5's folder, never committed), re-run at #1227's fix-round head 2d56c1906 on git 2.43.0 and on 2.47.1 (the same outcome on both), offline (run10.sh: stub gh, GIT_SSH_COMMAND=false, GIT_CONFIG_GLOBAL=/dev/null); logs in work/n1150g/out/head243/ and out/head247/ (p6b-*.log, p6-*.log). The family has gitlinks at members/IRRS and members/IRSS, and HEAD's .gitmodules gives both sections.
- P6b, a clean file.
git rm -q --cached -- .gitmodules(exit 0); the work tree's file is untouched and equals HEAD's.git status --porcelainsaysD .gitmodulesand?? .gitmodules.- The gate (no flag,
--pins,--no-members) isfamily ok, exit 0, with the head's script and with main's (blob172647b3e). - A plain
git commitexits 0.git show HEAD:.gitmodulesthen exits 128 (path '.gitmodules' exists on disk, but not in 'HEAD') andgit status --porcelainsays?? .gitmodules. - The next run, in all three modes, exits 1 with two
member-gitmodules-absentfindings, one for each member.
- The gate (no flag,
- P6, a value only the work tree's file gives. The same deletion staged, and the work tree's file gives IRRS
update = !true; HEAD's does not. (git status --porcelainitself exits 128 here,invalid value for 'submodule.members/IRRS.update', as git reads the work tree's file.)- The gate gives one
gitmodules-value-refusedfinding, "in the work tree, not in HEAD", exit 1 in every mode, with head and main alike. Its one line isgit config -f .gitmodules --unset-all submodule.members/IRRS.update, with nogit add -- .gitmodulesafter it. - Typed (exit 0), then a plain
git commit(exit 0): the same loss. HEAD holds no.gitmodules, and the gate gives twomember-gitmodules-absentfindings.
- The gate gives one
Suggested fix
Name the staged deletion itself, as member-gitlink-removal-staged names the gitlink's: where HEAD holds .gitmodules and the index holds none at any stage, say that its removal is staged and not committed, that the next commit drops it from HEAD (and member-gitmodules-absent follows for every member), and give the line that puts it back, git reset -q -- .gitmodules, or git add -- .gitmodules where the work tree's file is the one to keep. That is a new refusal code, so AGENTS.md's code list, tests/test_agents_md_codes.py, tests/test_cli_reference.py and the docs that list the gate's findings change with it.
Whether the finding is its own code or member-gitlink-removal-staged's sibling is for the fix's author. Either way, the value check's stage line should count an index that holds no .gitmodules while HEAD's does (the staged argument of _value_taken_out), so that a value only the work tree's file gives, in this state, ends with git add -- .gitmodules as the M3 row's does.
Verify
- A row for P6b: the deletion staged, the file clean on disk; the gate is not
family ok, in every mode; its lines typed in order, then a plaingit commit, leave HEAD's.gitmodulesas it was and the gate passing in every mode (ends_well), on git 2.43.0 and 2.47.1. - A row for P6: the lines typed in order, then a plain
git commit, leave HEAD's file holding the sections and no value, and the gate passing. - Each row fails on main's script.
- The other states stay as they are: the deletion staged with the work tree's file gone (test_validate_family_index_gitmodules.py and validate-family.py: a row pins path-twice's wording of whose file it puts back, the index's or HEAD's as the index holds none, a row pins the value check's reading of HEAD's where the deletion of
.gitmodulesis staged, and_listed_as_git_reads's docstring says it returns nothing where the work tree's file is on disk (#1181) #1208's row), the file never staged for deletion, and a holder with no members. tests/test_path_guard_hygiene.py,tests/test_repo_hygiene.py,tests/test_agents_md_codes.py,tests/test_cli_reference.pyandtests/test_pinned_copy_text.pypass.
Found by rv1227c's NIT 3 on #1227 (issuecomment-6722728204), probes P6 and P6b.
Lane: openreposhape-5 (openRepoShape-5)
Activity
validate-family.py: the check for values git dies on reads the index'…