Skip to content

shape-doctor.py: the members row asks the origin question too, so a fork beside the holder is no longer called the member's working clone (#146) - #147

Merged
brettheap merged 5 commits into
mainfrom
fix/doctor-member-origin-like-siblings
Sep 12, 2026
Merged

brettheap merged 5 commits into
mainfrom
fix/doctor-member-origin-like-siblings

Conversation

@brettheap

@brettheap brettheap commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openreposhape-2 (openRepoShape-2)
Claim: #146 (comment)

Closes #146.

What was wrong

shape-doctor.py's is_this_member decided that the directory beside a family
holder IS that member on the strength of project.yaml alone — a git
repository, a project-manifest, an id matching the row — and never looked
at where the clone came from.

The family's OWN verifier asks two questions, not one.
templates/family-root/scripts/siblings.py::verify_sibling refuses a clone
whose origin is not the row's remote as WRONG ORIGIN before it compares
an id, and refuses a matching origin with a different id as WRONG PROJECT. So
a fork, a stale clone of a repository that has since been renamed, or any
second copy of the same project from another remote was reported as
working_clone by the doctor and called WRONG ORIGIN by make siblings —
the report and the tool disagreeing about one directory on one disk, which is
the one thing a command whose every row is somebody else's check must not do.
is_this_member's own docstring already claimed the two asked the same
question; it was half true.

Found by Copilot on PR #142 and left alone there under that PR's
"behaviour byte-identical" law.

What landed

No digest-pinned file is touched. An estate re-pin is in flight, and a line
in scripts/repo_shape.py or under templates/ would put every project
upstream-changed again the moment it landed.

  • scripts/shape_materialize.py gains remote_key and same_repository — the
    doctor's half of the "is this the same repository" definition, mirroring
    siblings.py::same_repository's semantics (scheme, credential prefix, scp
    colon, trailing /, .git suffix and host case all folded; a manifest's
    bare Org/Repo matched by its tail). shape-doctor.py imports nothing out
    of templates/, and scripts/repo_shape.py — where ONE shared definition
    belongs — is digest-pinned; this module is already the doctor's one
    non-pinned import for exactly that reason (the lane trailer, update-shape.py apply --branch and family.py bump write commits with no Lane:/Co-Authored-By trailers; add a repeatable --trailer #111) and
    scripts/family.py imports it too, which is where the second caller is
    expected to come from. Consolidating both copies into repo_shape.py is
    the better long-term home and can ride the next change that has to move the
    pin anyway
    — the section comment in shape_materialize.py says so out
    loud, so a later PR does not have to re-derive the reasoning.
  • shape-doctor.py: sibling_origin (git remote get-url origin, which reads
    .git/config and talks to nothing), mounted_from (the url the holder
    MOUNTS the member from — .gitmodules first and family.yaml's
    repository: second, which is clone_url's order and therefore the remote
    an estate mounted from a mirror, an SSH host or a bare repository on disk
    actually names), and working_clone, which asks both of verify_sibling's
    questions and accepts either spelling of the remote exactly as it does.
    member_state calls it; the LABEL_* constants, member_problem and the
    #134 split are untouched.
  • It stays a REPORT and never becomes a refusal. The verdict for a member
    with no working clone beside the holder is unchanged — where somebody keeps
    their checkouts is the workstation's layout, not a compliance fact about the
    repository. What changes is that the row now SAYS which origin it found
    (IRRS: <path> is a clone of <origin>, not of <the url the holder mounts it from>), because "no working clone beside the holder for IRRS", said about a
    directory named IRRS sitting right there, is the sentence that sends a
    person looking for a bug in this command. The --json member entry gains
    mounted_from and other_origin beside working_clone.

How it was proven

tests/test_shape_doctor.py, beside the existing members-row tests:

  • test_a_sibling_with_this_members_id_but_another_origin_is_not_counted — the
    defect itself: this member's manifest, another origin; not counted, the
    origin named in the row, verdict still ok / COMPLIANT.
  • test_a_real_working_clone_beside_the_holder_is_counted — the other
    direction, and it now CLONES instead of copying the submodule checkout: the
    .git FILE git leaves in a submodule working tree carries a relative
    gitdir: into the holder's .git/modules/, so the old copy was a directory
    git itself refuses to answer about (fatal: not a git repository) and it
    passed only because nothing asked about origin. It also asserts the url
    compared against came out of .gitmodules rather than from
    https://github.com/<repository>.git.
  • test_a_sibling_at_the_right_origin_with_another_id_is_not_the_member — the
    WRONG PROJECT half, still asked.
  • test_an_origin_spelled_scp_where_the_row_is_https_is_the_same_clone — the
    normalisation, end to end: without it this fix would have turned a false
    positive into a false negative on every clone spelled [email protected]:....
  • test_a_directory_that_is_not_a_clone_at_all_is_not_called_a_stranger — the
    copied-submodule state, reported with siblings.py's own (no origin)
    wording.
  • test_the_doctor_and_siblings_agree_on_what_one_repository_is — the parity
    test
    : one table of remote spellings (scp vs https, with and without .git,
    a trailing /, host case, file:// vs a bare path, a manifest's bare
    Org/Repo, a genuinely different repository, a fork under another owner) run
    through BOTH definitions and asserted equal on every pair, with the table
    itself asserted not to be all one answer. The two copies cannot drift in
    silence.

Every one of the six fails against the unfixed shape-doctor.py and
shape_materialize.py (checked by reverting both files and re-running).

Whole suite from the worktree, foreground: 1141 passed, 1 skipped (1136 + 5
new). No --help text changed, so docs/cli.md is untouched;
tests/test_cli_reference.py was run anyway — 13 passed.

🤖 Generated with Claude Code

Summary by Sourcery

Align shape-doctor member detection with sibling verification by requiring the correct repository origin and reporting mismatches without turning them into compliance failures.

New Features:

  • Make member detection verify both the declared project identity and the clone's origin against the holder's mounted repository.
  • Report mismatched sibling origins in text and JSON while preserving the existing compliant verdict for workstation layout issues.

Bug Fixes:

  • Prevent forks, stale renamed-repository clones, and unrelated copies with matching manifests from being reported as working clones.
  • Protect reported and JSON remote URLs by redacting embedded credentials.

Enhancements:

  • Normalize repository and relative remote URL comparisons to match sibling verification across URL schemes, credentials, path spellings, mirrors, and local repositories.
  • Resolve member remotes from tracked .gitmodules declarations and the holder's origin, including relative URLs, and add parity coverage with sibling verification.

Tests:

  • Add coverage for origin mismatches, matching origins with incorrect project IDs, URL normalization, missing origins, credential redaction, relative mounts, and report behavior on finding paths.

…ork beside the holder is no longer called the member's working clone (#146)

`is_this_member` decided that the directory at `../<Project>` WAS this member
on the strength of `project.yaml` alone -- a git repository, a
`project-manifest`, an `id` matching the row -- and never looked at where the
clone came from. The family's own verifier asks two questions, not one:
`templates/family-root/scripts/siblings.py::verify_sibling` refuses a clone
whose `origin` is not the row's remote as `WRONG ORIGIN` BEFORE it compares an
id, and refuses a matching origin with a different id as `WRONG PROJECT`. So a
fork, a stale clone of a repository that has since been renamed, or any second
copy of the same project from another remote was reported as the working clone
by `shape-doctor.py` and skipped by `make siblings`, about one directory on one
disk -- the one thing a report whose every row is somebody else's check must
not do.

`working_clone` now puts the two halves back together in the doctor's own
read-only way: `git remote get-url origin` in the sibling (which reads
`.git/config` and talks to nothing), compared against the url the holder
MOUNTS the member from -- `.gitmodules` first and `family.yaml`'s
`repository:` second, which is `siblings.py::clone_url`'s order and therefore
the remote an estate mounted from a mirror, an SSH host or a bare repository on
disk actually names -- with either spelling accepted, exactly as
`verify_sibling` accepts either.

IT STAYS A REPORT AND NEVER BECOMES A REFUSAL. The verdict for a member with no
working clone beside the holder is unchanged: where somebody keeps their
checkouts is the workstation's layout, not a compliance fact about the
repository. What changes is that the row now SAYS which origin it found --
"`IRRS`: <path> is a clone of <origin>, not of <the url the holder mounts it
from>" -- because "no working clone beside the holder for IRRS", said about a
directory named `IRRS` that is sitting right there, is the sentence that sends
a person looking for a bug in this command. The `--json` member entry gains
`mounted_from` and `other_origin` beside `working_clone`.

THE COMPARISON IS `same_repository`'S, IN A NON-PINNED HOME. Nobody's own clone
has to spell a remote the way a manifest does -- `[email protected]:Org/Repo.git`,
`https://github.com/Org/Repo` and `ssh://[email protected]/Org/Repo.git` are one
repository -- so a comparison on the text would have turned a false positive
into a false negative. `scripts/shape_materialize.py` gains `remote_key` and
`same_repository`: `shape-doctor.py` imports nothing out of `templates/`, and
`scripts/repo_shape.py`, where one shared definition belongs, is digest-pinned
into every project, so a line there would leave every estate `upstream-changed`
until it re-pins. That module is already the doctor's one non-pinned import for
exactly this reason (the lane trailer, #111) and `scripts/family.py` imports it
too, which is where the second caller is expected to come from; consolidating
both copies into `repo_shape.py` is the better long-term home and can ride the
next change that has to move the pin anyway.

WHAT KEEPS THE TWO COPIES HONEST is a parity test: one table of remote
spellings -- scp against https, with and without `.git`, a trailing `/`, a
host's case, `file://` against a bare path, a manifest's bare `Org/Repo`, a
genuinely different repository and a fork under another owner -- run through
BOTH definitions and asserted equal on every pair, with the table itself
asserted not to be all one answer.

The regression tests sit beside the existing members-row ones: a sibling with
this member's id and another origin is reported rather than counted (verdict
unchanged, `COMPLIANT`); a real clone still counts, and is compared against the
`.gitmodules` url rather than a derived `https://github.com/...`; a clone at
the right origin carrying another id is still not the member; an origin spelled
scp where the row is `Org/Repo` still matches. `test_a_real_working_clone_
beside_the_holder_is_counted` now CLONES instead of copying the submodule
checkout: the `.git` file git leaves in a submodule working tree carries a
relative `gitdir:` into the holder's `.git/modules/`, so the old copy was a
directory git itself refuses to answer about, and it passed only because
nothing asked about origin. That state is now its own test, reported with
`siblings.py`'s own `(no origin)` wording.

Suite: 1141 passed, 1 skipped. No `--help` text changed, so `docs/cli.md` is
untouched; `tests/test_cli_reference.py` was run anyway and is green.

Lane: openreposhape-2 (openRepoShape-2)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 12, 2026 16:22

@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 2 days and 1 hour by commenting @sourcery-ai review. Upgrade to get a review now.

@brettheap

Copy link
Copy Markdown
Contributor Author

@codex review

@sourcery-ai

sourcery-ai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Reviewer's Guide

The doctor now agrees with make siblings about whether a directory beside a family holder is the member's working clone: it requires both the expected project ID and an origin matching the holder's mounted repository, normalizes common remote spellings, and reports mismatches without turning them into compliance failures.

Sequence diagram for working-clone verification

sequenceDiagram
    participant Doctor as shape-doctor.py
    participant Holder as Family holder
    participant Sibling as Member directory
    participant Git as Git config

    Doctor->>Holder: mounted_from(root, rel, repository)
    Holder-->>Doctor: mounted repository URL
    Doctor->>Sibling: is_this_member(sibling, row)
    Sibling-->>Doctor: project identity matches
    Doctor->>Git: sibling_origin(sibling)
    Git-->>Doctor: origin URL or no origin
    Doctor->>Doctor: same_repository(origin, mounted repository)
    alt origin and project identity match
        Doctor-->>Doctor: working_clone = sibling
    else wrong origin or no origin
        Doctor-->>Doctor: working_clone = none, other_origin = found origin
    end
Loading

Flow diagram for member-origin reporting

flowchart TD
    A[Inspect member directory beside holder] --> B{Project identity matches row?}
    B -- No --> C[Not a member clone]
    B -- Yes --> D[Read origin with sibling_origin]
    D --> E{"same_repository(origin, mounted_from)"}
    E -- Yes --> F[Count as working_clone]
    E -- No --> G[Report other_origin and WRONG ORIGIN context]
    E -- No --> H[Keep compliance verdict unchanged]
    D --> I[No origin]
    I --> G
Loading

File-Level Changes

Change Details Files
Align member working-clone detection with siblings verification by checking both project identity and the clone's origin.
  • Added normalized remote comparison supporting HTTPS, SSH/scp, local paths, credentials, host case, trailing slashes, and .git suffixes.
  • Read the member's mounted URL from .gitmodules before falling back to family.yaml repository data.
  • Added read-only origin discovery and made mismatched or unavailable origins non-working clones without changing compliance/refusal behavior.
  • Preserved the existing project-ID check so a correct-origin repository with a different ID remains excluded.
scripts/shape_materialize.py
shape-doctor.py
Expose and explain origin-based member diagnostics in report output.
  • Added mounted_from and other_origin to JSON member entries.
  • Report the discovered alternate origin or '(no origin)' while retaining the compliant verdict and existing member labels/problem split.
shape-doctor.py
Add regression and parity coverage for origin-aware member detection.
  • Use a real git clone for the positive working-clone case and verify the mounted URL comes from .gitmodules.
  • Cover wrong origins, wrong project IDs, scp/HTTPS equivalence, invalid copied submodule checkouts, and report-only behavior.
  • Compare the doctor's repository-matching function against siblings.py across equivalent and distinct remote spellings.
tests/test_shape_doctor.py

Assessment against linked issues

Issue Objective Addressed Explanation
#146 Make the members-row working-clone detection require both a matching project identity and an origin matching the member's repository or the holder's mounted URL, using equivalent normalization for URL spellings. ✅
#146 Keep the origin mismatch as a read-only report condition rather than a compliance failure or refusal, while identifying the unexpected origin in the report and JSON output. ✅
#146 Add regression coverage for wrong origins, correct origins, wrong project IDs, missing origins, URL normalization, and parity with the family's sibling verifier. ✅

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

Resolve relative .gitmodules URLs against the holder origin before comparison and reporting.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Aligns member working-clone detection with sibling verification by matching repository origins.

Changes:

  • Adds remote normalization and comparison helpers.
  • Reports clone origins in human-readable and JSON output.
  • Adds regression and parity tests.
File summaries
File Summary
tests/test_shape_doctor.py Adds origin-matching, normalization, and parity coverage.
shape-doctor.py Adds origin-aware working-clone detection; relative .gitmodules URLs need holder-origin resolution.
scripts/shape_materialize.py Provides remote normalization and repository comparison helpers.
Review details
  • Files reviewed: 3/3 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 thread shape-doctor.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ef0e206986

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread shape-doctor.py Outdated
Comment on lines +2218 to +2219
"detached": loose, "mounted_from": remote,
"working_clone": clone, "other_origin": elsewhere}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Redact credentials from reported remote URLs

