Skip to content

scaffold-project.py _build_assembly_root runs git submodule add without --force, so a leg path an ignore rule matches (--code-path __pycache__ or .DS_Store under the shape's own .gitignore, or the default spec under an operator's global excludes) passes --dry-run, then dies at the mount AFTER all three repositories exist and both legs are pushed #229

Closed

Description

@brettheap

Lane: openreposhape-4 (openRepoShape-4)

Found by this lane's review of the #197 branch (aabfae0, its out-of-scope note O1), re-verified on main a5b09c3 today. Not claimed.

What is wrong. _build_assembly_root mounts each leg with git submodule add -q <leg working tree> <path> and no --force (scaffold-project.py:805-807 at a5b09c3). When an ignore rule matches the mount path, git refuses. The root is a fresh git init the materializer has just filled, so two sets of rules reach the mount: the shape's own templates/assembly-root/.gitignore (__pycache__/, *.py[cod], .venv/, .DS_Store), copied into the root, and the operator's own excludes (a global core.excludesFile; GIT_CONFIG_GLOBAL stands in for it below). The mount runs after _create_remotes (:967) and _seed_legs (:970) have created all three repositories and pushed both legs, so the run exits 2 with three repositories and no project. --dry-run returns at :946-948, after the plan, and asks nothing of any ignore rule, so it exits 0 for the same arguments; README's "If it fails part-way" box calls the plan "literally a --dry-run" and says there is no rollback, so the typed yes is given over a plan that cannot succeed. A corrected re-run is refused as scaffold-remote-exists, whose remedy for the legs is "Delete them, or scaffold under a different --project. There is no --force." Against GitHub the three repositories are real. This is #174 (adopt, fixed by #200) on the scaffold side; #175 (PR #185) made the scaffold force-STAGE what the shape wrote past the operator's excludes, and the mount, the other git step that reads ignore rules, was not part of it.

# $U: a clean checkout at a5b09c3. gh is a PATH shim that logs its argv and exits 97 (never called: its log was never created).
# Every repository is a bare repository under $R/remotes; no network.
scaffold="python3 $U/scaffold-project.py --org testorg --project Northwind --elected-by 'Test Human' \
          --elected-on 2026-09-02 --local-remote-dir $R/remotes"
$scaffold --work-dir $R/work --code-path __pycache__ --dry-run
#   exit 0   legs mounted at spec/ and __pycache__/ inside Northwind ... --dry-run: nothing was created.
$scaffold --work-dir $R/work --code-path __pycache__
#   exit 2   REFUSED a git or gh command failed. THE EXACT COMMAND WAS:
#                git -c protocol.file.allow=always submodule add -q $R/work/Northwind-code __pycache__
#                (in $R/work/Northwind)
#                exit 128
#            --- output ---
#            The following paths are ignored by one of your .gitignore files:
#            __pycache__
#            hint: Use -f if you really want to add them.
#            fatal: Failed to add submodule '__pycache__'
ls $R/remotes                    # Northwind-code.git  Northwind-spec.git  Northwind.git
for r in Northwind Northwind-spec Northwind-code; do git --git-dir $R/remotes/$r.git for-each-ref; done
#   Northwind: no refs (the root was never committed).  Northwind-spec, Northwind-code: refs/heads/main (pushed)
# the corrected re-run, same remotes directory, a path nothing ignores:
$scaffold --work-dir $R/work2 --code-path src
#   exit 2   REFUSED scaffold-remote-exists: $R/remotes/Northwind.git already exists
$scaffold --work-dir $R/work3 --code-path src --reuse-empty-repo
#   exit 2   REFUSED scaffold-remote-exists: $R/remotes/Northwind-spec.git already exists and has commits

The same on a5b09c3, one row per input (every real run left all three bare repositories and a root with no refs; gh was never called):

input rule that matches --dry-run real run git's own exit
--code-path __pycache__ .gitignore:1 __pycache__/ 0 2 128, after the leg was cloned into __pycache__/
--code-path legs/__pycache__ same 0 2 128
--code-path .venv .gitignore:3 .venv/ 0 2 128
--spec-path __pycache__ same, on the FIRST mount 0 2 128
--code-path legs.pyc .gitignore:2 *.py[cod] 0 2 1, before any clone
--code-path .DS_Store .gitignore:4 .DS_Store 0 2 1, before any clone
no path flags, global excludes code and spec the operator's core.excludesFile 0 2 1, at spec
--code-path src (control) none 0 0 none

The second-to-last row matters most: the DEFAULT paths fail for an operator whose own excludes name spec or code, and no spelling of the invocation avoids it.

Why. git submodule add runs git add --dry-run --ignore-missing before it clones and a plain git add after (seen with GIT_TRACE=1, git 2.43.0). A directory-only rule (__pycache__/, .venv/) cannot match a path that does not exist yet, so the first passes, the leg is cloned into the path and the second refuses (exit 128); a file rule (*.py[cod], .DS_Store, an operator's spec) is caught by the first (exit 1). Nothing asks an ignore rule anything before _create_remotes: the leg paths go through refuse_bad_leg_paths (scaffold-project.py:873, #179/#201), which reads their spelling only. adopt-project.py passes --force for exactly this (_mount_the_legs, :2389; reasons at :2373-2387; #174, #200) and _refuse_an_unmountable_path (:2275) refuses, before the add, the two things --force would otherwise let through. The scaffold has neither.

What it should do. Two ways; the issue asks for the first.

  1. --force on the mount, as 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 did (one token at scaffold-project.py:806-807). A gitlink that is added is tracked, so the rule never touches it again. It is the only fix that covers the operator's excludes, since a refusal there leaves nothing in the invocation for the operator to change. On a throwaway copy of a5b09c3 with that one change, every input in the table exits 0, the pushed root's HEAD holds both gitlinks, git clone --recurse-submodules of it succeeds, and the clone's own scripts/validate-manifest.py prints manifest ok and scripts/validate-pins.py prints pins ok. It changes nothing for the failures scaffold-project.py accepts a leg path that collides with a path the shape writes (--spec-path contracts, --code-path project.yaml), creates all three repositories and pushes both legs, then dies: #172's shape half on the scaffold side #197 owns: --code-path README.md, project.yaml, scripts and contracts die identically with and without --force. The two refusals --force turns off need no guard here: the index holds only the first mount's gitlink, refuse_bad_leg_paths already makes the two paths distinct and non-nested, and the template holds no symlink.
  2. A refusal before anything is created, like scaffold-project.py accepts a leg path that collides with a path the shape writes (--spec-path contracts, --code-path project.yaml), creates all three repositories and pushes both legs, then dies: #172's shape half on the scaffold side #197's _refuse_colliding_leg_paths and scaffold-project.py: a leg's mount path must be canonical or it is refused before anything is created, so --spec-path spec/ no longer scaffolds a project whose recursive clone fails once the work directory is gone (#179) #201's refuse_bad_leg_paths, placed before --dry-run returns so a dry run refuses too. It must ask git, not read the template's text, because the operator's excludes decide, and it must ask with the path as a DIRECTORY (git check-ignore --no-index -- __pycache__/, or create the directory first): git check-ignore -- __pycache__ on a path that does not exist answers "not ignored" for __pycache__/ and .venv/, the two rules that fail after the clone. (adopt-project.py _mount_the_legs runs git submodule add without --force, so a source .gitignore that hides a mount path (* + !.gitignore, or spec/code) dies at the mount AFTER both leg remotes are pushed, and nothing in check warns #174's suggested git check-ignore -q --no-index <path> has the same gap for its spec/ and code/ cases.) It cannot help the default-path case, where the operator's only answer is to edit their global excludes, and it refuses spellings (__pycache__, .venv) that --force turns into a working project, so it is a policy choice, not a correctness fix. If both are wanted, --force is the fix and the refusal a courtesy on top for the shape's own patterns.

How to test. A new tests/test_scaffold_mount_ignored.py, modelled on tests/test_scaffold_ignored_shape_files.py (its excluding() writes the global excludes through GIT_CONFIG_GLOBAL) and tests/test_scaffold_leg_paths.py, with --local-remote-dir and no gh. (a) The default paths under global excludes code and spec: exit 0, the pushed root's HEAD holds a gitlink at each path (git ls-tree, never the exit code alone), .gitmodules names the canonical remotes, a recursive clone succeeds and its validate-pins.py passes. (b) --code-path over a directory-only rule (__pycache__, git exits 128 after the clone), a nested one (legs/__pycache__) and two file rules (legs.pyc, .DS_Store, git exits 1 before it), plus --spec-path __pycache__ for the first mount, with the same assertions, and src as the control. (c) Removing --force makes (a) and (b) fail. (d) --code-path README.md, scripts and contracts still exit 2. If the refusal is chosen instead, (a) and (b) assert exit 2, no remote created, gh never asked, and --dry-run refusing with the same sentence.

Related: #174 (#200), #197

Activity

  1. brettheap commented on Oct 11, 2026

    @brettheap
    ContributorAuthor

    CLAIMED — lane openRepoShape-4, session 83338f75-6338-4d51-9749-89179ecaf55f@Eagle, 2026-10-11T19:04:22Z, for #229

    Logged in lanes/log/openRepoShape-4.md at 0a7ac85d55faf424867e3e5b1946b1ef63a3640a.

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions