Repository navigation
scaffold-project.py and family.py init force-stage every file the shape wrote past the operator's own excludes (#175) - #185
Conversation
…hape wrote past the operator's own excludes, so a global `core.excludesFile` such as `.*`, `contracts/` or `scripts/` no longer leaves `.gitattributes`, `.github/`, `.gitignore`, `contracts/*` and `scripts/*` out of a new project's first commit (#175) The scaffold's two legs (`git_init_commit`), its assembly root and the family holder all staged their first commit with `git add -A -- .`, which honours a global `core.excludesFile` and `.git/info/exclude`. Under the excludes `.*`, `contracts/`, `scripts/` the scaffold exited 0 with an assembly root whose first commit held neither `contracts/shape-pin.yaml` nor any file it pins under those names, the legs lost their `.gitignore` and `.gitkeep`, and the first `make bootstrap` could not run. It is the scaffold side of #167, with the same fix. `shape_materialize.stage_written(work, written)` is the one helper: `git add -A -- .`, then `git add -f -- <written>` over exactly the paths the shape wrote, never `-f .`, so a file an ignore rule hides that the shape did not write stays out. `copy_tree` now returns the paths it wrote (POSIX, `root_key`), `git_init_commit` takes them as `written=`, and the scaffold's assembly root and `family.py init` pass `Materialized.written` (what `place()` returns). A caller that passes nothing stages as before; `adopt-project.py`'s seeded leg is such a caller and is untouched here. tests/test_scaffold_ignored_shape_files.py (9 tests, all red on b18cca9) scaffolds and inits a holder into local bare remotes under a `GIT_CONFIG_GLOBAL` with those excludes, asserts every path `contracts/shape-pin.yaml` names is in the first commit and that each first commit holds every file the run wrote, and bootstraps both clones; litters ignored stray files beside the shape's own in-process and asserts they stay out; and covers `git_init_commit` under an `info/exclude` rule and the exact argv of `stage_written`. Forcing `-f .` instead turns the four stray and helper tests red. Co-Authored-By: Claude Opus 5.5 <[email protected]> Lane: openreposhape-2 (openRepoShape-2)
|
@codex review |
|
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 13 minutes by commenting |
Reviewer's GuideThe PR fixes first-commit omissions caused by global or repository-local Git excludes by tracking every path written by shape materialization and force-staging only those paths. Scaffold legs, the assembly root, and family holders now retain all generated files and bootstrap correctly under restrictive excludes, while unrelated ignored files remain excluded; focused regression tests cover end-to-end, negative, and helper behavior. Sequence diagram for force-staging materialized project filessequenceDiagram
participant Scaffold
participant Materializer
participant Git
participant Commit
Scaffold->>Materializer: copy_tree()
Materializer-->>Scaffold: written paths
Scaffold->>Git: git init
Scaffold->>Git: stage_written(work, written)
Git->>Git: git add -A -- .
Git->>Git: git add -f -- written paths
Scaffold->>Commit: env_commit()
Commit-->>Scaffold: first commit includes generated files
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
(lane openRepoShape-2, 2026-10-09T08:03:57Z) Full suite on this head b40e22e, run from a detached worktree in py-bench with git-filter-repo 2.47.0 on PATH: 1278 passed, 1 skipped (SHAPE_MEDXEHR_CLONE unset) in 10m52s, no filter-repo skips. Log: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b40e22eccd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| target.parent.mkdir(parents=True, exist_ok=True) | ||
| write_lf(target, render(path.read_text(encoding="utf-8"), values, | ||
| str(path))) | ||
| written.append(root_key(target, dst)) |
There was a problem hiding this comment.
Filter untracked template artifacts before force-staging
When the openRepoShape checkout contains a locally ignored file under templates/spec-root or templates/code-root (for example .vscode/settings.json, which the template's own .gitignore excludes), the unrestricted rglob copies it and this line adds it to written; _seed_legs then passes that list to git add -f, committing and potentially publishing the operator's local artifact. Previously, the copied .gitignore caused git add -A to skip such files. Build the forced list from tracked/declared template inputs, or otherwise exclude source-local ignored artifacts while still bypassing the operator's global excludes.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
(lane openRepoShape-2, 2026-10-09T08:35Z) Taken in d4ead9f: copy_tree now skips every file the tool's own checkout holds untracked AND ignored (git ls-files -z --others --ignored --exclude-standard, which applies the tool's, the template's and the operator's global excludes as that checkout sees them), so the stray is neither copied nor in written and a non-UTF-8 .pyc no longer crashes the read. A tracked file is never listed under --others, so the template .gitignore a global .* hides is still copied and force-staged (#175 holds), and the filter applies only when the template dir's git top level is the shape root (outside a work tree, or vendored in another repository, everything is copied as before). Six new tests in tests/test_scaffold_ignored_shape_files.py (15 in the file): stray and binary stray skipped, #175 under .*, untracked-but-unignored file copied, no repository, foreign repository, and the scaffold end to end against a littered private git copy of the tool; four are red on b40e22e.
…s untracked and ignored, so a locally ignored `.vscode/settings.json` or `__pycache__/x.pyc` under `templates/spec-root` or `templates/code-root` is no longer copied, returned in `written` and force-staged into a new leg, and a binary stray no longer crashes the UTF-8 read (#175) The Codex review of PR #185 (P2, `copy_tree`): #175 made `git_init_commit` force every path `copy_tree` returns past an ignore rule, and `copy_tree` walked the whole template directory, so an operator's editor file in the checkout of the tool was copied, forced and pushed. Before #175 the copied template `.gitignore` made `git add -A` skip it by accident; a `.pyc` stray died in `read_text` before that. `_local_strays(src)` asks the tool's own checkout: `git ls-files -z --others --ignored --exclude-standard -- .` (the tool's `.gitignore`, the template's nested one, `.git/info/exclude` and the operator's global excludes, all as that checkout sees them), and `copy_tree` neither copies nor returns what it lists. A TRACKED file is never listed under `--others`, so the template `.gitignore` a global `.*` hides (the #175 case) is still copied and forced, and an untracked file nothing ignores (a template file not yet committed) is still copied. The rules apply only when `src`'s git top level is the shape root, two levels above `templates/<role>/`: `rev-parse` failing (a tarball install) or naming another repository (the tool vendored inside one, whose rules are not this tool's) means no strays and the copy of before. `adopt-project.py`'s seeded leg calls the same `copy_tree` and no longer carries a stray either; its staging is untouched. Not chosen: `git add -f .` (stages what an ignore rule exists to keep out; `stage_written` refuses it); filtering by the template's own `.gitignore` (that file is exactly what #175 forces past `.*`); building the list from `git ls-files` alone (drops an uncommitted template file and needs an index a tarball lacks). `stage_written` and `git_init_commit` are unchanged. tests/test_scaffold_ignored_shape_files.py gains 6 tests (15 in all): the stray and the non-UTF-8 stray left out of a fake tool checkout; the tracked `.gitignore` still copied and committed under a `.*` global exclude; an untracked, unignored template file still copied; a tree outside any repository and one inside a foreign repository copied whole; and the scaffold run end to end against a private git copy of the tool littered under both templates, whose legs hold exactly what the checkout tracks. Four are red on b40e22e; the other two pin today's copy where the filter must not act. Removing the shape-root comparison turns the foreign-repository test red, and listing tracked-but-ignored files as strays turns six red. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Lane: openreposhape-2 (openRepoShape-2)
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
(lane openRepoShape-2, 2026-10-09T08:46:54Z) Full suite on this head d4ead9f (fix round for Codex thread 4228073499), run from a detached worktree in py-bench with git-filter-repo 2.47.0 on PATH, git 2.43: 1284 passed, 1 skipped in 10m29s (the skip is the MedxEHR clone fixture, as on main). Codex re-review of d4ead9f: no issues found. Log: |
…taged by name past the operator's excludes, so a global `core.excludesFile` such as `.*` or `src/` no longer leaves `.gitignore` and `src/.gitkeep` out of the first commit it pushes (#175) `_seed_leg` (a leg the plan assigns no path, seeded from `templates/<role>-root/`: a spec-only source gets a seeded code leg, and the reverse) was the fourth caller of `git_init_commit` and the one #175's first commit left alone. It called `copy_tree` and discarded the list it returns, so `git_init_commit` staged with `git add -A -- .` alone, which honours the operator's global excludes. Under `.*` and `src/` the seeded code leg was committed and pushed without its `.gitignore` and `src/.gitkeep`, and the root pinned that leg at a commit that lacked files its template ships, exactly as #175 describes for the scaffold's legs. `_seed_leg` now keeps `copy_tree`'s list and passes it to `git_init_commit` as `written`, so `stage_written` forces exactly those paths past an exclude rule, never `-f .`. The docstring says why and points at `stage_written`; the one sentence in `stage_written`'s own docstring that named its callers now names this one. The split's commit is `_commit_the_split`'s, which #167 already force-stages, and is untouched. tests/test_adopt_spec_only.py gains one test: a spec-only source is adopted into local bare remotes under a `GIT_CONFIG_GLOBAL` whose excludes are `.*` and `src/` (the premise is asserted: both files are ignored in the seeded leg's work tree), and the code leg read back from the pushed remote, one commit, holds exactly the files `git ls-files templates/code-root` lists, `.gitignore` and `src/.gitkeep` included. Run with the two `_seed_leg` lines reverted it fails (`['.gitignore', 'src/.gitkeep'] == []`, the two files missing from the pushed tree); with them it passes. It went into this file rather than test_scaffold_ignored_shape_files.py because the spec-only plan, source tree and seeded-leg tests are here; it takes `excluding`, `ignored` and `tracked_under` from that file. test_adopt_spec_only.py, test_scaffold_ignored_shape_files.py, test_adopt_e2e.py and test_shape_doctor.py: 212 passed; `render-cli-reference.py --check` ok. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Lane: openreposhape-2 (openRepoShape-2)
|
|
(lane openRepoShape-2, 2026-10-09T13:55Z) 6c8f50f: adopt's seeded leg ( |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
(lane openRepoShape-2, 2026-10-09T18:21:40Z) Full suite on this head 6c8f50f (the seeded-leg slice), run from a detached worktree in py-bench with git-filter-repo 2.47.0 on PATH, git 2.43: 1285 passed, 1 skipped in 21m (the MedxEHR clone skip, as on main). All three OS jobs pass, Sonar passed, Codex re-review of 6c8f50f found no issues. Log: |



Lane: openreposhape-2 (openRepoShape-2)
Claim: #175 (comment)
What changes
scaffold-project.py(its two legs throughgit_init_commit, and its assembly root) andscripts/family.py init(the holder) staged their first commit withgit add -A -- .. That command honours a globalcore.excludesFileand.git/info/exclude. With the excludes.*,contracts/andscripts/, the scaffold exited 0, but the assembly root's first commit had no.gitattributes,.github/,.gitignore,contracts/*(includingcontracts/shape-pin.yaml) orscripts/*. The legs also lost their.gitignoreand.gitkeep, and the clone's firstmake bootstrapcould not findscripts/bootstrap.py. This is the scaffold-side twin of #167, and it gets the same fix.scripts/shape_materialize.py: newstage_written(work, written). It runsgit add -A -- .and thengit add -f -- <written>over exactly the paths the shape wrote. It never runs-f ., so an ignored file the shape did not write stays out.copy_treenow returns the paths it wrote (POSIX, viaroot_key).git_init_committakes them aswritten=.scaffold-project.py: the legs passcopy_tree's list togit_init_commit. The assembly root stages withstage_written(assembly, materialized.written), using the listplace()already returns.scripts/family.py:initstages the holder withstage_written(work, materialized.written).A caller that passes nothing stages exactly as before.
adopt-project.py's seeded leg is the fourth caller, and it is covered (6c8f50f)._seed_legbuilds a leg the plan assigns no path fromtemplates/<role>-root/(a spec-only source gets a seeded code leg, and the reverse), and it discarded the listcopy_treereturns, so under the excludes.*andsrc/the leg it pushed had a first commit without.gitignoreandsrc/.gitkeep, the same defect as the scaffold's legs. It now passes that list togit_init_commit, which forces exactly those paths. The split's commit (_commit_the_split) is #167's, already force-staged there, and is untouched.copy_treealso leaves out a stray (Codex review of this PR, P2, taken in d4ead9f). A file the tool's own checkout holds untracked AND ignored (git ls-files -z --others --ignored --exclude-standard), such as an editor's.vscode/settings.jsonundertemplates/spec-root/, is neither copied nor returned inwritten, so it is never forced into a new leg and pushed; a binary one (__pycache__/x.pyc) no longer crashes the UTF-8 read. A tracked file is never listed under--others, so the template.gitignorea global.*hides is still copied and forced, and an untracked file nothing ignores is still copied. The filter applies only whensrc's git top level is the shape root: outside a work tree (a tarball install), or with the tool vendored inside another repository, everything is copied as before. Not chosen:git add -f ., filtering by the template's own.gitignore(the file #175 forces past.*), and a list built fromgit ls-filesalone.adopt-project.py's seeded leg calls the samecopy_treeand no longer carries a stray either.Reproduced on b18cca9 before the change:
Atlas.gitHEAD held only.gitmodules AGENTS-shape.md AGENTS.md CLAUDE.md Makefile README.md code project.yaml spec, andInkRouter.gitHEAD was missing the same classes of file. After the change, every pinned path is in both first commits, and both clones bootstrap (bootstrap ok,family bootstrap ok) under the same excludes.Tests
tests/test_scaffold_ignored_shape_files.pyadds 9 tests. All 9 fail on b18cca9.GIT_CONFIG_GLOBALset to the excludes above):contracts/shape-pin.yamlnames, read from the commit, is in the assembly root's first commit, after a premise check that the excludes really hide them.gitmodulesand the two mounts includedfamily.py initdrop ignored stray files (.env,scripts/stray.py) into each root right after the shape writes it. The strays stay out of every first commit, and.gitignoreis still forced in the same run.git_init_commitovercopy_tree's list under an.git/info/excluderule commits exactly the written set and leaves the strays outstage_written's exact argv is checked, including no forced add at all when the list is emptyMutation check: changing the forced add to
-f .makes the 4 stray and helper tests fail.Stray filter (d4ead9f): 6 more tests, 15 in the file. A locally ignored editor file and a non-UTF-8
.pycin a fake tool checkout are neither copied nor returned; the tracked.gitignoreis still copied and committed under a.*global exclude; an untracked, unignored template file is still copied; a tree outside any repository and one inside a foreign repository are copied whole; and the scaffold runs end to end against a private git copy of the tool littered under both templates, each leg's first commit holding exactly what the checkout tracks. 4 are red on b40e22e (the other 2 pin today's copy where the filter must not act). Mutations: dropping the shape-root comparison turns the foreign-repository test red; listing tracked-but-ignored files as strays turns 6 red.Seeded leg (6c8f50f):
tests/test_adopt_spec_only.pyadds 1 test. A spec-only source is adopted into local bare remotes under global excludes.*andsrc/(a premise check asserts both.gitignoreandsrc/.gitkeepare ignored in the leg's work tree), and the pushed code leg, one commit, holds exactly whatgit ls-files templates/code-rootlists, those two files included. It is red with the two_seed_leglines reverted (the two files missing from the pushed tree) and green with them.pytest tests/test_adopt_spec_only.py tests/test_scaffold_ignored_shape_files.py tests/test_adopt_e2e.py tests/test_shape_doctor.py: 212 passed (at 6c8f50f)pytest tests/test_scaffold_ignored_shape_files.py tests/test_scaffold_e2e.py tests/test_scaffold_pin_and_reuse.py tests/test_family.py: 155 passedpytest tests/test_adopt_spec_only.py tests/test_repo_hygiene.py: 63 passedpython3 scripts/render-cli-reference.py --check: okRun locally (the full suite was not run here):
pytest tests/test_scaffold_ignored_shape_files.py tests/test_scaffold_e2e.py tests/test_scaffold_pin_and_reuse.py tests/test_reuse_visibility.py tests/test_cli_reference.py tests/test_repo_hygiene.py: 138 passedpytest tests/test_family.py tests/test_windows_paths.py tests/test_commit_trailers.py tests/test_reference_default.py tests/test_adopt_spec_only.py: 270 passedpython3 scripts/render-cli-reference.py --check: ok (no flag changed)Closes #175
🤖 Generated with Claude Code
Summary by Sourcery
Preserve complete initial repositories under user Git excludes while keeping unrelated ignored files out of the first commit.
Bug Fixes:
Enhancements:
Tests: