Skip to content

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

Merged
brettheap merged 5 commits into
mainfrom
fix/doctor-way-in-project-token
Sep 11, 2026
Merged

brettheap merged 5 commits into
mainfrom
fix/doctor-way-in-project-token

Conversation

@brettheap

@brettheap brettheap commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

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)

🤖 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:

  • Make shape-doctor preserve repository identities that already satisfy the naming policy when suggesting adopt or scaffold project names.
  • Use the repository’s local origin name consistently for naming checks and way-in suggestions without inheriting origins from ancestor repositories.
  • Correct origin parsing for Windows paths, SCP-style remotes, bracketed IPv6 hosts, and literal colons or backslashes in POSIX paths.

Enhancements:

  • Ensure generated project suggestions are valid assembly names, with normalized fallback derivation for unsupported identities.

Tests:

  • Add coverage for verbatim classified names, origin precedence, scaffolding, valid fallback suggestions, ancestor-origin isolation, and diverse remote URL formats.

…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]>
Copilot AI lite review requested due to automatic review settings September 11, 2026 14:32
@brettheap

Copy link
Copy Markdown
Contributor Author

@codex review

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

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.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

@sourcery-ai

sourcery-ai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Reviewer's Guide

Updates 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 recommendation

sequenceDiagram
    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
Loading

Flow diagram for identity-aware project token selection

flowchart 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
Loading

File-Level Changes

Change Details Files
Preserve repository identities that already satisfy the assembly naming policy when generating adoption or scaffold commands.
  • Added a policy-aware helper that returns an accepted name verbatim and retains the existing capitalization fallback for invalid names.
  • Loaded and reused the shared NamingPolicy and accepts_role logic used by downstream project validation.
  • Applied the same project identity to both human-readable and JSON suggestions.
shape-doctor.py
Base way-in suggestions on the repository’s origin name rather than the local directory name when available.
  • Use origin_name(root), falling back to root.name, before handling adoption versus scaffolding.
  • Keep the behavior consistent for Git repositories and non-repository scaffolding directories.
shape-doctor.py
Add regression coverage for identity preservation, origin precedence, fallback derivation, scaffolding, and policy acceptance.
  • Verify classifying names remain unchanged and non-classifying names retain the prior derived token.
  • Verify origin names override differently named clone directories.
  • Parametrize checks that every suggested project is accepted for the assembly role.
tests/test_shape_doctor.py

Assessment against linked issues

Issue Objective Addressed Explanation
#109 Make shape-doctor.py preserve the repository's existing identity verbatim as the suggested --project value when that name is accepted by the naming policy for the assembly role. ✅
#109 Use the origin repository name when available, otherwise the directory name, and fall back to the existing capitalization-based derivation only when the identity is not accepted by the naming policy. ✅
#109 Ensure the human-readable and JSON way-in suggestions use the same corrected project value, while preserving behavior for scaffolding and non-classifying names. ✅

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

Copilot AI 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.

🟡 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.repo becomes My.repo, but adopt-project.py rejects 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.

Comment thread shape-doctor.py Resolved
Comment thread shape-doctor.py Resolved
… -- 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]>
Copilot AI review requested due to automatic review settings September 11, 2026 15:00
@brettheap

Copy link
Copy Markdown
Contributor Author

Addressed all three findings from Copilot's review of 747d49d, in 2812e7c:

  1. Fallback separator normalization (the "Suppressed comments" entry on shape-doctor.py:2063 — my.repo → My.repo, refused by adopt-project.py): confirmed live, fixed. project_token_for's fallback now splits on re.split(r"[^A-Za-z0-9]+", name) instead of only -/_, and refuses a result with no leading letter (9lives → Project, the same finding at the other end of the string).
  2. Leaked ancestor origin (inline comment on shape-doctor.py:2085): confirmed live — from a loose subdirectory with no .git of its own, git remote get-url origin does walk up to the nearest ancestor repository. check_the_way_in now calls origin_name(root) only when is_repo is true. Replied on the thread.
  3. Unsplit Windows-style remote path (inline comment on shape-doctor.py:2085): confirmed live — a remote added as D:\a\_work\1\s\Atlas.git round-trips unchanged through git remote get-url, and the old basename split found no / to split on. origin_name now normalizes \ to / first. Replied on the thread.

6 tests added for the three (968 passed / 1 skipped, up from 962 / 1 on 747d49d; python3 -m pytest -q from a neutral cwd). render-cli-reference.py --check still [ok].

🤖 Generated with Claude Code

Copilot AI 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.

🔵 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 naming row still calls origin_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 becomes GitExampleComAtlas instead of Atlas. Handle the host:path form 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.git has foo\bar as its basename, but this line turns it into bar, so project_token_for derives 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]>
Copilot AI review requested due to automatic review settings September 11, 2026 15:23
@brettheap

Copy link
Copy Markdown
Contributor Author

Addressed all three findings from Copilot's second review (of 2812e7c), in 7219966:

  1. naming row's own ancestor leak (shape-doctor.py:2122 — the row disagreed with the now-fixed the way in row for a loose folder nested inside another checkout): confirmed live, fixed. check_not_a_root_naming now reads repo_local_origin_name(ctx.root), the same is-this-directory-itself-a-repository guard the way in already used, shared as one function.
  2. Unsplit scp-style remote with no slash (shape-doctor.py:1851 — [email protected]:Atlas.git → GitExampleComAtlas): confirmed live, fixed. Once a URL scheme (://) is ruled out, everything after the last : is read as the path.
  3. Over-eager backslash rewrite (shape-doctor.py:1851 — /tmp/foo\bar.git → bar instead of foo\bar): confirmed live, fixed. \ → / normalization now only runs when the URL is recognizably a Windows path (a drive letter or a UNC share); everywhere else a \ is left alone.

3 tests added (971 passed / 1 skipped, up from 968 / 1 on 2812e7c; python3 -m pytest -q from a neutral cwd). render-cli-reference.py --check still [ok].

🤖 Generated with Claude Code

Copilot AI 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.

🟡 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 use repository_origin so 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 repositorys misspelling, and its inline reference repeats it too. Use repository_origin in 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

Comment thread shape-doctor.py Resolved
…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]>
Copilot AI review requested due to automatic review settings September 11, 2026 16:27
@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openreposhape-2 (openRepoShape-2)

Addressed all three findings from Copilot's third review (of 7219966), in 296d3b5:

  1. Local-path remote's own colon read as an scp/drive separator (shape-doctor.py:1874, in origin_name -- /tmp/openRepo:Project.git → Project instead of openRepo:Project): confirmed live, fixed. The colon-splitting rule now only fires when the text BEFORE the colon is a drive letter (D) or an SCP host ([email protected]) -- i.e. contains no / and no \ -- so a colon already inside a local path's basename is left alone. The Windows-path and SCP cases from the earlier two reviews still resolve the same way. New test: test_origin_name_preserves_a_colon_in_a_local_path_basename.
  2. Misspelled test name (tests/test_shape_doctor.py:2118 -- test_the_way_in_row_never_leaks_an_ancestor_repositorys_origin): confirmed, fixed. Renamed to test_the_way_in_row_never_leaks_an_ancestor_repository_origin.
  3. Misspelled test name and docstring reference (tests/test_shape_doctor.py:2207 -- test_the_naming_row_also_never_leaks_an_ancestor_repositorys_origin, same misspelling repeated in its own docstring's reference to the first test): confirmed, fixed. Renamed to test_the_naming_row_also_never_leaks_an_ancestor_repository_origin, and the docstring reference now names the first test correctly too.

1 test added, 2 tests renamed (971 passed / 1 skipped / 1 failed, up from 971 passed / 1 skipped on 7219966; python3 -m pytest -q from the worktree). The 1 failure, test_naming_policy.py::test_cli_reports_an_unread_link_as_a_warning_and_still_classifies, is a pre-existing, location-dependent flake (real openXdox/openDox checkouts beside this worktree on this workstation) unrelated to this change: it reproduces identically on the unmodified 7219966 from this same cwd, and passes in isolation from a neutral cwd. python3 -m pytest -q tests/test_cli_reference.py: 13 passed, docs/cli.md unchanged.

🤖 Generated with Claude Code

Copilot AI 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.

🟡 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

Comment thread shape-doctor.py Resolved
…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]>
Copilot AI review requested due to automatic review settings September 11, 2026 16:54
@brettheap

Copy link
Copy Markdown
Contributor Author

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 (shape-doctor.py:1884, in origin_name): confirmed live, fixed. The third review's fix split on the LAST colon (rpartition), which is wrong twice over: (1) [email protected]:team:repo.git has a group prefix with its own colon, so the last colon lands one separator too far into the path and drops team:, returning repo instead of team:repo; (2) [::1]:repo.git's first colon, by plain text position, sits inside the brackets, part of the host, so even a first-colon rule would split the host in half without bracket-awareness. origin_name now parses the separator explicitly: a bracketed host (_BRACKETED_HOST_RE) is read whole and the path is everything after the colon following its 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 contains — is kept; a recognized Windows drive/UNC path is excluded from that rule explicitly rather than by coincidence. New tests: test_origin_name_reads_scp_like_syntax_with_a_colon_in_the_path ([email protected]:team:repo.git → team:repo) and test_origin_name_reads_a_bracketed_ipv6_host ([::1]:repo.git → repo). Every existing origin_name test (drive-letter, plain-SCP, literal-backslash, colon-in-a-local-path) still passes unchanged.

2 tests added (973 passed / 1 skipped / 1 failed, 975 collected, up from 973 collected on 296d3b5; python3 -m pytest -q from the worktree). The 1 failure, test_naming_policy.py::test_cli_reports_an_unread_link_as_a_warning_and_still_classifies, is the same pre-existing, location-dependent flake already documented in this branch's history (real openXdox/openDox checkouts beside this worktree on this workstation): neither that test file nor scripts/validate-repository-naming.py is touched by this commit or by any commit in this PR, so it is unrelated to this change by construction. python3 -m pytest -q tests/test_cli_reference.py: 13 passed, docs/cli.md unchanged.

🤖 Generated with Claude Code

@sonarqubecloud

Copy link
Copy Markdown

Copilot AI 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.

🟢 Approval recommended

No unresolved review issues were identified, and comprehensive regression coverage is included.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@brettheap
brettheap merged commit cd57c4b into main Sep 11, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants