Skip to content

A neutral product may elect the shape and be its own assembly root (#41) - #45

Merged
brettheap merged 1 commit into
mainfrom
fix/neutral-product-root
Sep 5, 2026
Merged

brettheap merged 1 commit into
mainfrom
fix/neutral-product-root

Conversation

@brettheap

@brettheap brettheap commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Lane: xfactory-2 (xFactory-2)
Claim: #41 (comment)

Closes #41.

What this changes

A neutral product may elect the shape and be its own assembly root. Ruled by Brett Heap on 2026-09-05T14:52Z, in session, verbatim: "elect the shape for both, follow the pin chain, no family yet" (recorded on opensoft/openXfactory#656), for openDox and openXdox. #42 landed the pin-chain half (#40); this is the other half, found while that PR was being written: the scaffold REFUSED both names at main and at the commit openxFactory pins, because accepts_role() admitted only project-leg/<role> and a declared domain-descendant/assembly, and the project-leg/assembly overlap the classifier computed for openDox was thrown away.

Option 1 of the issue, as the ruling reads — no opt-in flag:

  • contracts/repository-naming.yaml — the neutral-product family gains admits_declared_role: [assembly] as DATA, the mechanism the descendant family already uses, with the ruling quoted beside it. install gets no admission, on purpose: <X>-Install carries a hyphen and satisfies no leg form to be admitted into. openDox/openXdox join the family's examples.
  • scripts/repo_shape.py — ONE definition. NamingPolicy.classify at the neutral/install step: where the family admits the declared role AND the name also satisfies that project-leg form, the answer is neutral-product carrying the declared role, consuming (neutral-product, None) so project-leg/assembly still survives in also_matches. The FORM still wins; the overlap is recorded, not resolved. accepts_role admits ("neutral-product", "assembly") — a fact, never a claim, because the tuple only exists when the policy admitted it. Referent-chain logic from Descendant referent follows the declared pin chain (#40) #42 is byte-identical.
  • scaffold-project.py, adopt-project.py, templates/assembly-root/scripts/validate-manifest.py — consult the same definition; stale comments and remediation text corrected. The manifest a scaffold writes records form: neutral-product, role: assembly, also_matches: [project-leg/assembly] and its own validate-manifest.py accepts it.
  • scripts/validate-repository-naming.py --explain names the admission when a role is declared; without --role the answer is what it always was.
  • templates/assembly-root/project.yaml comment and one README paragraph in § "A descendant form is a claim; a claim needs a referent", quoting the ruling. README hygiene cap raised 725 → 742 with the reason recorded beside it.

Still refused, and tested: openDox-spec offered as the assembly root; openDox offered as a spec or code leg; Widget-Install as any leg. Unchanged, and tested: openDox with no declared role; a declared descendant root (MedxGlass pinning openGlass); every #42 chain case. Nothing else in the standard moves; the shape still confers nothing.

Evidence

python3 -m pytest tests -q: 496 passed (468 on main, +28 net). Offline end to end: a local scaffold of openDox writes the block above and both project validators exit 0; openXdox --pin openDox@<sha> --pin-source <clone> additionally passes validate-pins.py.

Before:

$ python3 scaffold-project.py --org Example --project openDox --dry-run
REFUSED naming-role-mismatch: 'openDox' classifies as neutral-product, not as the 'assembly' form of a project leg (the neutral-product form is unambiguous by construction, so it needs nothing declared)

After:

project      openDox (opendox)   topic xf-project-opendox
  assembly  Example/openDox              -> https://github.com/Example/openDox.git
  spec      Example/openDox-spec         -> https://github.com/Example/openDox-spec.git
  code      Example/openDox-code         -> https://github.com/Example/openDox-code.git
--dry-run: nothing was created.

Worktree fix/neutral-product-root from origin/main c2cc9e2 (after #42). Adversarial Opus review pass run before opening; its seven findings (a misleading --explain arm, the plan not naming the classification without a pin, the referent lines on openx<Product> names now explained and tested, the openXdox/openxDox id collision recorded, two comment corrections, the README paragraph promoted to its own heading) are all folded in. Merge word: Brett Heap, 2026-09-05, "open the PR when it's done and merge on green".

🤖 Generated with Claude Code

Summary by Sourcery

Allow eligible neutral-product repositories to elect the project shape as their own assembly root while preserving naming precedence, overlap records, and existing role restrictions.

New Features:

  • Allow neutral-product repositories such as openDox and openXdox to elect the three-repository shape and serve as their own assembly roots.
  • Record the elected neutral-product assembly classification alongside its project-leg overlap in generated manifests and naming diagnostics.

Bug Fixes:

  • Fix scaffold and adoption flows that previously rejected eligible neutral-product assembly roots after discarding their project-leg overlap.

Enhancements:

  • Centralize role admission so neutral products are accepted only for assembly and continue to be rejected as spec or code legs.
  • Preserve existing descendant pin-chain behavior while exposing clearer classification and role-admission explanations.

Documentation:

  • Document neutral-product assembly roots, their recorded overlaps, and the forms that remain refused.

Tests:

  • Add coverage for neutral-product roots, pinned neutral-product chains, manifest validation, adoption, dry runs, refusal cases, and unchanged descendant behavior.

Chores:

  • Raise the README hygiene limit to accommodate the new user-facing rule.

Ruled by Brett Heap on 2026-09-05: "elect the shape for both, follow the pin
chain, no family yet" (openxFactory#656), for openDox and openXdox. The
scaffold refused both: accepts_role() admitted only project-leg/<role> and a
declared domain-descendant/assembly, and the project-leg/assembly overlap the
classifier computed for open<Product> was discarded.

The neutral-product family now ADMITS the declared assembly role as data
(admits_declared_role, the descendant family's own mechanism), and classify
carries that role where the name also satisfies the leg form, consuming
(neutral-product, None) so project-leg/assembly survives in also_matches: the
form still wins, the overlap is recorded, not resolved. accepts_role admits
("neutral-product", "assembly"). install is admitted into no role, and could
not be. Electing confers nothing, so openDox mounting openDox-spec and
openDox-code is a fact about layout, not a claim about neutrality.

496 tests (+28). Referent-chain logic from #42 untouched.

Lane: xfactory-2 (xFactory-2)
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 5, 2026 17:16
@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 21 hours and 47 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

@sourcery-ai

sourcery-ai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR adds a data-driven assembly admission for neutral products and threads the resulting neutral-product / assembly classification through policy evaluation, manifests, scaffold/adopt workflows, validators, diagnostics, documentation, and regression coverage while preserving form precedence, overlap recording, pin-chain behavior, and existing refusals.

Sequence diagram for scaffolding a neutral-product assembly root

sequenceDiagram
    participant User
    participant Scaffold as scaffold-project.py
    participant Policy as NamingPolicy
    participant Manifest as AssemblyManifest
    participant Validator as validate-manifest.py
    User->>Scaffold: scaffold openDox as assembly
    Scaffold->>Policy: classify(openDox, assembly)
    Policy-->>Scaffold: neutral-product / assembly
    Note over Policy: also_matches includes project-leg/assembly
    Scaffold->>Manifest: write naming form and role
    Manifest-->>Validator: validate manifest
    Validator->>Policy: accepts_role(neutral-product / assembly, assembly)
    Policy-->>Validator: true
    Validator-->>User: validation succeeds
Loading

Entity relationship diagram for elected assembly manifest

erDiagram
    ASSEMBLY_ROOT ||--|| NAMING_RECORD : records
    ASSEMBLY_ROOT ||--|{ PROJECT_LEG : mounts
    ASSEMBLY_ROOT {
        string repository_name "openDox"
        string role "assembly"
    }
    NAMING_RECORD {
        string form "neutral-product"
        string role "assembly"
        string also_matches "project-leg/assembly"
    }
    PROJECT_LEG {
        string role "spec or code"
        string repository_name
    }
Loading

Flow diagram for neutral-product assembly admission

flowchart TD
    A["openDox with declared assembly role"] --> B{"Neutral-product family admits assembly?"}
    B -- No --> C["Classify as neutral-product"]
    B -- Yes --> D{"Name also matches project-leg/assembly?"}
    D -- No --> C
    D -- Yes --> E["Classify as neutral-product / assembly"]
    E --> F["Record also_matches: project-leg/assembly"]
    F --> G["accepts_role permits assembly root"]
Loading

File-Level Changes

Change Details Files
Extend naming-policy classification so a neutral product can serve as an elected assembly root without losing its primary form or overlapping leg match.
  • Declare neutral-product admission for the assembly role and add the newly supported examples.
  • Return neutral-product / assembly only when the declared role is policy-admitted and the name also matches the assembly leg form.
  • Preserve project-leg/assembly in also_matches, and allow accepts_role to recognize the admitted root.
  • Keep neutral products ineligible for spec/code roles and keep install forms ineligible for all leg roles.
contracts/repository-naming.yaml
scripts/repo_shape.py
Propagate the elected-root classification through scaffolding, adoption, manifest materialization, and validation.
  • Allow scaffold and adopt workflows to plan or create neutral-product assembly roots, including roots with neutral-product pins.
  • Write and validate form: neutral-product, role: assembly, and the recorded project-leg overlap in manifests.
  • Retain referent-chain and spelling-overlap recording independently of the winning classification.
  • Update remediation text and template documentation to describe supported root forms and refused cases.
scaffold-project.py
adopt-project.py
scripts/shape_materialize.py
templates/assembly-root/project.yaml
templates/assembly-root/scripts/validate-manifest.py
Improve naming diagnostics and document the neutral-product assembly-root ruling.
  • Make --explain --role assembly identify the policy admission while leaving role-free explanations unchanged.
  • Document the ruling, classification precedence, layout semantics, collision considerations, and unsupported leg forms.
  • Raise the README hygiene limit to accommodate the new guidance.
scripts/validate-repository-naming.py
README.md
tests/test_repo_hygiene.py
Add comprehensive regression and end-to-end coverage for elected neutral-product roots and preserved refusals.
  • Test classification, overlap retention, role admission, CLI explanations, manifest validation, adoption, and scaffolding.
  • Cover openDox, openXdox, neutral-product pin chains, and unchanged descendant-chain behavior.
  • Verify refusal of spec/code misuse, install forms, malformed overlap records, and incorrect manifest classifications.
tests/test_adopt_plan.py
tests/test_manifest_validator.py
tests/test_naming_policy.py
tests/test_scaffold_e2e.py
tests/test_scaffold_pin_and_reuse.py

Assessment against linked issues

Issue Objective Addressed Explanation
#41 Allow a neutral-product name such as openDox or openXdox to elect the three-repository shape and serve as its own assembly root, including pinned and unpinned scaffold operations. ✅
#41 Centralize the admission rule so the scaffold, adoption flow, manifest validation, and naming validation consistently accept neutral-product/assembly while continuing to reject neutral-product names as spec or code legs and rejecting project-leg names such as openDox-spec as assembly roots. ✅
#41 Record the neutral-product classification, assembly role, and project-leg overlap in manifests and document the ruling and behavior in the naming contract, template comments, README, and tests. ✅

Possibly linked issues


Tips and commands

Interacting with Sourcery

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

Customizing Your Experience

Access your dashboard to:

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

Getting Help

@sonarqubecloud

sonarqubecloud Bot commented Sep 5, 2026

Copy link
Copy Markdown

@brettheap
brettheap merged commit 5ffa8d5 into main Sep 5, 2026
4 checks passed
@brettheap
brettheap deleted the fix/neutral-product-root branch September 5, 2026 17:19

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

It modifies the core naming classifier and multiple tooling/validator paths, so it warrants final human review despite strong test coverage.

Pull request overview

Enables a neutral-product repository name (open<Product>) to elect the three-repo shape and serve as its own assembly root (while preserving form precedence and recording overlaps like project-leg/assembly), aligning scaffold/adopt/validators/manifests with that admission.

Changes:

  • Extend the naming policy contract and classifier to allow neutral-product to carry the declared assembly role when admitted, while still recording (not resolving) the project-leg/assembly overlap.
  • Update scaffold/adopt and project/template validators to accept and explain neutral-product assembly roots consistently.
  • Add/adjust end-to-end and unit tests plus documentation to cover elected neutral-product roots, pinned neutral-product roots, and refusal edges (e.g., <X>-Install, openDox-spec as root).
File summaries
File Description
tests/test_scaffold_pin_and_reuse.py Adds e2e coverage for a pinned neutral-product root (openXdox pinning openDox) and validator passes.
tests/test_scaffold_e2e.py Adds end-to-end scaffolding/dry-run assertions for openDox as a neutral-product assembly root; keeps refusal edge cases.
tests/test_repo_hygiene.py Raises README line-count cap to accommodate new documentation.
tests/test_naming_policy.py Expands naming-policy and CLI coverage for neutral-product assembly admission and overlap recording.
tests/test_manifest_validator.py Adds manifest-validation coverage for neutral-product assembly roots and related refusal edges.
tests/test_adopt_plan.py Ensures adopt-project.py plan accepts a neutral-product assembly root and still refuses install-form roots.
templates/assembly-root/scripts/validate-manifest.py Updates template validator docs/comments to reflect the additional acceptable root form.
templates/assembly-root/project.yaml Documents neutral-product assembly roots and how the overlap must be recorded in naming:.
scripts/validate-repository-naming.py Enhances --explain output to name and explain admitted declared roles for forms like neutral-product.
scripts/shape_materialize.py Clarifies naming-block materialization behavior for overlaps vs. “winning” family.
scripts/repo_shape.py Implements the core policy change: neutral-product may carry declared assembly role when admitted, preserving overlap recording.
scaffold-project.py Adjusts scaffold diagnostics/output to surface neutral-product/descendant classification consistently in planning.
README.md Documents the new neutral-product assembly-root rule and its implications/edges.
contracts/repository-naming.yaml Adds admits_declared_role: [assembly] to neutral-product and expands explanatory contract text/examples.
adopt-project.py Updates refusal remediation text to reflect the expanded set of admissible assembly-root forms.
Review details
  • Files reviewed: 15/15 changed files
  • Comments generated: 1
  • 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 on lines +305 to +306
assert len(lines) <= 743, (
f"README.md is {len(lines)} lines; the cap is 743")
brettheap added a commit that referenced this pull request Sep 11, 2026
…row already classified, verbatim, instead of an unconditional respelling of it (#109) (#110)

* 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)

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]>

* shape-doctor.py: fix the three moderate issues Copilot found in PR #110 -- 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]>

* shape-doctor.py: fix the three moderate issues Copilot found in its second 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]>

* shape-doctor.py: fix Copilot's third review of PR #110 -- a local path'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]>

* shape-doctor.py: fix Copilot's fourth review of PR #110 -- the colon 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]>

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

scaffold-project.py refuses a neutral-product name as an assembly root: openDox and openXdox cannot elect the shape

2 participants