Repository navigation
shape-doctor.py: the way-in row hands back the identity the naming row already classified, verbatim, instead of an unconditional respelling of it (#109) - #110
Conversation
…row already classified, verbatim, instead of an unconditional respelling of it (#109) Lane: openreposhape-2 (openRepoShape-2) Closes #109. ## What was wrong `openRepoShape --doctor ~/projects/openRepoProject` (a plain git repository, origin `[email protected]:opensoft/openRepoProject.git`, no shape manifest) printed: ``` ok naming openRepoProject: classifies under the naming policy n/a the way in this is a git repository with no shape manifest: it is ADOPTED in place, keeping its name, identity and history NEXT python3 …/adopt-project.py plan --source /home/brett/projects/openRepoProject --project Openrepoproject ``` The `naming` row had just verified that `openRepoProject` classifies -- `neutral-product` (`^open(?:[A-Z]|x[A-Z])[A-Za-z0-9]*$`), which since #45's `admits_declared_role` ruling ADMITS being its own assembly root -- yet `check_the_way_in`'s `--project` was derived UNCONDITIONALLY, by `"".join(part.capitalize() for part in root.name.replace("_", "-") .split("-") if part)`, which turns `openRepoProject` into `Openrepoproject`: a DIFFERENT name that still happens to classify, as a bare `project-leg/assembly` token, so nothing in the naming policy caught the mismatch. `adopt-project.py` keeps the source repository's own name, identity and history and derives the two new legs' names from `--project`. Run as printed, `execute` would have named the legs `Openrepoproject-spec` / `Openrepoproject-code` beside a root still called `openRepoProject` -- a family nobody chose, from a line that looks safe to paste. This was never adopt refusing the lowercase form: `_check_names` already accepts `--project openRepoProject` (`accepts_role` admits `("neutral-product", "assembly")`, and `tests/test_adopt_plan.py::test_a_neutral_product_may_be_adopted_as_its_own_assembly_root` already covered exactly this with `openDox`, confirmed passing at `origin/main`). The defect was only in what `shape-doctor.py` suggested, and confirmed live: `adopt-project.py plan --project openRepoProject` exits 0 today, unpatched. ## What landed **`project_token_for(name, policy)`**: `name` VERBATIM where `accepts_role(policy.classify(name, "assembly"), "assembly")` already admits it -- the exact gate `adopt-project.py`'s own `_check_names` runs -- and the unchanged capitalized-parts derivation only for a name the policy admits no form of at all (`my-repo` -> `MyRepo`, exactly as before). **`check_the_way_in` reads the same identity the `naming` row does**: `origin`'s repository name where there is one, else the directory's own name -- `check_not_a_root_naming`'s own docstring, "the name that matters for the policy is the repository's" -- because a clone into a differently named folder does not change what would actually be adopted. The suggestion is computed once, before the branch on `is_repo`, so the SCAFFOLD half of this row (no `.git` at all) gets the identical treatment: a loose folder already named like a live neutral product is offered to `setup.sh` / `setup-project.py` as itself too. Both the human-readable `NEXT` line and the `--json` `next` agree by construction: one `project` variable feeds both, as before. `NamingPolicy` and `accepts_role` join `shape-doctor.py`'s existing in-process imports from `repo_shape` (`adopt-project.py`'s own `_check_names` already uses both the same way, so this is the second caller of one definition, not a second definition). ## The proof **9 tests added, 0 changed, 0 removed** (953 passed / 1 skipped before, 962 passed / 1 skipped after, `python3 -m pytest -q` from a neutral cwd), next to the existing way-in tests in `tests/test_shape_doctor.py`: * `test_the_way_in_row_emits_a_classifying_name_verbatim` -- `openRepoProject` comes back as `openRepoProject`, not `Openrepoproject`. * `test_the_way_in_row_prefers_origins_name_over_the_local_folder` -- a folder named `clone-of-openrepoproject` (classifies nothing) beside an `origin` named `openRepoProject` still emits `--project openRepoProject`. * `test_the_way_in_row_still_derives_a_token_for_a_name_that_does_not_classify` -- `my-repo` still comes back `MyRepo`, unchanged. * `test_the_way_in_row_also_keeps_a_classifying_name_when_scaffolding` -- the SCAFFOLD branch (no `.git`) gets the same treatment: `openWidget` stays `openWidget`. * `test_the_way_in_rows_suggested_project_always_classifies`, parametrized over `openRepoProject`, `openDox`, `Thing`, `my-repo`, `brett-wip` -- whichever branch answered, the value it handed back is re-checked in-process against the policy the doctor itself loaded (`NamingPolicy.classify` + `accepts_role`), the way `tests/test_naming_policy.py` checks a classification. `test_naming_policy.py::test_cli_reports_an_unread_link_as_a_warning_and_still_classifies` -- the known location-dependent test (real `openXdox`/`openDox` checkouts beside this worktree on this workstation) -- passes at `origin/main` and here alike when the suite is run from a neutral cwd, confirmed explicitly both ways rather than assumed. `python3 scripts/render-cli-reference.py --check`: `[ok] docs/cli.md is what the generator produces` -- no `--help` text moved. Live, before and after, against a throwaway fixture matching the reported repository exactly (directory and origin both `openRepoProject`): ``` - --project Openrepoproject (origin/main, unpatched) + --project openRepoProject (this branch) ``` Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
@codex review |
There was a problem hiding this comment.
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 3 days and 2 hours by commenting @sourcery-ai review. Upgrade to get a review now.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Reviewer's GuideUpdates shape-doctor’s way-in recommendations to reuse the naming policy and repository identity, preserving already-valid project names verbatim while retaining the legacy derivation fallback; comprehensive tests cover adoption, scaffolding, origin handling, and downstream acceptance. Sequence diagram for the way-in recommendationsequenceDiagram
participant Doctor as shape-doctor.py
participant Git as Repository identity
participant Policy as NamingPolicy
participant Output as Way-in row
Doctor->>Git: origin_name(root)
Git-->>Doctor: repository name or empty
Doctor->>Policy: load(repository-naming.yaml)
Doctor->>Policy: classify(name, assembly)
Policy-->>Doctor: naming classification
Doctor->>Policy: accepts_role(classification, assembly)
alt name is accepted verbatim
Doctor-->>Output: project = identity
else name is not accepted
Doctor-->>Output: project = capitalized parts
end
Output-->>Doctor: NEXT and JSON next use the same project
Flow diagram for identity-aware project token selectionflowchart TD
A[check_the_way_in] --> B["origin_name(root) or root.name"]
B --> C["project_token_for(identity, policy)"]
C --> D{"accepts_role(policy.classify(name, assembly), assembly)"}
D -->|yes| E[Use identity verbatim]
D -->|no| F[Capitalize hyphen or underscore parts]
E --> G["Build adoption or scaffold NEXT command"]
F --> G
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
🟡 Changes recommended
Three moderate issues remain in origin parsing, fallback validation, and loose-directory origin handling.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR preserves valid repository identities in shape-doctor.py suggestions while retaining fallback normalization.
Changes:
- Reuses naming-policy validation for project suggestions.
- Prefers origin repository names where applicable.
- Adds regression coverage for adoption, scaffolding, and fallback behavior.
File summaries
| File | Summary |
|---|---|
shape-doctor.py |
Implements identity-preserving project suggestions; moderate issues remain around Windows origins, invalid fallback names, and ancestor repository detection. |
tests/test_shape_doctor.py |
Adds coverage for identity preservation, origin precedence, scaffolding, and fallback cases. |
Review details
Suppressed comments (1)
shape-doctor.py:2063
- The fallback still emits invalid project suggestions for names it does not normalize: an origin such as
my.repobecomesMy.repo, butadopt-project.pyrejects that because the assembly form only permits letters/digits (aside from the leg suffixes). Since this change now feeds the origin name into the fallback, a clone in an otherwise valid folder can regress to a command that immediately refuses; normalize all disallowed separators and ensure the fallback starts with a letter before emitting it.
return "".join(part.capitalize()
for part in name.replace("_", "-").split("-")
if part) or "Project"
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
… -- an unnormalized fallback separator, a leaked ancestor origin, and an unsplit Windows-style remote path Lane: openreposhape-2 (openRepoShape-2) Follow-up to #109, PR #110 -- addresses Copilot's review on commit 747d49d. ## What was wrong Three findings, all confirmed live before this commit: 1. **The fallback derivation only split on `-` and `_`.** `my.repo` is an ordinary repository name -- and, since 747d49d, `origin`'s name feeds the same fallback a directory's always did -- but `.` matches no family in the naming policy, so `project_token_for("my.repo", ...)` returned `My.repo` verbatim: a token `adopt-project.py` refuses outright. (`shape-doctor.py:2063` in Copilot's review body) 2. **`git remote get-url origin` does not stop at `root` looking for one.** Run from a directory that has none, it walks UP to the nearest ancestor repository and answers for THAT one. `check_the_way_in` started reading `origin_name(root)` unconditionally in 747d49d, so a loose folder with no `.git` of its own, sitting inside a clone of `openRepoProject`, suggested `--project openRepoProject` to the SCAFFOLD line -- creating a project named after a repository the folder is not. Confirmed live: `git remote get-url origin`, run from such a nested loose directory, answers with the ancestor's URL, exit 0. 3. **The basename split only understood `/`.** A local-path `origin` on Windows can be backslash-spelled (`D:\a\_work\1\s\Atlas.git` -- this shape's own CI runner lays a checkout out exactly like that), which carries no `/` at all, so `origin_name`'s `rsplit("/", 1)` found nothing to split on and returned the WHOLE path. `identity` then became a string with a colon and a run of backslashes in it, which classified nothing and fed a mangled, useless token to the derivation. Confirmed live: a remote added with that literal value round-trips through `git remote get-url` unchanged, on any host -- reading it back is a string operation, not a filesystem one. ## What landed * `project_token_for`'s fallback now splits on `re.split(r"[^A-Za-z0-9]+", name)` -- any run of characters the policy does not admit, not only `-` and `_` -- and refuses a result with no leading letter (`9lives` -- the same finding at the other end of the string), falling back to the same `"Project"` placeholder an empty derivation already used. * `check_the_way_in` only calls `origin_name(root)` when `is_repo` is true -- the exact fact that guard needs, already computed for the branch just below it, so asking costs nothing new. * `origin_name` normalizes `\` to `/` before taking the last path segment, so a Windows-style local-path remote's basename comes out the same as a forward-slash one's. Both of `origin_name`'s callers (this row and the `naming` row) get the fix; it is one function, read twice. ## The proof **6 tests added** (2 new parametrized cases on the existing `test_the_way_in_rows_suggested_project_always_classifies`, plus 4 new functions), **968 passed / 1 skipped** (962 / 1 before this commit, 953 / 1 at `origin/main`), `python3 -m pytest -q` from a neutral cwd: * `test_the_way_in_rows_fallback_normalizes_every_separator` -- `my.repo` -> `MyRepo`. * `test_the_way_in_rows_fallback_refuses_a_name_with_no_leading_letter` -- `9lives` -> `Project`. * `test_the_way_in_row_never_leaks_an_ancestor_repositorys_origin` -- a `Loose` folder with no `.git`, inside a clone of `openRepoProject`, still scaffolds itself as `Loose`. * `test_origin_name_reads_a_windows_style_local_path_remote` -- a remote added as `D:\a\_work\1\s\Atlas.git` reads back as `Atlas`, asserted on whichever host runs the suite. `python3 scripts/render-cli-reference.py --check`: `[ok] docs/cli.md is what the generator produces`. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Addressed all three findings from Copilot's review of 747d49d, in 2812e7c:
6 tests added for the three (968 passed / 1 skipped, up from 962 / 1 on 747d49d; 🤖 Generated with Claude Code |
There was a problem hiding this comment.
🔵 Needs a closer look
Moderate issues remain with ancestor-repository identity consistency and origin-path parsing.
Review details
Suppressed comments (3)
shape-doctor.py:2122
- This guard fixes the way-in command for a loose folder, but the
namingrow still callsorigin_name(ctx.root)unconditionally at line 1865. From a directory nested under another checkout, Git walks to that ancestor and the doctor reports the ancestor's origin while this row suggests the loose folder's name, so the rows still disagree about the identity being classified. Make the naming row use the same repository-local identity guard/helper and add a regression assertion for that row.
identity = (origin_name(root) if is_repo else None) or root.name
shape-doctor.py:1851
- The basename extraction still misses a valid scp-style remote with no slash, such as
[email protected]:Atlas.git: this returns[email protected]:Atlas, so the new origin-based suggestion becomesGitExampleComAtlasinstead ofAtlas. Handle thehost:pathform when no/is present and add a regression test, otherwise some repository-backed suggestions still change the repository identity.
name = url.replace("\\", "/").rstrip("/").rsplit("/", 1)[-1]
shape-doctor.py:1851
- Normalizing every backslash here also rewrites valid POSIX local-path remotes. For example, an origin such as
/tmp/foo\bar.githasfoo\baras its basename, but this line turns it intobar, soproject_token_forderives from the wrong repository identity. Restrict the replacement to recognizable Windows drive/UNC path spellings (or otherwise preserve backslashes for POSIX paths).
name = url.replace("\\", "/").rstrip("/").rsplit("/", 1)[-1]
- Files reviewed: 2/2 changed files
- Comments generated: 0 new
- Review effort level: Lite
…econd review of PR #110 -- the naming row's own ancestor leak, an unsplit scp-style remote, and an over-eager backslash rewrite Lane: openreposhape-2 (openRepoShape-2) Follow-up to #109, PR #110 -- addresses Copilot's review on commit 2812e7c. ## What was wrong Three findings, all confirmed live before this commit: 1. **The `naming` row had the identical ancestor-leak 2812e7c fixed only in `the way in`.** `check_not_a_root_naming` still called `origin_name` unconditionally, so a loose folder nested inside a clone of `openRepoProject` was classified there as `Loose, openRepoProject` while `the way in` row right beside it, after 2812e7c, suggested `--project Loose` -- the two rows disagreeing about the identity of the exact same directory. 2. **The basename split still had no answer for scp-like syntax with no group prefix.** `[user@]host:path` -- `[email protected]:Atlas.git` -- has no `/` anywhere in it, which is the identical "nothing to split on" failure 2812e7c fixed for a Windows path, just without a `\` to normalize first. `origin_name` returned the whole string, and the fallback derived `GitExampleComAtlas` from it. Confirmed live. 3. **2812e7c's `\` -> `/` replacement was not restricted to Windows spellings.** A valid POSIX local-path remote whose basename merely contains a literal `\` of its own -- `/tmp/foo\bar.git` -- had that character rewritten as a separator too, so the basename came back `bar` instead of `foo\bar`, silently discarding half of the actual name. Confirmed live. ## What landed * `repo_local_origin_name(root)`: `origin_name(root)`, but only when `root` itself carries the `.git` that remote belongs to. Both callers that read an origin for `root`'s OWN identity -- `naming` and `the way in` -- now share this one guard instead of each re-deriving "is this directory itself a repository." * `origin_name` normalizes `\` to `/` only when the URL is RECOGNIZABLY a Windows path (`_WINDOWS_PATH_RE`: a drive letter or a UNC share) -- everywhere else a `\` is left exactly where it was, an ordinary character in a POSIX path or repository name. * Once a URL scheme (`://`) is ruled out, everything after the LAST `:` is read as the path -- scp-like syntax's own grammar, which also happens to be exactly the substring a Windows drive letter's colon isolates, so one rule reads both correctly once the previous point has already turned a Windows path's backslashes into slashes. ## The proof **3 tests added, 971 passed / 1 skipped** (968 / 1 before this commit, 962 / 1 after 747d49d, 953 / 1 at `origin/main`), `python3 -m pytest -q` from a neutral cwd: * `test_origin_name_reads_scp_like_syntax_with_no_slash_at_all` -- `[email protected]:Atlas.git` -> `Atlas`. * `test_origin_name_preserves_a_literal_backslash_in_a_posix_path` -- `/tmp/foo\bar.git` -> `foo\bar`, unchanged. * `test_the_naming_row_also_never_leaks_an_ancestor_repositorys_origin` -- the `naming` row on a nested loose folder now reports `names: ["Loose"]`, `origin: null`, matching `the way in` row beside it. `python3 scripts/render-cli-reference.py --check`: `[ok] docs/cli.md is what the generator produces`. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Addressed all three findings from Copilot's second review (of 2812e7c), in 7219966:
3 tests added (971 passed / 1 skipped, up from 968 / 1 on 2812e7c; 🤖 Generated with Claude Code |
There was a problem hiding this comment.
🟡 Changes recommended
Address the moderate path-parsing issue and the two test-name spelling nits.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (2)
tests/test_shape_doctor.py:2118
- The new test identifier spells the possessive as
repositorys, which is misspelled. Rename it to userepository_originso the test name remains readable.
def test_the_way_in_row_never_leaks_an_ancestor_repositorys_origin(standard,
tests/test_shape_doctor.py:2207
- This new test name repeats the
repositorysmisspelling, and its inline reference repeats it too. Userepository_originin both places so the test name and the reference are grammatically correct.
def test_the_naming_row_also_never_leaks_an_ancestor_repositorys_origin(
standard, tmp_path):
"""Copilot, second review of PR #110: the `way in` row's guard against
an ancestor's `origin` (`test_the_way_in_row_never_leaks_an_ancestor
_repositorys_origin`, above) meant nothing if the `naming` row right
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
…h's own colon read as an scp/drive separator, and two misspelled test names Follow-up to #109, PR #110 -- addresses Copilot's third review, on commit 7219966. ## What was wrong Three findings, all confirmed live before this commit: 1. **MODERATE -- the colon fix from the second review was itself too broad.** `origin_name`'s `if "://" not in url and ":" in url: url = url.rsplit(":", 1)[-1]` reads EVERY colon in a non-URL remote as the scp/drive separator, not only the one that actually is one. A local-path remote whose own basename contains a colon -- `/tmp/openRepo:Project.git` -- was truncated the same way `[email protected]:Atlas.git` legitimately is, down to `Project` instead of `openRepo:Project`. Confirmed live: a remote added with that literal value round-trips through `git remote get-url` unchanged, and `origin_name` returned `Project`. 2. **NIT -- `test_the_way_in_row_never_leaks_an_ancestor_repositorys_origin` misspells the possessive.** `repositorys` has no apostrophe where one belongs. 3. **NIT -- `test_the_naming_row_also_never_leaks_an_ancestor_repositorys _origin` repeats the same misspelling**, in its own name and again in its docstring's inline reference to the first test. ## What landed * `origin_name` only strips up to the last `:` when the text BEFORE it is a drive letter (`D`) or an SCP host (`[email protected]`) -- i.e. that text contains no `/` and no `\`. Everywhere else, including a local path whose basename already has a colon of its own, the colon is an ordinary character and the string is left alone. The Windows-path and SCP-syntax cases from the first two reviews still resolve the same way, since a drive letter or an SCP host never itself contains a `/` or `\`. * Both misspelled test names are corrected to `..._ancestor_repository_origin`, and the docstring reference in the second one now names the first test correctly. ## The proof **1 test added, 2 tests renamed**, `python3 -m pytest -q` from the worktree: **971 passed, 1 skipped, 1 failed in 413.88s** -- `test_naming_policy.py::test_cli_reports_an_unread_link_as_a_warning_and _still_classifies`, a PRE-EXISTING, location-dependent flake (real `openXdox`/`openDox` checkouts beside this worktree on this workstation), unrelated to this change: it reproduces identically, same assertion, on the unmodified 7219966 from this same cwd (`git stash` + rerun), and passes in isolation from a neutral cwd (`/tmp`). 973 collected, up from 972 on 7219966 -- the one test added. * `test_origin_name_preserves_a_colon_in_a_local_path_basename` -- `/tmp/openRepo:Project.git` -> `openRepo:Project`, unchanged. * `test_origin_name_reads_a_windows_style_local_path_remote` and `test_origin_name_reads_scp_like_syntax_with_no_slash_at_all` still pass, unchanged, confirming the drive-letter and SCP cases the new prefix check must keep working. `python3 -m pytest -q tests/test_cli_reference.py`: **13 passed** -- no `--help` text moved, `docs/cli.md` unchanged. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Lane: openreposhape-2 (openRepoShape-2) Addressed all three findings from Copilot's third review (of 7219966), in 296d3b5:
1 test added, 2 tests renamed (971 passed / 1 skipped / 1 failed, up from 971 passed / 1 skipped on 7219966; 🤖 Generated with Claude Code |
There was a problem hiding this comment.
🟡 Changes recommended
Fix SCP-style remote parsing so repository identities containing additional colons are preserved.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
…split must be the FIRST one, and a bracketed IPv6 host must be read whole Follow-up to #109, PR #110 -- addresses Copilot's fourth review, on commit 296d3b5. ## What was wrong The third review's fix split a non-URL remote on its LAST colon (`rpartition`) once the text before it looked like a drive letter or an SCP host. That is right when there is only one colon, and wrong twice over when there is not: 1. **An SCP path with its own group prefix has a second colon.** `[email protected]:team:repo.git` is ordinary syntax -- `team` is a group, not part of the host -- but the LAST colon lands one separator too far into the path, reading `team:` as more of the host and dropping it: `repo` instead of `team:repo`. Confirmed live: the value round-trips through `git remote get-url` unchanged, and `origin_name` returned `repo`. 2. **A bracketed IPv6 host has colons of its own.** `[::1]:repo.git`'s FIRST colon, by plain text position, sits inside the brackets, part of the host -- so even a first-colon rule, without bracket-awareness, would split the host in half instead of finding the real separator right after the closing `]`. ## What landed `origin_name` now parses the separator explicitly instead of reaching for either end of the string: * A bracketed host (`_BRACKETED_HOST_RE`: optional `user@` then `[...]:`) is read whole; the path is everything after the colon that follows the closing `]`. * Otherwise, when the text before the FIRST colon contains no `/` and no `\` -- a drive letter or a plain SCP host -- that FIRST colon is the separator, and everything after it, however many further colons the path itself goes on to contain, is the path. * A recognized Windows drive or UNC path is excluded from that rule explicitly, rather than relying on it happening to come out right anyway: the drive letter is part of the path, never a host. ## The proof **2 tests added** (975 collected, up from 973 on 296d3b5): * `test_origin_name_reads_scp_like_syntax_with_a_colon_in_the_path` -- `[email protected]:team:repo.git` -> `team:repo`. * `test_origin_name_reads_a_bracketed_ipv6_host` -- `[::1]:repo.git` -> `repo`. Every existing `origin_name` test still passes unchanged: the drive-letter, plain-SCP, literal-backslash, and colon-in-a-local-path cases from the first three reviews. `python3 -m pytest -q` from the worktree: **973 passed, 1 skipped, 1 failed in 405.67s**. The failure is the same pre-existing, location-dependent flake already documented in this branch's own commit history (`test_naming_policy.py::test_cli_reports_an_unread_link_as_a _warning_and_still_classifies` -- real `openXdox`/`openDox` checkouts beside this worktree on this workstation): neither `tests/test_naming_policy.py` nor `scripts/validate-repository-naming.py` is touched by this commit, or by any commit in this PR (`git diff --stat 7219966 -- tests/test_naming_policy.py scripts/validate-repository-naming.py` is empty), so the failure is unrelated to this change by construction, not only by re-running it. `python3 -m pytest -q tests/test_cli_reference.py`: **13 passed** -- no `--help` text moved, `docs/cli.md` unchanged. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Lane: openreposhape-2 (openRepoShape-2) Addressed the finding from Copilot's fourth review (of 296d3b5), in eb2a395: Colon split must be the FIRST colon, and a bracketed IPv6 host must be read whole ( 2 tests added (973 passed / 1 skipped / 1 failed, 975 collected, up from 973 collected on 296d3b5; 🤖 Generated with Claude Code |
|



Lane: openreposhape-2 (openRepoShape-2)
Closes #109.
What was wrong
openRepoShape --doctor ~/projects/openRepoProject(a plain git repository,origin
[email protected]:opensoft/openRepoProject.git, no shape manifest)printed:
The
namingrow had just verified thatopenRepoProjectclassifies --neutral-product(^open(?:[A-Z]|x[A-Z])[A-Za-z0-9]*$), which since #45'sadmits_declared_roleruling ADMITS being its own assembly root -- yetcheck_the_way_in's--projectwas derived UNCONDITIONALLY, by"".join(part.capitalize() for part in root.name.replace("_", "-") .split("-") if part), which turnsopenRepoProjectintoOpenrepoproject:a DIFFERENT name that still happens to classify, as a bare
project-leg/assemblytoken, so nothing in the naming policy caught themismatch.
adopt-project.pykeeps the source repository's own name, identity andhistory and derives the two new legs' names from
--project. Run asprinted,
executewould have named the legsOpenrepoproject-spec/Openrepoproject-codebeside a root still calledopenRepoProject-- afamily nobody chose, from a line that looks safe to paste.
This was never adopt refusing the lowercase form:
_check_namesalreadyaccepts
--project openRepoProject(accepts_roleadmits("neutral-product", "assembly"), andtests/test_adopt_plan.py::test_a_neutral_product_may_be_adopted_as_its_own_assembly_rootalready covered exactly this with
openDox, confirmed passing atorigin/main). The defect was only in whatshape-doctor.pysuggested,and confirmed live:
adopt-project.py plan --project openRepoProjectexits0 today, unpatched.
What landed
project_token_for(name, policy):nameVERBATIM whereaccepts_role(policy.classify(name, "assembly"), "assembly")alreadyadmits it -- the exact gate
adopt-project.py's own_check_namesruns --and the unchanged capitalized-parts derivation only for a name the policy
admits no form of at all (
my-repo->MyRepo, exactly as before).check_the_way_inreads the same identity thenamingrow does:origin's repository name where there is one, else the directory's ownname --
check_not_a_root_naming's own docstring, "the name that mattersfor the policy is the repository's" -- because a clone into a differently
named folder does not change what would actually be adopted. The suggestion
is computed once, before the branch on
is_repo, so the SCAFFOLD half ofthis row (no
.gitat all) gets the identical treatment: a loose folderalready named like a live neutral product is offered to
setup.sh/setup-project.pyas itself too.Both the human-readable
NEXTline and the--jsonnextagree byconstruction: one
projectvariable feeds both, as before.NamingPolicyandaccepts_rolejoinshape-doctor.py's existingin-process imports from
repo_shape(adopt-project.py's own_check_namesalready uses both the same way, so this is the secondcaller of one definition, not a second definition).
The proof
9 tests added, 0 changed, 0 removed (953 passed / 1 skipped before,
962 passed / 1 skipped after,
python3 -m pytest -qfrom a neutral cwd),next to the existing way-in tests in
tests/test_shape_doctor.py:test_the_way_in_row_emits_a_classifying_name_verbatim--openRepoProjectcomes back as
openRepoProject, notOpenrepoproject.test_the_way_in_row_prefers_origins_name_over_the_local_folder-- afolder named
clone-of-openrepoproject(classifies nothing) beside anoriginnamedopenRepoProjectstill emits--project openRepoProject.test_the_way_in_row_still_derives_a_token_for_a_name_that_does_not_classify--
my-repostill comes backMyRepo, unchanged.test_the_way_in_row_also_keeps_a_classifying_name_when_scaffolding--the SCAFFOLD branch (no
.git) gets the same treatment:openWidgetstays
openWidget.test_the_way_in_rows_suggested_project_always_classifies, parametrizedover
openRepoProject,openDox,Thing,my-repo,brett-wip--whichever branch answered, the value it handed back is re-checked
in-process against the policy the doctor itself loaded
(
NamingPolicy.classify+accepts_role), the waytests/test_naming_policy.pychecks a classification.test_naming_policy.py::test_cli_reports_an_unread_link_as_a_warning_and_still_classifies-- the known location-dependent test (real
openXdox/openDoxcheckoutsbeside this worktree on this workstation) -- passes at
origin/mainandhere alike when the suite is run from a neutral cwd, confirmed explicitly
both ways rather than assumed.
python3 scripts/render-cli-reference.py --check:[ok] docs/cli.md is what the generator produces-- no--helptext moved.Live, before and after, against a throwaway fixture matching the reported
repository exactly (directory and origin both
openRepoProject):🤖 Generated with Claude Code
Summary by Sourcery
Preserve valid repository identities in shape-doctor project suggestions while making origin detection robust across local and remote Git URL formats.
Bug Fixes:
Enhancements:
Tests: