Skip to content

adopt-project.py: the split force-stages every file the shape wrote past a source .gitignore such as .*, and the verification fails on any file contracts/shape-pin.yaml names that the split commit lacks, so a hidden .gitattributes no longer passes as adoption verified and then fails the first bootstrap (#167) - #182

Merged
brettheap merged 3 commits into
mainfrom
fix/adopt-split-force-add-shape-files
Oct 9, 2026

Conversation

@brettheap

@brettheap brettheap commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

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

What

adopt-project.py execute now commits every file the shape wrote into the assembly root, even when the source's .gitignore hides it. Its verification also fails when a file contracts/shape-pin.yaml names is missing from the split commit. Before this, a source with the common .* + !.gitignore got a split without .gitattributes and .github/workflows/validate.yml, execute still printed adoption verified, and the assembly's first make bootstrap refused.

This is head b635473, the first push (119d666) plus a round that took the adversarial review's findings (below). The branch is based on 7f84ca4; main has since moved to b18cca9 (#168, merged as #170).

Why

_commit_the_split staged the assembly root with git add -A -- ., which follows the source's .gitignore, so every new dot-file the shape wrote was skipped. _verify checks only the source's own paths, so nothing noticed the gap. Reproduced on 7f84ca4: a source whose .gitignore is .* + !.gitignore, with no submodules, taken through plan, check and execute --local-remote-dir, then git clone --recurse-submodules and scripts/bootstrap.py:

=== main 7f84ca4
plan exit 0
check exit 0
    adoption verified: every source path is in exactly one place
execute exit 0
split has .gitattributes: False | .github/workflows/validate.yml: False
clone exit 0
    FINDING shape-copy-missing: contracts/shape-pin.yaml: .gitattributes is pinned but absent
    FINDING shape-copy-missing: contracts/shape-pin.yaml: .github/workflows/validate.yml is pinned but absent
bootstrap exit 1

The same run on this branch, re-run at the head:

=== branch b635473
plan exit 0
check exit 0
    adoption verified: every source path is in exactly one place
execute exit 0
split has .gitattributes: True | .github/workflows/validate.yml: True
clone exit 0
    bootstrap ok
bootstrap exit 0

(The reproduction script prints a command's lines before its exit code, so adoption verified is execute's, printed above execute exit 0.)

The fix

  1. Staging: _stage_the_split. It runs git add -A -- . as before, which stages the mount's deletions and any edit to a tracked file. Then it runs git add -f -- on exactly the paths materialize_assembly_root returned in Materialized.written. That list records where each file was actually written, including a copy written beside a source file under shape/ and the Makefile with the adopt block. The paths use the forward-slash form root_key gives on every platform, which git also accepts on Windows. It never runs -f ., so a file the source itself ignored stays out.

    Each path is staged as _where_it_landed spells it: unchanged when no symlink is on the way to it, the path the assembly's own symlinks lead to when one is, and not staged at all when the link leads out of the assembly. A path with no link on the way is never resolved, so Windows never gets a respelled one.

  2. Verification: _shape_file_findings. It reads the pin from the split commit (not from disk) with repo_shape.parse_yaml and checks every listed path against that commit's tree. It has to read the commit because the working tree still holds the ignored file, so a disk check would miss the gap. Each missing path is one finding.

    A pinned path is looked up the way the first bootstrap's validate-pins.py opens it, by _SplitTree: through the tree's own symlinks (mode 120000, the blob is the target), each target read from the link's own directory, .. taken only from a directory and never above the root, an absolute target leading out, and more than 40 hops (Linux's MAXSYMLINKS) a loop. The path counts as present only when it leads to a regular file of the tree (100644 or 100755), which is what a checkout's is_file() finds. A gitlink at a listed path, or a link left unfollowed, does not count.

    A missing pin is reported with the same finding id. A pin that is not a files: list of paths, an empty list included, is reported as adopt-shape-pin-unreadable rather than passing as if it listed nothing. The check covers presence only; validate-pins.py still checks the digests at the first bootstrap.

  3. One remediation, SHAPE_FILE_EXIT. Once the files are forced, a source .gitignore can no longer hide one, so the finding fires for a plan answer (the source's own file at a shape path, most often its own contracts/shape-pin.yaml, or a symlink on the way to a shape path, kept in the root) or for a defect of the tool. Both findings now say so, and nothing else:

    FINDING adopt-shape-file-missing: src/app/main.py is named by contracts/shape-pin.yaml but is not in the split commit 486c2dae365e, so the assembly's first `make bootstrap` refuses with shape-copy-missing. If the plan kept in the root a file of the source's own at a shape file's path -- its own contracts/shape-pin.yaml most often, the shape's then beside it as shape/contracts/shape-pin.yaml -- or a symlink on the way to one, send that path to a leg or `drop` it, and re-run into fresh legs. Otherwise the split itself is wrong: do not merge it, and report it to opensoft/openRepoShape
    

_verify changes by exactly one line, findings += _shape_file_findings(assembly, split_commit) after _account_for. Its signature and root-tree loop are untouched because #165 changes them.

Review findings taken

An adversarial review of 119d666 (it reproduced the fix's own table, found six correct adoptions byte-identical to main, and ran the four-way merges) found one blocker, one coordination blocker, one should-fix and seven nits. What was done with each:

finding what it was taken as
B1 A root-kept symlink on a directory the shape writes through (a source with ci/workflows/ci.yml and a tracked .github -> ci, both answered root) adopts and bootstraps on main, but died on 119d666 at git add -f with pathspec '.github/workflows/validate.yml' is beyond a symbolic link, after the legs were pushed. The new check also called that file missing in main's own bootstrapping split. Not refused: main handles it. The staging follows the assembly's symlinks (item 1 above) and the check follows the tree's (item 2). On the review's own runs: 119d666 gave execute 2; b7083ca gives check 0, execute 0 adoption verified, clone 0, bootstrap 0, and the check gives 0 findings on main's own split a06bcbd33ae9. A link out of the tree, a loop and a dangling link are findings, never a hang or a quiet pass.
S1 The adopt-shape-file-missing remediation (.gitignore hid it; git add -f, commit and push the split branch) named a cause this commit makes impossible, prescribed a command that fails in every case still reachable, and contradicted AGENTS.md step 7 and the footer _verify prints under it. Reworded to the one SHAPE_FILE_EXIT above: the plan answer with the footer's own exit, else a defect report. No .gitignore, git add -f or push advice.
N1 The tail "refuses with shape-copy-missing" was untrue for a missing pin: validate-pins.py says shape-pin-missing there. Each finding names the refusal the bootstrap gives: shape-pin-missing for the pin, shape-copy-missing for a pinned file.
N2 adopt-shape-pin-unreadable named no exit. It carries SHAPE_FILE_EXIT.
N3 Test gap: the mutant accepting files: [] survived 15 of 15. files: [] is a parameter of a_pin_that_is_not_a_list_of_paths_fails_closed; it fails under that mutant (MM4 below).
N4 Test gap: no end-to-end test of the case the finding is now left for. a_source_pin_kept_in_the_root_fails_verification_with_the_plan_answer: the source keeps its own contracts/shape-pin.yaml in the root, execute exits 1 with one finding naming src/app/main.py, the plan answer and the defect exit, and the split's pin is the source's own bytes. On main the review's equivalent run (own-pin-moved) got execute 0 and then a bootstrap that refused.
M1 Coordination, below. Named as a dependency.
N5 After #165 the raw "160000" should be GITLINK_MODE. Not yet, see below.
N6 _verify lists the split tree twice (once itself, once in _shape_file_findings): one extra git ls-tree -r. Left: harmless, and passing the listing in would change the helper's signature the tests call.
N7 plan --spec-path contracts and --code-path scripts pass plan and check, then fail at staging after both legs are pushed (on main, at the first bootstrap). Pre-existing, and the branch is strictly better. Not in this PR: filed as #172.

Dependencies

Tests

tests/test_adopt_ignored_shape_files.py (new; 30 test items, 21 of them run without git-filter-repo, so they also run on the Windows job):

  • Staging on a hand-made assembly whose .gitignore is .*: the shape's paths (one of them under shape/) are staged, three stray ignored files planted in the assembly are not, and the README edit and the mount's deletion are still staged. A second test checks the git command line built from a Windows-keyed written: forward slashes, and never a bare . after -f. A third has a real symlink on the disk: a path written through .github -> ci is staged at ci/workflows/, and one through a link out of the assembly is not staged (it skips on win32, where a tracked symlink is a plain file).
  • The check on hand-made split commits: a listed file present on disk but missing from the commit is a finding; a commit holding every listed file has none; a missing pin, four malformed pins (no files:, a row without a path, not parseable, files: []) and a gitlink at a listed path are each reported.
  • The check through the split tree's symlinks, with the link in the commit's tree only (git update-index --cacheinfo), so no platform needs a symlink privilege: four layouts are found (a linked directory, a linked file, a chain read from each link's own directory, the pin itself behind a link), and six lead nowhere and are findings (an absolute link, a link above the root, a link to itself, a loop of two, through a name that is not a directory, a dangling link). The lookup runs under a 60-second thread bound, so a loop fails the test and cannot hang the run.
  • End to end under git-filter-repo, with a source that has no submodules and the .* ignore, run with and without a tracked .gitattributes of its own (in the second case the shape's copy goes to shape/.gitattributes, which .* hides again): every pinned file is in the split, and the recursive clone bootstraps.
  • The B1 source end to end (a disk symlink, so it skips on win32): execute adopts, the split holds the 120000 link and the workflow where it leads, and the recursive clone bootstraps.
  • execute run in process, with ignored files written into the assembly right after the shape's files (the only way an ignored file can be on disk when the split is staged): none of them is committed, and the source's own untracked ignored files are untouched.
  • execute run in process with the staging put back as it was on main: it exits 1 and names both missing files.
  • N4: the source's own pin kept in the root, as in the table above.

Revert table

Each test item was run against the original code and against deliberately broken versions (mutants) of the fix, one at a time, over the whole new test file at b635473. Every item fails on main, except the two B1 end-to-end tests, which pass there by design (main adopts that source) and are the guard against the regression 119d666 introduced. Every item fails under at least one mutant that breaks its own part of the fix.

  • main: the whole change reverted (7f84ca4's adopt-project.py). R0: this round reverted (119d666's adopt-project.py).
  • Staging: R1 forced add removed; M3 git add -f -- .; MS1 staging not resolved through symlinks; MS2 a link out of the assembly still staged.
  • Verification wiring: R2 the _verify line removed; R2b the check reports nothing; M4 presence read from the disk, the pin still from the commit; M6 every listed path reported; M7 a malformed pin passes; M8 a missing pin passes.
  • The tree lookup: MV1 the tree's symlinks not followed; MV2 no loop limit; MV3 an absolute target followed; MV4 .. at the root stays at the root; MV5 no directory check on ..; MV6 targets read from the root, not from the link's directory; MV8 the last link not followed; MV10 a gitlink counts as a file (the old M5).
  • Wording: MM1 the old .gitignore / git add -f remediation; MM2 the missing-pin tail says shape-copy-missing; MM3 the unreadable finding without its exit; MM4 files: [] accepted.
test main R0 also fails under
the_split_forces_the_shape_files_and_nothing_else FAIL pass R1, M3
the_forced_paths_are_the_written_ones_in_posix_spelling FAIL pass R1, M3
a_file_written_through_a_symlink_is_staged_where_it_landed FAIL FAIL MS1, MS2
a_pinned_file_the_split_commit_lacks_is_a_finding FAIL FAIL R2b, M4, M6, MM1
a_split_commit_holding_every_pinned_file_has_no_findings FAIL pass M6
a_split_commit_with_no_pin_is_one_finding_about_the_pin FAIL FAIL R2b, M8, MM1, MM2
a_pin_that_is_not_a_list_of_paths_fails_closed[no-files-block] FAIL FAIL R2b, M7, MM1, MM3
a_pin_that_is_not_a_list_of_paths_fails_closed[row-without-a-path] FAIL FAIL R2b, M7, MM1, MM3
a_pin_that_is_not_a_list_of_paths_fails_closed[not-parseable] FAIL FAIL R2b, M7, MM1, MM3
a_pin_that_is_not_a_list_of_paths_fails_closed[an-empty-list] FAIL FAIL R2b, M7, MM1, MM3, MM4
a_gitlink_at_a_pinned_path_is_not_the_pinned_file FAIL pass R2b, MV10
a_pinned_path_is_found_through_the_split_trees_symlinks[a-linked-directory] FAIL FAIL M4, M6, MV1
a_pinned_path_is_found_through_the_split_trees_symlinks[a-linked-file] FAIL pass M4, M6, MV1, MV8
a_pinned_path_is_found_through_the_split_trees_symlinks[a-chain-read-from-each-links-own-directory] FAIL FAIL M4, M6, MV1, MV6
a_pinned_path_is_found_through_the_split_trees_symlinks[the-pin-itself-behind-a-link] FAIL FAIL M6, MV1
a_link_out_of_the_tree_or_round_a_loop_is_a_finding[an-absolute-link] FAIL FAIL R2b, M4, M6, MV1, MV3
a_link_out_of_the_tree_or_round_a_loop_is_a_finding[a-link-above-the-root] FAIL FAIL R2b, M4, M6, MV1, MV4
a_link_out_of_the_tree_or_round_a_loop_is_a_finding[a-link-to-itself] FAIL FAIL R2b, M4, M6, MV1, MV2
a_link_out_of_the_tree_or_round_a_loop_is_a_finding[a-loop-of-two] FAIL FAIL R2b, M4, M6, MV1, MV2
a_link_out_of_the_tree_or_round_a_loop_is_a_finding[through-a-directory-that-is-not-there] FAIL FAIL R2b, M4, M6, MV1, MV5
a_link_out_of_the_tree_or_round_a_loop_is_a_finding[a-dangling-link] FAIL FAIL R2b, M4, M6
the_split_lands_the_files_the_pin_names[no-attributes-of-its-own] FAIL pass R1, M6
the_assembly_bootstraps_where_it_failed_with_shape_copy_missing[no-attributes-of-its-own] FAIL pass R1
the_split_lands_the_files_the_pin_names[its-own-attributes] FAIL pass R1, M6
the_assembly_bootstraps_where_it_failed_with_shape_copy_missing[its-own-attributes] FAIL pass R1
a_file_the_gitignore_hides_is_not_swept_into_the_split FAIL pass R1, M3, M6
execute_fails_at_verification_when_the_split_lacks_a_pinned_file FAIL pass R2, R2b, M4
a_root_kept_symlink_the_shape_writes_through_adopts pass FAIL M6, MS1, MV1
the_assembly_with_a_root_kept_symlink_bootstraps pass FAIL M6, MS1, MV1
a_source_pin_kept_in_the_root_fails_verification_with_the_plan_answer FAIL FAIL R2, R2b, M4, M6, MM1

R1, R2, R2b, M3, M4, M6, M7 and M8 are the first push's mutants, re-measured at b635473 (their code was reshaped by the round); MS, MV and MM are the round's own. Notes: [a-dangling-link] is a regression guard on the finding's message, and no single-line mutant isolates it from the others. [a-linked-file] passes on 119d666, whose check counted the link entry itself as the file, and fails under MV8 only because of the regular-file mode requirement. MV2 fails after two 60-second thread timeouts and does not hang. The one guard left unmutated is "no symlink on the way means pass the path as it is": it is invisible on POSIX by design, because it exists so that Windows never respells a path.

Test runs

python3 -m pytest tests/test_adopt_ignored_shape_files.py tests/test_adopt_e2e.py tests/test_adopt_spec_only.py tests/test_adopt_submodules.py tests/test_windows_paths.py tests/test_cli_reference.py -q -p no:cacheprovider, run at b635473:

run result
with git-filter-repo on PATH 120 passed in 78.89s
with /home/brett/.local/bin removed from PATH, so no git filter-repo, as on the Windows job 77 passed, 43 skipped in 28.23s

All 43 skips read "git filter-repo is not installed": 9 in the new file, all 19 of test_adopt_e2e.py, all 13 of test_adopt_spec_only.py, 2 of test_adopt_submodules.py. The full suite has not been run on this branch.

README.md, AGENTS.md and tests/test_adopt_submodules.py are unchanged.

Closes #167

🤖 Generated with Claude Code

Summary by Sourcery

Make project adoption verify and commit every shape-pinned file so ignored or symlinked files cannot cause a later bootstrap failure.

New Features:

  • Ensure all files written by the shape are included in the split commit even when hidden by the source repository’s ignore rules.
  • Verify that every file listed in the split commit’s shape pin is present and usable, including paths resolved through in-tree symlinks.

Bug Fixes:

  • Prevent adoption verification from passing when hidden shape files are absent and the first bootstrap would fail.
  • Report missing, malformed, or unusable shape pins with actionable verification findings instead of allowing silent success.

Enhancements:

  • Handle symlinked paths, links outside the assembly, loops, dangling links, and gitlinks consistently during staging and split-tree verification.
  • Add a focused test suite covering ignored files, symlink resolution, malformed pins, end-to-end adoption, and bootstrap behavior.

Tests:

  • Add comprehensive unit and integration coverage for forced staging and shape-pin completeness verification across supported environments.

brettheap and others added 3 commits October 9, 2026 00:59
…ast a source `.gitignore` such as `.*`, and the verification fails on any file `contracts/shape-pin.yaml` names that the split commit lacks, so a hidden `.gitattributes` no longer passes as `adoption verified` and then fails the first bootstrap (#167)

`_commit_the_split` staged the assembly root with `git add -A -- .`, which honours the source's `.gitignore`. With the common `.*` + `!.gitignore` it skipped every new dot-file the shape wrote -- `.gitattributes` and `.github/workflows/validate.yml` -- so the split commit lacked two files its own `contracts/shape-pin.yaml` pins, `execute` still printed `adoption verified` because `_verify` accounts only for the SOURCE's paths, and the assembly's first `make bootstrap` refused with `FINDING shape-copy-missing: contracts/shape-pin.yaml: .gitattributes is pinned but absent`.

The staging is now `_stage_the_split`: `git add -A -- .` as before, for the deletions the mount made and edits to tracked files, then `git add -f --` over exactly the paths `materialize_assembly_root` returned in `written` -- where each landed, a collision copy under `shape/` included, in the POSIX spelling `root_key` gives on every platform. Never `-f .`: a file the source itself ignored stays out.

`_verify` gains one line, after `_account_for`: `_shape_file_findings` reads the pin out of the SPLIT COMMIT with `repo_shape.parse_yaml` and reports `FINDING adopt-shape-file-missing` for every pinned path that commit's tree does not hold (a gitlink is not the file), so the gap fails `execute` instead of the first bootstrap. The commit, never the disk: the assembly's working tree still has the ignored file. A pin that is absent is that same finding; one that is not a `files:` list of paths is `adopt-shape-pin-unreadable`, never a vacuous pass. `_verify`'s signature and root-tree loop are untouched (#165 edits them).

Tests (tests/test_adopt_ignored_shape_files.py): the staging on a hand-made assembly with stray ignored files planted in it, and the argv on a Windows-keyed `written`; the new check on hand-made split commits, including a pinned file present only on disk, a missing or malformed pin and a gitlink at a pinned path -- all without git-filter-repo; and, under git-filter-repo, a source with no submodules and the `.*` ignore adopted end to end (with and without a `.gitattributes` of its own), whose split holds every pinned file and whose recursive clone bootstraps; `execute` run in process with ignored files dropped into the assembly as the shape is written, which commits none of them; and `execute` with the staging put back as it was, which exits 1 naming both files.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ps in the root is staged where it landed and found there by the verification, the way the first bootstrap finds it, and every shape-file finding names the plan answer or a defect report instead of a hand-staged `git add -f` (#167)

A source that tracks `ci/workflows/ci.yml` and a symlink `.github -> ci`, both kept in the root, adopted and bootstrapped on main: the shape's workflow is written THROUGH the link, to `ci/workflows/validate.yml`, and `validate-pins.py` opens the pinned `.github/workflows/validate.yml` through the clone's link. 119d666 broke it twice. Its forced add died with `fatal: pathspec '.github/workflows/validate.yml' is beyond a symbolic link` after the legs were pushed, and its check, run on main's bootstrapping split, called that file missing.

Staging: `_stage_the_split` passes each written path through `_where_it_landed`. A path with no symlink on the way is passed as it is, never resolved, so nothing that verified before changes spelling. One with a symlink inside the assembly is staged where the links lead, `ci/workflows/validate.yml`. One whose link leads out of the assembly is not staged, and the verification reports it.

Verification: `_SplitTree` reads the split commit the way a checkout does. A pinned path, the pin's own included, is followed through the tree's own symlink entries (mode 120000, the blob is the target), each target read from the link's own directory, the last component too. `..` is taken only from a directory and never above the root, an absolute target leads out, and the 41st link is a loop (Linux's MAXSYMLINKS). Each of these is a finding naming the link, never a hang and never a quiet pass. On the review's own adoptions the check now agrees with bootstrap everywhere: 0 findings on main's symlinked split a06bcbd33ae9 (bootstrap 0), the same findings as before on the splits whose bootstrap fails.

The findings (review S1, N1, N2): once the add is forced a `.gitignore` cannot keep a shape file out, so the `.gitignore` diagnosis and the `git add -f` / push advice are gone. That advice contradicted the footer printed under it and AGENTS.md step 7, and it fails in every case still reachable. `SHAPE_FILE_EXIT` gives the two exits that remain. If the plan kept the source's own file at a shape path in the root (its own `contracts/shape-pin.yaml` most often, the shape's then beside it under `shape/`), or a symlink on the way to one, send that path to a leg or `drop` it and re-run into fresh legs. Otherwise the split itself is wrong: do not merge it, and report it to opensoft/openRepoShape. The tail names the refusal bootstrap actually gives: `shape-pin-missing` for the pin itself, `shape-copy-missing` for a file it names. `adopt-shape-pin-unreadable` now says what to do too.

Tests (tests/test_adopt_ignored_shape_files.py):
- With no git-filter-repo and no disk symlinks, so they run on Windows: the tree resolution through a linked directory, a linked file, a chain read from each link's own directory, and the pin itself behind a link. Six links that lead nowhere are each one finding: absolute, above the root, a self-link, a loop of two, `..` through a missing directory, and dangling. A thread bounds each lookup, so a loop fails the test rather than hanging the run.
- `files: []` is now a pin parameter (N3). The message assertions now require the two exits and forbid `gitignore`, `git add` and `push`.
- With a disk symlink (skipped on Windows): the staging of a file written through `.github -> ci`, and a link out of the assembly that is not staged.
- Under git-filter-repo: the review's symlinked source, adopted, verified, cloned recursively and bootstrapped. And the source's own pin kept in the root (N4): `execute` exits 1 with exactly one finding, carrying the plan answer and no `git add`.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… to a regular file of the split tree, mode 100644 or 100755, which is what a checkout's `is_file()` finds, rather than to any entry that is not a mount (#167)

`_SplitTree.blob_at` used to accept any entry at the resolved path except a gitlink. The two are equivalent today, because `_resolve` follows every symlink, the last one included, so the resolved entry can never be a link. But a regression that stopped following the last link would then have counted the link entry itself as the pinned file, and `test_a_pinned_path_is_found_through_the_split_trees_symlinks[a-linked-file]` would still have passed. Naming the two regular-file modes says what the check means and turns that regression into a failing test. `mounts` stays, for `..` out of a mounted leg's directory.

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-09T03:40:26Z)
@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 16 hours and 22 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

Updates adoption execution so shape-written files cannot be silently omitted by the source .gitignore, and verification checks the split commit’s tree—including symlink semantics—against its shape pin before reporting adoption verified; extensive regression and end-to-end tests cover the corrected behavior.

Sequence diagram for adoption staging and verification

sequenceDiagram
    participant Execute
    participant Materializer
    participant Git
    participant Verifier
    participant SplitTree

    Execute->>Materializer: materialize_assembly_root()
    Materializer-->>Execute: Materialized.written
    Execute->>Git: git add -A -- .
    Execute->>Git: git add -f -- written paths
    Execute->>Git: env_commit()
    Git-->>Execute: split_commit
    Execute->>Verifier: _shape_file_findings(assembly, split_commit)
    Verifier->>Git: cat-file blob contracts/shape-pin.yaml
    Verifier->>SplitTree: blob_at(pinned path)
    SplitTree-->>Verifier: regular-file presence or finding
    Verifier-->>Execute: adoption verified or findings
Loading

Flow diagram for shape-file verification outcomes

flowchart TD
    A[Split commit created] --> B[Read contracts/shape-pin.yaml from split commit]
    B --> C{Valid non-empty files list?}
    C -- No --> D[adopt-shape-pin-unreadable]
    C -- Yes --> E[Resolve each pinned path through split-tree symlinks]
    E --> F{Leads to regular file?}
    F -- Yes --> G[Verification continues]
    F -- No --> H[adopt-shape-file-missing]
    D --> I[SHAPE_FILE_EXIT]
    H --> I
    G --> J[adoption verified if no other findings]
Loading

File-Level Changes

Change Details Files
Force staging of files materialized by the shape while preserving source ignore behavior for unrelated files and correctly handling symlinked destinations.
  • Add _stage_the_split to combine normal add behavior with targeted git add -f pathspecs.
  • Use Materialized.written and _where_it_landed to stage files at their resolved in-assembly locations, excluding paths that resolve outside the assembly.
  • Preserve forward-slash path spelling and avoid forcing the entire assembly tree.
adopt-project.py
Verify shape-pinned files against the committed split tree rather than the working tree.
  • Read and validate contracts/shape-pin.yaml from the split commit, failing closed for missing or malformed pins.
  • Add _SplitTree to resolve pinned paths through committed symlinks, reject external paths, loops, invalid .. traversal, dangling links, and gitlinks, and require regular-file modes.
  • Wire shape-file findings into _verify and distinguish shape-pin-missing from shape-copy-missing bootstrap failures.
adopt-project.py
Add focused regression, cross-platform, symlink, and end-to-end coverage for ignored shape files and verification failures.
  • Test targeted staging, ignored stray files, deletions, edits, Windows path spelling, and symlink destinations.
  • Test committed-tree pin lookup, malformed and empty pins, missing files, gitlinks, symlink chains, escape paths, and loops.
  • Test real execute/bootstrap flows and the remediation path when a source-owned pin is retained in the root.
tests/test_adopt_ignored_shape_files.py

Assessment against linked issues

Issue Objective Addressed Explanation
#167 Ensure that every file materialized by the shape is staged into the split commit even when the source .gitignore would exclude it, while continuing to stage mount deletions and tracked edits without sweeping in unrelated ignored files. ✅
#167 Extend adoption verification to read contracts/shape-pin.yaml from the split commit and report a finding when the pin or any file it names is missing or invalid, including correct handling of split-tree symlinks and gitlinks. ✅
#167 Prevent execute from reporting adoption verified when the resulting assembly would fail its first bootstrap because shape files are absent, while providing actionable remediation for plan conflicts or tool defects. ✅

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

@sonarqubecloud

sonarqubecloud Bot commented Oct 9, 2026

Copy link
Copy Markdown

@brettheap
brettheap merged commit 21f5c33 into main Oct 9, 2026
5 checks passed
@brettheap
brettheap deleted the fix/adopt-split-force-add-shape-files branch October 9, 2026 07:52
@brettheap

Copy link
Copy Markdown
Contributor Author

(lane openRepoShape-2, 2026-10-09T07:54:18Z) This head, b635473, was reviewed by lane openRepoShape-2 before the PR opened; the findings are on the issue: #167 (comment). Verdict MERGEABLE WITH NITS: #167 fixed, the symlinked-root regression fixed, merges clean with main, #166 and #165. Still open from that review: the pin-collision case (a source keeping its own contracts/shape-pin.yaml at root makes C9b and the symlinked D13 print "adoption verified" while bootstrap fails), one new P3 (a root-kept symlink INTO a mount aborts after the legs), and the b7083ca message's "agrees with bootstrap everywhere" wording. Review was read-only; lane openRepoShape-2 holds no claim here.

brettheap added a commit that referenced this pull request Oct 9, 2026
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

Labels

None yet

Projects

None yet

1 participant