When either .gitmodules or the sibling's origin embeds credentials (for example, https://TOKEN@host/...), these raw URLs are stored in detail, which --json serializes verbatim; a mismatched origin is also interpolated into the human-readable row. A doctor run can therefore disclose PATs in terminal output or CI artifacts. Keep the raw values only for comparison and redact URL userinfo before storing or formatting them.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lane: openreposhape-2 (openRepoShape-2)

Taken, in 8db73d6. redacted lives in scripts/shape_materialize.py beside same_repository: it replaces the userinfo of a scheme-bearing url with *** (https://x-access-token:<pat>@github.com/Org/Repo.git -> https://***@github.com/Org/Repo.git). The RAW value is still what same_repository compares; redaction happens on the way OUT, so both mounted_from and other_origin are redacted before they are stored in detail (which --json serializes) or interpolated into the row's reason. The host and the path survive, which is the whole of what a person needs in order to see which repository it is. The scp spelling git@host:Org/Repo.git carries a user name and no secret — ssh takes no password in a url — and is left legible.

Regression test: test_a_credential_in_an_origin_is_not_printed_or_put_in_the_json — a sibling whose origin is https://x-access-token:[email protected]/Someone/Fork.git is reported as https://***@github.com/Someone/Fork.git, and the token appears nowhere in either --json or the printed report.

Comment thread shape-doctor.py Outdated
Comment on lines +2285 to +2290
strangers = [f"{entry['project']}: {ctx.root.parent / entry['project']} "
f"is a clone of {entry['other_origin']}, not of "
f"{entry['mounted_from']}, so it is not counted as its "
"working clone (`make siblings` calls the same directory "
"WRONG ORIGIN and leaves it exactly as it is)"
for entry in rows if entry["other_origin"]]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Report wrong origins when a mounted copy also fails

When any pinned member copy has a problem, such as an uninitialized submodule after a non-recursive clone, members_verdict returns before this new strangers list is constructed. The default report therefore omits the detected wrong-origin sibling and only reveals it after the user bootstraps and reruns the doctor, despite the family workflow requiring a clone of a different repository to be reported and skipped. Append the alternate-origin information to the finding path as well.

AGENTS.md reference: AGENTS.md:L370-L374

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lane: openreposhape-2 (openRepoShape-2)

Taken, in 8db73d6. strangers is now built before the if problems: return and appended to the FINDING row's reason as well, after the words "and, though it is not what fails this row" — the pinned copies are still the whole of what makes the row red, and the sentence says so rather than letting a layout fact look like a compliance failure. You are right about the sequence it produced: the person would bootstrap the mount, re-run, and only then hear about a clone that had been the wrong one all along.

Regression test: test_a_stranger_is_reported_even_when_a_pinned_copy_also_fails — a member moved off its pin (so the row is FINDING) with a wrong-origin sibling beside the holder, asserting the finding, the disclaimer and the stranger sentence all appear.

…e urls with their separators folded, because git escapes a backslash on the way into a config file (#146)

`tests-windows` failed on the first of them and on nothing else. The value
under test was RIGHT -- `mounted_from` was
`D:\a\_temp\t\family1\remotes\IRRS.git`, exactly the url the holder mounts the
member from -- but the assertion looked for that string inside the RAW BYTES of
`.gitmodules`, and git escapes a backslash when it writes a config value: the
file holds `D:\\a\\_temp\\...` and hands `D:\a\_temp\...` back to whoever reads
it through `git config`. Two spellings of one url, and a substring test between
them can only fail.

So both assertions now compare the value against the path the fixture built,
with `\` folded to `/` on both sides -- which is what `same_repository` itself
does before it compares two remotes, and the reason this is a test-only defect.
The row's reason is asserted to quote whatever origin the doctor FOUND rather
than a second spelling of it composed here.

Lane: openreposhape-2 (openRepoShape-2)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 12, 2026 16:38

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

One critical credential-leak risk and two moderate correctness/reporting issues remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (2)

shape-doctor.py:2297

  • The new strangers diagnostic is only appended on the OK path: members_verdict returns earlier whenever any member has a pin/population problem. A holder with both an invalid mount and a wrong-origin sibling therefore loses the origin explanation from the normal report, even though this change says the row should identify the origin it found. Build this context before the early return and include it with the existing finding reason without changing the verdict semantics.
    if strangers:
        note += "; " + "; ".join(strangers)

shape-doctor.py:2150

  • When .gitmodules contains a relative URL such as ../IRRS.git, siblings.py::clone_url resolves it against the holder's origin before verifying the sibling. Returning the raw relative string here makes working_clone reject a valid clone from a local, mirror, or SSH holder origin because its actual origin matches neither ../IRRS.git nor the bare repository: value. Resolve the relative URL against root before comparing so the doctor preserves the supported layout and agrees with make siblings.
    return f"https://github.com/{repository}.git"
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread shape-doctor.py Resolved
…ved, redacts any credential in one, and says a wrong-origin sibling on the red path too (#146)

Three findings from the first review round on PR #147, all of them real.

RELATIVE `.gitmodules` URLS (Copilot). `../Repo.git` is not a remote: it is
arithmetic against the SUPERPROJECT'S remote, one path component dropped per
`..`, and `mounted_from` handed the literal string back. For a family whose
holder is not on github.com -- a mirror, an enterprise host -- the sibling's
origin then matched neither `../Repo.git` nor the manifest's `Org/Repo`, and a
perfectly good working clone was reported as a clone of something else.

The fix is not to re-derive the arithmetic. Git HAS already resolved it, into
the holder's own `.git/config`, at the moment it initialized the submodule, and
that copy is read first: it is the url the mount actually uses, for the mount
that actually exists, and a second implementation of git's rule beside it is
precisely how a report and `make siblings` come to hold two opinions about one
url. `scripts/siblings.py::resolve_relative` does the arithmetic because it is
about to CLONE, with no initialized mount to read from; this row has one.
`submodule_config` is the shared reader for the two sources -- git's own
parser, never a `.gitmodules` text parser, since config syntax escapes a
backslash and a Windows path is stored `D:\\a\\...`.

A relative url git has NEVER resolved -- a member mounted by hand and never
initialized -- is still handed back as it is, and `working_clone` now declines
to accuse anybody on the strength of it: the answer falls back to the one this
row gave before the origin question existed. Telling somebody their clone is a
stranger, on a url the report admits it could not resolve, is worse than the
silence it used to keep.

CREDENTIALS IN A REPORTED URL (Codex P1, Copilot). Git permits
`https://x-access-token:<pat>@host/Org/Repo.git` as a remote and people do use
one; `--json` from this command is pasted into issues and kept as a CI
artifact. `redacted` (in `scripts/shape_materialize.py`, beside
`same_repository`) replaces the userinfo of a scheme-bearing url with `***`
before anything is stored in `detail` or printed -- the raw value is still what
`same_repository` compares, and the host and path a person needs in order to
see which repository it is both survive. The scp spelling `git@host:Org/Repo`
carries a user name and no secret, and is left legible.

A STRANGER ON THE RED PATH (Codex P2). `members_verdict` returns the finding
row before the green wording is composed, so a holder with one unbootstrapped
or off-pin mount said nothing at all about the directory beside it: the person
would fix the mount, re-run, and only then hear about a clone that had been the
wrong one all along. The sentence is now appended to the finding as well, after
the words "and, though it is not what fails this row" -- the pinned copies are
still the whole of what makes it red.

Tests, all beside the existing members-row ones: a credentialed origin is
redacted to `***` and the token appears nowhere in `--json` or the printed
report; a `../Repo.git` mount on a holder whose remote is a mirror, spelled
https in one parametrization and scp in the other and with the sibling spelled
the other way each time, is resolved through `git submodule sync` and counted
(the assertion on `mounted_from` is what fails without the fix); a relative url
with no resolved copy in the holder's config accuses nobody; and a wrong-origin
sibling beside a member that is off its pin is reported inside the FINDING row.

Suite: 1146 passed, 1 skipped (992 + 154, run in two chunks). No `--help` text
changed, so `docs/cli.md` is untouched; `tests/test_cli_reference.py` is green.

Lane: openreposhape-2 (openRepoShape-2)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 12, 2026 17:09

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

One critical and two moderate origin-matching issues remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (1)

shape-doctor.py:2167

  • resolved is preferred over the URL declared in .gitmodules, but siblings.py::clone_url uses the declaration first (and only resolves relative entries from it). If a holder's .gitmodules is updated without git submodule sync, its untracked .git/config can still contain the old URL; the doctor will then report a sibling cloned from the current declaration as other_origin, while make siblings would accept it. Please make the current .gitmodules entry authoritative, or otherwise verify the cached config still corresponds to it, and cover the stale-config case.
    declared = submodule_config(root, ["-f", str(root / ".gitmodules")])
    resolved = submodule_config(root, [])
    for name, mount in declared.items():
        # A submodule's NAME is its path unless somebody mounted it by hand
        # under another one, which git allows and this reads rather than
        # assumes.
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread scripts/shape_materialize.py Resolved
Comment thread shape-doctor.py Resolved
…metic against the holder's tracked remote, and a clone with no origin is never counted (#146)

The second review round on PR #147, and the first of the two findings undoes a
choice the first round made.

THE TRACKED DECLARATION IS AUTHORITATIVE, NOT THE CACHE. The previous commit
read the url git had already resolved into the holder's `.git/config`, to avoid
a second implementation of git's arithmetic sitting beside
`siblings.py::resolve_relative`. Copilot pointed out what that costs: the cache
is exactly that -- a `.gitmodules` edited without `git submodule sync` leaves
the old url in it -- and `make siblings` reads the DECLARATION. A report that
read the cache would come to accept a clone the tool refuses, or refuse one it
accepts, which is the disagreement this whole issue exists to remove.

So the arithmetic is written down instead, in the module that already holds
`same_repository` and under the same law: `join_remote`, `remote_is_a_path`,
`_up_one` and `resolved_remote` in `scripts/shape_materialize.py`, mirroring
`join_relative`, `base_is_a_path`, `_one_level_up` and `resolve_relative` --
one component dropped per `..`, one appended per name, a `..` too many
consuming nothing rather than eating a scheme or an scp host, and the
separator handed back in the base's own spelling so a Windows remote (which
has no `/` in it at all) is walked rather than appended to. The parity test
grows a second table: ten `(base, relative url)` pairs run through BOTH
implementations and asserted EQUAL AS STRINGS, because a url a person reads
off a report and a url a tool fetches from should not even be spelled
differently. `mounted_from` is now `.gitmodules` first and `family.yaml`'s
`repository:` second -- `clone_url`'s order exactly -- with the declaration
resolved against the holder's own `origin`.

AND AN UNANSWERABLE REFERENCE IS NOT AN UNANSWERABLE CLONE. The fallback that
declines to accuse anybody when the row's url cannot be resolved was accepting
a directory with NO readable origin as the working clone -- a dangling `.git`
file left by a copied submodule would have counted the moment a family mounted
a member with a relative url. It now requires an origin before it excuses one:
`verify_sibling` refuses that state too, and the row still calls it
`(no origin)`.

`sibling_origin` becomes `origin_url` and carries the `.git` guard itself: the
holder is asked the same question now -- its remote is what a relative url is
resolved against -- and `git remote get-url` in a directory with no repository
of its own walks UP to the nearest ancestor, which for `../<Project>` is often
the family's own workspace.

Tests: the relative-mount test (parametrized over a mirror remote spelled https
and spelled scp, sibling spelled the other way each time) now DELIBERATELY does
not run `git submodule sync`, so the holder's cached url stays stale and a row
reading it would fail the assertion; the no-remote case keeps its silence; and
a new test puts an origin-less directory beside a holder whose mount url is
relative and asserts it is still reported rather than counted.

Suite: 1147 passed, 1 skipped (992 + 155, in two chunks).

Lane: openreposhape-2 (openRepoShape-2)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openreposhape-2 (openRepoShape-2)

Round 2 answered in 107cce0, including the SUPPRESSED comment on shape-doctor.py:2167 (the resolved copy in .git/config vs the tracked .gitmodules declaration), which has no thread to reply on.

That one was right and it undoes a choice round 1 made. Reading git's cached resolution avoided a second implementation of git's arithmetic — but the cache is exactly that: a .gitmodules edited without git submodule sync leaves the old url in it, and make siblings reads the DECLARATION. A report reading the cache would come to accept a clone the tool refuses, or refuse one it accepts, which is the disagreement this issue exists to remove.

So the arithmetic is written down instead, in the module that already holds same_repository and under the same law: join_remote, remote_is_a_path, _up_one and resolved_remote mirror join_relative, base_is_a_path, _one_level_up and resolve_relative, and the parity test grows a SECOND table — ten (base, relative url) pairs through both implementations, asserted equal AS STRINGS (a Windows remote with no / in it, a .. too many, an scp base, a file:// base, a POSIX root). mounted_from is now .gitmodules first and repository: second, which is clone_url's order exactly, with the declaration resolved against the holder's own origin. The relative-mount test deliberately does NOT run git submodule sync, so the holder's cached url stays stale and a row reading it fails the assertion.

The other two: the origin-less fallback is fixed (reply on the thread), and the case-folding of path remotes is declined here and filed as #149 — it must change in BOTH copies of the rule at once, and siblings.py is digest-pinned.

Suite: 1147 passed, 1 skipped. gh pr diff 147 --name-only = scripts/shape_materialize.py, shape-doctor.py, tests/test_shape_doctor.py — no digest-pinned file.

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 the critical unresolved-relative-URL origin validation issue.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread shape-doctor.py Resolved
…g from the origin question, so the row answers exactly what `verify_sibling` answers (#146)

The third review round, and the finding is in a branch this PR invented rather
than in anything it inherited.

`working_clone` had a fallback: when the member's mount url was a relative
`../Repo.git` that could not be resolved -- a holder with no `origin` of its
own -- any non-empty sibling origin was accepted, on the reasoning that a row
should not accuse anybody on the strength of a url it admits it could not
resolve. That skipped the `repository:` comparison sitting immediately above
it, so a directory carrying the member's manifest and cloned from
`.../SomethingElse.git` was COUNTED as the working clone, while
`scripts/siblings.py::verify_sibling` reports that same directory as
`WRONG ORIGIN` whether or not the mount url resolved.

Which is the whole defect this issue is about, re-created one commit after it
was removed. So the branch is gone. An unresolved reference matches nothing,
`family.yaml`'s `repository:` -- the other reference `verify_sibling` accepts
-- is then the whole of the question, and that is exactly the state
`siblings.py` is in for the same holder. The row and the tool cannot disagree
about a directory again by this route.

The test that asserted the fallback now asserts the parity instead, in both
directions: with the mount url unresolvable, a clone from the repository the
row NAMES is counted on the manifest's spelling alone, and a clone from
somewhere else is reported. Its second half names a host this suite has never
used, because a developer's own `url.<base>.insteadOf` rewrites
`https://github.com/` on the way into `.git/config` -- the row would then
quote a spelling the test never wrote -- and it compares against the url git
itself reports rather than the string that was handed to `set-url`.

Suite: 1147 passed, 1 skipped (992 + 155, in two chunks).

Lane: openreposhape-2 (openRepoShape-2)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 12, 2026 18:06
@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

The reviewed changes are comprehensively tested and have no unresolved blocking issues.

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

@brettheap
brettheap merged commit 5c63116 into main Sep 12, 2026
6 checks passed
@brettheap
brettheap deleted the fix/doctor-member-origin-like-siblings branch September 12, 2026 18:33
brettheap added a commit that referenced this pull request Sep 12, 2026
…out of the ONE definition now, and the parity test that held two copies together is an identity assertion (#155)

`templates/family-root/scripts/siblings.py` keeps `resolve_relative` — the
half that reads the holder's own `origin`, which is the only part of this
that touches a machine — and imports the arithmetic from `repo_shape`, which
`family.py init` copies in beside it and `contracts/shape-pin.yaml` carries
with it. `shape-doctor.py` takes `same_repository`, `resolved_remote` and
`redacted` out of its EXISTING guarded `repo_shape` import and keeps
`lane_trailer_argument` in the `shape_materialize` one.
`scripts/shape_materialize.py` never called any of them — it held them for
the doctor while the pin could not move — so what is left there is a pointer
to where they went, for the next reader of #146 or #147, and no code.

Every message `make siblings` prints is byte-identical and so is every row
`shape-doctor.py` reports: the functions moved unchanged except for #149's
case rule, which the previous commit argues.

THE PARITY TEST WAS THE RIGHT INSTRUMENT FOR TWO COPIES AND THE WRONG ONE FOR
A RULE THAT SHOULD HAVE ONE. It ran 14 url pairs and 10 relative-url pairs
through both implementations and asserted they answered the same, which can
only ever say the two have not drifted YET — never that either is right. It
now asserts the doctor's name, the holder's name and `repo_shape`'s are the
SAME OBJECT, and then runs both tables against that one function with the
answer each row must get, including the rows #149 asks for: a host folds case
through every spelling, a filesystem path does not, and a path still matches
itself however it is spelled.

`tests/test_windows_paths.py` asks the holder's `join_remote` the Windows
questions it used to ask `join_relative` — so a holder that stopped importing
the shared rule fails there rather than quietly answering out of a second
copy — and asks `repo_shape.remote_is_a_path` the path-versus-scp-url
question directly.

PINNED FILES: `scripts/repo_shape.py` (previous commit) and
`templates/family-root/scripts/siblings.py`. Every project and every holder
reads `upstream-changed` for them in `update-shape.py check` until its estate
re-pins, which is the price #147 named and deferred and this change was told
to ride.

Lane: openreposhape-2 (openRepoShape-2)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
brettheap added a commit that referenced this pull request Sep 12, 2026
… in scripts/repo_shape.py, and #149's case rule lands with the move (#155) (#156)

* scripts/repo_shape.py holds the ONE definition of "do these two remote spellings name the same repository", and #149's case rule lands in it (#155)

The rule was written TWICE: `templates/family-root/scripts/siblings.py` is
what `make siblings` REFUSES a working clone by (`WRONG ORIGIN`) and
`scripts/shape_materialize.py` is what `shape-doctor.py`'s `members` row
REPORTS by (#146, #147). The second copy's own section comment says why it
was written and what ends it — `repo_shape.py` is the home a rule shared by
every tool belongs in, and the price is that it is digest-pinned, so every
estate reads `upstream-changed` for it until it re-pins. That price is owed
either way now, and #155 is the change that was told to ride it.

This commit only ADDS the section; the callers move onto it next, and the two
copies go with them. It is placed beside the other shared vocabulary this
module owns, because `checked_value` and `SAFE_PATH_RE` already draw the same
drive-letter-versus-scp-colon distinction for a value on a git command line.

ONE BEHAVIOUR CHANGES WITH THE MOVE, AND ONLY ONE (#149). `same_repository`
lowercased the WHOLE normalised remote. For a remote that names a HOST that
is right — GitHub treats an owner and a name case-insensitively, and a report
that called `https://GitHub.com/Org/Repo` and `https://github.com/org/repo`
two repositories would send somebody to delete a good clone over a
capitalisation. For a FILESYSTEM PATH it is wrong: `/srv/mirrors/IRRS.git`
and `/srv/mirrors/irrs.git` are two different bare repositories on a
case-sensitive host, and the estates that mount members from bare
repositories on disk are exactly the ones where a remote is a path. So
`_remote_names_a_host` asks that question once, and the case is folded only
for a host — `<scheme>://host/…`, git's scp `[user@]host:path`, and the bare
`Org/Repo` a `family.yaml` row is written as. Strict on every platform,
deliberately: Windows and macOS filesystems are case-INsensitive by default,
and a report that changed its answer with the machine it ran on would be
worse than one that is strict everywhere.

Proven against both copies over a corpus of 38 remote spellings and every
one of the 1444 ordered pairs: 12 pairs change answer, every one of them two
filesystem paths differing only in case, and `join_remote`, `resolved_remote`,
`remote_is_a_path` and `redacted` answer identically for every input.

Lane: openreposhape-2 (openRepoShape-2)

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* siblings.py and shape-doctor.py answer "is this the same repository" out of the ONE definition now, and the parity test that held two copies together is an identity assertion (#155)

`templates/family-root/scripts/siblings.py` keeps `resolve_relative` — the
half that reads the holder's own `origin`, which is the only part of this
that touches a machine — and imports the arithmetic from `repo_shape`, which
`family.py init` copies in beside it and `contracts/shape-pin.yaml` carries
with it. `shape-doctor.py` takes `same_repository`, `resolved_remote` and
`redacted` out of its EXISTING guarded `repo_shape` import and keeps
`lane_trailer_argument` in the `shape_materialize` one.
`scripts/shape_materialize.py` never called any of them — it held them for
the doctor while the pin could not move — so what is left there is a pointer
to where they went, for the next reader of #146 or #147, and no code.

Every message `make siblings` prints is byte-identical and so is every row
`shape-doctor.py` reports: the functions moved unchanged except for #149's
case rule, which the previous commit argues.

THE PARITY TEST WAS THE RIGHT INSTRUMENT FOR TWO COPIES AND THE WRONG ONE FOR
A RULE THAT SHOULD HAVE ONE. It ran 14 url pairs and 10 relative-url pairs
through both implementations and asserted they answered the same, which can
only ever say the two have not drifted YET — never that either is right. It
now asserts the doctor's name, the holder's name and `repo_shape`'s are the
SAME OBJECT, and then runs both tables against that one function with the
answer each row must get, including the rows #149 asks for: a host folds case
through every spelling, a filesystem path does not, and a path still matches
itself however it is spelled.

`tests/test_windows_paths.py` asks the holder's `join_remote` the Windows
questions it used to ask `join_relative` — so a holder that stopped importing
the shared rule fails there rather than quietly answering out of a second
copy — and asks `repo_shape.remote_is_a_path` the path-versus-scp-url
question directly.

PINNED FILES: `scripts/repo_shape.py` (previous commit) and
`templates/family-root/scripts/siblings.py`. Every project and every holder
reads `upstream-changed` for them in `update-shape.py check` until its estate
re-pins, which is the price #147 named and deferred and this change was told
to ride.

Lane: openreposhape-2 (openRepoShape-2)

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* A RELATIVE remote is a filesystem path too, and the trailing `owner/repo` fallback is a forge question, so a mirror clone is no longer called WRONG ORIGIN over a capitalisation (#155)

Both halves came out of the review on PR #156 (Copilot twice, Codex the first
one as a P1), and both are places where #149's rule as first written either
did not reach or reached too far.

A RELATIVE PATH IS A PATH. `_remote_names_a_host` called anything that was
not absolute and not a Windows drive a host, so `../mirrors/Fam.git` — which
is what `git remote get-url origin` answers in a holder cloned from a
relative local remote — was lowercased, and `../IRRS.git` and `../irrs.git`
were one repository again on a case-sensitive disk. That is the exact false
positive #149 is about, so `./` and `../` join the absolute path, the
`file://` url with an empty authority and the Windows drive in the path
branch, and `remote_is_a_path` — the separator half of the rule — has always
called them paths, so the two halves now agree about every spelling.

THE BARE TWO-SEGMENT FORM STAYS A FORGE NAME, deliberately and as the one
thing here that cannot be decided from the string: `mirrors/Fam.git` might be
a directory under wherever the process is standing, but `Org/Repo` is what
every manifest in this standard writes, and git requires the `./` of anybody
who means a path from somewhere. The docstring says so where the decision is.

THE TAIL IS A FORGE QUESTION UNLESS BOTH SIDES ARE PATHS. `same_repository`
falls back to the trailing `owner/repo` of the reference, and preserving the
case of a path broke that for a normal mirror layout: a clone whose origin is
`/srv/mirrors/InkRouter/IRRS.git` was matched against the row's bare
`InkRouter/IRRS`, which folds — so the suffix check failed and `make
siblings` would have reported the InkRouter estate's own layout as `WRONG
ORIGIN`. The tail now compares case-insensitively whenever either side names
a host or a forge repository, and strictly when both sides are paths, where
the filesystem is the only authority there is.

The rows for all three findings are in the table:
`../IRRS.git` != `../irrs.git`, `../mirrors/Repo.git` !=
`../mirrors/repo.git`, `/srv/mirrors/InkRouter/IRRS.git` ==
`InkRouter/IRRS` (and with the case swapped, and in either argument order,
and from a relative mirror), `/srv/mirrors/InkRouter/Other.git` !=
`InkRouter/IRRS` so the fold cannot make everything match, and
`/srv/mirrors/InkRouter/IRRS.git` != `/srv/mirrors/inkrouter/irrs.git`
because two paths compare strictly through the tail as well.

Re-proven against the copy on `main` over 45 remote spellings and all 2025
ordered pairs: 29 pairs differ, every one of them main=True head=False with
TWO FILESYSTEM PATHS on it, and every one of them answers True again when
both sides are lowercased — the case fold and nothing else. No pair gained a
True, and `join_remote`, `resolved_remote`, `remote_is_a_path` and `redacted`
answer identically to main for every input.

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

2 participants