Skip to content

scaffold-project.py: a leg's mount path must be canonical or it is refused before anything is created, so --spec-path spec/ no longer scaffolds a project whose recursive clone fails once the work directory is gone (#179) - #201

Merged
brettheap merged 7 commits into
mainfrom
fix/scaffold-canonical-leg-paths
Oct 11, 2026

Conversation

@brettheap

@brettheap brettheap commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

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

What

scaffold-project.py asks the same question adopt-project.py asks of a leg's mount path (#169), before it creates anything. It refuses, as REFUSED scaffold-bad-leg-path with exit 2 (the tool's own refusal style), when --spec-path or --code-path is:

  • not canonical: a trailing /, a leading ./, a doubled //, a . segment, a backslash, an absolute path, a ... Where a canonical spelling exists the refusal names it (spec/ is answered Write 'spec'.); an absolute path or a .. names another place, so no spelling is offered;
  • a path a leg cannot be mounted at: a segment that is .git, git~1 or .gitmodules (any case), ends in a dot or a space, or is a Windows device name (CON, NUL, COM1.txt);
  • outside the alphabet that may reach a git command line (a shell metacharacter, a leading -): refused under the same code with checked_value's own sentence, where it used to be unsafe-value;
  • equal to the other leg's path, inside it, or equal to it once case is ignored (legs and legs/code, Spec and spec), including a path equal to the OTHER flag's default (--spec-path code).

The check runs before the work directory, the remotes and the first gh call exist, and --dry-run runs it too, so a rehearsal no longer prints a plan the real run would refuse. Both bad paths are named in one refusal.

The rule moved, it was not rewritten. leg_path_problem, leg_path_problems, _spelling_reason, _unmountable_reason, _canonical_spelling, LEG_PATH_REMEDIATION and their constants moved from adopt-project.py into scripts/shape_materialize.py, which both tools already import. A diff of the two blocks against main's adopt-project.py shows the code byte for byte the same; the refusal helper's name is the only difference in it (_refuse_bad_leg_paths there, refuse_bad_leg_paths here), and what was added is comment and docstring text: the section header's #179 paragraphs, a docstring on the helper, and a reworded comment on WINDOWS_ABSOLUTE_RE that says --source and Source.open are adopt's. adopt-project.py imports back leg_path_problem, leg_path_problems, WINDOWS_ABSOLUTE_RE and the refusal helper, which keeps its private name there through refuse_bad_leg_paths as _refuse_bad_leg_paths, so no call site changed (leg_path_problem is imported only so that tests/test_adopt_leg_paths.py keeps asking it through the adopt module). Its edit is the removal, that import, a section comment that now says where the rule went, and dropping SAFE_ARG_RE from its repo_shape import list, which only the moved block used. WINDOWS_ABSOLUTE_RE moved with the rest because the spelling check needs it; adopt still imports it for Source.open.

#172 landed while this was open, as #198, and this head merges it (main 20e13f0, a clean merge). The calls into the rule that adopt-project.py makes, those #198 reworked among them, resolve through the imports this branch adds: _refuse_bad_leg_paths for the refusals in plan and execute, and leg_path_problems for check's findings. assembly_root_paths, which #198 put in shape_materialize.py, stays in the materializer's own import list. An AST check of adopt-project.py, scaffold-project.py and shape_materialize.py finds no name used that is bound nowhere in its own file (only __file__).

Why shape_materialize.py and not scripts/repo_shape.py. #179 asks for the move into scripts/repo_shape.py, and #180 ("ideally moved to") and its close comment name it too. It is the wrong home: shape_materialize.py line 148 REPO_SHAPE = "scripts/repo_shape.py" is in COPIED_FROM_SHAPE and FAMILY_COPIED_FROM_SHAPE, so every project carries a copy and contracts/shape-pin.yaml digests it. About 250 lines added there (this diff adds 251 to shape_materialize.py) would put an upstream-changed scripts/repo_shape.py row in front of every project in the estate for a rule no project's own copy asks. shape_materialize.py is in no copy list and is not pinned, and both tools already import it.

