Skip to content

adopt-project.py: verification passes over the two leg mounts and no other gitlink, so the source's own submodule kept in the root is adopt-root-submodule, any other root gitlink adopt-unexpected-gitlink, one in a leg AND the root adopt-duplicated, and a missing mount adopt-mount-missing (#165) - #173

Merged
brettheap merged 8 commits into
mainfrom
fix/adopt-verify-mounted-gitlinks
Oct 11, 2026

Conversation

@brettheap

@brettheap brettheap commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

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

Merge order: nothing left to wait for. #166 (#194) and #168 (#170) are on main. So are #167 (#182), #169 (#187), #172 with #191 (#198), #179 (#201) and #174 (#200). This branch has main a5b09c3 merged in, with no conflict. While #166 and #168 were open, this branch had to merge after both; the last section says why. Lane 2's P2-1, taken in c2723dd, makes the verification fail closed on a root-kept submodule, so it no longer depends on those refusals at all.

Head: 28fee0f. That is c2723dd, the round that takes lane 2's review, on top of 0448944. Then main was merged three times: 20e13f0 (2d979c9), 8df21e6 (b11d457) and a5b09c3 (28fee0f). The branch's diff over main is byte-identical at all four commits.

What

adopt-project.py's verification now passes over only the two gitlinks the shape adds: the leg mounts at legs.spec_path and legs.code_path. It used to pass over every gitlink in the split commit's root tree. Every other root gitlink is now accounted for the same way a blob is. Each one is ALSO a finding of its own, because the assembly root keeps no gitlink but the two mounts.

Why: reproduction on main

When #165 was filed, main was at 7f84ca4. The source had one commit with one real submodule, upstream/dependency, and the remotes were local bare repositories. The plan upstream/ -> root, .gitmodules -> code passed check and then failed verification on a false finding:

main   check exit 0, execute exit 1
       root      11 of 29 source paths
       FINDING adopt-lost: upstream/dependency (a057e7469a37) is in no leg, not in the root tree, and not listed as drop

The finding was false. The split branch's root tree holds that gitlink at the source's own commit:

$ git ls-tree -r adopt/three-repo-shape | awk '$1=="160000"'
160000 commit cb9ae12ab13bc37e6e60c5b50b71e13f533b5582	code
160000 commit 89fdd5a1d46920bb8e8e57c5d50680bffea310b4	spec
160000 commit a057e7469a373ceefc31cf78473fc9f5e8039884	upstream/dependency

check and execute now refuse that plan: #166 made it plan-submodule-root, a check finding and an execute refusal, and #168 makes execute refuse every check finding. So on main a5b09c3 the blind spot shows only in splits that no plan reaches. The table below calls _verify directly on hand-made one-commit repositories, with the gitlinks written by git update-index --cacheinfo. Each split carries a minimal shape pin, which #167's check needs. The first row is the reproduction above in small. The other rows are splits the blind spot passes.

case main a5b09c3 this branch, 28fee0f
source submodule kept in root at its commit exit 1, false adopt-lost exit 1, root 2 of 4, adopt-root-submodule
source submodule in the code leg AND the root exit 0, adoption verified exit 1, adopt-duplicated and adopt-root-submodule
root gitlink vendor/extra nobody asked for exit 0, adoption verified, added 3 exit 1, adopt-unexpected-gitlink, added 4
root gitlink at the source submodule's path, at another commit exit 0, adoption verified exit 1, adopt-unexpected-gitlink
root gitlink at src/app.py, a source blob the code leg took exit 0, adoption verified exit 1, adopt-unexpected-gitlink
no gitlink at the code mount: absent, a blob, or a directory exit 0, adoption verified exit 1, adopt-mount-missing, naming which

The plan-level view uses lane 2's scen.py. It runs seven plans that keep the source's submodule or its .gitmodules in the root, or leave one of them with no leg. R1, R2 and R3 are #165's three, and T1 to T4 are #168's trap. E1, the control, sends both to the code leg.

The rule as implemented

Tests

tests/test_adopt_verify.py is a new file with sixteen cases. Fourteen call _verify through importlib on hand-made one-commit repositories. They need no git-filter-repo, so the Windows job runs them:

  • the common case: both mounts passed over, spec/code/root 1 of 3, added 3;
  • a root-kept submodule: counted root 2 of 4, adopt-root-submodule, and no adoption verified;
  • a lost submodule (adopt-lost);
  • a dropped submodule (drop 1 of 4);
  • a submodule in a leg and the root: adopt-duplicated and adopt-root-submodule;
  • adopt-unexpected-gitlink at a new path, at the source's submodule path at another commit, and at a path where the source had a blob;
  • adopt-mount-missing when the code mount is absent, a blob, or a directory;
  • mounts at legs/spec and impl/code, passed over and verified;
  • the spec leg's gitlink at spec while the plan spells the mount spec/ (how git recorded it before adopt-project.py accepts a non-canonical leg path such as --spec-path spec/, so the mount and its .gitmodules registration disagree and main still says adoption verified #169) or legs/spec: exactly the two findings, plus the closing paragraph.

The other two run execute. Like every execute test, they are skipped without git-filter-repo:

tests/test_adopt_submodules.py gains test_the_root_that_mount_leaves_never_verifies. #166 relabelled the mount-level defence in depth; this test runs the real _mount_the_legs on a root-kept plan. It then shows that the verification's own functions fail the root the mount leaves, on adopt-root-submodule and on adopt-lost: .gitmodules. It needs only git, so it runs without git-filter-repo too.

The hand-made split commits carry a minimal contracts/shape-pin.yaml that names project.yaml. Since #167, the check reads the pin out of the split commit. Without the pin, these cases fail on adopt-shape-file-missing (variant P below).

Every case fails with the fix reverted or under a named mutation. Each variant below ran tests/test_adopt_verify.py in a scratch clone at 28fee0f, with git-filter-repo on PATH:

