Skip to content

adopt-project.py: a leg's mount path must not be, hold or lie inside a path the assembly root holds, so --spec-path contracts no longer checks ok and dies staging the split after both legs are pushed, and --code-path project.yaml no longer says adoption verified over an assembly with no manifest (#172) - #198

Merged
brettheap merged 6 commits into
mainfrom
fix/adopt-leg-path-collisions
Oct 11, 2026

Conversation

@brettheap

@brettheap brettheap commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openreposhape-1 (openRepoShape-1)
Claim: #172 (comment)
Claim: #191 (comment)

What

A leg's mount path is refused when it EQUALS, CONTAINS or LIES INSIDE, whatever the case:

  • a path the shape writes into the assembly root. The list is assembly_root_paths() in scripts/shape_materialize.py. It is built from the same TEMPLATED, COPIED_VERBATIM and COPIED_FROM_SHAPE lists materialize_assembly_root hands _materialize, plus the shape pin it renders last (SHAPE_PIN, named there; adopt-project.py keeps adopt-project.py _commit_the_split stages with git add -A -- ., so a source .gitignore of .* silently drops .gitattributes and validate.yml from the split, execute still says adoption verified, and the assembly fails its first bootstrap #167's own SHAPE_PIN, and a test holds the two to one spelling), so nobody keeps a second list. plan's collision follow-ups read the same list. It covers every root FILE the shape writes (project.yaml, AGENTS-shape.md, README.md, .gitattributes, Makefile, ...), the directories they live in (contracts, scripts, .github), and shape/, where execute writes its copy of a file the root already holds. shape/ is reserved for those copies, so a mount at or under it is refused even where the source needs no copy, and the finding and the remediation say so. A test materializes into an empty directory and checks that the list is exactly what was written, in order.
  • a SOURCE PATH the plan keeps in the root: a path of the source tree that a leg: root entry covers, including a file, symlink or submodule on the way to the mount.

Where it is asked:

shape half root-kept half
plan REFUSED adopt-leg-path-collides, exit 2, no plan file, after #169's spelling check a NOTE for each leg: root entry plan wrote itself, in check's words; exit 0 and the plan is written, because the answer is the person's to change
check FINDING plan-leg-path-collides, exit 1, from _leg_findings the same finding, from the Source.tree() that _entry_findings hands _leg_findings (a required argument)
execute refused through #168's _refuse_what_check_finds, which reads #166's _entry_findings as check does, before any leg repository exists the same

A finding names the leg, the path and what it overlaps, and says so when the overlap holds only once case is ignored:

FINDING plan-leg-path-collides: legs.spec_path 'contracts' contains `contracts/spec-pin.yaml` and 3 more. The shape writes them into the assembly root, and `execute` would write them into the mounted leg or beside it under `shape/`, leaving the root without them: choose another path for the leg.
FINDING plan-leg-path-collides: legs.spec_path 'src' contains the file `src/app/main.py` and 1 more. The plan keeps them in the assembly root under the entry `src/`, and Git cannot mount a leg at a path the root's own tree holds, or beyond a file, symlink or submodule it holds on the way there: choose another path for the leg, or send `src/` to a leg or `drop` it.
FINDING plan-leg-path-collides: legs.spec_path 'spec' contains the file `SPEC/notes.md` once case is ignored, as a macOS or Windows disk does. The plan keeps it in the assembly root under the entry `SPEC/`, ...

The collision question is asked only when both mount paths are canonical, the same way #169 compares the two legs. So shape/ stays #169's plan-bad-leg-path (compared as written, it would read as "inside shape"), and a number is never compared. The new code lives in its own functions (leg_path_collisions, _overlap, _shape_collisions, _kept_collisions, _kept_in_root, _leg_collision_findings, _kept_collision_notes, _flag_leg_paths). _leg_findings, _checked_plan_inputs and _print_plan_report call them, and #169's leg_path_problem(s), _leg_path_reason, _canonical_spelling and LEG_PATH_REMEDIATION are not edited, so #179's move of those into scripts/repo_shape.py stays mechanical.

One reading differs from the issue's wording. The root-kept half compares against the source PATHS a leg: root entry covers, not against a directory entry's own path. docs/spec with docs/ kept is refused where the source holds something at or under docs/spec. Where docs/ holds nothing there, it is not refused, because that layout already works on main: adoption verified, the recursive clone succeeds and bootstrap ok. With this branch the layout is byte for byte as it is on main (below).

Why (repro on main f25d805, local remotes)

--spec-path contracts      plan rc 0 / check `plan ok` / execute rc 2 after BOTH legs are pushed:
                           fatal: Pathspec 'contracts/spec-pin.yaml' is in submodule 'contracts'
--code-path scripts        ... fatal: Pathspec 'scripts/validate-pins.py' is in submodule 'scripts'
--spec-path .github        ... fatal: Pathspec '.github/workflows/validate.yml' is in submodule '.github'
--spec-path shape          ... fatal: Pathspec 'shape/README.md' is in submodule 'shape'
--code-path project.yaml   execute rc 0 `adoption verified`; the shape's manifest went to shape/project.yaml
                           ("the source already has project.yaml"); shape-doctor on the clone: `kind not a shape root`, exit 2
--code-path AGENTS-shape.md  execute rc 0 `adoption verified`; doctor COMPLIANT (exit 0), only `note agent files absent:
                           AGENTS-shape.md`: the root's AGENTS-shape.md is the code leg's gitlink, the rules sit at shape/AGENTS-shape.md
src/ kept, --spec-path src            both legs pushed, then fatal: 'src' already exists in the index
docs (a FILE) kept, docs/spec         both legs pushed, then fatal: could not create leading directories of '.../docs/spec': Not a directory
legs -> <outside> kept, legs/spec     both legs pushed, then fatal: pathspec 'legs/spec' is beyond a symbolic link
vendor (submodule) kept, vendor/spec  both legs pushed, then fatal: Pathspec 'vendor/spec' is in submodule 'vendor'
SPEC/ kept, default spec, core.ignorecase=true   `adoption verified`, NO spec gitlink in the split, bootstrap REFUSED pin-gitlink-absent

On this branch every row above is refused: by plan for the shape rows, and by check and execute for the root-kept rows, the case-only one included (re-run with core.ignorecase=true on 4868074). --local-remote-dir never gets a repository.

Tests

tests/test_adopt_leg_path_collisions.py, 92 tests (81 at 4868074, 11 from the merge round):

  • the list is the materializer's own (materialized into an empty directory: written == assembly_root_paths()), and every path on it is refused as a mount;
  • the shape half at plan and check for contracts, scripts, .github, .github/workflows, project.yaml, AGENTS-shape.md, .gitattributes, contracts/shape-pin.yaml, Makefile/code, shape and shape/spec. At execute it is tested for contracts, scripts, .github, project.yaml and shape. Three case-only spellings (Contracts, PROJECT.YAML, Shape) say they overlap only once case is ignored;
  • 14 paths that collide with nothing pass, among them legs/.github, scripts/spec, Scripts/x, shapes, shape-x and project. legs/.github neither contains nor lies inside .github, because the shape writes .github/ at the ROOT; it also plans, and checks plan ok;
  • the root-kept half at check and execute: a kept directory, a source path inside a kept directory (docs/spec), a kept file at the mount and before it, and a case-only twin. At check only: a kept symlink and a kept submodule before the mount, and .specify/, which plan itself keeps in the root. docs/spec under a kept docs/ that holds nothing there passes check;
  • 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's finding comes first and alone: shape/ at plan; shape/ and a number at check;
  • the merge round: _leg_findings reads the tree it is given, raises with none, and raises on None beside a legs: mapping (canonical or not); plan --spec-path .specify notes the collision, exits 0, writes the plan, and the note is check's finding with --spec-path for legs.spec_path; the defaults and .specify/spec note nothing, nor does a .specify/ asked about for a submodule it holds; --spec-path shape/x is still refused, and its finding and remediation both say shape/ is reserved; plan predicts a collision for every path the shape writes, the shape pin included; adopt's SHAPE_PIN equals the materializer's;
  • end to end (needs_filter_repo): spec_path: contracts and code_path: project.yaml edited into a plan check once passed are refused, and the EMPTY --local-remote-dir stays empty. A kept docs/ is refused where it holds docs/spec/overview.md and adopted with the leg at docs/spec where it does not.

Revert table at 4868074. Each mutation was applied to a fresh clone of main with this branch's three files laid over it, and the new file was run. M0 (no mutation): 81 passed. Every test fails under at least one row.

reverted failed
M1 the whole fix (main's adopt-project.py and shape_materialize.py) 78 of 81
M2 plan's refusal 12
M3 _leg_findings no longer asks (check and execute) 34
M4 the canonical-path guard (collisions asked of any value) 2
M5 the shape half 48
M6 the root-kept half 15
M7 shape/ 9
M8 case-insensitive comparison 5
M9 the / segment boundary (shapes would overlap shape) 5
M10 assembly_root_paths without the shape pin 7
M11 kept half compared against ENTRY paths, not source paths 9
M12 execute reads no source tree 6
M13 check reads no source tree 9
M14 every kept entry called a file 2
M15 execute's remediation sentence 1
M16 the "and N more" count 9
M17 collisions asked before #169's spelling at plan 1
M18 an over-broad rule: a shared top-level directory collides 30
M19 an over-broad rule: everything collides 80

The three tests M1 leaves passing are the #169-first tests: main asks no collision question, so they pass there trivially. Each fails when its own piece is reverted (M4: both bad_leg_path_is_reported_and_not_also_as_a_collision cases; M17: plan_refuses_a_bad_spelling_before_it_asks_about_collisions). The 14 "collides with nothing" cases fail under M1 (the function is gone) and under M19, and five of them under M9 and four under M18.

Unchanged from main, byte for byte (measured at 4868074 against f25d805). One source with fixed dates, run by main and by this branch at the same paths: the defaults spec/code, nested legs/spec + legs/code, and docs/spec under a kept docs/ that holds nothing there. The plan file, plan's output, check's output (plan ok), execute's output (exit 0, adoption verified), the split commit's ls-tree -r, the split commit sha and both leg heads are IDENTICAL in all three. Re-measured after the merge round for plan (exit code, stdout, stderr, plan file) and check (exit code, stdout, stderr) against main e4decfb at the same paths: IDENTICAL in all three, check exit 0 on both. execute was not re-run for that comparison.

Targeted run at 163173e, tests/test_adopt_leg_path_collisions.py tests/test_adopt_leg_paths.py tests/test_adopt_submodules.py tests/test_adopt_plan.py tests/test_adopt_e2e.py tests/test_adopt_execute_refusals.py tests/test_shape_doctor.py tests/test_windows_paths.py tests/test_cli_reference.py:

  • git-filter-repo on PATH: 916 passed, 1 skipped (SHAPE_MEDXEHR_CLONE unset), 551s
  • git-filter-repo hidden: 877 passed, 40 skipped (39 needs_filter_repo, 1 MedxEHR), 498s

docs/cli.md is generated, and render-cli-reference.py --check says [ok]: the module docstring lines this edits are in no --help.

Not in this PR (probed, as asked): scaffold-project.py has the same bug, but it fails loudly where adopt failed silently. With --spec-path contracts (and --code-path project.yaml), --dry-run exits 0. The real run, into local remotes, creates all three repositories, pushes both legs to main, leaves the assembly root empty, and exits 2 at git submodule add: fatal: 'contracts' already exists and is not a valid git repo (for project.yaml: destination path '.../project.yaml' already exists and is not an empty directory). Against GitHub that is three created repositories. leg_path_collisions takes (what, value) pairs and needs only the shape list, so the scaffold can ask it once #179 has moved #169's helpers.

Review

Lane openRepoShape-2 reviewed this branch at 4868074 and found it mergeable with nits: no P1 or P2, and three P3s (#172 (comment)). That review also found this branch closes #191 in full. A root-kept submodule, directory or file at a mount path, a file or symlink above one, and the case twins all get check 1 and execute 2 before any leg exists.

Merge round, after #166 landed on main as e4decfb (PR #194). Five commits on top of 4868074:

Revert table for the round, at 163173e. Each row reverts one change in its own clone and runs tests/test_adopt_leg_path_collisions.py (92 tests) unless a file is named. M0: 92 passed.

reverted failed
MA the merge's _leg_findings(plan, tree) in _entry_findings 65 (38 here + 27 in test_adopt_execute_refusals.py), all TypeError
MB the merge's remediation clause (main's text) 1
MC the merge's *remediation (#166's submodule remedy), test_adopt_submodules.py 1
M1a P3-1: tree = () default restored 1
M1b P3-1: None beside a mapping no longer raises 2
M2a P3-2: no note printed 1
M2b P3-2: notes read the rules' proposal (an asked entry counted as root) 1
M2c P3-2: the note's second line does not name the finding 1
M3a P3-3: remediation back to 4868074's 1
M3b P3-3: shape/ finding back to 4868074's 1
M3c P3-3: policy loosened to shape alone 4
M4a nit: _predict_collisions back on its own list 1
M4b guard: adopt's SHAPE_PIN respelled 1

For the next merge. fix/adopt-root-kept-symlinks (#183, 7b5af45) also extends _entry_findings, and its line is still _leg_findings(plan). git merge-tree of it against this head conflicts in adopt-project.py and scripts/shape_materialize.py. Whichever lands second must keep tree. A resolution that drops it now raises on every check and execute, instead of quietly letting a mount over a kept source path through.

Closes #172
Closes #191

🤖 Generated with Claude Code

…a path the assembly root holds, so `--spec-path contracts` no longer checks ok and dies staging the split after both legs are pushed, and `--code-path project.yaml` no longer says `adoption verified` over an assembly with no manifest (#172)

A leg's mount path is now refused when it EQUALS, CONTAINS or LIES INSIDE,
whatever the case:

- a path the shape writes into the assembly root. That list is
  `assembly_root_paths()` in scripts/shape_materialize.py, read from the
  same lists `materialize_assembly_root` hands `_materialize`, plus the
  shape pin it renders last (`SHAPE_PIN`, now named once there). It covers
  every root FILE the shape writes (`project.yaml`, `AGENTS-shape.md`,
  `.gitattributes`, ...), the directories they live in (`contracts`,
  `scripts`, `.github`), and `shape/`, where `execute` writes its copy of
  a file the root already holds. A test materializes into an empty
  directory and holds the list to what was written.
- a SOURCE PATH the plan keeps in the root: a path of the source tree that
  a `leg: root` entry covers. That includes a file, symlink or submodule
  on the way to the mount.

`plan` refuses the first half (`adopt-leg-path-collides`, exit 2, nothing
written), after #169's spelling check. `check` reports both halves as
`FINDING plan-leg-path-collides`, naming the leg, the path and what it
overlaps, from `_leg_findings`. It asks only once both mount paths are
canonical, so `shape/` stays #169's finding and a number is never compared.
`execute` refuses both through #168's `_refuse_what_check_finds`, before
any leg repository exists. The new code sits in its own functions beside
#169's, which it does not edit, so #179's move of those stays mechanical.

On main at f25d805, with local remotes: `contracts`, `scripts`, `.github`
and `shape` checked `plan ok`, made and pushed both legs, then died
staging the split (`Pathspec 'contracts/spec-pin.yaml' is in submodule
'contracts'`). `project.yaml` ended `adoption verified`, and shape-doctor
calls that assembly `not a shape root`. `AGENTS-shape.md` ended
`adoption verified` and doctor `COMPLIANT` with the code leg mounted where
the shape's rules belong. A mount at a path the plan keeps in the root
(`src` with `src/` kept, `docs/spec` with a kept FILE `docs`, `legs/spec`
past a kept symlink, `vendor/spec` inside a kept submodule) died at `git
submodule add`, after both legs were pushed. With `core.ignorecase=true`,
a kept `SPEC/` and the default `spec` ended `adoption verified` with no
`spec` gitlink and a bootstrap that refuses `pin-gitlink-absent`.

A mount inside a kept DIRECTORY where the source holds nothing (`docs/spec`
with `docs/` kept and no `docs/spec` in the source) overlaps no source
path. It mounts, verifies and bootstraps on main, and it still passes. The
defaults, nested `legs/spec` + `legs/code`, and that case are byte for byte
as on main: plan file, `plan`, `check` and `execute` output, the split
tree, the split commit and both leg heads.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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 1 hour by commenting @sourcery-ai review. Upgrade to get a review now.

@brettheap

Copy link
Copy Markdown
Contributor Author

(lane openRepoShape-1, 2026-10-09T21:57:40Z) @codex review

@sourcery-ai

sourcery-ai Bot commented Oct 9, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR closes adoption’s late and silent mount-path failures by deriving the shape’s written paths from the materializer, checking canonical leg paths against those paths and source paths retained by the plan, and enforcing consistent refusals across plan, check, and execute before any leg repositories are created. Extensive tests validate overlap semantics, case-insensitive filesystems, diagnostics, ordering, and safe no-side-effect behavior.

Sequence diagram for early adoption collision refusal

sequenceDiagram
    participant User
    participant Adopt as adopt-project.py
    participant Materializer as shape_materialize.py
    participant Source
    participant Remotes

    User->>Adopt: plan --spec-path contracts
    Adopt->>Materializer: assembly_root_paths()
    Materializer-->>Adopt: shape-written paths
    Adopt->>Adopt: leg_path_collisions()
    Adopt-->>User: Refusal adopt-leg-path-collides

    User->>Adopt: execute corrected plan
    Adopt->>Source: Source.tree()
    Source-->>Adopt: paths kept in assembly root
    Adopt->>Adopt: _leg_collision_findings()
    Adopt-->>User: Refusal before repository creation
    Note over Remotes: No leg repositories are created or pushed
Loading

Flow diagram for adoption mount-path collision validation

flowchart TD
    A[adopt plan, check, or execute] --> B{Canonical leg paths?}
    B -- no --> C[Existing bad-leg-path handling]
    B -- yes --> D[leg_path_collisions]
    D --> E[assembly_root_paths]
    D --> F[Source.tree paths kept by root entries]
    E --> G{Overlap found?}
    F --> G
    G -- yes --> H[Refuse with plan-leg-path-collides]
    G -- no --> I[Continue adoption]
    H --> J[No leg repositories created or pushed]
Loading

File-Level Changes

Change Details Files
Reject leg mount paths that overlap paths written or retained in the assembly root.
  • Expose the materializer’s actual root output paths, including the rendered shape pin.
  • Add case-insensitive path overlap detection with segment-boundary handling for equality, containment, and nesting.
  • Check shape-written paths during plan validation and report both shape and root-kept collisions during check and execute.
  • Inspect source-tree paths covered by leg: root, including files, symlinks, and submodules, while preserving valid mounts inside empty kept directories.
  • Reuse collision findings and prevent execute from creating or pushing leg repositories before refusal.
adopt-project.py
scripts/shape_materialize.py
Add comprehensive regression coverage for collision detection and command behavior.
  • Verify the collision list exactly matches files materialized into an empty assembly root.
  • Cover shape paths, shape/, case-only overlaps, path-boundary cases, and non-colliding paths.
  • Cover root-kept files, directories, symlinks, submodules, empty kept directories, and finding precedence over invalid path handling.
  • Verify plan, check, and execute exit codes, diagnostics, remediation, and absence of created remotes or split branches.
tests/test_adopt_leg_path_collisions.py

Assessment against linked issues

Issue Objective Addressed Explanation
#172 Refuse canonical leg mount paths that equal, contain, or lie inside paths materialized by the shape in the assembly root, including the shape copy directory, with plan rejecting them before writing a plan and check reporting them. ✅
#172 Detect and refuse leg mount paths that collide with source paths the plan keeps in the assembly root, including paths involving kept files, directories, symlinks, submodules, and case-insensitive matches, with check finding them and execute rejecting them before creating or pushing any leg repository. ✅
#172 Preserve valid default and non-colliding nested mount paths while ensuring collision findings and refusals are consistently applied across plan, check, and execute. ✅
#191 Make check detect when a source-tree entry kept in the assembly root equals, contains, or lies along/beyond spec_path or code_path, including files, directories, symlinks, and submodules, before any leg repositories are created. ✅
#191 Ensure execute refuses the same mount collisions before creating or pushing either leg, so reruns do not encounter partially created leg remotes. ✅
#191 Provide a clear collision finding identifying the affected leg, mount path, overlapping source entry, and remediation. ✅

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

@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.

@brettheap

brettheap commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor Author

(lane openRepoShape-2, 2026-10-10T02:43:40Z) This PR's head 4868074 is the head this lane reviewed on the issue: #172 (comment), MERGEABLE WITH NITS (no P1/P2; three P3s: the tree=() default in _leg_findings lets a sibling merge silently drop the kept-root half; plan proposes root entries its own check then rejects; everything under shape/ is refused). It closes #191 in full, as the body says. CI on this head: tests, tests-macos and tests-windows all pass; Codex limit-refused. Sequencing with #194: the two conflict in adopt-project.py (5 hunks), and whichever lands second must thread tree into #194's _entry_findings (_leg_findings(plan, tree)) and keep both remediation sentences, or #191's fix is lost without a compile error; this lane's pass 7 on #194 (#194 (comment)) has the hunk-by-hunk recipe and the test counts for both resolutions.

brettheap and others added 4 commits October 11, 2026 00:34
…lisions: #166's `_entry_findings` hands `_leg_findings` the source tree, so the root-kept half of #172 (#191) stays on

#166 replaced the two compositions this branch had edited, in `check` and
in #168's `_refuse_what_check_finds`, with `_entry_findings`, the one list
both now read. The merge conflicted in 5 hunks of adopt-project.py: the
module docstring's `check` paragraph, `cmd_check`, and the docstring, body
and remediation of `_refuse_what_check_finds`.

Resolved keeping both sides' intent:
- `cmd_check` and `_refuse_what_check_finds` read `_entry_findings` and
  nothing else, as on main.
- `_entry_findings` calls `_leg_findings(plan, tree)`. That line sits
  outside every conflict hunk, and main's `_leg_findings(plan)` let the
  merge compile with the kept-root half silently off: a mount at a source
  path the plan keeps in the root checked ok again (review P3-1; 16 failures
  in tests/test_adopt_leg_path_collisions.py without it, 81 passed with it).
- `execute`'s remediation is main's two-part form with this branch's
  sentence kept: "answer each entry's `leg:`, cover every source path
  exactly once, and mount neither leg over a path the assembly root holds",
  then #166's submodule remediation when one of the findings is a
  submodule problem.
- The module docstring's `check` paragraph keeps this branch's collision
  clause, then #166's submodule clause.
- `_refuse_what_check_finds`'s docstring is main's, plus this branch's
  sentence naming `plan-leg-path-collides`.

scripts/shape_materialize.py and the tests merged cleanly.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lt, so a caller that loses it, as #166's `_entry_findings` did, raises instead of turning the root-kept half of #172 off without a word

The review of 4868074 (P3-1) found that `_leg_findings(plan, tree=())`
let #166's `_entry_findings`, which calls `_leg_findings(plan)` outside
every conflict hunk, merge and run with the root-kept half (#191) silently
off. The merge commit passes the tree; this makes losing it loud.

- `tree` is required. `_leg_findings(plan)` is a `TypeError`.
- `None` says there is NO source tree. That is true only of the doctor's
  placement plan, whose `legs:` is a list with no mount path to ask about,
  so the doctor-side callers (tests/test_shape_doctor.py and
  tests/test_adopt_leg_paths.py, which hand a placement plan to `Plan` and
  `_leg_findings`) now pass `None`. Beside a `legs:` mapping `None` raises
  too, canonical paths or not, rather than reading as a source that keeps
  nothing in the root.
- Every caller checked: `_entry_findings` is the only one outside the
  tests, and it passes `source.tree()`. shape-doctor.py itself never calls
  `_leg_findings`.

A count corrected: the merge message says 16 tests fail without the tree.
Measured on the merge commit with only that argument removed, 15 fail; 16
is the review's count for a merge that took every hunk from main and so
also lost this branch's remediation sentence.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ps in the root itself, so `plan --spec-path .specify` no longer exits 0 in silence for `check` to reject its own `leg: root` one command later

The review of 4868074 (P3-2) found that `plan` asked only the shape's half
of #172's rule and never the root entries `walk` itself proposed:
`plan --spec-path .specify` wrote a plan that keeps `.specify/` in the root,
exited 0, said nothing, and `check` then found `plan-leg-path-collides` on
it.

`plan` now runs `_kept_collisions` over the `leg: root` entries of the plan
it wrote and prints each as a NOTE, in the sentence `check` will print with
`--spec-path` for `legs.spec_path`, followed by one line naming the finding
`check` will report. Nothing is refused and the exit stays 0: the entry's
answer is the person's to change, and then nothing collides. The entries
read are the ones the plan file carries, so an entry asked again because it
holds a submodule (#166, `leg: null`) keeps nothing in the root and is not
noted; `check` finds `plan-unresolved` there, not a collision.

`_flag_leg_paths` names `--spec-path` and `--code-path` beside their values
once, for `_checked_plan_inputs` and the note, which takes each literal from
three spellings to two. `LEG_COLLIDES` names `check`'s finding once.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the directory is reserved for the shape's own copies, so `--spec-path shape/x` is no longer refused for copies that would not land there

The review of 4868074 (P3-3) found the refusal of everything under `shape/`
over-broad in its words: on main `--spec-path shape/x` adopted, verified
and bootstrapped, and the finding said "the leg's mount and those copies
would share it", which is not why it is refused when no copy lands there.

The policy stays: a mount at or under `shape/` is refused, so whether a
path there collides never depends on which of the root's files a source
happens to hold. The finding and `LEG_COLLISION_REMEDIATION` now both say
why, from one constant: `shape/` is reserved for the shape's own copies of
files the root already holds, so no leg is mounted at or under it, even
where this source needs no copy.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ly_root_paths()`, the list #172's mount rule reads, so a kept `contracts/shape-pin.yaml` is no longer missing from the follow-ups while `execute` writes the shape's pin beside it

The review of 4868074 found `_predict_collisions` still building its own
list from the materializer's three tuples (a nit). That list lacked the
shape pin, which `execute` writes beside a copy the source keeps and names
in the split commit, so the follow-ups a person approves at `plan` did not
match the commit they read after `execute`. It now reads
`assembly_root_paths()`, and the local import of the three tuples is gone.
With the default path policy `contracts/**` goes to the spec leg, so no
plan the rules alone write changes.

adopt-project.py's own `SHAPE_PIN` (#167's, beside its comment) is left as
it landed: unifying it with the materializer's means deleting #167's lines,
not only editing an import. A test holds the two to one spelling instead.

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

@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.

Sourcery assessment

Approved.

@sonarqubecloud

Copy link
Copy Markdown

@brettheap
brettheap merged commit 20e13f0 into main Oct 11, 2026
5 checks passed
@brettheap
brettheap deleted the fix/adopt-leg-path-collisions branch October 11, 2026 16:01
brettheap added a commit that referenced this pull request Oct 11, 2026
…eak-names (#199)

Brings #198's leg mount-path checks under the #199 branch before fix
round 1, so the round's tests run against what main now is. The merge is
clean (no conflicting hunks); the review of d3023fb found the same.

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
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 #172 (#198) and #166 (#194). The leg-path helpers #198's code
asks of adopt-project.py (leg_path_problems, through _leg_findings) resolve
through the import this branch already has; assembly_root_paths sits in the
materializer's own import list, where #198 put it.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 11, 2026
…-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 added a commit that referenced this pull request Oct 11, 2026
…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) (#200)

`_mount_the_legs` passes `--force` to `git submodule add`. A source `.gitignore` that covers the mount path (`*` + `!.gitignore`, `.*`, or one naming `spec` or `code`) therefore no longer kills adoption at the mount after both leg remotes were pushed. Once added, a gitlink is tracked, so ignore rules never touch it again.

`--force` also skips git's own checks of the path, so `_refuse_an_unmountable_path` asks them first, before each mount:
- `adopt-mount-occupied`: the assembly's index already holds the path, a file on the way to it, or a case-only twin of it, on every disk.
- `adopt-mount-unaddable`: git's own dry run refuses the path, for example beyond a symlink.

The remediation names a fresh `--local-remote-dir` and an empty `--work-dir`.

With #172 landed (#198), a plan that keeps such a path in the root is refused earlier, at `check`, and at `execute` before any leg exists. This guard is the defence behind that refusal, and its own refusals are tested in-process past it.

Reviewed adversarially and re-verified, and by lane openRepoShape-2 (mergeable with nits). CI is green on Linux, macOS and Windows.

Closes #174

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
…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 added a commit that referenced this pull request Oct 11, 2026
…-failure-notice

One conflict, in adopt-project.py, on the `from shape_materialize import`
block. This branch had dropped `RULESET_HINT` from it (c77cef0: an adoption
prints its own `ADOPT_RULESET_HINT`, and nothing in adopt-project.py uses
the scaffold's any more). Main had added `assembly_root_paths` and
re-flowed the lines. The resolution keeps both changes: `RULESET_HINT` is
not imported, and `assembly_root_paths` is. Nothing in the merged
adopt-project.py names `RULESET_HINT` outside a comment.

Everything else merged cleanly. `_leg_findings(plan, tree)` and
`_entry_findings` are as #198 left them, with `tree` passed. The only
unused import is `COMMIT_RE`, which is unused on main as well.

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
…findings` hands `_leg_findings` the tree #198 requires and still ends with the root-symlink findings, so `check` and `execute` report both from one list

#198 (#172 + #191) made `_leg_findings(plan, tree)` take the source tree
as a REQUIRED argument, and added `assembly_root_paths()` and
`SHAPE_PIN` to the materializer, the same function and constant this
branch had added. The merge conflicted in four hunks. Each is resolved
keeping both sides:

- scripts/shape_materialize.py, `assembly_root_paths()`'s docstring. The
  body and `SHAPE_PIN` were identical on both sides. The docstring now
  names both of its readers in adopt-project.py, the mount-path refusal
  (#172) and `check`'s walk through the symlinks a plan keeps (#178),
  and both test files that hold the list to an empty-target run.
- adopt-project.py, the module docstring's `check` paragraph: #198's
  mount-path clause inside the parenthesis, then #166's submodule
  clause, then this branch's symlink clause.
- adopt-project.py, the `shape_materialize` import list: this branch's
  side. It already held `assembly_root_paths`, the one name #198 added,
  beside `BOOTSTRAP` and `SYMLINK_HOPS`.
- adopt-project.py, `_entry_findings`'s docstring: coverage, then each
  entry's `leg:` and the two mount paths (#198), then the source's own
  submodules, then the root-symlink findings (this branch).

Merged without a conflict, and read after the merge:
- `_entry_findings` calls `_leg_findings(plan, tree)` and appends
  `_root_symlink_findings(plan, source, tree)` after the submodule
  findings.
- `_refuse_what_check_finds` keeps #198's remediation clause ("mount
  neither leg over a path the assembly root holds") followed by #166's
  `*remediation`. Its docstring keeps this branch's symlink clause and
  #198's `plan-leg-path-collides` sentence.
- `execute` still runs `_refuse_symlinks_checked_out_as_files` right
  after `_refuse_what_check_finds`, before any leg.
- This branch's own remediation sentences (the `plan-root-symlink`
  finding's, `adopt-symlinks-off`'s, and the materializer's
  `UNWRITABLE_REMEDIATION`) are in code #198 did not touch.

Where both fire for one plan (`.github -> ci` kept with `ci/` kept and
`legs.spec_path: ci`; `.github -> ../outside-ci` with
`legs.spec_path: .github`), `check` prints `plan-leg-path-collides`
first and `plan-root-symlink` after it. Each sentence is true of the
plan as written. `execute` refuses under the first code with all of
them, before any leg exists.

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
…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
…, #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
…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
…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
…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
…, #208, #197, #202 and #194's scaffold half merge with two hunks kept on both sides, `_entry_findings` still hands `_leg_findings` the tree, and the walker says #198's case aside through #197's one phrase

origin/main moved 54aa69a -> 39ac59c: 4835fb4 (#199), 404760f (#213),
e7d1720 (#208), b538015 (#197), 150c41d (#202), 39ac59c.

Conflicts, each resolved by keeping both sides:
- adopt-project.py, the `shape_materialize` import list. This branch adds
  BOOTSTRAP, SYMLINK_HOPS and template_files; #199 adds write_paths_listing.
  The resolution is the union.
- scripts/shape_materialize.py, `assembly_root_paths()`'s docstring. #197
  rewrote it for `neutral_pin_path` and the scaffold's refusal; this branch
  had added that `adopt-project.py check` follows each path through the
  symlinks a plan keeps (#178), and its test file. The resolution keeps
  #197's text and adds both of those.

Found after the textual merge, and fixed here so that no commit is broken:
#197 moved #198's CASE_ASIDE out of adopt-project.py into
shape_materialize.py. Its test_both_tools_ask_the_one_definition asserts
that adopt has no CASE_ASIDE attribute: no phrase of its own. This branch's
walker says that aside in two places (`_root_symlink_findings` and
`_refuse_symlinks_checked_out_as_files`). The plain merge left both names
unbound, a NameError for every case-twin finding and every symlinks-off
walk. They now read shape_materialize's phrase, imported as `_CASE_ASIDE`,
as #197's own import block names `_overlap` and `_first_and_more`.

Checked on the merged tree:
- `_entry_findings` still calls `_leg_findings(plan, tree)` and ends with
  `_root_symlink_findings(plan, source, tree)`.
- No name in adopt-project.py or scripts/shape_materialize.py is loaded but
  bound nowhere (AST). Every line over 79 columns is main's own.
- Both sides are intact by +/- line sets. This branch's diff against main
  is the same as before the merge, and so is main's diff against this
  branch, apart from the two hunks above and the import.
- The same resolution, rehearsed in a scratch clone (tree e914b55, the same
  tree as this commit's), passed tests/test_adopt_root_symlinks.py,
  test_adopt_leg_path_collisions.py, test_adopt_plan_escapes.py,
  test_adopt_verify.py, test_scaffold_leg_path_collisions.py and
  test_repo_hygiene.py: 418 passed.

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
…, #238, #196, #254, #242 and #262/#263 merge with three adopt-project.py hunks kept on both sides, and #262's `_CASE_ASIDE` import kept as the name's one binding

origin/main moved b30595c -> 71b58a1:
- be2790e (#204 via #227), update-shape.py;
- 6d8d88b (#203 via #236), family.py;
- ede15ce (#238 via #287), shape-doctor.py;
- 6f45bf9 (#196 via #231): adopt-project.py `entry_path_problem`,
  scripts/shape_materialize.py;
- b421e6b (#254 via #281): scripts/shape_materialize.py, bump-leg.py,
  update-shape.py;
- c0ed615 (#242 via #308), family.py;
- 71b58a1 (#262 and #263 via #313): adopt-project.py
  `_root_shape_findings` and scripts/shape_materialize.py
  `copy_in_the_way`. It fixes what this branch's pull request listed as
  follow-ups (i) and (ii): a source's own `shape/` where the shape
  writes its copy, and a plain FILE where the shape needs a directory.

Conflicts, all in adopt-project.py, each resolved by keeping both sides:
- The module docstring's `check` paragraph. 71b58a1 adds "no path kept
  in the root where the shape writes ..." before the submodule clause,
  and this branch adds the symlink clause after it. Both are kept, in
  that order.
- `_entry_findings`' docstring. 6f45bf9 and 71b58a1 give the order
  "each entry's path, then coverage, then each entry's `leg:`, the two
  mount paths and what the root keeps where the shape writes, then the
  source's own submodules". This branch adds "then each symlink the plan
  keeps in the root that a shape file cannot be written through".
- `_entry_findings`' return line. 6f45bf9 returns
  `unsafe_remediation + remediation`, and this branch appends
  `_root_symlink_findings(plan, source, tree)` to the findings. The
  merge returns both.

Found after the textual merge, and resolved here so that no commit binds
a name twice: 71b58a1 (through 65a9262) imports #198's phrase as
`_CASE_ASIDE` in the "#172's shape half" import block, and b37159a had
imported it on a line of its own. Main's import is kept; this branch's
line and its five-line comment go.

scripts/shape_materialize.py merges with no conflict. `place` gets
71b58a1's `copy_in_the_way` inside its collision block and this branch's
`_refuse_unwritable` after it, as 71b58a1's message foresaw.

Checked on the merged tree:
- `_entry_findings` still hands `_leg_findings` the tree, and the
  symlink findings still come last in its list.
- AST: no top-level name is bound twice in adopt-project.py,
  scaffold-project.py, scripts/repo_shape.py or
  scripts/shape_materialize.py, and none is loaded but bound nowhere.
  Main changed the signature of no function this branch calls.
- Both sides are intact by +/- line sets, apart from the three hunks and
  the import above.

The next two commits fix what this merge breaks, each with a revert
line. #262's rule and this branch's both name a symlink kept AT the
copy under `shape/`. And where the shape's copy lands is now
`copy_in_the_way`'s question, asked before this branch's own check of
it.

Lane: openreposhape-1 (openRepoShape-1)
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