The two new imports are their own statements, so the materializer import lists in both tools stay as they were on main. git merge-tree of this head (a merge with main 20e13f0, which holds #166 and #172) against the current tip of each of origin/fix/adopt-history-gitlinks, fix/adopt-mount-past-gitignore (#200), fix/adopt-plan-quote-yaml-keywords, fix/adopt-record-submodule-placement, fix/adopt-report-filter-repo-failure (#184) and fix/adopt-verify-mounted-gitlinks (#173) reports no conflict. Two branches edit the from repo_shape import (...) list in adopt-project.py, which abuts this branch's removal of SAFE_ARG_RE from it, so that list is a conflict hunk with this head which neither has against main: fix/adopt-relative-submodule-url (#190, whose four other hunks already conflict with main) and fix/adopt-plan-linebreak-names (#199, which merges with main cleanly). Whichever merges second resolves it by keeping that branch's added names (redacted, remote_key and remote_local_path for #190; double_quoted for #199) and not listing SAFE_ARG_RE, which adopt no longer uses: both branches use it only in the comment and the f-string of the block that moves. Four more branches (fix/adopt-check-unsafe-path, fix/adopt-late-failure-notice, fix/adopt-root-kept-symlinks and fix/scaffold-leg-path-collisions) conflict with main already, in as many hunks as they do with this head.

tests/test_scaffold_pin_and_reuse.py::test_a_leg_path_with_a_shell_metacharacter_is_refused is the one existing test changed: the code is now scaffold-bad-leg-path, the sentence is checked_value's own, and nothing is created. docs/cli.md is unchanged (no --help text changed; render-cli-reference.py --check says it is what the generator produces).

Also answers #180, which was closed as a duplicate of this issue.

Why (repro on main)

The issue's command, in local mode, on main 20e13f0:

scaffold-project.py --org testorg --project Northwind --elected-by 'Test Human' --elected-on 2026-09-02 \
  --spec-path spec/ --local-remote-dir remotes --work-dir work
exit 0, remotes: Northwind-code.git Northwind-spec.git Northwind.git
git show HEAD:.gitmodules   ->  [submodule "spec"]  [submodule "spec/"]  [submodule "code"]
mv work work.moved && git clone --recurse-submodules remotes/Northwind.git clone
exit 1: fatal: repository '.../work/Northwind-spec' does not exist
        Failed to clone 'spec'. Retry scheduled
        Failed to clone 'spec' a second time, aborting

On this branch the same command exits 2 and creates nothing (no remotes, no work):

REFUSED scaffold-bad-leg-path: --spec-path is 'spec/', which is not a canonical leg path: Git records a mount without its `.` segments (a leading `./`), a trailing `/` or a doubled `/`, so the mount and its `.gitmodules` entry would name two different paths. Write 'spec'.

Tests

tests/test_scaffold_leg_paths.py is new: 27 tests. 26 of them run scaffold-project.py, 25 with --local-remote-dir (no network) and the one that proves gh is never asked with a fake gh first on PATH instead; the 27th only compares which function the two tools call. None needs git filter-repo. By group, and what each asserts:

  • refused (14): spec/, ./code, legs//spec, legs/./code, legs\spec, /spec, ../code, .git, legs/.git, .gitmodules, CON, spec., a shell metacharacter, a leading -. Each asserts exit 2, REFUSED scaffold-bad-leg-path, the same sentence adopt-project.py says for the same value (asked of the adopt module, not copied), the shared remediation paragraph, the canonical spelling where one exists (and no Write ' where none does), an empty stdout, and that nothing was created: no remotes, no work, and no work directory of the tool's own in a TMPDIR made empty for the run;
  • collisions (5): equal, code inside spec, spec inside code, equal and nested once case is ignored. Each asserts the same, less the spelling and the remediation: exit 2, the code, adopt's sentence for the pair, an empty stdout, nothing created;
  • --spec-path code against the other flag's default: exit 2, the code, its sentence (--spec-path and --code-path are both 'code'), nothing created;
  • one refusal names both bad paths: exit 2, both paths named, nothing created;
  • --dry-run refuses as the real run does: exit 2, the code, an empty stdout, nothing created;
  • a fake gh on PATH is never asked: exit 2, the code, no gh call, no work;
  • the issue's own command is refused and leaves no Northwind.git to clone: exit 2, Write 'spec'., no remotes and no work;
  • still scaffolds (2): the defaults and legs/spec + impl/code each scaffold, hold exactly one .gitmodules registration per mount (none naming the work directory), and clone recursively after the work directory is moved;
  • one definition: both tools resolve leg_path_problem(s) and refuse_bad_leg_paths to the one function in shape_materialize.

One existing test changed: test_scaffold_pin_and_reuse.py::test_a_leg_path_with_a_shell_metacharacter_is_refused (code, sentence, nothing created). tests/test_adopt_leg_paths.py is unchanged and passes, which is the proof the move changed no behaviour; the review's differential run of the moved functions against main's is under Review.

Each test fails with its change undone. The scaffold tests, with the one changed test in test_scaffold_pin_and_reuse.py, were run against a copy with the mutation applied; the rows down to "no case-insensitive equality check" ran at 8050563, the last two at a11a128, which added the assertions NITs 3 and 4 name (see Review):

mutation result
scaffold-project.py back to main (the whole fix reverted) 26 fail (all 25 refusal-side tests and the changed one); the 2 that pass are the still-scaffolds guards, which pass on main by design
the refusal always fires 2 fail: exactly those two still-scaffolds guards
adopt keeps its own copy of the rule 1 fails: test_both_tools_ask_one_definition
a slash is refused 7 fail
check runs after the work directory is made 25 fail
check runs after --dry-run returns 21 fail
check runs after the first gh probe 25 fail
the unmountable-name rule off 5 fail
no canonical spelling offered 6 fail
no nesting check 3 fail
no equality check 1 fails
no case-insensitive equality check 1 fails
the refusal prints another remediation than LEG_PATH_REMEDIATION 14 fail: the 14 single-path refusals (none failed at 8050563)
the refusal moves to just after the plan is printed 21 fail, the dry-run test among them (20 failed at 8050563, that test passing)

Targeted run on the head, a11a128: tests/test_scaffold_leg_paths.py, test_scaffold_pin_and_reuse.py, test_scaffold_e2e.py, test_scaffold_ignored_shape_files.py, test_adopt_leg_paths.py, test_adopt_leg_path_collisions.py, test_adopt_plan.py, test_adopt_e2e.py, test_adopt_execute_refusals.py, test_adopt_spec_only.py, test_adopt_submodules.py, test_adopt_ignored_shape_files.py, test_shape_doctor.py, test_windows_paths.py, test_cli_reference.py, test_repo_hygiene.py, test_naming_policy.py, test_reference_default.py, test_shape_advisory.py, test_load_yaml_refusals.py, test_free_plan_hint.py, test_commit_trailers.py, test_family.py, test_bump_leg.py, test_park_resume_targets.py, test_update_shape.py and test_update_shape_add.py: the eight adopt and four scaffold test files, every other test file that names shape_materialize, and test_free_plan_hint.py and test_load_yaml_refusals.py.

  • with git-filter-repo on PATH: 1707 passed, 1 skipped (exit 0; the skip is the MedxEHR-backed plan test, which needs a read-only clone of MedxSoft/MedxEHR);
  • with it hidden from PATH: 1645 passed, 63 skipped (exit 0; 62 are git filter-repo is not installed, all in the test_adopt_* files, and the 63rd is the same MedxEHR test).

render-cli-reference.py --check: docs/cli.md is what the generator produces (no --help text changed). The full suite was not run; the three-OS CI gate is the full check.

Review

An adversarial review of 8050563 found it PR-READY: no BLOCKER or SHOULD-FIX, eight NITs.

  • The move is verbatim. The moved functions agree with main's in 244,744 comparisons, with no difference. Adopt's plan, check and execute output is identical in 18 cases, on the reviewed head and on its merge with main e4decfb.
  • The scaffold refuses first. Every bad value was refused before anything existed, in 180 runs across four modes (local remotes with and without --work-dir, a logging gh shim, and --dry-run).
  • The issue's repro no longer reproduces.
  • Merges were clean except an import-list hunk (described above). 737 tests passed on the reviewed head and on its merge with main e4decfb.

The follow-up is three commits on this branch: 469d14c merges main 20e13f0, 6cc2a87 takes NITs 1 and 2, and a11a128 takes NITs 3 and 4. What became of the eight NITs:

  1. A moved comment named --source and Source.open as if they were in shape_materialize.py. Taken, in 6cc2a87: the comment on WINDOWS_ABSOLUTE_RE now says they are adopt-project.py's.
  2. "About two hundred lines" was about 250. Taken, in 6cc2a87 for the comment and here for this body. The moved section is 247 lines, from its header rule to the end of the file, and git diff origin/main --numstat adds 251 to the file (the review measured 245 and 249; NIT 1's longer comment adds the two).
  3. No scaffold test checked the remediation paragraph. Taken, in a11a128: the 14 single-path refusal tests assert shape_materialize.LEG_PATH_REMEDIATION in result.stderr. With the refusal printing another remediation, none of the 28 tests (these 27 and the changed one) failed at 8050563; now 14 do.
  4. The dry-run test checked less than its docstring said. Taken, in a11a128: it asserts an empty stdout. With the refusal moved to just after the plan is printed, it passed before and fails now.
  5. This body's wording. Taken, here: the sentence on what the refusal tests assert is now stated group by group (see Tests), and the merge it names is this head's own: main 20e13f0.
  6. The default-collision sentence names a flag the operator never typed. --code-path SPEC alone is refused with --spec-path 'spec' and --code-path 'SPEC' differ only in case, and --spec-path code alone with --spec-path and --code-path are both 'code'; both are true, because those are the defaults. Not taken. The sentence is the one adopt-project.py shares (leg_path_problems): adopt-project.py plan --spec-path code prints the same words under its own code, so changing it changes adopt too, and tests/test_adopt_leg_paths.py asserts parts of it (are both 'spec', differ only in case). It is a wording choice for a change of its own, to both tools.
  7. The one test that renames a scaffold work directory had not run on Windows. It has now: CI at 8050563 passed tests, tests-macos and tests-windows (1634 passed, 220 skipped on windows-latest, running python -m pytest tests -q), and test_canonical_paths_still_scaffold_and_a_clone_survives_the_work_dir carries no skip marker (only the fake-gh test is WINDOWS_SKIP), so it ran there.
  8. The scaffold twin of adopt-project.py accepts a leg mount path that collides with a directory the shape writes, such as --spec-path contracts, so the adoption fails after both legs are pushed (main: at the first bootstrap) #172 (a canonical leg path that the assembly root holds, such as --spec-path contracts, still kills the scaffold after the three remotes exist) is out of scope here. Filed as scaffold-project.py accepts a leg path that collides with a path the shape writes (--spec-path contracts, --code-path project.yaml), creates all three repositories and pushes both legs, then dies: #172's shape half on the scaffold side #197. adopt-project.py accepts a leg mount path that collides with a directory the shape writes, such as --spec-path contracts, so the adoption fails after both legs are pushed (main: at the first bootstrap) #172's adopt side has landed (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); the scaffold does not ask assembly_root_paths() yet, and this PR does not add that.

Closes #179

🤖 Generated with Claude Code

brettheap and others added 4 commits October 9, 2026 18:40
…fused before anything is created, so `--spec-path spec/` no longer scaffolds a project whose recursive clone fails once the work directory is gone (#179)

`scaffold-project.py --spec-path spec/` exited 0 and pushed three remotes.
Git records the mount at `spec`, but the `.gitmodules` write names a second
section, `spec/`, so the real `spec` registration kept the operator's work
directory as its URL and `git clone --recurse-submodules` of the new project
failed (`Failed to clone 'spec' a second time`) as soon as that directory was
moved. It is #169's bug in the other tool that writes `legs.spec_path` and
`legs.code_path`; its argument check was `checked_value` alone, which lets
`spec/`, `./code`, `legs//spec`, `.git` and equal or nested paths through.

The rule that #169 gave `adopt-project.py` (`leg_path_problem`,
`leg_path_problems`, the spelling and name checks and the remediation text)
moves, unchanged, to `scripts/shape_materialize.py`, which both tools already
import, and `adopt-project.py` imports it back: its own edit is the removal and
the import. It is NOT `scripts/repo_shape.py`, which is a shape copy that every
project carries and `contracts/shape-pin.yaml` digests: two hundred lines there
would put an `upstream-changed` row in front of every project for a rule no
project's copy asks.

The scaffold asks it first, as `scaffold-bad-leg-path` (exit 2, its own
refusal style), before a work directory, a remote or a `gh` call exists and
also under `--dry-run`, with the same sentence adopt says and the canonical
spelling where one exists. A shell metacharacter in a leg path is now refused
under that code instead of `unsafe-value`, with `checked_value`'s own sentence.

Tests: tests/test_scaffold_leg_paths.py (each refused class and each collision,
nothing created, no `gh` call, the issue's repro, the defaults and nested
paths still scaffold and clone with the work directory gone, one definition
for both tools).

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…as a statement of its own, so the materializer import lists stay as they were and this branch merges with the two that rewrite them (#179)

`fix/adopt-late-failure-notice` rewrites adopt-project.py's
`from shape_materialize import (...)` list and `fix/scaffold-force-add-shape-files`
adds a name to scaffold-project.py's, and a name added to the same list here
conflicted with both. The moved names now arrive in their own import
statement in each tool, and the lists are byte-identical to main's.

No behaviour changes: the same names, the same one function behind them.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…nt, so no literal is spelled three times (#179)

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

sourcery-ai Bot commented Oct 11, 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 day and 23 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Oct 11, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR prevents scaffolding projects with non-canonical, unmountable, unsafe, or colliding leg mount paths by moving adoption’s validation rule into the shared materializer and invoking it before any scaffold side effects, with extensive regression coverage for refusal behavior and valid recursive clones.

Sequence diagram for scaffold leg-path validation

sequenceDiagram
    participant User
    participant Scaffold as scaffold-project.py
    participant Materializer as shape_materialize
    participant GitHub as gh
    participant Filesystem as WorkDirectoryAndRemotes

    User->>Scaffold: _scaffold(args)
    Scaffold->>Materializer: refuse_bad_leg_paths(scaffold-bad-leg-path, spec_leg, code_leg)
    Materializer->>Materializer: leg_path_problems(spec_leg, code_leg)
    alt invalid, unsafe, unmountable, or colliding paths
        Materializer-->>Scaffold: Refusal(scaffold-bad-leg-path)
        Scaffold-->>User: exit 2 with refusal, no stdout
    else valid leg paths
        Materializer-->>Scaffold: no refusal
        Scaffold->>Scaffold: checked_value(--spec-path, spec_path)
        Scaffold->>Scaffold: checked_value(--code-path, code_path)
        Scaffold->>Filesystem: create work directory and local remotes
        Scaffold->>GitHub: probe gh and create project resources
    end
Loading

File-Level Changes

Change Details Files
Centralize leg-path validation so scaffolding and adoption use one implementation.
  • Moved canonical spelling, mountability, command-line safety, and cross-leg collision checks into the shared materializer module.
  • Updated adoption to import the moved helpers while preserving its existing private refusal alias and behavior.
  • Added shared imports for the validation dependencies and retained the Windows absolute-path regex in the shared module.
scripts/shape_materialize.py
adopt-project.py
Reject invalid scaffold leg paths before any side effects occur.
  • Validate both --spec-path and --code-path before work directories, remotes, gh, or dry-run output are created.
  • Use scaffold-bad-leg-path and report all path problems, including canonical spellings where applicable.
  • Continue applying normal checked_value validation after the shared leg-path check.
scaffold-project.py
Add comprehensive regression coverage for early refusal and successful canonical scaffolding.
  • Cover malformed, unmountable, unsafe, colliding, default-overlapping, and dry-run paths, including assertions that nothing is created.
  • Verify both tools resolve the same shared definitions and that the issue reproduction is refused.
  • Verify valid paths still produce consistent .gitmodules registrations and survive recursive cloning after the work directory is moved.
  • Update the existing shell-metacharacter test for the new refusal code and message.
tests/test_scaffold_leg_paths.py
tests/test_scaffold_pin_and_reuse.py

Assessment against linked issues

Issue Objective Addressed Explanation
#179 Reject non-canonical or otherwise unmountable --spec-path and --code-path values before scaffold-project.py creates any work directory, remote, or repository, including paths such as spec/. ✅
#179 Use a shared leg-path validation rule between adopt-project.py and scaffold-project.py, covering canonical spelling, Git/Windows-invalid segments, unsafe command-line values, and collisions or nesting between the two leg paths. ✅
#179 Prevent scaffolding from producing inconsistent .gitmodules registrations that retain work-directory URLs and cause recursive clones to fail after the work directory is removed. ✅

Possibly linked issues


Tips and commands

Interacting with Sourcery

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

Customizing Your Experience

Access your dashboard to:

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

Getting Help

@brettheap

Copy link
Copy Markdown
Contributor Author

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

@chatgpt-codex-connector

Copy link
Copy Markdown

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

brettheap and others added 3 commits October 11, 2026 16:05
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]>
…is true in this file, so `WINDOWS_ABSOLUTE_RE` no longer points at a `--source` and a `Source.open` that are adopt-project.py's, and the section's size is said as about 250 lines and not two hundred (#179)

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…diation paragraph and a dry run asserts an empty stdout, so a changed remediation, or a plan printed before the refusal, no longer passes the scaffold's own tests (#179)

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

Copy link
Copy Markdown

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

@brettheap

Copy link
Copy Markdown
Contributor Author

(lane openRepoShape-2, 2026-10-11T17:16:40Z) Heads-up: this lane is re-verifying a11a128 read-only against its earlier review of 8050563 (delta since then, P3-1 and nits 1 to 5, the moved rule's AST and a differential run, merges against the current heads including #197's aabfae0 and #199's d566e12). The result follows on this PR within the hour. No hold is requested; Brett's merge word stands.

@brettheap
brettheap merged commit 8df21e6 into main Oct 11, 2026
5 checks passed
@brettheap
brettheap deleted the fix/scaffold-canonical-leg-paths branch October 11, 2026 17:26
brettheap added a commit that referenced this pull request Oct 11, 2026
Clean merge: #201 moves the leg-path helpers into scripts/shape_materialize.py; this branch's mount guard and tests do not touch them.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 11, 2026
…links, so the fail-closed root gitlink check is tested beside the leg-path helpers #201 moved into scripts/shape_materialize.py

No conflicts: git merged adopt-project.py, scaffold-project.py,
scripts/shape_materialize.py and #201's two test files without a
conflicting hunk. #201 moves the leg-path checks out of adopt-project.py
into scripts/shape_materialize.py; this branch edits only the verification
(`_land_the_root_tree`, `_root_gitlink_finding`, the two exit texts) and two
comments, so no hunk touches both.

Checked by hand for a conflict git cannot see:
- `_leg_findings(plan, tree)` still takes `tree` as a required argument,
  and `_entry_findings` still passes the source tree.
- Every refusal the three gitlink findings name still exists after the
  move: `plan-bad-leg-path` and `adopt-bad-leg-path`, `plan-submodule-root`,
  `plan-unresolved`, `plan-uncovered` and `plan-bad-leg`.
- The branch's delta over main is the same as before the merge.

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

origin/main moved from 20e13f0 to 8df21e6 (#201: the leg-path helpers
move into scripts/shape_materialize.py) while this branch was being
finished. This merge brings it in.

It merged with no conflict. #201 removed `SAFE_ARG_RE` from the
`repo_shape` import, and this branch added `REMEDIATION` there; both
changes are kept. The `shape_materialize` import is unchanged from the
previous merge: `assembly_root_paths` is imported and `RULESET_HINT` is
not. `_leg_findings(plan, tree)` is unchanged. The only unused imports
are `COMMIT_RE` and `leg_path_problem`, and main has the same two.

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

Copy link
Copy Markdown
Contributor Author

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

Closing this lane's 17:16Z heads-up. The re-verification of a11a128 was cut off by the account's usage limit at 17:48Z and never reported. The PR merged at 17:26:42Z as 8df21e6, whose tree (6f575e0f) equals a11a128's. This is a read-only check of main a5b09c3, which holds it, by this lane in detached worktrees, nothing authored, no claim.

POST-MERGE: FOLLOW-UP NEEDED (P3-1: YAML-keyword leg paths, now #225)

Tests on a5b09c3 with git-filter-repo, the 13 files the brief named: 920 passed, 1 skipped (the MedxEHR plan test). render-cli-reference.py --check is ok.

CI: tests, tests-macos and tests-windows were green on a11a128. The push run on main 8df21e6 is green.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Lane: openreposhape-5 (openRepoShape-5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 11, 2026
…te=`, so an operator's `init.templateDir` holding `modules/spec` no longer plants a module store that the leg mount's `--force` reactivates, which pushed a root whose gitlinks were a stranger's commit and whose recursive clone failed (#229)

The review of 5878305 found a third refusal of git's that `--force` on the leg mount turns off and that the commit body did not name: a `.git/modules/<path>` already there is REACTIVATED ("Reactivating local git directory") instead of refused. The assembly root was a fresh `git init`, and `git init` copies the operator's template (`init.templateDir`, or `GIT_TEMPLATE_DIR`) into `.git`, so a template that holds a `modules/spec` store (one made by copying a working Triad root's `.git` does) planted one. Reproduced on 5878305: the scaffold exited 0, the pushed root's `spec` and `code` gitlinks were the planted store's commit and neither leg's tip, and `git clone --recurse-submodules` of it exited 128 (`Fetched in submodule path 'code', but it did not contain ...`). On main, without `--force`, the same input exits 2 at the mount, so 5878305 had turned a loud refusal into a quiet wrong success.

The cure is `git init -q --template= -b <tracking branch>`: an empty template is git's documented way to copy none. The assembly root is a temporary build directory the tool fills and pushes, so no template content belongs in it, and whoever clones the pushed root still gets their own template from `git clone`. Leaving the default template out also leaves `hooks/*.sample`, `info/exclude` and `description` out of the root's `.git`; nothing in the scaffold reads them, and the targeted set below, which clones the root and runs its bootstrap, passes.

The other `git init` calls the scaffold runs never reach a `--force`, so they are left as they were: scaffold-project.py:708 is `git init --bare` for the three local remotes, which are only pushed to and cloned from; `git_init_commit` (scripts/shape_materialize.py:559, called from `_seed_legs` at scaffold-project.py:758) seeds each leg's working tree, which is the SOURCE of the mount and is never mounted into; and the work root is a `mkdir`. The one `--force` is the submodule add in `_build_assembly_root`, and `_refuse_existing_trees` (scaffold-project.py:675) has made the assembly directory empty before its `git init`, so `.git/modules` holds nothing before the first mount and only that mount's store at the second.

The comment in `_build_assembly_root` is corrected where the review found it wrong or stale. It named two refusals `--force` turns off and said neither can arise; it now names three, and says why `--template=` closes the new one. "The index holds only the first mount" was incomplete: when the second mount runs the index holds `.gitmodules` and the first gitlink, and no leg path can be `.gitmodules`, which `refuse_bad_leg_paths` refuses (#201). And "a path the SHAPE wrote ... git refuses it after the clone" was wrong about where git refuses (at the mount, exit 128: `already exists and is not a valid git repo` for `scripts` and `contracts`, `destination path ... already exists and is not an empty directory` for `README.md` and `project.yaml`) and would go stale the day #197 refuses those paths up front. It now says a leg AT a path the shape wrote is a collision of another kind, refused up front by the collision check where there is one and by git at the mount where there is not, and that `--force` changes neither, which holds before and after #197 lands. The same wording is corrected in the test module.

A correction to 5878305's body, which cannot be amended: it said every file the materializer writes goes through `write_lf`. `copy_out` (scripts/shape_materialize.py:1183-1186) writes byte copies with `shutil.copyfile`. The conclusion stands: `copyfile` follows a source link and writes a regular file, `find templates -type l` is empty and no tracked entry has mode 120000, so the materializer makes no symlink for a mount to lie beyond.

tests/test_scaffold_mount_ignored.py gains four tests over ONE more real scaffold, run as an operator whose `init.templateDir` (set through the test's own `GIT_CONFIG_GLOBAL`, as the excludes are) holds a non-bare store at `modules/spec` and at `modules/code`, each with a commit of its own and an `origin` (a store with none dies at `git remote set-url origin`, loudly, which is not the defect). One asks git that a plain `git init` under that configuration plants the store and `--template=` plants none, so the rest cannot quietly stop running the defect. One asserts exit 0 and no "A git directory for". One asserts the pushed root's `spec` and `code` gitlinks EQUAL the tips the legs were pushed at and are not the planted commit. One clones the root recursively with the template config OFF, so the clone itself is clean, and asserts it succeeds and passes the clone's `validate-manifest.py`, `validate-pins.py` and (review N5) `bootstrap.py`. The clone check is now one helper shared with the ignore-rule cases, so `bootstrap.py` runs in all eight clones, about 0.5 s each.

Mutation: with `--template=` removed from the `git init` and nothing else changed, the module fails 2 of its 42 tests, the gitlink test (`{'spec': <planted>, 'code': <planted>} != {'spec': <spec tip>, 'code': <code tip>}`) and the clone test (`Fetched in submodule path 'code', but it did not contain <planted>`), and passes the other 40, the premise test and the exit test among them. Against 5878305 itself the same two fail.

The targeted set, this module and five existing files, passes on this commit: 161 passed, 0 failed, 0 skipped (tests/test_scaffold_mount_ignored.py, test_scaffold_ignored_shape_files.py, test_scaffold_leg_paths.py, test_scaffold_e2e.py, test_scaffold_pin_and_reuse.py, test_cli_reference.py). `docs/cli.md` is unchanged, since no `--help` text is.

Closes #229

Lane: openreposhape-4 (openRepoShape-4)
Co-Authored-By: Claude Sonnet 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
…the shape writes into the assembly root, a `--pin`'s `contracts/<product>-pin.yaml` included, is refused before anything is created, under `--dry-run` alike, through the one definition adopt-project.py asks, so `--spec-path contracts` no longer creates three repositories and pushes both legs to die at `git submodule add` (#197) (#234)

scaffold-project.py refuses a leg path that is, holds or lies inside any path the shape writes into the assembly root, each `--pin`'s `contracts/<product>-pin.yaml` included. The refusal comes before any process starts and under `--dry-run` alike, and it asks the same question adopt-project.py asks, from one definition.

- `scripts/shape_materialize.py`: the shape half of #172's collision rule (`shape_path_collisions`, `path_overlap`, `first_and_more`, `CASE_ASIDE`, `MOVE_THE_LEG`) moves here from adopt-project.py, beside `assembly_root_paths`. That function now takes `neutral_pins` and lists each pin file in the order the materializer writes it, and `neutral_pin_path(product)` is the pin file's one spelling. adopt-project.py imports the helpers back, and its output is byte-identical.
- `scaffold-project.py`: `_refuse_colliding_leg_paths` runs straight after the leg paths' own checks, before `_identity`, `_declaration`'s `gh api`, the dry-run return and the work root, and refuses as `scaffold-leg-path-collides`. A malformed `--pin` is now refused by `parse_pin` before `_identity`.
- `tests/test_scaffold_leg_path_collisions.py` (new, 104 tests).

Non-canonical spellings of a colliding path are refused first by #179's canonical-spelling check (#201). Reviewed adversarially twice (MERGEABLE WITH NITS; its SHOULD, the `--pin` path, is in this change). CI is green on Linux, macOS and Windows.

Closes #197

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

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

Conflicts, and how each was resolved:

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

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

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

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