variant fails
main a5b09c3's adopt-project.py 15. The 14 direct cases fail with _verify() takes from 6 to 7 positional arguments but 8 were given. The fail-closed case gets a false adopt-lost: upstream/dependency where it expects adopt-root-submodule. The nested-mount case passes, because main passes over every gitlink
C: c2723dd's adopt-project.py change reverted 11: kept-in-root, duplicated, all three unexpected, all three mount-missing, both spec-gitlink-elsewhere, fail-closed
M0: the blanket gitlink skip restored, no root findings the same 11
M1: the two mounts are no longer passed over all 16
M2: source gitlinks dropped from before 5: kept-in-root, lost, dropped, duplicated, fail-closed
M3: the source's own matched by path alone (path in before) 2: unexpected at the source's submodule path at another commit, and over a source blob
P2: the P2-1 rule reverted, so the source's own at its own commit passes 3: kept-in-root, duplicated, fail-closed
W1: SPLIT_DEFECT's text through 0448944 8: all three unexpected, all three mount-missing, both spec-gitlink-elsewhere
W2: "as the plan spells" taken out of both findings the same 8
W3: the closing paragraph reverted 2: both spec-gitlink-elsewhere
W4: ROOT_SUBMODULE_DEFECT no longer names plan-bad-leg 3: kept-in-root, duplicated, fail-closed
Z: the mount map zipped to the wrong legs 5: all three mount-missing, both spec-gitlink-elsewhere
R1: _verify passes over spec and code whatever the plan says 4: the legs/spec + impl/code case, both spec-gitlink-elsewhere, nested mounts
R1u: the plan's paths AND spec/code passed over the same 4
R2: cmd_execute passes "spec", "code" instead of the plan's paths 1: nested mounts
U: the mount's .gitmodules URL rewrite dropped 1: nested mounts, at its recursive clone
P: the shape pin dropped from the hand-made splits (test side) 14: every direct case
this head, unmutated none (16 passed)

The same check for c2723dd's own changes ran tests/test_adopt_verify.py and tests/test_adopt_submodules.py (148 tests) at 28fee0f. Each mutation gave the same failures as it did at b11d457:

c2723dd change reverted or mutated fails
its whole adopt-project.py change 12: kept-in-root, duplicated, all three unexpected, all three mount-missing, both spec-gitlink-elsewhere, fail-closed, test_the_root_that_mount_leaves_never_verifies
only the P2-1 rule, reverted to if gitlink and before.get(path) != oid 4: kept-in-root, duplicated, fail-closed, test_the_root_that_mount_leaves_never_verifies
SPLIT_DEFECT back to its 0448944 text 8: all three unexpected, all three mount-missing, both spec-gitlink-elsewhere
the source's own matched by path alone 2: unexpected at the source's submodule path at another commit, and over a source blob
ROOT_SUBMODULE_DEFECT no longer names plan-bad-leg 3: kept-in-root, duplicated, fail-closed
_mount_the_legs no longer rewrites each leg's .gitmodules URL 1: nested mounts, at assert cloned.returncode == 0. The 0448944 version of that test, which has no clone, passes under this mutation, so the P3-3 clone is what catches it

Targeted runs at 28fee0f, over eleven files: test_adopt_verify, _submodules, _e2e, _execute_refusals, _leg_paths, _leg_path_collisions, _mount_ignored, _ignored_shape_files, test_shape_doctor, test_windows_paths and test_cli_reference.

  • With git-filter-repo on PATH: 936 passed.
  • With git-filter-repo hidden from PATH: 877 passed, 59 skipped, and every skip is "git filter-repo is not installed". By file: test_adopt_e2e 19, test_adopt_submodules 12, test_adopt_ignored_shape_files 9, test_adopt_leg_path_collisions 6, test_adopt_mount_ignored 6, test_adopt_leg_paths 4, test_adopt_verify 2, test_adopt_execute_refusals 1.

tests/test_repo_hygiene.py: 50 passed. render-cli-reference.py --check: ok. The writer did not run the full suite at this head.

A plain adoption is unchanged from main. The suite's SYNTHETIC_TREE, which has no submodule, ran on main a5b09c3 and on 28fee0f with the same results:

  • spec 5, code 13, root 9, drop 0 of 27, added 19, and adoption verified;
  • the recursive clone exits 0 and bootstrap exits 0;
  • the leg heads are identical.

The split root trees differ only where they must:

  • .gitmodules records each run's own remote paths, and is identical once those are normalised;
  • contracts/shape-pin.yaml, project.yaml and shape/README.md record the shape's own commit and its tree digest.

Merge order, as it stood while #166 and #168 were open

This PR removes a verification blind spot. On main at the time, that blind spot made two kinds of wrong plan fail with a false adopt-lost. Without the refusals in #166 and #168, both verified at 05fa0e0. Each left the root holding a source gitlink that its .gitmodules does not register, so a recursive clone left that directory empty.

Both are on main now. With P2-1, both kinds fail verification even when the plan checks before it are taken away (the bypass rows above).

Reviews

Lane openRepoShape-2 reviewed 05fa0e0 (#165 (comment)). Its verdict was CHANGES NEEDED on one P2, otherwise mergeable with nits, and only after #166 and #168. c2723dd takes each finding:

Beyond the review: the exit text of adopt-unexpected-gitlink and adopt-mount-missing no longer sends the reader to re-spell legs.spec_path first, because #169 refuses that spelling before any leg exists.

Closes #165

🤖 Generated with Claude Code

brettheap and others added 3 commits October 8, 2026 21:56
… other gitlink, so a source submodule the root keeps at its commit is counted `root`, one in a leg AND the root is `adopt-duplicated`, and a gitlink nobody asked for or a missing mount is a finding (#165)

`_verify` skipped every `160000` entry of the split commit's root tree. The shape adds exactly two, the mounts at `legs.spec_path` and `legs.code_path`, and those are now the only entries passed over: every other root gitlink lands like a blob. A source submodule the root kept at its own commit is counted `root` instead of `adopt-lost`. One the split failed to remove, in a leg and in the root, is `adopt-duplicated` instead of passing. A gitlink that is neither a mount nor the source's own submodule at the SAME commit is the new `adopt-unexpected-gitlink`, and a mount path that holds no gitlink is the new `adopt-mount-missing`. On main the last three printed `adoption verified`, and an unexpected gitlink was not even counted as added.

The root `.gitmodules` is still compared byte for byte, and `_land_the_root_tree` says why: #166 makes `root` an illegal answer for a source's `.gitmodules` and for every source gitlink, so the source's own cannot reach the root, and the fresh one `_mount_the_legs` writes is the shape's file, counted as added. `_mount_the_legs`, the plan and check code and contracts/path-classification.yaml are untouched; they are #166's. `_verify` gains `spec_path` and `code_path` parameters, and its one call site in `cmd_execute` passes them.

Merge after #166. Without its refusal, a plan that sends `upstream/` to `root` and `.gitmodules` to `code` now verifies, where main reported `adopt-lost` for the wrong reason, and leaves the root a gitlink that nothing registers.

Tests: tests/test_adopt_verify.py calls `_verify` directly on hand-made one-commit repositories whose gitlinks are written with `git update-index --cacheinfo`, so it runs without git-filter-repo. It covers the common case, a root-kept submodule, a lost one, a dropped one, a duplicated one, an unexpected gitlink at a new path and at a source path at another commit, and a mount path that is absent, a blob or a directory.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he same three lines #166 adds, so `_land_the_root_tree` stops spelling `160000` and the merge after #166 leaves one definition and no literal (#165)

#166's branch (aaa9099) adds `GITLINK_MODE = "160000"` beside `GITMODULES`, and its review (N5) left the one literal still spelled out, in this branch's root-tree loop, to this branch. The definition here is byte for byte #166's, at the same place, so whichever lands second merges it as an identical change: a trial merge of this branch into aaa9099 is clean, has one definition and no `"160000"` left in adopt-project.py, and passes tests/test_adopt_verify.py, test_adopt_submodules.py and test_adopt_plan.py (94 passed, 1 skipped). A one-line insertion after `_account_for` in `_verify`, where #167 adds its call, also merges clean with both.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ec_path` or `legs.code_path` back to the plan before they call the split this tool's defect, the verification is tested with mounts at `legs/spec` and `impl/code`, and the hand-made splits carry a shape pin so #167's check passes them (#165)

The review of d780495 found the one route `execute` takes to `adopt-unexpected-gitlink` and `adopt-mount-missing`: a mount path that the plan spells in a form git canonicalises. `plan --spec-path spec/` writes `spec_path: spec/`, `check` says `plan ok`, and `git submodule add` records the mount at `spec`. Both findings then fire. Both said "no plan answer does that ... report it", which is false there, and which contradicted `_verify`'s closing "fix the plan and re-run". `SPLIT_DEFECT` now says not to merge the split, to look at `legs.spec_path` and `legs.code_path` first and re-spell a non-canonical value, and to report the split only when both values are canonical. The findings name the mount paths "as the plan spells them". The closing paragraph keeps its exit, "unless a finding above names another exit". Refusing a non-canonical value in the plan code is left to a follow-up.

Tests: the `verify` fixture now takes the plan's mount paths. The new cases are:
- mounts at `legs/spec` and `impl/code` pass;
- the spec leg's gitlink at `spec`, while the plan says `spec/` or `legs/spec`, gives exactly the two findings and the closing line;
- plan, check and execute with `--spec-path legs/spec --code-path impl/code` verify, with the split's gitlinks at exactly those paths. This one needs git-filter-repo.
A `_verify` that hard-codes `spec` and `code`, or a `cmd_execute` that passes them, now fails. The hand-made split commits carry a minimal `contracts/shape-pin.yaml`: with #167 merged, its check reads the pin out of the split commit, and without one it failed all ten earlier cases with `adopt-shape-file-missing`. `_verify` builds its mount map from `EXTRACTED_LEGS` instead of adding `"spec"` and `"code"` literals.

Merge order: #166, then #168, then this. #166 refuses a plan that answers `root` for a source submodule. It does not refuse a plan that leaves the submodule in no entry at all. `check` reports that plan as `plan-uncovered`, but until #168 `execute` runs it anyway, and the uncovered gitlink stays in the root at its own commit. Main then fails with a false `adopt-lost`. This branch instead counts the gitlink as `root` and says `adoption verified`, over a root whose `.gitmodules` does not register it, so a recursive clone leaves it empty. #168 makes `execute` refuse every finding `check` reports, before any leg exists.

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

Copy link
Copy Markdown
Contributor Author

(lane openRepoShape-1, 2026-10-09T02:12:38Z)
@codex review

@sourcery-ai

sourcery-ai Bot commented Oct 9, 2026

Copy link
Copy Markdown

Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 17 hours and 50 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@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 commented Oct 9, 2026

Copy link
Copy Markdown

Reviewer's Guide

Verification now skips only the two plan-specified leg gitlinks, accounts for every other root entry—including retained source submodules—and rejects unexpected gitlinks or missing mounts, with comprehensive direct and end-to-end tests covering the new behavior.

Sequence diagram for plan-specified mount verification

sequenceDiagram
    participant Execute as cmd_execute
    participant Verify as _verify
    participant Root as _land_the_root_tree
    participant Account as _account_for

    Execute->>Verify: _verify(source, assembly, work_root, names, paths_for, split_commit, spec_path, code_path, seeded)
    Verify->>Root: _land_the_root_tree(after, root_tree, before, mounts)
    Root-->>Verify: root_findings
    Verify->>Account: _account_for(before, after, paths_for[drop])
    Account-->>Verify: counts, findings
    Verify-->>Execute: 1 on findings, otherwise adoption verified
Loading

Flow diagram for root-tree verification

flowchart TD
    A[Split commit root tree] --> B{Entry is gitlink at plan-specified leg mount?}
    B -->|Yes| C[Skip mount gitlink]
    B -->|No| D[Land entry as root:oid]
    D --> E{Gitlink matches source submodule at same path and commit?}
    E -->|Yes| F[Account as root]
    E -->|No| G[adopt-unexpected-gitlink]
    C --> H{Both leg mounts present?}
    F --> H
    G --> H
    H -->|No| I[adopt-mount-missing]
    H -->|Yes| J[_account_for checks source paths]
    I --> J
    J --> K{Findings?}
    K -->|Yes| L[Reject verification]
    K -->|No| M[Adoption verified]
Loading

File-Level Changes

Change Details Files
Restrict root-tree gitlink exclusion to the two plan-specified leg mounts and verify all other root entries.
  • Define and reuse the gitlink mode constant.
  • Pass the plan’s spec and code mount paths into verification.
  • Extract root-tree handling into a helper that lands non-mount entries as root paths.
  • Count source submodules retained at their original commit as root and detect duplication across a leg and root.
adopt-project.py
Add explicit findings for invalid root gitlinks and missing leg mounts.
  • Report unexpected gitlinks at new paths or source-submodule paths with a different commit.
  • Report mount paths containing nothing, a blob, or a directory instead of a gitlink.
  • Use plan-spelled mount paths in diagnostics and preserve the appropriate remediation/exit guidance.
adopt-project.py
Add focused verification coverage for gitlink accounting and plan mount-path handling.
  • Test retained, lost, dropped, duplicated, unexpected, and missing submodule cases.
  • Test canonical and nested mount paths, including the execute path passing plan values through.
  • Verify root counts, findings, diagnostics, and mount locations.
tests/test_adopt_verify.py

Assessment against linked issues

Issue Objective Addressed Explanation
#165 Update _verify so that it skips only the gitlinks at the planned spec_path and code_path, while accounting for every other root gitlink, including a source submodule intentionally kept at its original commit. ✅
#165 Prevent false verification failures for a root .gitmodules that the plan keeps by validating its submodule registrations rather than requiring byte-for-byte equality with the source blob. ❌ The PR explicitly retains byte-for-byte comparison of .gitmodules. It relies on separate PRs (#166 and #168) to reject plans that keep or drop the source .gitmodules, so this issue is not independently fixed by this PR and such plans can still fail verification without those changes.
#165 Ensure the assembly-root validation workflow's treatment of .gitmodules remains correct when the root contains a source submodule in addition to the two leg mounts. ❌ The PR states that it read the workflow but leaves templates/assembly-root/.github/workflows/validate.yml unchanged. Its correctness is assumed to follow from the separate plan restrictions, rather than being updated to account for every registered root submodule as requested.

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-2, 2026-10-09T02:24:54Z) Review of this head, 05fa0e0, is on the issue: #165 (comment). Verdict: CHANGES NEEDED on one P2, otherwise MERGEABLE WITH NITS only if this PR merges strictly after #166's branch AND #168 (PR #170). The P2: _land_the_root_tree (adopt-project.py:1819-1828 at 05fa0e0, pinned by tests/test_adopt_verify.py:154) counts a non-mount root gitlink as root when it is the source's own at its commit, and in every reachable case the root's .gitmodules no longer registers it, so _verify prints "adoption verified" over an assembly where the dependency directory is empty and git submodule status exits 128, while the recursive clone and bootstrap pass. Reachable on this head alone (link root, .gitmodules code: check passes), and with #166 but without #168 (bad-leg or uncovered link). The three-way merge 09d7889 + a25dcd7 + 05fa0e0 is clean and refuses every such plan before any leg exists (197 passed / 1 skipped), so the order makes it unreachable; making every non-mount root gitlink a finding would make the order irrelevant. Review was read-only; lane openRepoShape-2 holds no claim here.

brettheap added a commit that referenced this pull request Oct 9, 2026
…or a source whose `src/` or `contracts/` holds a submodule, spells every path its question names so a non-UTF-8 or newline name no longer crashes it or empties `--out`, and caps the split it names; `check` reads a key with no value beside no submodule as git does, says where git fails on a `.gitmodules` it cannot read, and why a named entry registers nothing; `execute` refuses with the one list `check` prints (#166)

Round 4, from this lane's re-verification of ca5fb3d (S1-S3, N1-N4) and
lane openRepoShape-2's passes 4 and 5 (NEW-1, NEW-2, NEW-3, R5-1, R5-2).

NEW-1 / S1. `cmd_plan` computed the collision prediction, the follow-ups
and the seeding record after `ask_about_submodules` had set the entry
holding a submodule to `leg: null`. A submodule under `src/` dropped
main's follow-up for a harness there that reads `contracts/`, and called
the code leg empty: a SEEDED warning, `seeded_from_template: true`, and
an `--allow-empty-leg code` it never needed. One under `contracts/` lost
the harness line and the `CONTRACTS_DIR` line. All three are now read
from `walk`'s entries, before the question is asked; a source with no
submodule plans byte for byte as before.

NEW-2 / S2 / R5-1. Every path the question names, the submodules and the
entries that replace a directory alike, is `_spelled`: between backticks,
a byte that is not UTF-8 as `\xe9`, a newline as `\n`, any other
character that is not printable by a backslash, and a backslash or a
backtick escaped so the backticks still delimit it. A raw surrogate made
`write_lf` raise mid-write and leave `--out` empty; a raw newline read
back as a space. The spelled newline, between double quotes, is the YAML
entry that covers the file.

R5-2. Past SPLIT_ENTRIES_NAMED (8) entries the question no longer names
them one by one: "replace it with an entry for each path directly in
`src/`, 402 in all", or "in one of `docs/`, `docs/theme/`, other than
those directories" when it is nested. That edit is the one `check`
passes.

S3. A `.gitmodules` whose one defect is a key with no value is fatal to
git's submodule reader alone, which git runs only for a gitlink. Beside
no submodule it is now read as registering nothing: main adopts and
clones such a source, and this branch no longer refuses it. Measuring
every shape end to end against main also found where git really fails
on a file it cannot read, so `plan-gitmodules-unreadable` now says so:
beside a submodule, `git filter-repo`'s `git fast-export` reads the
checked-out `.gitmodules` for each gitlink and fails the extraction of
either leg, wherever the plan sends the two. That includes both of them
dropped, which this branch passed and main and this branch both died on
after making both leg remotes; it is refused now. Only a plan that
extracts no leg escapes it. Otherwise the finding names the assembly's
recursive clone, which fails in a leg that keeps a file with a line git
cannot parse (no submodule needed), or a `.gitmodules` that is itself a
gitlink. SUBMODULE_REMEDIATION no longer offers dropping such a file
beside a submodule as an exit.

NEW-3 / N1. `check` and `_refuse_what_check_finds` read one list,
`_entry_findings`: coverage, each entry's `leg:` (#169's leg paths
among them) and the submodule problems. A plan `check` rejected as
uncovered and split was refused by `execute` for the split alone; it is
refused for both, in one refusal, with #168's remedy and the submodule
one. `_refuse_an_unrunnable_plan` is main's again, so its literal `8`
cap is gone with the code that had it. #168's tests pass unchanged.

N2. `.gitmodules` is now read into `Registrations`, which also keeps why
a path an entry names registers nothing: the entry holding it has no url
git reads, its name is one git ignores as suspicious, its path starts
with `-`, or another entry's move dropped it. The
`plan-submodule-unregistered` detail says that, and "no .gitmodules
entry ... registers its path with a url" only when no entry names it.

N3. git calls the file read through `--file -` "standard input"; the
finding says `.gitmodules`.

N4. `_SplitTree` reads `GITLINK_MODE` (`_verify`'s literal is left to
#173), and `cat-file` is `GIT_CAT_FILE`, as `config` is `GIT_CONFIG`.

Tests: new ones for each of the above (follow-ups and seeding for
`src/vendor/dep` and `contracts/vendor/x`; four names no plan line can
hold, built through `update-index --index-info` and skipped where git
refuses them; a newline entry typed from the question; the capped split,
flat and nested; why an entry registers nothing, eight ways; where git
fails, six shapes; one refusal for an uncovered and split plan through
`cmd_execute`); the unreadable-file matrix now refuses both dropped, and
says the extraction; the end-to-end refusal gains that case and the
end-to-end acceptance a key with no value beside no submodule.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…links, so the mounted-gitlink check is tested on the main it will land on

Lane: openreposhape-1 (openRepoShape-1)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ounts no leg, the source's own submodule at its own commit as `adopt-root-submodule`, so a split that keeps one beside a `.gitmodules` that does not register it no longer says `adoption verified` when a plan check fails to refuse it (#165)

`_land_the_root_tree` counted the source's own submodule, kept in the root
at its own commit, as a `root` landing and nothing more. Since #166 and #168
no plan `execute` runs can put one there, so the only ways left are a defect
or a regression in those refusals, and in both the run said `adoption
verified` over an assembly whose fresh `.gitmodules` registers only the two
mounts: its recursive clone leaves that directory empty and `git submodule
status` exits 128 (lane openRepoShape-2's P2-1 on 05fa0e0). Every gitlink
other than the two mounts is now a finding: `adopt-root-submodule` for the
source's own at its own commit, `adopt-unexpected-gitlink` for anything
else, as before. It is still counted where it is, so a submodule left in a
leg and the root is both `adopt-duplicated` and `adopt-root-submodule`.

The findings' exit text no longer sends the person to re-spell
`legs.spec_path` first: #169, merged in 0448944, refuses a mount path git
would record at another spelling before any leg exists, so every one of
these findings means the split itself is wrong. #166's docstring and #162's
mount comment say the byte comparison of a root-kept `.gitmodules` is
deliberate, and name the finding the mount's defence in depth meets, instead
of reading as work #165 had still to do.

Tests: the root-kept case at test_adopt_verify.py:154 is flipped (it now
fails verification), the duplicated case gets both findings, a gitlink over
a source blob is `adopt-unexpected-gitlink`, the mount-level defence in
depth in test_adopt_submodules.py is shown to fail verification, and two
`needs_filter_repo` runs of `execute`: the nested-mount adoption is cloned
with `--recurse-submodules` after its work directory is moved away and
bootstrapped, and a root-kept plan with `_refuse_what_check_finds` taken away
exits 1 on `adopt-root-submodule`.

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-11T00:59:47Z)
RE-VERIFICATION of this PR at 0448944 (merge of main e4decfb into 05fa0e0), by this lane, read-only in its own detached worktrees; nothing authored, no claim.

Verdict: MERGEABLE WITH NITS. No ordering constraint is left. 0448944's tree is exactly git merge-tree --write-tree 05fa0e0 e4decfb (2ff09e1f, diff 0 bytes), so it adds no hand-written code. GITLINK_MODE is defined once (adopt-project.py:170), and 160000 appears only in that definition.

The prior P2 is CLOSED, by sequencing. #166 (e4decfb, PR #194; plan-submodule-root) and #168 (b18cca9, PR #170; execute refuses every finding check reports) are both ancestors of 0448944. I ran 22 real plans on head and main. Every one that used to leave a non-mount gitlink in the root is refused: check exits 1, and execute exits 2 with no remote made. Those plans are a root-kept submodule, a kept .gitmodules, a bad leg, an uncovered link, an orphan, a stale .gitmodules, a nested-mount variant and one submodule per leg. On 05fa0e0, six of them printed "adoption verified" over an empty dependency directory with submodule status exit 128. Head and main agree on all 22 rows. Every plan that verifies clones recursively, populates the dependency, and passes make bootstrap.

P3

  1. The root-kept code path is unchanged (adopt-project.py:2855-2867). A source gitlink left in the root at its own commit still lands as root with no finding, and tests/test_adopt_verify.py:154 pins that. No plan reaches it now, but it fails open again if adopt-project.py: a plan that sends .gitmodules to one leg and a submodule it registers to another passes check and execute, says adoption verified, and the assembly's recursive clone then fails: plan should ask, check should find, execute should refuse #166 or adopt-project.py execute refuses only plan-unresolved and plan-stale, so a plan check rejects as uncovered or with a bad leg creates and pushes both legs before it fails verification #168 regress. A 5-line elif gitlink: finding (adopt-root-submodule) changes only :154 and :179's expectations and no real-plan row (prototype checked).
  2. SPLIT_DEFECT is stale since adopt-project.py accepts a non-canonical leg path such as --spec-path spec/, so the mount and its .gitmodules registration disagree and main still says adoption verified #169 (f25d805). adopt-project.py:2801-2811 says a non-canonical leg path is accepted and "not refused here". :2812-2819 tells the reader to re-spell it first; :2841-2842 and tests/test_adopt_verify.py:251 say the same. On this head, spec_path: spec/ and ./spec are refused as plan-bad-leg-path before any leg exists. So both findings now mean a defect, and their first sentence points at a cause that cannot occur. The fix is text only.

Nits

  1. Test gaps carried from 05fa0e0. The e2e runs no recursive clone, and no world puts a root gitlink over a source blob. Only the filter-repo e2e catches cmd_execute passing literal spec/code, and the Windows job skips that e2e.
  2. The PR body describes 05fa0e0 against 7f84ca4. That covers the merge-order section, the "follow-up" that adopt-project.py accepts a non-canonical leg path such as --spec-path spec/, so the mount and its .gitmodules registration disagree and main still says adoption verified #169 already did, and the test counts. Update it if the squash commit uses the body.

Prior P3s: the #162 mount comment and test label were fixed by #166; the PR body now explains both things the issue asked for and the PR declined.

Tests on r173-head: all 8 test_adopt_*.py files plus test_shape_doctor.py: 831 passed, 1 skipped (SHAPE_MEDXEHR_CLONE). With filter-repo on PATH, test_adopt_verify.py is 14 of those; with filter-repo hidden it gives 13 passed, 1 skipped. render-cli-reference.py --check ok.

Merges (merge-tree with 0448944):

CI at 0448944: tests, tests-macos and tests-windows all SUCCESS; mergeable CLEAN.

Report and drivers: opensoft/brett-wip handoffs/xFactory/attachments/lane-openRepoShape-2/review173-0448944/.

…unted-gitlinks, so the fail-closed root gitlink check is tested on the main it will land on

No conflicts: git merged adopt-project.py, scripts/shape_materialize.py and
the three test files #198 touches without a conflicting hunk. #198 edits
the plan side (`_leg_findings`, `_entry_findings`, `_refuse_what_check_finds`
and the leg-path collision lists); this branch edits the verification side
(`_land_the_root_tree`, `_root_gitlink_finding`, the two exit texts) and two
comments, so no hunk touches both.

Checked by hand for a conflict git cannot see:
- `_leg_findings(plan, tree)` keeps `tree` as a required argument, and
  its one caller, `_entry_findings`, passes the source tree.
- `_refuse_what_check_finds` is still the one plan gate in `cmd_execute`
  before the legs are made, so the fail-closed e2e, which takes that gate
  away, still reaches `_verify`.
- The exit texts of `adopt-unexpected-gitlink`, `adopt-mount-missing` and
  `adopt-root-submodule` stay true: #198 adds `plan-leg-path-collides` to
  what `execute` refuses before any leg exists and removes no refusal they
  name.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap and others added 2 commits October 11, 2026 17:38
…links, so the fail-closed root gitlink check is tested beside the leg-path helpers #201 moved into scripts/shape_materialize.py

No conflicts: git merged adopt-project.py, scaffold-project.py,
scripts/shape_materialize.py and #201's two test files without a
conflicting hunk. #201 moves the leg-path checks out of adopt-project.py
into scripts/shape_materialize.py; this branch edits only the verification
(`_land_the_root_tree`, `_root_gitlink_finding`, the two exit texts) and two
comments, 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.
- Every refusal the three gitlink findings name still exists after the
  move: `plan-bad-leg-path` and `adopt-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]>
…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]>
@sonarqubecloud

Copy link
Copy Markdown

This was referenced Oct 11, 2026
@brettheap brettheap changed the title adopt-project.py's verification passes over the two leg mounts and no other gitlink, so a source submodule the root keeps at its commit is counted root, one in a leg AND the root is adopt-duplicated, and a gitlink nobody asked for or a missing mount is a finding (#165) adopt-project.py: verification passes over the two leg mounts and no other gitlink, so the source's own submodule kept in the root is adopt-root-submodule, any other root gitlink adopt-unexpected-gitlink, one in a leg AND the root adopt-duplicated, and a missing mount adopt-mount-missing (#165) Oct 11, 2026
@brettheap
brettheap merged commit 54aa69a into main Oct 11, 2026
5 checks passed
@brettheap
brettheap deleted the fix/adopt-verify-mounted-gitlinks branch October 11, 2026 19:16
This was referenced Oct 11, 2026
brettheap added a commit that referenced this pull request Oct 11, 2026
#173 landed on main as 54aa69a: verification passes over the two leg
mounts and no other gitlink. The textual merge is clean. The next commit
spells its two new findings and updates the assertions this branch's
spelling changes.

Lane: openreposhape-3 (openRepoShape-3)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 11, 2026
…-gitlink` spell the gitlink they name, as every other finding does since this branch, so a source submodule path holding a line break or an ESC no longer splits or escapes the verification line (#212)

#173 (54aa69a) added two findings to `_land_the_root_tree`, through
`_root_gitlink_finding`, that printed the gitlink's path raw. That path
is a source or split name, so it now goes through `_spelled`:
- `adopt-root-submodule`: the source's own submodule at its own commit,
  left in the root.
- `adopt-unexpected-gitlink`: any other gitlink in the root.

The leg mount paths these findings and `adopt-mount-missing` name are
left as the plan spells them: a leg path passes `checked_value`'s
alphabet, which keeps it printable.

Assertions updated to the spelled text, all of them on findings this
branch spells:
- tests/test_adopt_verify.py: `root_submodule()`, `adopt-lost`,
  `adopt-duplicated`, both `adopt-unexpected-gitlink` assertions and
  `plan-submodule-root`.
- tests/test_adopt_submodules.py: `adopt-root-submodule` and
  `adopt-lost` in `test_the_root_that_mount_leaves_never_verifies`.

tests/test_adopt_finding_spelling.py gains a case for each of the two
findings over the five characters (10 cases), through
`_land_the_root_tree`. All 10 fail without the change.

Lane: openreposhape-3 (openRepoShape-3)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 11, 2026
Brings in #173 (#165: verification passes over the two leg mounts and no other gitlink, with `adopt-root-submodule`, `adopt-unexpected-gitlink`, `adopt-duplicated` and `adopt-mount-missing`), which landed after this branch merged a5b09c3. No conflicts: git merged adopt-project.py and tests/test_adopt_submodules.py itself, and tests/test_adopt_verify.py is new. This branch's change set against main is line for line the one it had against a5b09c3. No rebase.

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
…e-notice

One file conflicted, adopt-project.py, in four hunks, all in or at
`_verify`. Every one keeps both sides:

- `cmd_execute`'s call to `_verify`: main passes the plan's two mount
  paths, `spec_path` and `code_path`, and this branch passes `urls` and
  `branch` by keyword. The call now passes both, in that order.
- `_verify`'s signature: main added `spec_path` and `code_path` as
  positional parameters before `seeded`; this branch added `urls` and
  `branch` as keyword-only. The signature has both:
  `(..., split_commit, spec_path, code_path, seeded=(), *, urls, branch)`.
- `_verify`'s docstring: main's #165 paragraph (only the two mounts are
  passed over) and this branch's #188 N1 paragraph (a failed
  verification is the last late failure) are both kept, #165's first,
  since it says what is checked and #188's says what a failure prints.
- `_verify`'s footer: main added `findings += root_findings` and "unless
  a finding above names another exit", for its findings whose exit is to
  report the split. This branch flushes stdout first, prints the findings
  in one write, and follows them with the notice and the split branch's
  deletion. The footer keeps all of it: the root findings join the list,
  the flush and the notice follow, and the sentence now reads "fix the
  plan and re-run, unless a finding above names another exit".

The merged diff against main differs from this branch's diff against
a5b09c3 in those hunks alone. tests/test_adopt_submodules.py and the new
tests/test_adopt_verify.py merged without conflict.

The merge breaks main's new direct `_verify` tests: they call it without
`urls` and `branch`, which this branch makes required, and one reads the
footer's old last sentence. The next commit fixes them.

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
… `_verify` names in its way out, and read its exit sentence as merged, so the 14 that call it directly no longer fail on this branch with `TypeError: _verify() missing 2 required keyword-only arguments` (#188, #165)

#165 (via #173) added tests/test_adopt_verify.py, whose `verify` fixture
calls `_verify` positionally with the plan's two mount paths. This
branch makes `urls` and `branch` keyword-only and required, because a
failed verification names the legs, the work directory and the split
branch with the command that deletes it (#188 N1). On the merge, e52f6be,
14 of its 16 tests failed with that TypeError; the two that run
`execute` passed, since `cmd_execute` passes both.

- The fixture passes `urls`, one per repository as `execute` would have
  them against GitHub (the assembly's is the source itself), and
  `branch=SPLIT_BRANCH`. Nothing is pushed to them: `_verify` only names
  them.
- `test_a_spec_gitlink_not_where_the_plan_spells_the_mount_is_two_findings`
  read main's last sentence, "re-run into a fresh --local-remote-dir or
  fresh leg repositories, unless a finding above names another exit.",
  at the end of stderr. As merged, that exit is "fix the plan and re-run,
  unless a finding above names another exit.", and the notice and the
  branch deletion follow it. The test now reads that sentence where it
  stands, right after the count.

No code changed. All 16 pass.

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
…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 11, 2026
… a refusal names, and the branch `plan-stale` names, as `plan`'s questions spell a path, so a name holding a carriage return, a line feed, U+0085, U+2028 or an ESC no longer overwrites, splits or escapes the line it is printed on (#212) (#223)

`plan` already writes every path a question names through `_spelled`.
The path goes between backticks. Each character `str.isprintable`
refuses is written as a backslash escape (`\r`, `\n`, `\x85`, `\u2028`,
`\x1b`), a byte that is not UTF-8 as `\xNN`, and a backslash or a
backtick is escaped too, so the backticks still delimit the path. The
findings were not given it. On main a5b09c3, `check` printed
`FINDING plan-uncovered: Icon<CR> is in the source tree ...` with the raw
carriage return, which a terminal turns into an overwrite of the code and
the path. A hand-written entry `"README\nX.md"` came out as one finding on
two physical lines, the second not starting with `FINDING`. `execute`
refused with the same raw lines, "as `check` prints them".

Every path a finding or a refusal names now goes through `_spelled`:
- `_coverage_findings`: `plan-duplicate-path`, `plan-uncovered`,
  `plan-covered-twice` and `plan-empty-entry`. The entries that cover a
  path twice are listed with `_listed` (`` `src/`, `src/app/` ``), where
  main printed a Python list.
- `_leg_findings`: `plan-unresolved` and `plan-bad-leg`.
- `_as_entry`, which names the submodule and its entry in
  `plan-submodule-root`, `plan-submodule-split` and
  `plan-submodule-unregistered`.
- `_kept_collisions`, behind `plan-leg-path-collides` and `plan`'s
  collision note. It put a source path between backticks by hand and
  now spells it with `_spelled`. `first_and_more`, which #197 moved to
  scripts/shape_materialize.py and `scaffold-project.py` also calls,
  takes an optional `spell` for the path it names, and
  `_kept_collisions` passes `_spelled`. With no `spell` it writes what
  it wrote, so the scaffold's collision refusals are byte-identical to
  main's.
- `_refuse_an_unrunnable_plan`: `execute`'s own `plan-unresolved` refusal
  lists its paths with `_listed`.
- `_account_for`: `adopt-duplicated` and `adopt-lost`, the verification
  `execute` prints after the split.
- `_root_gitlink_finding`: `adopt-root-submodule` and
  `adopt-unexpected-gitlink`, the root-tree gitlink findings #173 added
  to the same verification.
- `_missing_shape_file` and `_SplitTree`: `adopt-shape-file-missing`
  spells the pinned path, the symlink a lookup met, the target it leads
  out to, and a path that is not a directory.
- `_entry_named`: `adopt-mount-occupied` is the guard #174 put before
  `git submodule add --force`. It names the index entry it found under
  the leg mount path, which it used to put between backticks by hand.
  `_index_entries` now decodes index names with `surrogateescape`, as
  `Source.tree` does, so a byte that is not UTF-8 is spelled `\xfe`.
  Decoded with `replace`, `a<0xFE>` and `a<0xFF>` both read `a<U+FFFD>`.

`plan-stale`, in `check` and in `execute`'s refusal, also spells the
source's branch. git's ref-name rules refuse only ASCII control
characters, so a branch named with U+0085 or U+2028 split that line.

The leg mount paths that these findings name are left as the plan spells
them, because a leg path passes `checked_value`'s alphabet, which keeps it
printable. `execute`'s refusal is `_entry_findings`, the same list `check`
prints, so both commands change together.

One ambiguity is left, as main's `_spelled` already had it. A raw byte
0x80-0xA0 or 0xAD and the character U+0080-U+00A0 or U+00AD are both
spelled `\xNN`, which makes 34 pairs. A source holding both `Icon<0x85>`
and `Icon<U+0085>` prints the same finding twice.

Unchanged: a path or branch with no backslash, backtick or unprintable
character is spelled with backticks around it and nothing else. The
coverage, leg, submodule, verification and `plan-stale` findings now show
those backticks, as questions already did. `adopt-mount-occupied` and the
collision findings showed them already. I measured this on the test
suite's synthetic source, against main 39ac59c, with the default plan, a
`plan-leg-path-collides` plan (`--spec-path .specify`),
`--spec-path docs/architecture.md`, and the refused `--code-path Makefile`
and `--code-path .github`. In every case, `plan`'s exit code, stdout,
stderr and plan file, and `check`'s exit code, stdout and stderr, are
byte-identical to main.

tests/test_adopt_finding_spelling.py is new. It asks each of these
findings over the five characters, with the non-UTF-8 index names and a
real branch named with U+0085 and with U+2028. The existing assertions in
test_adopt_execute_refusals.py, test_adopt_ignored_shape_files.py,
test_adopt_submodules.py and test_adopt_verify.py gain the backticks. So
does the one assertion in test_adopt_plan_escapes.py (#199) that pinned
the raw `Icon<CR>` in `plan-unresolved`: it expects `` `Icon\r` `` now.

Left out:
- The `question:` text that `plan-unresolved` repeats is printed as the
  plan holds it, so a hand-edited question with a line break still
  splits that line.
- `fix/adopt-root-kept-symlinks` adds a `plan-root-symlink` finding that
  names its paths raw. Whichever of the two PRs lands second should spell
  them.
- A last-line guard in `cmd_check` could escape any character a finding
  should never hold.
- Giving the 34 byte/character pairs above two forms, for example
  `\u00NN` for a character below U+0100 and `\xNN` for a raw byte, would
  remove the remaining ambiguity.

Lane: openreposhape-3 (openRepoShape-3)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 12, 2026
…erification merges with no conflict, and `_entry_findings` still hands `_leg_findings` the tree and ends with the root-symlink findings

54aa69a is #165 (#173): `_verify` passes over the two leg mounts and no
other gitlink, so a submodule the source keeps in the root is
`adopt-root-submodule`, any other root gitlink `adopt-unexpected-gitlink`,
one in a leg AND the root `adopt-duplicated`, and a missing mount
`adopt-mount-missing`.

Conflicts: none. `git merge-tree --write-tree HEAD origin/main` gave tree
02f87a1 with no conflicted file, and `git merge --no-ff --no-commit`
staged the same tree: adopt-project.py, tests/test_adopt_submodules.py
and tests/test_adopt_verify.py (new).

Checked on the staged merge:
- `_entry_findings` still calls `_leg_findings(plan, tree)` (#198's
  required argument), then appends `_root_symlink_findings(plan, source,
  tree)` last, after the submodule findings.
- tests/test_adopt_root_symlinks.py and tests/test_adopt_verify.py:
  74 passed. test_adopt_verify.py switches `_refuse_what_check_finds`
  off with `lambda *_: None`, so it takes whatever `execute` passes.

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
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant