Skip to content

adopt-project.py: the leg mount passes --force to git submodule add, so a source whose .gitignore is * + !.gitignore, or names spec or code, adopts instead of dying at the mount after both leg remotes were pushed (#174) - #200

Merged
brettheap merged 9 commits into
mainfrom
fix/adopt-mount-past-gitignore
Oct 11, 2026

Conversation

@brettheap

@brettheap brettheap commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openreposhape-1 (openRepoShape-1)
Claim: #174 (comment)

What

Three commits in _mount_the_legs in adopt-project.py, and two merges of main (f25d805 for #169, 22c9fdd for #192). Described, reviewed and tested at head a5f0ab4, which contains main 22c9fdd. Since then, f82b737 merges main e4decfb (#166 via #194), 0ec844f merges main 20e13f0 (#172 via #198), and cd1c065 moves the three end-to-end tests that now meet #198's earlier refusal; see Tests and "Relation to #172".

The comment block above if GITMODULES in removed: is untouched. #194 edited that block, and f82b737 takes it as main has it.

#169 (merged as f25d805) refuses equal and nested leg paths at plan, check and execute. #172 (merged as 20e13f0, via #198) refuses, at check and in execute before any leg exists, what the two path values alone do not show:

  • an entry the plan keeps in the root at or on the way to the mount path;
  • a symlink on the way to it;
  • a case-only twin.

So the guard is defence in depth for every plan. It gives the same answer where the mount is made, for a run that got there anyway. With #169's refusal switched off and the guard left in, execute on a plan with spec_path: code still refuses (exit 2, nothing split). With both switched off it exits 0 with adoption verified over an assembly that mounts the spec leg only (the last two rows of the revert table at a5f0ab4 below).

Why: reproduction on main

The driver builds make_source_repo's source, runs plan, answers its three questions, runs check, and runs execute --yes --local-remote-dir remotes --work-dir work. Every row below was run on main 22c9fdd and on this branch's head a5f0ab4, with local remotes.

The issue: a source .gitignore that hides a mount path.

source .gitignore check execute on main left behind on main execute on this branch
* + !.gitignore plan ok exit 2, The following paths are ignored by one of your .gitignore files: both leg repositories created and pushed, no split branch exit 0, adoption verified, recursive clone and bootstrap ok
spec plan ok exit 2, the same the same the same as above
code/ plan ok exit 2, ... ignored ... then fatal: Failed to add submodule 'code' the same the same as above

code/ is the subtle one. The rule names a directory, so git's check of the path before the clone passes, and the refusal comes from the git add that git runs after it has cloned the leg there. Both mounts are 160000 commit in adopt/three-repo-shape.

What the reviews found at the mount, on main and on 51998db. Each is refused before the add now, with the entry or git's own words named.

plan execute on main execute on this branch
spec_path: docs/spec, docs a root-kept FILE exit 2, raw fatal: could not create leading directories of '.../docs/spec': Not a directory, after both legs were pushed exit 2, REFUSED adopt-mount-occupied: the assembly's index holds docs (a file) where the leg mount path docs/spec needs a directory, with the remediation
a root-kept FILE spec, mount at spec exit 2, raw fatal: 'spec' already exists in the index exit 2, REFUSED adopt-mount-occupied: the assembly's index already holds the leg mount path spec: spec (a file)
--spec-path src, src/ kept in the root exit 2, raw fatal: 'src' already exists in the index exit 2, REFUSED adopt-mount-occupied: ... already holds paths under src, the leg mount path: src/app/main.py (a file) and 1 more
a root-kept SPEC/notes.md, default spec mount exit 0, adoption verified, bootstrap ok on Linux; on a macOS or Windows clone SPEC and spec are one directory exit 2, REFUSED adopt-mount-occupied: ... holds paths under spec, the leg mount path: SPEC/notes.md (a file)
a root-kept legs -> <a directory outside>, --spec-path legs/spec cloned the spec leg THROUGH the link, outside --work-dir, with --force alone (51998db); main refuses it itself, after both legs exist exit 2, REFUSED adopt-mount-unaddable: git will not add the leg mount path legs/spec: fatal: pathspec 'legs/spec' is beyond a symbolic link, nothing written outside
spec_path and code_path both code (51998db alone) exit 0, adoption verified, the spec leg's commit the only mount plan-bad-leg-path from #169 at plan/check/execute; the guard behind it refuses with adopt-mount-occupied

Since #198 (20e13f0), main and this branch alike report the first five rows of that table at check as FINDING plan-leg-path-collides, and execute refuses them before any leg exists. The guard's answers in the table are what a run gets if it passes that refusal; see Tests.

The SPEC/notes.md row is a deliberate stricter outcome. An assembly is cloned on macOS and Windows too, and #169 already refuses case-only twins of the two leg paths on every disk, so the guard does too. Lane 2 calls it a design note (NEW-1, under Reviews); #198 now reports it at check, under "Relation to #172".

The remediation's next step. After a refused mount, legs.spec_path was changed and check said plan ok. A fresh --local-remote-dir with the SAME --work-dir exits 2 and leaves two new, empty leg repositories behind: git clone into <work-dir>/Northwind-spec finds it already there. With a fresh --work-dir as well, execute exits 0 with adoption verified, and a recursive clone of the split bootstraps. That is why the remediation now names --work-dir.

The decision: --force, not a refusal

The issue offered two fixes: --force at the mount, or a check/execute refusal built on git check-ignore. This PR takes --force, for three reasons:

  • The source is a legitimate one to adopt. A * + !.gitignore file means "track only what we add by name". A rule naming spec or code is about the source's own untracked files. Neither says anything about where the shape mounts a leg. A refusal would make the human edit the source's .gitignore to get past a step the tool controls.
  • A gitlink, once added, is tracked. Ignore rules apply only to untracked paths. After the mount, the source's rule never touches the gitlink again: _stage_the_split's git add -A does not skip it, and neither does a clone or a checkout.
  • This file already set the precedent. fix(adopt): preserve existing gitmodules through leg extraction #162 adds the fresh .gitmodules with git add -f past a .* rule, and that line's comment says why. This is the same move at the next line.

What --force does besides, and what the guard refuses first

git's documentation says: "If exists and is already a valid Git repository, then it is staged for commit without cloning." Without --force, git refuses any index entry at the path; with it, only an entry that is not a gitlink. --force also skips git's own dry run of the path before the clone. So _refuse_an_unmountable_path asks both questions first:

  • Index entries. git ls-files -s -z -- <path> <each proper prefix of path>, always with --icase-pathspecs. An entry at the path or under it, or exactly a proper prefix of it, is adopt-mount-occupied. -z because git quotes a path with a non-ASCII character otherwise, and "src/d\303\266.py" is not a path under src.
  • git's dry run. It refuses a path beyond a symlink or inside a submodule, as adopt-mount-unaddable. It runs BEFORE the prefix refusal, so a symlink or a submodule on the way keeps git's own words, and the prefix refusal speaks only for what git does not catch: a file.

What --force still does past the guard:

Both refusals come after the legs exist, because the mount is the first point where the assembly's index exists to be asked. The remediation says so: both leg repositories were made and pushed, and nothing was committed to or pushed to the source.

Every ordinary adoption is unchanged

Eight sources were each built once with a fixed date and executed by main 22c9fdd and by a5f0ab4 at the same paths. Every file of each split commit was compared after normalising the shape repository's own commit and tree digest, which differ per copy by construction. The leg commits and the .gitmodules are identical too.

source exit: main / this branch files in the split split identical
no .gitignore 0 / 0 31 same
ordinary .gitignore 0 / 0 32 same
.* + !.gitignore 0 / 0 28 same
seeded code leg 0 / 0 23 same
a submodule at upstream/dependency 0 / 0 32 same
a spec/ directory, sent to the spec leg 0 / 0 32 same
a submodule at spec, sent to the spec leg (its .gitmodules to code) 0 / 0 32 same
the same, with * + !.gitignore 2 / 0 32 (main cannot adopt it: #174)

The last two rows send a registered submodule to the spec leg and its .gitmodules to the code leg. They ran at a5f0ab4, before f82b737 merged main e4decfb. #194 reports that plan at check as plan-submodule-split (a registered submodule goes where .gitmodules goes), so on the merged head those two rows no longer reach execute. That is #194's rule, not this PR's.

A path the plan moves is not "held": git rm has taken it out of the index before the guard asks. A root-kept docs/ directory with spec_path: docs/spec, and legs/spec beside legs/code, mount on this branch as on main (exit 0, bootstrap ok).

Tests

tests/test_adopt_mount_ignored.py has 26 tests. 20 call _mount_the_legs through importlib on hand-made repositories, so they need no git filter-repo and run on the Windows job; the two with a symlink on the disk skip there. 6 reach execute and carry needs_filter_repo; since the merge with #198, three of them assert #198's earlier refusal (see "Relation to #172"). The case-twin test sets core.ignorecase by hand to both values, so it says on Linux, macOS and Windows alike that the answer does not depend on the disk.

tests/test_adopt_leg_path_collisions.py gains 3 tests that reach the guard end to end, past #198's refusal. They carry needs_filter_repo, and the symlink test also skips on Windows.

Revert table at a5f0ab4. Each change was reverted alone, in a plain copy of the tree at a5f0ab4 outside the worktree, and the file run on it. On the unmutated tree: 26 passed. The end-to-end rows name three tests that assert #198's refusal since cd1c065. Their proofs about the guard are now the new tests in the next table.

change reverted tests that fail
the prefix refusal (a file on the way) 5: test_a_mount_path_under_a_kept_file_is_refused_before_the_clone, test_a_case_only_twin_is_refused_whatever_this_disk_does_with_case[a-twin-file-on-the-way-false] and [...-true], and end to end test_execute_refuses_a_mount_under_a_kept_file_in_its_own_words, test_the_remediations_next_step_adopts_the_source
the prefix refusal widened to any entry at or under the prefix test_a_mount_path_beside_a_kept_directorys_files_is_mounted
the prefix refusal run before git's dry run 3: beyond a kept symlink, inside the other leg's mount, and end to end through a kept symlink
"file" dropped from the remediation test_the_remediation_says_how_to_run_again, test_execute_refuses_a_mount_under_a_kept_file_in_its_own_words
the empty --work-dir dropped from the remediation test_the_remediation_says_how_to_run_again, test_the_remediations_next_step_adopts_the_source
--icase-pathspecs never passed all 6 test_a_case_only_twin_is_refused_whatever_this_disk_does_with_case cases
--icase-pathspecs only where core.ignorecase is true (round 1) the 3 ...-false cases
"holds the leg mount path" said for entries under it 4: kept directory, non-ASCII name, and the a-twin-directory pair
a raw tab inside the backticks 14
a symlink named as a file test_a_mount_path_a_kept_symlink_holds_is_refused
the entry listed first named, not the one at the path test_the_entry_at_the_mount_path_is_named_before_one_under_it
ls-files not NUL-terminated test_a_mount_path_holding_a_file_with_a_non_ascii_name_is_refused
all of 1c44c78's change to adopt-project.py 16
the call to _refuse_an_unmountable_path 18
--force 5: the three hidden-mount cases and end to end test_execute_mounts_both_legs_past_a_gitignore_that_hides_them, test_the_assembly_whose_gitignore_hides_its_mounts_bootstraps
git's dry run 3: beyond a kept symlink, inside the other leg's mount, end to end through a kept symlink
#169's refusal of equal and nested paths (guard stays) none: all 26 pass. test_execute_refuses_a_plan_that_mounts_both_legs_at_one_path still passes on the guard alone
#169's refusal AND the guard call 19, among them test_execute_refuses_a_plan_that_mounts_both_legs_at_one_path: exit 0, adoption verified

Revert table at cd1c065, for the three moved tests and the three new ones. Each change was reverted alone, in a plain clone of cd1c065, and the six tests run on it. On the unmutated tree: 6 passed.

change reverted tests that fail
the test change: the three moved tests as they were at f82b737, run on the merge 0ec844f all three: REFUSED plan-leg-path-collides where adopt-mount-unaddable was expected, and the fixture's check finds plan-leg-path-collides on docs (1 failed, 2 errors)
#198's root-kept half (_kept_in_root returns nothing) the 3 moved tests. The runs reach the mount after both legs are pushed, and the guard refuses there (adopt-mount-unaddable for the symlink, adopt-mount-occupied for docs); check says plan ok. The 3 new tests pass
execute not refusing check's findings (_refuse_what_check_finds not called) the 3 moved tests; the 3 new tests pass
the call to _refuse_an_unmountable_path the 3 new tests: git fails raw at git submodule add --force (CommandFailed). The 3 moved tests pass
the prefix refusal (a file on the way) the 2 new kept-file tests (CommandFailed)
git's dry run test_the_mount_guard_refuses_a_mount_through_a_kept_symlink: adopt-mount-occupied, not adopt-mount-unaddable
the remediation's first claim ("both leg repositories were made and pushed ...") test_the_mount_guard_refuses_a_kept_file_on_the_way_after_both_legs_exist
"file" dropped from the remediation test_the_mount_guard_refuses_a_kept_file_on_the_way_after_both_legs_exist
the empty --work-dir dropped from the remediation test_the_mount_guards_next_step_adopts_the_source
the test's switch of _kept_in_root left out the 3 new tests: plan-leg-path-collides, not the guard's code

KEPT_CASES' file-on-the-way tree is now the named DOCS_A_FILE, which the new tests share. The collected test ids are unchanged apart from the 3 new ones, and the inside-a-kept-file parameters are equal.

test_a_mount_path_beside_a_kept_directorys_files_is_mounted passes on round 1's code by design: it is the other side of the file on the way, and only the widened refusal fails it. test_execute_refuses_a_plan_that_mounts_both_legs_at_one_path asserts exit 2, a REFUSED line, no adoption verified and no split branch, and does not name the code, because #169's refusal comes first.

Test counts at cd1c065.

This lane, the ten files test_adopt_mount_ignored.py test_adopt_leg_path_collisions.py test_adopt_leg_paths.py test_adopt_submodules.py test_adopt_e2e.py test_adopt_execute_refusals.py test_adopt_plan.py test_shape_doctor.py test_windows_paths.py test_cli_reference.py:

  • with git-filter-repo on PATH: 945 passed, 1 skipped (1408s);
  • without it: 897 passed, 49 skipped (1180s).

render-cli-reference.py --check ok.

Lane 2, in its re-verification at a5f0ab4 below:

  • tests/test_adopt_mount_ignored.py: 26 passed. With git-filter-repo off PATH: 20 passed, 6 skipped. On Windows, by the marks: 18 run, 8 skip.
  • tests/test_adopt_*.py plus tests/test_shape_doctor.py: 717 passed, 1 skipped (the MedxEHR clone).
  • Its own mutation runs: every rule in 1c44c78 fails at least one test, and round 2's surviving mutation now fails 4.
  • render-cli-reference.py --check ok. The diff against main is adopt-project.py and the mount test file only.

Merges with main. f82b737 merges main e4decfb (#166 via #194), a clean auto-merge with no change to this branch's own code: its tree equals git merge-tree --write-tree a5f0ab4 e4decfb. 0ec844f merges main 20e13f0 (#172 via #198), also clean: its tree equals git merge-tree --write-tree f82b737 20e13f0.

The full suite was not run here. The three-OS CI gate decides it: tests, tests-macos and tests-windows. Not run on a disk that ignores case: the Linux tests set core.ignorecase by hand, and the macOS and Windows jobs are where the case tests meet one. Everything above ran on git 2.43.0 with local remotes, so the real gh repo create path was not exercised (lane 2 did not verify it either).

Reviews

Relation to #172 (PR #198) and other branches

PR #198 (#172 and #191) landed on main as 20e13f0, and 0ec844f merges it here. It reports a leg mount path that a path the plan keeps in the root holds, or lies beyond (a file, a symlink, a submodule, a directory), and its case-only twins, as FINDING plan-leg-path-collides at check. execute refuses it before any leg exists. So this guard is defence in depth: it answers where the mount is made, for a run that got there anyway, which is after both legs are pushed. #198 landing first is the fix for lane 2's NEW-1: a Linux-only team meets the case rule at check, with no remote made, not after two leg repositories exist.

On 0ec844f, before any test moved, this PR's test file and #198's gave 115 passed, 1 failed and 2 errors. The 20 mount-level tests passed. Three end-to-end tests met #198's earlier refusal and not this PR's, and cd1c065 moves them to what that refusal says:

  • test_execute_refuses_a_mount_through_a_kept_symlink got REFUSED plan-leg-path-collides, not adopt-mount-unaddable. It now asserts that refusal and its finding: legs.spec_path 'legs/spec' is inside the symlink legs``. It also asserts that the run leaves the --local-remote-dir empty (it was made empty first), puts no clone in `--work-dir`, makes no split branch and writes nothing through the link.
  • The refused_under_a_file fixture's checked_ok failed with FINDING plan-leg-path-collides: legs.spec_path 'docs/spec' is inside the file docs``, which errored the next two tests. The fixture now records what check and `execute` say:
    • test_execute_refuses_a_mount_under_a_kept_file_in_its_own_words asserts check's finding, execute's refusal in check's words before any leg exists, and the same empty directories.
    • test_the_remediations_next_step_adopts_the_source follows that refusal's words: another path for the leg, then execute again into the SAME --local-remote-dir and --work-dir, which adopts. After the guard's refusal, which comes after both pushes, a re-run needs fresh ones.

What those three proved about the guard is kept, end to end:

Not this PR's, but the same gap (lane 2's NEW-3): the leg-remote-exists remediation says "choose an empty --local-remote-dir" and never names --work-dir. On main and on this branch a re-run that reuses --work-dir exits 2 with nothing on stderr after the two bare lines. With fix/adopt-late-failure-notice (68d4d63, #171) the same re-run prints git's destination path '.../work/Northwind-spec' already exists and is not an empty directory.

Relation to #167

This change and #167 (merged as #182) are the two halves that let a * + !.gitignore source adopt.

With both, the end-to-end test asserts that a recursive clone of the split bootstraps.

Closes #174

🤖 Generated with Claude Code

Summary by Sourcery

Allow ignored leg mount paths to adopt successfully while preserving explicit safeguards against unsafe or conflicting mounts.

New Features:

  • Allow leg submodules to be mounted even when source ignore rules hide their mount paths.
  • Add explicit mount-time refusals for occupied paths, unaddable paths, and files blocking mount paths, with actionable remediation guidance.

Bug Fixes:

  • Prevent adoption from failing after leg repositories have already been created and pushed when .gitignore hides a leg mount path.
  • Prevent forced mounts from reusing existing gitlinks or traversing symlinks and from failing opaquely on files in the mount path.

Enhancements:

  • Make mount-path validation case-insensitive and report conflicting index entries with clear path and type information.

Tests:

  • Add mount-level and end-to-end coverage for ignored mount paths, path collisions, symlinks, blocking files, case-only conflicts, remediation, and recursive bootstrap verification.

brettheap and others added 6 commits October 9, 2026 08:06
…d`, so a source whose `.gitignore` is `*` + `!.gitignore`, or names `spec` or `code`, adopts instead of dying at the mount after both leg remotes were pushed (#174)

`_mount_the_legs` ran `git submodule add` with no `--force`, so when the source's own `.gitignore` matched a mount path git refused it -- `The following paths are ignored by one of your .gitignore files: spec` -- and `execute` exited 2 after `_create_leg_remotes` and both leg pushes had run, although `check` had said `plan ok`; a corrected re-run then met `leg-remote-exists`. `--force` is git's documented way past an ignore rule, and #162's `git add -f` of the fresh `.gitmodules` is the precedent. Such a source is a legitimate one to adopt, so there is no `check` refusal; a gitlink once added is tracked, so the rule never touches it again. The rest of what `--force` does cannot make a bad mount pass: the fresh clone has no `.git/modules/<name>` to reuse, a path the index already holds is still refused, and a newer git's renaming of a name already in use can only meet a root-kept `.gitmodules`, which verification never passes (#165).

tests/test_adopt_mount_ignored.py covers the mount boundary for `*` + `!.gitignore`, `spec` and `code/` without git-filter-repo (so on the Windows job too), and one end-to-end adoption of a `*` + `!.gitignore` source that is verified, holds both mounts as gitlinks at the pushed leg commits, and bootstraps, with #167's forced staging of the shape's files now on main. Every new test fails with `--force` removed.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…force`, a path the assembly's index already holds and one git's own dry run refuses, so `spec_path: code` no longer verifies an assembly that mounts only the spec leg, and `legs/spec` under a root-kept symlink no longer clones the leg outside the work directory (#174)

The adversarial review of 51998db found that `--force` does more than get a mount past an ignore rule, and that the comment saying none of the rest could make a bad mount pass was wrong:

- `spec_path` equal to `code_path`, edited into a plan `check` passes: the second `git submodule add --force` met the gitlink the first had just staged, which `--force` lets through, and git staged the repository already checked out there -- the spec leg -- as the code leg's mount. `execute` exited 0, `adoption verified`, with the spec leg's commit as the split's only gitlink, at `code`. Without `--force` git refuses any entry at the path: `'code' already exists in the index`.
- `--force` skips the `git add --dry-run` git makes before it clones, so `spec_path: legs/spec` under a root-kept `legs -> /elsewhere` cloned the spec leg through the link, outside the work directory, and only then failed.

`_refuse_an_unmountable_path` now runs before each add. `adopt-mount-occupied`: `git ls-files -s -- <path>` lists anything, named in the refusal; where the assembly's `core.ignorecase` is true (what `git clone` records on a disk that ignores case) it is asked with `--icase-pathspecs`, because `ls-files` matches case-sensitively even then. `adopt-mount-unaddable`: `git add --dry-run --ignore-missing -f --no-warn-embedded-repo -- <path>` fails, with git's own words; `-f`, so an ignore rule still passes it. Both say the legs were already made and pushed and nothing was committed to the source. The loop's comment now says what `--force` lets through and that the guard refuses it first; with the paths then distinct, the second mount has no `.git/modules/<name>` to reactivate, and a newer git's renaming of a name in use can still only meet a kept `.gitmodules`, which verification fails (`adopt-lost`).

tests/test_adopt_mount_ignored.py: five mount-level tests with no git-filter-repo (the same path twice; a kept submodule at the path; a case-only twin under `core.ignorecase`; a path beyond a root-kept symlink, skipped on Windows; a path inside the other leg's mount) and two end-to-end ones (`spec_path: code` edited into a plan is refused and nothing is split; `--spec-path legs/spec` through a root-kept symlink is refused with nothing written outside). Each fails with the change it guards reverted.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…o the mount path as `adopt-mount-occupied`, asks its index question case-insensitively on every disk, and its remediation names an empty `--work-dir`, so `spec_path: docs/spec` over a kept `docs` file no longer dies raw after both legs were pushed (#174)

`git submodule add --force` dies "could not create leading directories" on a
root-kept FILE on the way to the mount path (`docs` a file, `spec_path:
docs/spec`), after both legs are pushed, and neither guard asked about it: the
index holds nothing AT `docs/spec` and git's own dry run passes. The guard now
also refuses, naming the entry, a proper prefix of the path that is an index
entry; a root-kept `docs/` DIRECTORY, which only has paths under it, still
mounts.

The index question is asked with `--icase-pathspecs` whatever `core.ignorecase`
says: an assembly is cloned on macOS and Windows too, and #169 refuses case-only
twins of the two leg paths on every disk, so a root-kept `SPEC/notes.md` beside
a `spec` mount is refused on Linux as well. That removes the `core.ignorecase`
read. The message says "paths under <path>" when the entries are under it, and
names an entry by path and kind (a file, a submodule, a symlink) with no raw tab
inside backticks.

The remediation now says to run again with fresh leg repositories AND an empty
`--work-dir`, or none: the refused run's work directory still holds its clones
of both legs and the next run cannot clone into them. The `leg-remote-exists`
remediation is outside #174 and is not touched.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Lane: openreposhape-1 (openRepoShape-1)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR forces Git submodule mounts past source ignore rules while adding explicit, named preflight refusals for the index and filesystem hazards that --force would otherwise bypass. It also adds extensive unit and end-to-end coverage for ignored mounts, collisions, case handling, symlinks, submodules, non-ASCII paths, and safe remediation after late failures.

Sequence diagram for safe forced leg mounting

sequenceDiagram
    participant Execute
    participant Assembly
    participant Git
    participant Remote

    Execute->>Remote: create and push leg repositories
    Execute->>Assembly: _refuse_an_unmountable_path(path)
    Assembly->>Git: ls-files --icase-pathspecs -s -z -- path prefixes
    Git-->>Assembly: index entries
    alt index entry at, under, or on the way to path
        Assembly-->>Execute: Refusal adopt-mount-occupied
    else index is clear
        Assembly->>Git: add --dry-run --ignore-missing -f --no-warn-embedded-repo -- path
        alt Git rejects the mount path
            Assembly-->>Execute: Refusal adopt-mount-unaddable
        else path is addable
            Execute->>Git: submodule add --force -q leg_repository path
            Git-->>Assembly: gitlink mounted
        end
    end
Loading

File-Level Changes

Change Details Files
Make leg mounts succeed when the assembly’s .gitignore hides the mount paths.
  • Pass --force to git submodule add so ignored mount paths are accepted.
  • Document why the source should be adopted rather than modifying its ignore rules.
  • Add regression coverage for catch-all, spec, and code ignore rules, including end-to-end bootstrap verification.
adopt-project.py
tests/test_adopt_mount_ignored.py
Replace the safety checks disabled by --force with explicit pre-mount refusals.
  • Inspect index entries at, beneath, and on the way to each mount using NUL-delimited ls-files output and case-insensitive pathspecs.
  • Refuse occupied paths with named entry kinds and distinguish files, symlinks, and submodules.
  • Run Git’s forced dry-run before mounting to reject paths beyond symlinks or inside submodules using Git’s diagnostic.
  • Prevent equal or nested mount paths from silently reusing a prior leg.
  • Add remediation explaining that fresh leg remotes and an empty work directory may be required after a late refusal.
adopt-project.py
tests/test_adopt_mount_ignored.py
Add broad regression tests for mount-path collisions and late-failure remediation.
  • Cover files on the path, entries under a kept directory, symlinks, submodules, case-only twins, non-ASCII names, and paths inside the other leg.
  • Verify refusals happen before cloning or writing outside the work directory.
  • Verify failed executions leave no split and that following the remediation with fresh remotes and work space succeeds.
  • Validate the new refusal messages and mutation-sensitive behavior.
tests/test_adopt_mount_ignored.py

Assessment against linked issues

Issue Objective Addressed Explanation
#174 Ensure _mount_the_legs can mount legs when the source .gitignore ignores the spec or code mount paths, avoiding failure at git submodule add after both leg remotes have already been created and pushed. ✅
#174 Prevent --force from bypassing other Git safety checks or producing an invalid adoption when a mount path is occupied, lies beneath an invalid path component, or conflicts with an existing index entry. ✅
#174 Add regression coverage demonstrating successful adoption of sources with ignored mount paths and refusal of unsafe mount layouts before the submodule add. ✅

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@brettheap

Copy link
Copy Markdown
Contributor Author

(lane openRepoShape-1, 2026-10-11T00:43:47Z) @codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Needs a human reviewer. The change alters how submodules are created and adds path-safety checks around symlinks, existing index entries, and parent paths. If it is wrong, an adoption could record the wrong gitlink or write a leg into an unintended repository path; reverting the code would not remove already-created commits or pushed leg repositories, but those artifacts are bounded and can be cleaned up or the adoption rerun.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

brettheap and others added 2 commits October 11, 2026 16:05
Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-to-end tests that met its earlier `plan-leg-path-collides` assert that refusal, and the mount guard behind it is reached in process past #172's root-kept half, so its refusal, its remediation's claims and its next step are still proved end to end (#174)

#198 (#172) refuses, at `check` and in `execute` before any leg exists, a
leg mount path that a path the plan keeps in the root is, holds or lies
beyond. On the merge with 20e13f0 three end-to-end tests here met that
refusal instead of `_refuse_an_unmountable_path`'s: the kept-symlink run got
`REFUSED plan-leg-path-collides`, and the kept-file fixture's `check` found
`plan-leg-path-collides` on `docs`, erroring its two tests.

tests/test_adopt_mount_ignored.py: the three now say what `execute` does
with those plans: `check` reports the finding, `execute` refuses it in
`check`'s words, the EMPTY `--local-remote-dir` stays empty, `--work-dir`
holds no clone, nothing is split and nothing is written through the link;
and the corrected plan adopts into the SAME two directories. Each names
where the guard's own refusal of the path is still proved.

tests/test_adopt_leg_path_collisions.py, which already drives `cmd_execute`
in process: three tests switch off #172's root-kept half for one run
(`_kept_in_root`, which `execute` asks only through
`_leg_collision_findings`) and reach the guard after both legs are pushed:
`adopt-mount-occupied` for the kept file on the way, with its remediation's
first claim true of the run; `adopt-mount-unaddable` in git's words for the
kept symlink, with nothing written outside; and the remediation's next step,
fresh leg repositories AND an empty `--work-dir`, adopting where fresh
repositories alone do not. `KEPT_CASES`' file-on-the-way tree is named once
(`DOCS_A_FILE`) for both.

adopt-project.py: `_refuse_an_unmountable_path`'s docstring said the guard
"also covers" a root-kept entry or symlink on the way to the path; #172 now
refuses each of them first, so it says the guard is defence in depth for
every case it lists. No behaviour changes.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@brettheap

Copy link
Copy Markdown
Contributor Author

(lane openRepoShape-2, 2026-10-11T17:16:40Z) Heads-up: this lane is re-verifying cd1c065 read-only against its earlier review of a5f0ab4 (delta since then, the moved end-to-end tests, NEW-1 to NEW-3, targeted tests with and without git-filter-repo, merges against the current heads). The result follows on this PR within the hour. No hold is requested; Brett's merge word stands.

Clean merge: #201 moves the leg-path helpers into scripts/shape_materialize.py; this branch's mount guard and tests do not touch them.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sonarqubecloud

Copy link
Copy Markdown

@brettheap
brettheap merged commit a5b09c3 into main Oct 11, 2026
5 checks passed
@brettheap
brettheap deleted the fix/adopt-mount-past-gitignore branch October 11, 2026 18:27
brettheap added a commit that referenced this pull request Oct 11, 2026
…links, so the fail-closed root gitlink check is tested behind the mount guard #200 puts before `git submodule add --force`

No conflicts: git merged adopt-project.py without a conflicting hunk and
took #200's two test files as they are. #200 edits the mount loop in
`_mount_the_legs` (`--force`, and `_refuse_an_unmountable_path` before each
add); this branch edits the comment above that loop, the verification
(`_land_the_root_tree`, `_root_gitlink_finding`, the two exit texts) and a
docstring, so no hunk touches both.

Checked by hand for a conflict git cannot see:
- `_leg_findings(plan, tree)` still takes `tree` as a required argument,
  and `_entry_findings` still passes the source tree.
- #200's loop comment says a `.gitmodules` the plan kept in the root is
  one "verification never passes (#165)"; this branch's comment above the
  loop says how: on that file's bytes (`adopt-lost`) and on every
  submodule of the source's the root keeps (`adopt-root-submodule`). The
  two agree, and both are kept.
- `_refuse_an_unmountable_path` refuses only a mount path the index holds,
  one with a file on the way to it, and one git will not add. The
  fail-closed e2e keeps `upstream/dependency` in the root and mounts at
  `spec` and `code`, so it still reaches `_verify`: test_adopt_verify.py
  and the two mount tests in test_adopt_submodules.py pass on this tree,
  18 of 18, none skipped.
- Every refusal the three gitlink findings name still exists:
  `plan-bad-leg-path`, `plan-submodule-root`, `plan-unresolved`,
  `plan-uncovered` and `plan-bad-leg`.
- The branch's delta over main is the same as before the merge.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 11, 2026
…e-notice

It merged with no conflict. #200 passes `--force` to `git submodule add`
and adds `_refuse_an_unmountable_path` before each mount. This branch does
not touch `_mount_the_legs`: its `_commit_the_split` already runs it as the
step `mounting the legs`. `_leg_findings(plan, tree)` is unchanged.

One behaviour of #200 meets this branch's. The guard's two refusals,
`adopt-mount-occupied` and `adopt-mount-unaddable`, come after both legs
are pushed. So `_commit_the_split` reports them as it reports every late
failure: `REFUSED mounting the legs.`, #200's own remediation, then the
notice. `execute` exits 2, as it does on main. Three of #200's tests in
tests/test_adopt_leg_path_collisions.py run `cmd_execute` in-process and
expect the refusal to escape it. On this merge they fail with `DID NOT
RAISE Refusal`. The next commit brings them in line with this branch's
report.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 11, 2026
…he three #200 added no longer fail on this branch with `DID NOT RAISE Refusal` (#188, #174)

#200 (#174) added three tests to tests/test_adopt_leg_path_collisions.py.
Each switches off #172's root-kept half and runs `cmd_execute` in-process
until the mount guard refuses, after both legs are pushed. They expected
the `Refusal` to escape `cmd_execute`, as it does on main, where `main`
prints it and exits 2.

On this branch every failure once a leg repository exists is reported
where it happens (#188). `_commit_the_split` prints `REFUSED mounting the
legs.`, the refusal's code and detail, its own remediation, and then the
notice of what the run left. `cmd_execute` then returns 2. The exit code
and the guard's words are the same as on main. After the merge of a5b09c3
the three tests failed with `DID NOT RAISE Refusal`.

`refused_at_the_mount` now records the refusal the guard raises, by
wrapping `_refuse_an_unmountable_path`. It asserts that `cmd_execute`
returned 2, that stderr carries that refusal word for word under the step,
and that the notice is the last line. The three tests' own assertions are
unchanged. No code changed.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@brettheap

Copy link
Copy Markdown
Contributor Author

(lane openRepoShape-2, 2026-10-11T18:59:31Z)

Closing this lane's 17:16Z heads-up. The re-verification of cd1c065 was cut off by the account's usage limit at 17:43Z and never reported. The PR merged at 18:27:02Z as a5b09c3, whose tree (de81f3a3) equals the final head a28c3b9's. This is a read-only check of main a5b09c3 by this lane, in its own detached worktrees, nothing authored, no claim.

POST-MERGE: NO REGRESSION FOUND

Tests on a5b09c3 with git-filter-repo, the 13 files the brief named: 920 passed, 1 skipped (the MedxEHR plan test). Without it, the seven adopt and scaffold leg-path files: 537 passed, 36 skipped. render-cli-reference.py --check is ok.

CI: tests, tests-macos and tests-windows were green on a28c3b9. The push run on main a5b09c3 is green.

Report: opensoft/brett-wip handoffs/xFactory/attachments/lane-openRepoShape-2/review200-201-postmerge-a5b09c3/final-report.md.

brettheap added a commit that referenced this pull request Oct 11, 2026
…200 merge with no conflict, `_entry_findings` still hands `_leg_findings` the tree, and a symlink the plan keeps and the shape writes through is still refused before any leg, ahead of #200's mount guard

This brings in 8df21e6 (#201, for #179) and a5b09c3 (#200, for #174).
#201 moved the leg-path rule verbatim from adopt-project.py into
scripts/shape_materialize.py, and adopt-project.py now imports it back
as one unit. #200 added `_refuse_an_unmountable_path`
(`adopt-mount-occupied`, `adopt-mount-unaddable`), which runs before
each `git submodule add --force`.

There was no conflict. `git merge-tree` and the merge both resolved
every file without help. Read after the merge:

- `_entry_findings` calls `_leg_findings(plan, tree)`, then appends
  `_root_symlink_findings(plan, source, tree)` after the submodule
  findings, as at a61ccbe.
- `_PlannedRoot` reads `WINDOWS_ABSOLUTE_RE` and `leg_path_problems`.
  Both now live in shape_materialize.py and arrive through #201's
  second import block. The first block keeps this branch's `BOOTSTRAP`
  and `SYMLINK_HOPS`.
- In shape_materialize.py, this branch's block sits before
  `_materialize` and #201's sits at the end of the file. They share no
  name.
- This branch's diff against main in adopt-project.py and
  scripts/shape_materialize.py has the same lines after the merge as
  a61ccbe's diff against 20e13f0.
- Every remediation sentence is kept: #198's clause in
  `_refuse_what_check_finds`, #200's `MOUNT_REMEDIATION`, and this
  branch's `plan-root-symlink`, `adopt-symlinks-off` and
  `UNWRITABLE_REMEDIATION`.

Which fires first. `execute` refuses `check`'s findings in their order
before any leg exists: `plan-leg-path-collides` from `_leg_findings`,
then `plan-root-symlink`. `adopt-symlinks-off` comes next, also before
any leg. #200's guard comes at the mount, after both legs are pushed,
and the materializer's refusals come after that.

Four plans are refused by more than one of these:
- `.github -> ci`, with `ci/` kept and `spec_path: ci`;
- `.github -> ../outside-ci`, with `spec_path: .github`;
- `.github -> spec/ci`, with `ci/` kept and `spec_path: ci`;
- `.github -> ../outside-ci`, with `spec_path: .github/spec`.

For each, `check` lists `plan-leg-path-collides` first and
`plan-root-symlink` after it. `execute` refuses under the first code
with all of them, before any leg exists.

With #198's root-kept half switched off, as #200's tests do,
`plan-root-symlink` still refuses three of the four before any leg.
#198's shape half refuses the fourth. Only with `check`'s list switched
off does #200's guard meet them, after both legs are pushed, and it
refuses each by name. Each sentence is true of its plan.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 11, 2026
Brings in #198 (20e13f0: #172 + #191, a leg's mount path must not be, hold or lie inside a path the assembly root holds, and `_leg_findings(plan, tree)` takes `tree` with no default), #201 (8df21e6: #179, the leg-path rule moved verbatim from adopt-project.py into scripts/shape_materialize.py, where scaffold-project.py asks it too) and #200 (a5b09c3: #174, the leg mount passes `--force` behind `_refuse_an_unmountable_path`). One merge, no rebase. Six conflicts, all in adopt-project.py:

1. Module docstring, `check`'s list: main's clause (neither equal to, around or inside a path the shape writes into the root, `shape/`, or a source path the plan keeps there), then this branch's (every value `execute` writes into the project's YAML one its loader reads back as that same text, #181), in one sentence.
2. The first `from shape_materialize import`: this branch's `TEMPLATED` and main's `assembly_root_paths`, both, in main's line layout.
3. The #169 section ("A leg's mount path is CANONICAL, or it is refused"): main replaced it with a pointer to `shape_materialize`, where the code now lives, and this branch had edited it in two places. Main's pointer is taken, and both edits are re-applied to the moved code in scripts/shape_materialize.py, unchanged in substance: `NOT_TEXT_KINDS` gains `type(None): "no value at all"` (an explicit null leg path, the reviewer's question on 76a6153), and `leg_path_problem`'s not-text sentence says "a leg path is text: write the path you mean, or remove the key to mount the leg at its role's own name" instead of "so quote it", with the comment saying why. Only a value read out of a plan file reaches that sentence: `plan`'s flags and scaffold-project.py's are always text, so the scaffold prints nothing new.
4. Two new sections inserted at one place after `_plan_leg_paths`: main's "A leg's mount path overlaps nothing the assembly root holds (#172)" first, beside the leg-path helpers it extends, then this branch's "What `execute` writes into the project is read back as written (#181)". Neither section is edited.
5. `_entry_findings`'s docstring: main's "and the two mount paths", then this branch's sentence on the misread findings.
6. `_entry_findings`'s body: main's `_leg_findings(plan, tree)` (#198 made `tree` required; dropping it raises TypeError on every `check` and `execute`), then this branch's `plan-manifest-misread` findings, whose remediation is still printed ahead of the submodule remediation.

Outside the conflicts: main's second `from shape_materialize import` also takes `NOT_TEXT_KINDS`, which this branch's `_the_loader_made` reads, and its comment no longer says "`leg_path_problem` is not called here", because this branch's `_plan_fields` calls it. Everything else merged cleanly, tests/test_adopt_leg_paths.py included (main's `_leg_findings(plan, None)` and this branch's not-text test touch different lines). An explicit null leg path never reaches main's collision check or its mount guard: `_leg_findings` asks `_leg_collision_findings` only when `leg_path_problems` found nothing, and None is a `plan-bad-leg-path` there, and `_checked_plan_values` refuses it before `checked_value` and the mount. The resolution adds no line over 79 columns that neither parent has.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 11, 2026
…ebreak-names (#199)

One hunk conflicted, the `from repo_shape import (...)` list in
adopt-project.py: main (#201, 8df21e6) removed `SAFE_ARG_RE`, and this branch
added `double_quoted`. Resolved as main's list plus `double_quoted`, nothing
else; no `SAFE_ARG_RE` is left in adopt-project.py. Every other file
(scaffold-project.py, scripts/shape_materialize.py, the tests) merged
without a conflict.

Lane: openreposhape-5 (openRepoShape-5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 11, 2026
…, #201, #200 and #173 land beside #190, and `_entry_findings` hands `_leg_findings` the tree while still returning #190's NOTEs

Main moved from e4decfb to 54aa69a: 20e13f0 (#172 via #198), 8df21e6
(#179 via #201), a5b09c3 (#174 via #200) and 54aa69a (#165 via #173).
Five conflict hunks, all in adopt-project.py, each a #190 line beside a
main line. Each takes BOTH sides, by lane 2's recipe
(resolve_m5b_r190d.py, which asserts each hunk's two sides before it
writes anything):

1. Module docstring, `check`: #198's mount-path clause ("neither equal
   to, around or inside a path the shape writes into the root ..."),
   then #190's "each relative url naming the same repository from the
   leg as from the source".
2. The `repo_shape` import list: main's names, which since #201 leave
   out `SAFE_ARG_RE` (its one user moved to scripts/shape_materialize.py,
   and #190 adds none), plus #190's `redacted, remote_key,
   remote_local_path`.
3. `_entry_findings` docstring, first paragraph: #190's "and the NOTEs
   it prints beside them" with #198's "and the two mount paths".
4. `_entry_findings` docstring, ONE LIST paragraph: #190's "but in the
   one place a remote decides it" sentence, then #198's paragraph on why
   `_leg_findings` is handed the tree.
5. `_entry_findings` body: #198's `_leg_findings(plan, tree)` with
   #190's three-tuple from `_submodule_findings(plan, source, tree,
   local_remote_dir)`. This branch's `_leg_findings(plan)` alone is a
   TypeError on every `check` and `execute`, because #198's `tree` has
   no default; main's two-tuple alone breaks `check`'s three-way unpack
   and drops #190 from `execute`.

#173's verification (only the two leg mounts passed over;
`adopt-root-submodule`, `adopt-unexpected-gitlink`, `adopt-mount-missing`)
merges with no conflict: #190 does not touch `_verify`, and a relative
url it lets through is the source's `.gitmodules` byte for byte.
tests/test_adopt_submodules.py merges with no conflict: #173's `MOVED`
and its root-tree test beside #190's absolute default url. #190's added
and removed lines against 54aa69a are its lines against e4decfb, but for
the reflowed docstring lines of hunks 1 and 3.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 11, 2026
… a leg or the split before it creates any leg repository, and the notice says to fix what failed first and names the work directory only once this run built in it, so following `adopt-branch-exists`'s way out no longer makes a new pair of leg repositories and dies at the clone (#188)

The review of #188 at 8d4fef4 found one way out that looped (F1, a
BLOCKER). `adopt-branch-exists` says "delete the branch, then run
`execute` again", with no work-directory clause. It fires only after an
earlier run pushed its split, so that run had built both legs and the
split in its `--work-dir`. Followed as written, the re-run made both leg
repositories (against GitHub, two real ones), then died at `git clone`
with `destination path '<work>/Northwind-spec' already exists`. The
verification's own FINDING exit, "re-run into fresh legs", led there.

F1, the review's better fix. `_refuse_an_occupied_work_dir` refuses,
before `_confirm` and before any leg repository exists, a work directory
that holds anything at `<work>/<spec leg>`, `<work>/<code leg>` or
`<work>/<assembly>` other than an empty directory (`adopt-work-dir-
occupied`). That is what `git clone` refuses, and what a seeded leg's
first commit would take in. Its remediation names a `--work-dir` that is
new or empty, or none. It is the first refusal of what an earlier run
left, ahead of `adopt-branch-exists` and so of `leg-remote-exists`. That
way their own "run `execute` again" meets a free work directory, and
`adopt-branch-exists`'s way out now works as written.

A default run is never refused: `_work_root` makes a new, empty
directory with `mkdtemp`. A new path or an empty one holds nothing either.

The other ways out, made to work as written:
- `SHAPE_FILE_EXIT` said "re-run into fresh legs", which left out the
  work directory and the branch. It now says "re-run as the end of this
  report says". It is printed only in a failed verification's findings,
  and that footer names the legs, the work directory and the branch.
- #200's MOUNT_REMEDIATION already names an empty `--work-dir`, or none.
  Its text is unchanged. Its test now also sees that a re-run which keeps
  the work directory is refused before it makes a leg repository.
- The notice (`_nothing_rolled_back`), below.

F2. The notice never said to fix what failed, so a cause that was still
there (a hook, a ruleset, a symlink loop) made a new pair of legs on
every attempt. It now reads "Once what failed above is fixed, re-run the
adoption with them deleted or with fresh ones". For a run that was
STOPPED, by Ctrl-C say, it reads "Re-run the adoption with ...", since
nothing failed.

N2. The notice said "`git clone` refuses a directory this run has already
cloned into" even when nothing was cloned (the code leg's repository
failing, #188 N4). Its work-directory sentence is now read off the disk.
It is printed only when this run built something there, and names what:
"Use a fresh --work-dir as well, or none: <work> holds Northwind-spec,
Northwind-code and Northwind from this run, and `execute` refuses a
--work-dir that holds them."

Tests (tests/test_adopt_late_failure.py, tests/test_adopt_filter_repo_
failure.py, tests/test_adopt_leg_path_collisions.py):
- New: a work directory holding a leg's clone, the split's, or a file at
  a leg's path is refused before anything exists and ahead of the branch
  left beside it, with the work directory left unchanged. A default, new
  or empty work directory reaches the confirmation.
- The failed-verification e2e now follows the review's chain. A re-run
  into fresh legs that keeps the work directory is refused for it, with
  nothing made. Its way out meets `adopt-branch-exists`, with nothing
  made. That way out as written (the printed deletion, then the same
  command again) ends in `adoption verified`.
- The notice's tests read the fix-first opening, the STOPPED opening, a
  work-directory sentence that names exactly what was built, and none
  when nothing was (N4).

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 11, 2026
… add`, so a leg path an ignore rule matches (`__pycache__`, `.DS_Store`, or the default `spec` under an operator's own excludes) scaffolds instead of dying at the mount after all three repositories exist and both legs are pushed (#229) (#235)

scaffold-project.py's leg mount passes `--force` to `git submodule add`, as #200 did for adopt. A leg path that the shape's `.gitignore` or the operator's own excludes match (`__pycache__`, `.DS_Store`, or the default `spec`/`code` under global excludes) now scaffolds, instead of dying at the mount after all three repositories exist and both legs are pushed.

The assembly root is initialised with `git init --template=`, so an operator template cannot plant a module store that `--force` would reactivate. The code comment says exactly what `--force` changes in git 2.43, and why none of it can arise here.

- `tests/test_scaffold_mount_ignored.py` (new, 42 tests). Each case proves the ignore rule really matches. Then the pushed gitlinks must equal the legs' tips, and a clean recursive clone must validate and bootstrap.

Reviewed adversarially; its one MUST, the template-planted store, is fixed in this change and was re-checked. CI is green on Linux, macOS and Windows.

Closes #229

Lane: openreposhape-4 (openRepoShape-4)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 11, 2026
…cord-submodule-placement

Brings in 20e13f0 (#172 via #198), 8df21e6 (#179 via #201), a5b09c3
(#174 via #200) and 54aa69a (#165 via #173) on top of e4decfb. No rebase.

Conflicts, and how each was resolved:

- adopt-project.py, the module docstring's `execute` paragraph (textual).
  #173 ended the VERIFIES sentence with "and that the root's only
  submodules are the two leg mounts"; #189 added the sentence saying the
  split's `project.yaml` records each kept submodule's leg under
  `submodules:`. Kept both: main's clause closes the sentence, #189's
  sentence follows it. The docstring is not part of docs/cli.md
  (`render-cli-reference.py --check`: ok).

- tests/test_shape_doctor.py,
  `test_a_submodule_in_the_other_leg_from_its_record_is_misplaced`
  (semantic; the text merged cleanly). #198 made `_leg_findings(plan,
  tree)` take `tree` with no default, on purpose
  (tests/test_adopt_leg_path_collisions.py,
  `test_leg_findings_takes_no_default_tree`), and this branch's test
  called it with one argument, so it died with `TypeError: _leg_findings()
  missing 1 required positional argument: 'tree'`. It now passes `None`,
  as main's other placement-plan callers do: a placement plan has no
  source tree. This is P2-1 of lane openRepoShape-2's review of e167d8b.

`_leg_findings(plan, tree)` is main's, unchanged. `_commit_the_split`
auto-merged with the record's `append` intact. #189's 16 tests (36 items)
pass on this merge.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 12, 2026
…hat `place` will find, so `CLAUDE.md -> /home/me/CLAUDE.md` adopts beside it as on main while one to nothing there is refused before any leg, and a link that leads the shape's copy onto something already there, or a case twin, is refused too (#183, #178)

The review of 04792d2 found the walker refusing plans main adopts, and
passing plans main breaks after both legs exist. This answers each item.

B1. A link AT a path the shape writes is decided by what the materializer
will do with it. `place` asks whether something is already at the path,
following every link on the way. Where something is, it writes the shape's
copy beside it under `shape/` and never writes through the link; where
nothing is, it writes through. `_PlannedRoot` now simulates `place` in
`assembly_root_paths()` order. The simulation holds what the shape has
written by then, `.gitmodules`, and what each mounted leg will hold: the
paths the plan sends to it, or the seeded template, read through the new
`template_files`, which `copy_tree` now uses too.

A destination outside the assembly is asked of this machine's disk: an
absolute target as it stands, and a `..` climb from the work directory,
where `execute` makes the assembly's clone. A climb that comes back into
the assembly by its own name goes on inside. A climb into a leg's clone or
path list is refused, because `execute` makes those only after this check.
`check` and `execute` each ask their own disk, `execute` before any leg
exists. So `CLAUDE.md -> <abs>/CLAUDE.md` adopts, verified and
bootstrapped, when the file is there, and is refused ("..., and nothing is
there") when it is not; a two-link chain to an absolute target behaves the
same.

A link ABOVE a path the shape writes is a directory the shape writes into,
so it must still lead to a directory the root holds.

B2. The shape's copy under `shape/` is written without asking again. So a
link that leads a copy onto something already there is refused:
`shape -> .` would write over the source's README.md, and a copy that
lands on a directory raised IsADirectoryError. `shape -> vendor`, where
vendor/ holds none of the copies' names (R7), is still adopted, as on
main. The materializer refuses the same landing, for a caller that skipped
`check`.

S1. The paths are followed twice, keeping case and then folding it. A
finding only the folded walk makes carries #198's CASE_ASIDE. So
`.GitHub -> ../outside-ci` is refused like `.github -> ../outside-ci`, on
every disk, as #169, #198 and #200 refuse their twins. `adopt-symlinks-off`
names a case twin with the same aside.

S2. The materializer takes `..`, `.` and an empty part of a link's target
only from a directory that is there, as `open()` does. So `Makefile -> ci/`,
`a/..` and `README.md/..` are named `materialize-blocked` refusals, where
main raised IsADirectoryError, FileNotFoundError and NotADirectoryError. A
link whose target is empty is a refusal of its own, not `.`.

NITs:
- N6: findings spell links and targets with `_spelled`.
- N4: `_git_path` decodes a target.
- N3: no `" and "` literal.
- N5: the test's unused `source` is gone.
- N1: `UNWRITABLE_REMEDIATION` names the work directory as #200's does.
- N9: the `WINDOWS_ABSOLUTE_RE` comment names `_PlannedRoot`.
- N10: a link with an empty target is a finding of its own, to be fixed in
  the source. Linux cannot hold one, and both of `execute`'s clones of the
  source check it out, wherever the plan sends it.

tests/test_adopt_root_symlinks.py goes from 58 to 94 tests. Every old name
is kept, with its wording moved to the new form, and the new ones cover:
- B1 both ways (a direct link and a two-link chain), `execute` asking its
  own disk, a climb into the work directory both ways, into a leg's clone,
  and back by the assembly's name;
- the shape's own earlier writes, and leg mounts (holding, lacking, seeded,
  onto the mount);
- B2 (four cases), S1 (at, above, inside, and with symlinks off);
- spelled non-UTF-8 and newline targets, and the empty target in `check`
  and in the materializer;
- S2's three shapes, and the copy onto a file and into a directory;
- the end to end of B1: verified, the split keeps the link, recursive
  clone and bootstrap.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 12, 2026
…`git --literal-pathspecs add -f`, so an operator whose own excludes name `members`, `members/`, `*` or the member gets one commit instead of exit 2, `bump` moves a pin under them too, and each refusal `--force` turns off is made before the member is read (#242) (#308)

`add` ran `git submodule add` with no `--force` and `_commit_one` a plain
`git add`, and both read a global `core.excludesFile`. `members/` is a fixed
path, so an operator whose excludes named `members`, `members/`, `*` or the
member's name had every add of every family refused: git's dry run refused
the first four before the clone, and a directory-only rule on the member's
name (`Atlas/`) refused it only at git's last `git add`, after the clone.
`bump` died the same way under `members` or `*`: it stages the gitlink
twice, at the `git add` #219 put before its nothing-to-record check and in
`_commit_one`, and both read the excludes. This is #174 (adopt, fixed
by #200) and #229 (scaffold) on the family side.

Every reader is forced now. The mount passes `--force`, and every stage
`add`, `bump` and `remove` make is `shape_materialize.force_stage` (#233),
`git --literal-pathspecs add -f -- <paths>`: `-f` reaches only the named
paths, each taken literally, so no ignored neighbour a glob character would
match is staged with them (#202). One definition: `_commit_one` and `bump`'s
re-stage both call it.

`--force` turns off more than the ignore check, so each other thing it
changes is refused before the member is read, the holder left exactly as it
was, and a comment at the mount names each guard:
- a `.git/modules/<path>` left by a removed member, which `--force`
  reactivates: `member-git-dir-cached` (#236), at the store `git rev-parse
  --git-path` names, a linked worktree's included;
- an index entry at the path or under it with nothing on disk, which
  `--force` accepts and replaces with the member's gitlink:
  `member-path-taken` now asks the index too, and names the
  `git rm -r --cached` that clears it; on disk it asks `lexists`, so a
  dangling link is refused as well;
- git's own dry run, which `--force` skips (a symlinked `members` had the
  member cloned through the link, outside the holder; a `members` that is a
  submodule had it cloned into that submodule's tree): `member-path-unaddable`
  makes the same dry run first, with `-f`, so an ignore rule passes it and
  nothing else does; the refusal quotes git's line, and its remediation
  presumes neither a link nor a submodule (a held `index.lock` fails it
  too);
- a name another submodule already has, which git 2.51 and later rename the
  mount past and git 2.43 answers by rewriting the other section:
  `member-name-taken`, reading `.gitmodules` where git reads it (the working
  tree, else the index's copy, else HEAD's).
The PRIVATE/access sentence is printed only for the probe's failed clone of
the member, which no ignore rule reaches.

tests/test_family_add_excludes.py: under `members`, `members/`, `*`, `IRQS`,
`IRQS/` and none, `add` is ONE commit of `.gitmodules`, `family.yaml` and a
160000 gitlink at the member's tip, read with `git ls-tree`, that validates
under the same excludes and clones recursively for an operator with none;
`bump` under `members` moves the gitlink in one commit and `remove` is the
control; each guard above is refused before the member is read with the
holder unchanged. Mutations: without `--force` at the mount every rule's row
fails; without `-f` in `_commit_one` the `members`, `members/` and `*` rows
and the bump test fail; with `bump`'s re-stage a plain `git add` the bump
test fails; dropping the index check, the dry run, the name check, its
index/HEAD fallback or `lexists` fails exactly that guard's tests.

Closes #242

Lane: openreposhape-4 (openRepoShape-4)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 12, 2026
…d the verification refuses a mount whose gitlink is not the commit pushed to its leg (`adopt-mount-commit`), so an operator's `init.templateDir` holding `modules/spec` and `modules/code` no longer ends `adoption verified` over a split nobody can clone (#243) (#268)

`_commit_the_split` cloned the source with a plain `git clone`, which copies the operator's git template (`init.templateDir`, or `GIT_TEMPLATE_DIR`) into the assembly's `.git`. A template holding non-bare stores at `modules/spec` and `modules/code`, as a copy of a working Triad root's `.git` does, left `.git/modules/spec` and `.git/modules/code` there, and the mounts' `git submodule add --force` (#174, #200) reactivated them instead of refusing. Both gitlinks pushed on the split branch were then a stranger's commit, `execute` exited 0 and printed `adoption verified` over them, and `git clone --recurse-submodules` of the pushed branch exited 128. The verification checked that a mount holds a gitlink (#173) and never which commit. Reproduced on 39ac59c: gitlinks `c4a30be1705b` for both mounts, the legs pushed at `130ce8cf62dd` and `2564b5900076`, and `fatal: ... did not contain c4a30be1705b0fa270b35d5de5be8a681d436b92`.

Two changes, which are not alternatives:
- `_commit_the_split` clones with `--template=`, git's documented way to use none, as the scaffold's `git init` has since #229. The assembly's `.git/modules` is therefore empty when `_mount_the_legs` runs, and `git submodule add --force` has nothing to reactivate. The comment at the clone says why, and the comment in `_mount_the_legs` that argued no `.git/modules/<name>` is in the fresh clone now says what makes that true.
- `_verify` calls the new `_mount_commit_findings(tree, mounts, pushed)`, which reads the split tree `_verify` already reads and the `mounts` mapping `_land_the_root_tree` already takes. It reports `adopt-mount-commit` for each mount whose gitlink names any commit but the one pushed to its leg, whatever put the other commit there. `_pushed_commits` is the `HEAD` of each leg's work directory, which `_extract_leg` and `_seed_leg` push and whose tree `_verify` already accounts for. The question is asked of a gitlink only: a mount path that holds none stays `adopt-mount-missing` (#173), said once. The check does not undo the push, as no finding does; only the clone's `--template=` prevents the harm. `_land_the_root_tree` keeps its four-argument signature, since `tests/test_adopt_finding_spelling.py` and `tests/test_adopt_submodules.py` call it with four. The module docstring's `execute` bullet says each mount is at the commit pushed to its leg.

The other repositories `execute` makes keep the operator's template, because none is mounted into: the legs' bare remotes, the legs' work trees (the mount's `git submodule add` clones them by path, and a clone copies objects and refs, never a `.git/modules`) and the seeded legs.

One behaviour changes besides the cure. With no template the assembly has no `.git/hooks`, so hooks a git template installs (git-secrets and the pre-commit framework's `init-templatedir` both document that setup) no longer run on the split's commit and push, as they did before. Hooks set with `core.hooksPath` still run there, and the legs keep their template's hooks. The comment at the clone says so.

Tests: `tests/test_adopt_clone_template.py` is new, 31 tests, all passing at this head with `git filter-repo`. The 17 that run `execute` skip without it; the other 14 build their legs by hand and run on every OS (14 passed, 17 skipped without it). The operator's configuration reaches git through `GIT_CONFIG_GLOBAL`, a file each test writes, and the stranger's `.git` is copied with `shutil.copytree`, so nothing reads or writes a real configuration.
- 2: the premise, asked of git. A plain clone under the template gets the stranger's store and `--template=` gets none, for `init.templateDir` and for `GIT_TEMPLATE_DIR`.
- 16: `execute` end to end in four cases (template by configuration, template by environment, stores with no `origin`, and the no-template control), four tests each. `check` is ok and `execute` exits 0 with `adoption verified`; each gitlink on the pushed split branch equals its leg's pushed tip and is never the planted commit; the work directory's `.git/modules` holds only the two stores the mounts made; a recursive clone under a clean configuration succeeds, and `validate-manifest.py`, `validate-pins.py` and `bootstrap.py` pass in it.
- 10: the verification on its own, with no template, on hand-made splits. The control (the default and the plan's own mount paths); a swapped spec, code or both mount at both path spellings, with the exact finding text; a mount at an OLDER commit of its own leg, since the comparison is exact; and a missing mount, which stays one `adopt-mount-missing`.
- 2: the real `_mount_the_legs` over a clone made under the template, with no `git filter-repo`. A plain clone mounts the planted commit and the verification refuses both mounts; cloned with `--template=`, the same mounts are the legs' tips and verify.
- 1: `cmd_execute` with the spec mount's checkout moved after the mount: exit 1, the finding, no `adoption verified`, and the split pushed.

Run against main's `adopt-project.py` (c7c02fa), 19 of the 31 fail and 12 pass. The failures are the issue's. The gitlinks are the planted commit; the clean recursive clone exits 128; the no-`origin` variant exits 2 at `git remote set-url origin`; and the swapped or planted mounts still end `adoption verified` (`assert 0 == 1`, nine times). The 12 that pass are the premise, the control and the cases that hold on main. Measured at 06cb68e, without `--template=` on the clone 12 fail (the end-to-end tests of the three template cases), and without the `_mount_commit_findings` call 9 fail (the verification tests). With no template the run is unchanged: one source repository copied twice and adopted by main's `adopt-project.py` and by 65073c1's gave the same split tree, leg tips, stdout (but for the split commit's own line), stderr, `.git/modules` names and `.git/config`.

The first head failed 12 of these tests on tests-windows, each with one extra `adopt-lost` finding for the source's README.md. The fault was the test's: `the_source()` wrote that file through `write_text`, which writes CRLF on Windows, while the split's copy is LF, so the two were different blobs. It now writes the file byte-exact, as the split's is. `write_text(newline=...)` is not used because it needs Python 3.10 and the baseline is 3.9. Under an emulation of Windows' text-mode `write_text` and with no `git filter-repo` on PATH, the first head gave CI's result exactly (12 failed, 2 passed, 17 skipped) and this one gives 14 passed and 17 skipped.

Left out:
- The check does not undo the push. When it fires, the finding says the split is wrong and not to merge it, and the usual closing paragraph says the legs and the branch exist.
- Template hooks no longer run on the assembly's commit and push, as above.
- Nothing else in `adopt-project.py` changes: no `--help` text (`render-cli-reference.py --check` is ok), no plan field, no other finding.

Reviewed adversarially by this lane at 65073c1 (CHANGES NEEDED: the 12 tests-windows failures, a test-only fault, and two P3s, a merge note in the PR body and the missing sentence on hooks) and re-verified at 06cb68e after fix round 1 (MERGEABLE WITH NITS).

Lane: openreposhape-2 (openRepoShape-2)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 12, 2026
Main brings five commits since 6d8d88b:

- ede15ce (#238 via #287): shape-doctor.py's validator rows;
- 6f45bf9 (#196 via #231): `entry_path_problem`, one test of an entry's
  path for `check` and `execute`;
- b421e6b (#254 via #281): bump-leg.py and update-shape.py give the
  validators an explicit PYTHONIOENCODING (scripts/shape_materialize.py
  gains `captured_child_environment` and `inherited_child_environment`);
- c0ed615 (#242 via #308): family.py's `add` and `bump` under excludes;
- 71b58a1 (#262, #263 via #313): `check` finds, and `execute` refuses, a
  kept root path where the shape writes a directory or its `shape/`
  copy, and the materializer never writes over a copy.

It merged with no conflict. Only adopt-project.py changed on both sides.
Every other file the merge changes against this branch is main's, and
every file it changes against main is this branch's. In adopt-project.py
the merge's diff against this branch is main's own diff (559 lines), and
its diff against main is this branch's own diff (784 lines). Main's
twenty hunks there, by where they land:

1-2. the module docstring: `check` validates each entry's path and keeps
     no path in the root where the shape writes (6f45bf9, 71b58a1);
3. the `from shape_materialize import` block: `CASE_ASIDE`,
   `MOVE_THE_LEG`, `first_and_more` (71b58a1);
4-6. `_leg_findings`: a docstring line, the call to
     `_root_shape_findings`, and the new block after it (`ROOT_BLOCKS_SHAPE`,
     `ROOT_BLOCKS_COPY`, `_KeptTree`, `_shape_blocks`, `_blocked_sentence`,
     `_fix_the_kept_path`, `_root_shape_findings`) (71b58a1);
7. after `_submodule_findings`: `NOT_EXTRACTED`, `entry_path_problem`,
   `_misread`, `_refused_by_policy` and `_unsafe_path_findings` (6f45bf9);
8-11. `_entry_findings`: its docstring, and the entries' path findings
      first (6f45bf9);
12-13. `_extract_leg`: `literal:` on every `--paths-from-file` line
       (6f45bf9). This branch changed `_extract_leg` as well, further
       down: it reads the commit count and the digest before
       `_push_the_leg`. The two sets of lines do not touch, and the
       merged function has both;
14-15. `_mount_the_legs`: `git --literal-pathspecs rm` (6f45bf9);
16-17. `_leg_paths`: collected, not judged (6f45bf9);
18-20. `_refuse_what_check_finds`: its docstring and remediation
       (6f45bf9, 71b58a1).

The new findings of 6f45bf9 and 71b58a1 are `_entry_findings`, which
`cmd_execute` reaches only through `_refuse_what_check_finds`, before
`_create_leg_remotes`. So they are refused before any leg exists, and no
notice is due. The materializer's new `materialize-copy-blocked` is
raised after both legs are pushed, inside `_commit_the_split`, when a run
reaches the materializer without `check`'s finding. That makes it a late
failure, which this branch reports with the notice and exit 2. Main's
`test_with_check_skipped_execute_stops_at_the_copy_and_overwrites_nothing`
expects it to escape `cmd_execute`, so this merge breaks that test, as
9092fda's merge of #200 broke the mount-guard tests. The next commit
makes the test read the reported refusal.

No top-level name is bound twice in adopt-project.py, scaffold-project.py,
scripts/repo_shape.py, scripts/shape_materialize.py or tests/conftest.py.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 12, 2026
…ute` reports, so it no longer fails on this branch with `DID NOT RAISE Refusal` (#188, #262)

71b58a1 (#262, #263) gives the materializer a `materialize-copy-blocked`
refusal. adopt-project.py meets it inside `_commit_the_split`, after both
legs are pushed, when a run reaches the materializer without `check`'s
`plan-root-blocks-shape-copy`. On main it escapes `cmd_execute`. On this
branch it is a late failure: it is reported under its step, with the
notice, and `execute` exits 2. So the merge (922f2d8) failed
`test_with_check_skipped_execute_stops_at_the_copy_and_overwrites_nothing`
with `DID NOT RAISE Refusal`, while its stderr held "REFUSED committing
the split. materialize-copy-blocked: the shape's copy of `README.md`
cannot be written to `shape/README.md`: ...".

The test now asks the materializer what it raised, through
`refused_in_the_materializer`, as 8d4fef4's `refused_at_the_mount` asks
#200's mount guard. It asserts that `cmd_execute` returns 2, that the
refusal's code, detail and remediation are printed under `committing
the split`, and that the notice is the last line. Main's own assertions
are kept: the code, the detail, no split branch, the source's file as it
was, and both legs pushed.

Revert: with main's version of the test, it fails `DID NOT RAISE
Refusal` (1 failed, at the merge's tree 098d09f).

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 13, 2026
…d `open_glass` share one `SHAPE_PIN_SOURCE_<PRODUCT>`, so `--pin` refuses the pair and `validate-pins.py` notes a declared one and reads the variable for neither (#275) (#409)

`pin_source_env_name` turns every character outside `[A-Z0-9_]` into `_`, so
`open-glass`, `open_glass` and `open.glass` are three legal product names, with
three pin files (`contracts/<product lowercased>-pin.yaml`), and one variable,
`SHAPE_PIN_SOURCE_OPEN_GLASS`. On ab623dd (this branch's main parent; the same
rows reproduce on c7c02fa), with the issue's own probe against local bare
remotes and a `gh` that exits 97:

| step | ab623dd | this head (6494714) |
|---|---|---|
| `scaffold-project.py --pin open-glass@<A> --pin open_glass@<B>` | exit 0, three repositories | exit 2 `scaffold-pin-collides`, nothing created |
| `validate-pins.py`, no source, on a project that already declares the pair | exit 0, both skips offer `SHAPE_PIN_SOURCE_OPEN_GLASS` | exit 0, one `note neutral-pin-source-collides`; the skips offer `--pin-source <product>=<path>` and a sibling checkout only |
| `SHAPE_PIN_SOURCE_OPEN_GLASS=<open-glass>` | `neutral-pin-source-unreadable` for `open_glass`, exit 1 | exit 0, the note; the variable is read for neither pin, so each pin is read from its own source or skipped |
| `SHAPE_PIN_SOURCE_OPEN_GLASS=<open_glass>` | `neutral-pin-source-unreadable` for `open-glass`, exit 1 | the same |
| `--pin-source open-glass=... --pin-source open_glass=...` | exit 0 | both pins recompute, exit 0, the note |

**What changed.** Every variable name is kept: an operator may have set one and
the docs name them. What is done instead:

- `scripts/repo_shape.py`: `pin_source_env_collisions(products)` is the one
  pure answer, `{variable: [products]}` for each variable two or more distinct
  products share. Distinct means distinct PIN FILES (`pin_product_key`,
  `lower()`, which is what `contracts/<product lowercased>-pin.yaml` is named
  by), so a product typed twice or in two cases is #241's file collision and
  never this one. `pin_source_env_shared` is the set of those keys.
- `scaffold-project.py`: `_refuse_colliding_pins` (left where it is) names each
  variable's `--pin` arguments as typed after #241's file sentences, in the same
  `scaffold-pin-collides` refusal. Dry run and real run say the same no, before
  any process starts and ahead of the leg-path refusal. #241's wording and
  remediation are unchanged when only a file collides. A NEW pair is still
  refused, so the situation is not created anew.
- `templates/assembly-root/scripts/validate-pins.py`: one NOTE per variable,
  `neutral-pin-source-collides`, naming every product and the variable, the
  keyed `--pin-source <product>=<path>` that reads each pin, and that which
  declaration stays is the human's decision. It is never a finding and never
  moves the exit code. A product whose variable is shared does not read it (rule
  2 of `resolve_neutral_pin_source`), and its skip hint offers the keyed
  `--pin-source <product>=<path>` and not the variable or the bare form.
  A variable one product has to itself reads and is offered exactly as before.
- `scripts/repo_shape.py`, the two chain readers: `link_pins_from_trees` does
  not read a variable two links of one chain share, and the
  `declared-unverified` hint stops naming it. Only a hand-written chain can have
  two such links, since scaffold takes every link but the first from the naming
  policy's alphanumeric `open<Product>` form.

Each reader of `pin_source_env_name`, decided:

| site | decision |
|---|---|
| `scaffold-project.py --pin` | refuse (above) |
| `validate-pins.py` rule 2 and the skip hint | a note, and the variable is neither read nor offered for a shared product |
| `repo_shape.py` `resolve_link_source` (via `link_pins_from_trees`) | skip the variable when another link of the chain shares it |
| `repo_shape.py` `_chain_link_findings` hint | omit the variable for a shared link |
| `adopt-project.py --pin`, `plan`, `check`, `execute` | not in this PR, see below |

**Fix round 1 (from the review of 34dbd86).**

**The design change: a declared pair is a NOTE and not a finding. This is the
lane coordinator's decision, and Brett may reverse it.** The first round made
`neutral-pin-source-collides` a FINDING. Main through ab623dd scaffolds such a
project (`--pin open-glass@A --pin open_glass@B` exits 0), and
`update-shape.py apply` runs the NEW `validate-pins.py` over the rewritten root,
so for a project already declaring the pair the finding ended every apply as
`REFUSED update-validators-red`, rolled back, for this update and every later
one, until a person deleted a true declaration of descent. AGENTS.md tells an
agent never to edit "a pinned file, a digest or a manifest to make a row go
green", and the finding's remediation was exactly that, so the person was
locked out. The coordinator chose the review's option (b): it is a NOTE now.
The guard stays (the variable is read for neither pin), each pin still verifies
from its own source, scaffold still refuses a new pair, and `validate-pins.py`
says the rest in one line. To put the finding back, restore 34dbd86's
`report.finding(...)` call in `_report_pin_source_collisions` (it is not a word
swap for `report.advise`: `advise` takes one string, `finding` a code and a
detail), give the finding the remediation 34dbd86 had, and turn the tests that
expect the note (and `test_a_project_declaring_a_colliding_pair_takes_a_shape_update`)
back into exit 1; the first round's versions of all of them are on 34dbd86.

- **Proved on a real old project.** Main (ab623dd) scaffolded the pair into
  local bare remotes; `update-shape.py apply` to the first round's head 34dbd86
  exited 2 `REFUSED update-validators-red` and rolled back (`git branch` shows
  only `main`); to this head it exits 0, the project's validator passes and
  prints the note, and the doctor's `pins` row is `ok` before and after. The
  doctor prints `passes` for a validator that exits 0 and does not echo its
  stdout, so the note itself is visible in `update-shape.py apply`'s output and
  in `validate-pins.py`'s, and the verdict moves for no reason but the update
  (`COMPLIANT, SHAPE BEHIND` to `COMPLIANT`). It is now a test:
  `test_a_project_declaring_a_colliding_pair_takes_a_shape_update`, over local
  stand-ins beside the project, so no `gh` is asked.
- **Collisions by the variable.** Pairs were decided by `casefold()`, but
  the pin file is `lower()`. `openß`/`openss`, `openſ`/`opens`, `openfi`/`openfi`
  and `openς`/`openσ` (the letters are U+00DF, U+017F, U+FB01 and U+03C2 beside
  U+03C3) share a variable and have two pin files, and were never found. They
  are now, from the pin-file fold (`pin_product_key`). A pool of 31
  names is checked pairwise against `neutral_pin_path` and
  `pin_source_env_name` themselves, and no single product is ever a collision.
  They are reachable only from a hand-written `project.yaml`.
- **Windows.** The guard's only test needed the `#!` `gh` stub and was
  skipped on Windows. `test_a_shared_variable_answers_for_neither_pin_with_no_gh`
  puts a checkout of each pin beside the project, names one in the variable, and
  needs no `gh`: on ab623dd it is `neutral-pin-source-unreadable`, here each pin
  reads its own sibling. The hint and the non-ASCII rows are tested in-process,
  with no skip and no filesystem.
- **The hint.** For a product two pins share, the skip hint offers the keyed
  `--pin-source <product>=<path>`: the bare form answers for every pin with no
  more specific source, so with two pins it gives the other the finding this
  issue is about.
- **Trailers and title.** The trailers of the earlier commits (a30091f and
  34dbd86 name Sonnet 5.5) are settled in this message, which carries Opus 5.5.
  The PR title now names `repo_shape.py`.
- `scaffold-project.py` is not touched this round: `fix/adopt-pin-writes-pin-file`
  moves that code, and the change would only conflict with it.

**Left out.**

- `adopt-project.py` is untouched. Its half arrives with #273's PR, which moves
  scaffold's pin machinery into a shared module and routes adopt through
  `pin_source_env_collisions`. Once it lands, the one place that still keys by
  `casefold()` (`pin_variable_collisions` in `scripts/shape_materialize.py`)
  should read `pin_product_key`; it cannot differ for an ASCII `--pin`, which
  is all `PIN_ARG_RE` takes.
- `scaffold-project.py`'s own `_colliding_pin_variables` also keys its
  argument lists by `casefold()` and one docstring there still says the
  project's validator reports the pair "as a finding"; both go with the code
  when #273 moves it. #312's `PinSources` keys `--pin-source` by `casefold()`
  too, so `openß=` and `openss=` are one key there; that is #312's.
- A product in `neutral_product_pins:` and a chain link in
  `naming.referent_chain` that share a variable are read by two validators in
  one process, and neither sees both sets. Not detected here.
- The doctor does not print a passing validator's stdout, so its `pins` row
  does not carry the note. Not changed: it would add a file to this PR.
- No `--help` text changed, so `docs/cli.md` is untouched. `README.md` is at its
  line cap and its blob is pinned by `docs/handbook.html`, so the one README
  sentence this wants needs a regenerated handbook and waits for its own change.
- `validate-pins.py` and `repo_shape.py` ship into projects, so every project's
  `shape-pin.yaml` reads `upstream-changed` for both until `update-shape.py
  apply`, which now succeeds for a project that declares such a pair.

**Evidence.** All on the head (6494714), with git-filter-repo 2.47.0 on PATH, a
`gh` that cannot be reached (a stub first on PATH, `GH_TOKEN` bogus, an empty
`GH_CONFIG_DIR`), and the repository-local `user.name` blanked at command-line
scope, as the standard's checkout sets one that two scaffold tests read.

- `tests/test_pin_source_env_collisions.py` is 137 tests and passes on this
  head. Laid over 34dbd86, 50 fail and 87 pass: the note and update tests, the
  non-ASCII rows, the hint, the sibling guard, and `pin_product_key` itself
  (which 34dbd86 does not have); the scaffold refusals, the chain readers and
  the controls hold on both.
- Targeted, run on ad6f569, whose tree differs from this head in
  `tests/test_pin_source_env_collisions.py` only (the last edits made one
  comparison read the committed blob and wrapped one line): the new file,
  `test_pin_validator`, `test_neutral_pin_validator`, `test_cli_reference`,
  `test_manifest_validator`, `test_naming_policy` and `test_repo_hygiene`
  **445 passed**; the scaffold pin, collision, referent-chain, leg-path and e2e
  files **245 passed**; `tests/test_update_shape*.py` **218 passed, 3 skipped**
  (junctions, NTFS only); `tests/test_shape_doctor.py` **254 passed, 3 skipped**
  (the PowerShell line, a Windows host only).
- On this head itself: the new file, `test_repo_hygiene`, `test_cli_reference`,
  `test_pin_validator` and `test_neutral_pin_validator` **244 passed**.
- This head merged with origin/main a983e6a, in a throwaway worktree: the new
  file, `test_pin_validator`, `test_neutral_pin_validator`, the scaffold pin,
  collision, referent-chain and e2e files, the whole doctor file and
  `test_cli_reference` **590 passed, 3 skipped** (the PowerShell line); the new
  file alone, in its final form, **137 passed**. origin/main had moved twice
  since; the merge-tree below is against it.
- Twelve mutation probes, each hunk reverted alone: all caught. The
  note-to-finding one is caught by the update test (a committed mutant, since the
  test clones the repository's HEAD) and the guards by the sibling test, run with
  every test that needs a `#!` stub deselected as a Windows runner would;
  the hint one by an in-process test.
- Nothing ran on macOS or Windows before this PR's CI.

**Merge-tree, as computed during the fix round on 2026-10-12** (every sha and
head is the one it had then; main and the other branches have moved since).
`git merge-tree --write-tree` of this head (6494714) against origin/main 1f90a0f
is clean, and so is the merge of origin/main a983e6a, which the merged-tree runs
above used. #312, #309, #270, #268, #228, #245 and #351 have landed. The rest
were computed on ad6f569 (the same tree but for one test file) against
a983e6a. Open PRs touching this branch's files, all clean against the head: #314, #355
and #373 (`scaffold-project.py`), #343 (`validate-pins.py`), #390 (`repo_shape.py`)
and #394 (`repo_shape.py`, which conflicts with origin/main by itself). The other 25 open PRs and the lane-5 branches
`fix/adopt-check-link-and-manifest`, `fix/scaffold-free-text-values`,
`fix/family-init-values`, `docs/adopt-execute-exits`,
`fix/yaml-flow-brackets-surrogates` and `fix/adopt-pin-writes-pin-file`
(#273's, 7a94b6b, also clean for this head) are clean too. #356, #382 and
`fix/adopt-record-submodule-placement` conflict with origin/main and not with
this head; #358, `fix/adopt-late-failure-notice` and
`fix/adopt-plan-quote-yaml-keywords` conflict with both, with origin/main by
themselves, so they are not this branch's. Neither are the five PRs below #200
that origin/main has not landed (#94, #96, #98, #100 and #161), which conflict
with it too. The PR set is read from the refs under `refs/pull/` that
origin/main's history has no `(#n)` subject for, not from GitHub, so a closed
one may be in it.

**One conflict, with `fix/link-source-values` (#338, 40762ca) in
`scripts/repo_shape.py`, four hunks.** Not resolved in either branch; take both
sides: (1) `resolve_link_source`'s signature, `default_source=None,
env_shared: bool = False, *, tried: list | None = None`; (2) its docstring, both
paragraphs; (3) `link_pins_from_trees`'s docstring, both paragraphs; (4) its
call, `default_source, pin_product_key(name) in shared, tried=asked)` followed
by #338's `if tried is not None: tried[name] = asked`. The auto-merged
`resolve_link_source` body already composes: a shared variable is never an
`env` candidate and so never appears in #338's `tried`.

**Known limits after the re-verification (APPROVE WITH NITS, 0 blockers, 0 should-fixes, 3 nits, at 6494714).** For the four non-ASCII pairs this change now detects (`ß`/`ss`, `ſ`/`s`, `fi`/`fi`, `ς`/`σ`), the keyed `--pin-source <product>=<path>` form does NOT separate the two pins: #312's source lookup folds both keys into one, so one pin can get a false `unreadable` finding. A sibling checkout does separate them. Only a hand-written `project.yaml` can declare such a pair. The doctor's `pins` row still prints only "passes" for a validator that passes, so it does not carry the collision note; that needs `shape-doctor.py`, and is left for a follow-up. The wording for restoring the finding is under "Fix round 1" above: it is 34dbd86's `report.finding(...)` call, not a word swap.

Reviewed adversarially at 34dbd86 (CHANGES NEEDED: 0 blockers, 2 should-fixes, 5 nits). The first should-fix was the finding itself, which locked a project that already declares the pair out of every `update-shape.py apply`; the second was a description that had gone stale. Fix round 1 (6494714) made the pair a NOTE, which is the coordinator's decision and one Brett may reverse (the way back is above), keyed collisions by the pin file's own fold, gave the guard a test that runs on Windows, and made a shared product's skip hint offer the keyed `--pin-source`. Its re-verification at 6494714 found every finding handled: APPROVE WITH NITS (0 blockers, 0 should-fixes, 3 nits: the keyed form and the non-ASCII pairs, the doctor's silence about the note, and the wording for restoring the finding, each stated above). CI is green on Linux, macOS and Windows, with SonarCloud passing, at b70a07d (main a73b4e9 merged in). Its merge with main 5a25387 passed the targeted set (the six pin and scaffold test files, `tests/test_validate_pins_unreadable_workflow.py`, `tests/test_ruleset_hint_tracking_branch.py` and `tests/test_shape_doctor.py`): 850 passed, 3 skipped.

Closes #275

Lane: openreposhape-5 (openRepoShape-5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment