Skip to content

same_repository compares two filesystem paths by EXACT equality, so /srv/a/IRRS.git and /other/a/IRRS.git stop being one repository, and the symlinked-prefix case moves to the two callers that own a disk (#157) - #160

Merged
brettheap merged 6 commits into
mainfrom
fix/same-repository-path-tail
Sep 13, 2026

Conversation

@brettheap

@brettheap brettheap commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

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

Closes #157.

The RULING this implements was recorded on the issue before a line of code was
written, because the choice #157 asks for is a ruling and not a refactor:
#157 (comment)

What was wrong

same_repository's trailing owner/repo fallback matched ANY two remotes
whose last two path components agreed, whatever stood in front of them, so two
bare repositories under different roots were one repository:

/srv/a/IRRS.git                  vs  /other/a/IRRS.git               -> True
/srv/mirrors/InkRouter/IRRS.git  vs  /elsewhere/InkRouter/IRRS.git   -> True

It reached templates/family-root/scripts/siblings.py::verify_sibling, which
FETCHES into a directory it accepts and dispatches make park / make resume
inside it, and shape-doctor.py's members row, which reported it as the
member's working clone. Copilot raised it on PR #156
(#156 (comment)) and
it was declined THERE on purpose: #155's law was that behaviour is
byte-identical apart from #149's case rule, and this answer was the same before
and after it.

What landed

1. scripts/repo_shape.py (DIGEST-PINNED). same_repository's tail
fallback is now a FORGE question and only a forge question: when BOTH sides are
filesystem paths the normalised keys must be EQUAL and no tail is tried.

The difference is not arbitrary. In a forge name the two trailing components
ARE the whole identity — Org/Repo is an owner and a repository, with nothing
in front of it to lose — while in a path everything in front of the tail is
part of the identity, and a fallback that drops it calls two bare repositories
under two roots one repository. "A path" is the four-way question
_remote_names_a_host already answers for #149 (absolute, file:// with an
empty authority, a Windows drive, or a relative ./ or ../), so a path still
matches its own file:// spelling, which is one key rather than a tail match.

Everything else answers exactly what it answered on main, deliberately:

  • a mirror or an ENTERPRISE HOST — https://github.com/Org/Repo.git versus
    https://gitlab.example/Org/Repo — is what the fallback was written for;
  • a PATH against the bare Org/Repo a family.yaml repository: row is
    written as, case-folded: /srv/mirrors/InkRouter/IRRS.git versus
    InkRouter/IRRS is the InkRouter estate's own layout, and dropping it would
    call every clone in a mirror-based estate WRONG ORIGIN. It is safe for the
    same reason the path case is not — a forge name has no prefix to throw away
    — and it stays case-insensitive because the row was typed by a human and is
    case-insensitive at the forge, which is the fault same_repository folds the case of a filesystem path, so two bare repositories on a case-sensitive host that differ only in case are called one repository #149 is against and not
    for.

2. The macOS prefix case moved to the CALLERS, which is where the disk is.
One directory reached through a symlink answers as /private/var/folders/…
through one path and /var/folders/… through the other, this suite's own
fixtures reach one through both, and the tail match is what made the doctor and
make siblings agree about it. Only a machine can say those are one directory,
and nothing in repo_shape.py may touch a disk — the promise that lets
tests/test_windows_paths.py ask the Windows questions from Linux. So:

  • repo_shape.py gains the PURE half, remote_local_path: which spelling
    names a path and what path it names, None for a host remote and None for
    a relative one, because ../mirrors/Fam.git handed to realpath would
    resolve against whatever directory the process is standing in — the trap
    resolve_relative exists to avoid;
  • templates/family-root/scripts/siblings.py (DIGEST-PINNED) and
    shape-doctor.py each gain same_repository_here, the same seven lines in
    both: it asks same_repository FIRST and the disk only when that has said
    no, so resolving a symlink can ADD an answer and never take one away. Only a
    path that os.path.isabs calls absolute on THIS platform and that exists
    here is resolved. verify_sibling and working_clone ask it for the MOUNT
    comparison; the row's repository: Org/Repo is asked of the origin exactly
    as git reported it, because a mirror may be a symlink onto a storage path
    whose own tail is a serial number and that row is matched BY its tail. The
    finding and the --json row still quote origin as git reported it too.

3. file:///D:/mirrors/Fam.git folds to the Windows path it names. That
spelling is the file url RFC 8089 blesses and git accepts, and taking file://
off it left /D:/mirrors/Fam.git — a leading / that belongs to the URL and
not to the path, and the one spelling of a Windows remote that did not fold to
D:\mirrors\Fam.git's key. _remote_body drops it, so _remote_names_a_host,
remote_key and remote_local_path all answer about the same path. Only a
url's own leading / comes off, though (Copilot, round 2): a remote with no
scheme never had one, and /D:/mirrors/IRRS.git written as a PATH is a
directory called D: under a POSIX root, not the Windows drive of the same
three characters.

The pinned-copy consequence, named as the brief requires. The two pinned
files touched are scripts/repo_shape.py and
templates/family-root/scripts/siblings.py. Every project and every family
holder reads upstream-changed for them in update-shape.py check until its
estate re-pins; the re-pin is the orchestrator's and is owed after this lands.

One documented behaviour that was not true before and is now. A
.gitmodules url spelled ../Repo.git on a holder with NO remote of its own
cannot be resolved, and mounted_from's docstring says it "then matches
nothing, and the row's answer rests on the repository: comparison alone".
Under the old fallback an unresolved relative url could still tail-match a path
origin by accident (../a/IRRS.git versus /srv/a/IRRS.git was True); it
now matches nothing, exactly as documented.

How it was proven

  • Differentially, against the copy on main at b83ba5c, by the method PR
    The two copies of "is this the same repository" become ONE definition in scripts/repo_shape.py, and #149's case rule lands with the move (#155) #156 used: both modules loaded side by side and asked every ordered pair of
    59 remote spellings — 3481 pairs. 74 differ, every one of them
    main=True head=False with TWO FILESYSTEM PATHS on it, and no pair gained
    a True
    : 72 are a tail match main made over unequal keys, and the other
    2 are /D:/remotes/Fam.git against file:///D:/remotes/Fam.git in both
    orders, which main folded to one key and this tells apart.
    remote_is_a_path, redacted, join_remote and resolved_remote answer
    identically to main for every input and every ordered pair; remote_key
    differs for exactly the three file:///<drive>:/ spellings and for nothing
    else.
  • tests/test_shape_doctor.py::test_the_doctor_and_siblings_run_ONE_definition_of_one_repository
    keeps every row it had and gains: the two pairs same_repository's trailing owner/repo fallback calls any two remotes that share their last two components one repository, so /srv/a/IRRS.git and /other/a/IRRS.git are the same clone #157 names, plus their
    file://, relative and Windows spellings (file:///srv/a/IRRS.git vs
    /other/a/IRRS.git, ../a/IRRS.git vs ../../other/a/IRRS.git,
    D:\a\IRRS.git vs D:\other\a\IRRS.git), all False; and the rows same_repository's trailing owner/repo fallback calls any two remotes that share their last two components one repository, so /srv/a/IRRS.git and /other/a/IRRS.git are the same clone #157
    deliberately leaves alone — https://github.com/Org/Repo.git vs
    https://gitlab.example/Org/Repo and [email protected]:Org/Repo.git vs
    https://forge.example/Org/Repo.git, both True; and the Windows file url
    (file:///D:/mirrors/IRRS.git == D:\mirrors\IRRS.git, ==
    D:/mirrors/IRRS.git, != D:\mirrors\Other.git) with the raw POSIX path
    beside it (/D:/mirrors/IRRS.git is neither of those). The identity
    assertions now cover remote_local_path in both tools as well.
  • tests/test_shape_doctor.py::test_a_symlinked_prefix_is_ONE_directory_to_both_callers
    is the prefix case, built from a REAL symlinked directory so it runs on every
    platform that can make one rather than only on the macOS runner: the pure
    rule answers False for the two spellings, both callers' same_repository_here
    answer True in either order and through the file:// spelling, and every
    pair that does not need a disk — a host remote, a relative one, a path that
    is not here, two directories that really are two, the empty string — answers
    exactly what same_repository answers.
  • tests/test_shape_doctor.py::test_working_clone_and_verify_sibling_ACCEPT_a_symlinked_mirror
    is the END-TO-END test of the two callers themselves (Copilot, round 1), over
    a real clone whose origin is spelled through a real symlink and over the
    two shapes a symlink makes: a mirror reached through a symlinked PREFIX,
    which only the resolved comparison can accept, and a mirror that IS a symlink
    onto a storage path, which only the unresolved repository: fallback can
    accept. Both callers must accept both and must still refuse a stranger's
    clone at the same path. Mutation-checked: with the disk half removed both
    cases fail, and with the repository: fallback asked of a resolved origin
    the second fails.
  • macOS in CI is the proof for the estate, as same_repository's trailing owner/repo fallback calls any two remotes that share their last two components one repository, so /srv/a/IRRS.git and /other/a/IRRS.git are the same clone #157 asks: the suite's family
    fixtures mount members from bare repositories in a temporary directory, which
    is exactly the /private/var/folders/… versus /var/folders/… pair.
  • Whole suite, bounded chunks, from the worktree on Eagle, ON THE MERGED TREE:
    1191 passed, 1 skipped, 0 failed (tests/test_[a-m]*.py +
    tests/test_[n-r]*.py 725 passed 1 skipped, tests/test_[s-z]*.py 466
    passed). No tool's --help changed, so docs/cli.md is untouched.
  • origin/main is MERGED in at 1f82b42, not rebased onto — the branch is
    pushed and the ruleset refuses a force-push. The doctor's behind-pin row, apply's README phase order and the classifier's untested decode arm: PR #152's last three Copilot findings, taken (#158) #159 (ba14e1d) moved
    shape-doctor.py's behind-pin clause into what_a_re_pin_would_move and
    appended a test to tests/test_shape_doctor.py, where this branch adds
    same_repository_here beside working_clone and rows plus two tests; the
    hunks do not touch each other, git merged them clean, and both sides' tests
    run in the count above.
  • Green on ubuntu, windows and macos in CI at db73236 before the review round,
    with SonarCloud's PR-scoped query returning 0 open issues.

The review

Round 1: Copilot twice (one moderate on repo_shape.py, one moderate
suppressed on both callers, one test-coverage nit) and Codex once as a P2. All
four taken in c3a0b4d and answered on their threads; they are what produced
same_repository_here's "string rule first, disk only if it says no" shape,
the isabs guard, the file:///D:/ fold and the end-to-end test.

Round 2: Copilot, one finding — the drive fold was applied to every body
beginning /<drive>: rather than only to one a scheme had just come off.
Taken in 8a7c042 with the two regression rows it asked for, and its suppressed
note about the proof is answered: the body was corrected with c3a0b4d and the
numbers above are the current ones.

🤖 Generated with Claude Code

Summary by Sourcery

Correct repository identity handling so filesystem paths require exact normalized equality while callers can recognize equivalent symlinked directories on the local machine.

Bug Fixes:

  • Prevent filesystem paths with matching trailing owner/repository components from being incorrectly treated as the same repository.
  • Preserve repository matching for forge names and forge-name-to-mirror comparisons while separating filesystem identity from forge identity.
  • Support equivalent Windows file URL and drive-path spellings, including file:///D:/... URLs.

Enhancements:

  • Move symlink-aware repository comparison into the filesystem-owning sibling and doctor callers while keeping the shared repository comparison pure and disk-independent.
  • Add path extraction support for absolute local remotes and ensure unresolved relative remotes are not accidentally matched by path suffix.

Tests:

  • Expand repository identity coverage for distinct filesystem roots, forge mirrors, Windows paths and file URLs.
  • Add symlink-based tests covering both shared comparison helpers and end-to-end sibling and working-clone validation.

…srv/a/IRRS.git and /other/a/IRRS.git stop being one repository, and the symlinked-prefix case moves to the two callers that own a disk (#157)

The trailing `owner/repo` fallback matched ANY two remotes whose last two
path components agreed, whatever stood in front of them, so two bare
repositories under different roots were one repository. It reached
`templates/family-root/scripts/siblings.py::verify_sibling`, which FETCHES
into a directory it accepts and dispatches `make park`/`make resume` inside
it, and `shape-doctor.py`'s `members` row, which reported it as the member's
working clone. Copilot raised it on PR #156 and it was declined there on
purpose: #155's law was that behaviour is byte-identical apart from #149's
case rule, and this answer was the same before and after it.

THE RULING, recorded on the issue before this was written
(#157 (comment)):
shape 2, exact equality when both sides are paths.

  * The tail is a FORGE question and only a forge question. In a forge name
    the two trailing components ARE the whole identity -- `Org/Repo` is an
    owner and a repository with nothing in front of it to lose -- while in a
    path everything in front of the tail is part of the identity. So a host
    against a host, a path against a host, and a path against the bare
    `Org/Repo` a `family.yaml` row is written as all answer exactly what they
    answered before; two paths must now be the SAME path.
  * `/srv/mirrors/InkRouter/IRRS.git` is still matched against the row's bare
    `InkRouter/IRRS`, case-folded. Dropping that would call every clone in a
    mirror-based estate `WRONG ORIGIN` -- the InkRouter estate's own layout
    -- and it is safe for the same reason the path case is not: a forge name
    has no prefix to throw away.
  * ONE DIRECTORY REACHED THROUGH A SYMLINK is `/var/folders/...` through one
    path and `/private/var/folders/...` through the other on macOS, which is
    how this suite's own fixtures reach one, and the tail match is what made
    the doctor and `make siblings` agree about it. Only a machine can answer
    that, and `scripts/repo_shape.py` may not touch a disk -- the promise
    that lets `tests/test_windows_paths.py` ask the Windows questions from
    Linux. So the module gains the PURE half, `remote_local_path` (which
    spelling names a path, and what path it names, None for a host remote and
    None for a relative one that `realpath` would resolve against wherever
    the process is standing), and `siblings.py::local_spelling` and
    `shape-doctor.py::local_spelling` are the three lines of
    `os.path.realpath` on the side that has the disk.

Proven against the copy on `main` at b83ba5c over every ordered pair of 54
remote spellings: 62 of 2916 differ, every one of them `main=True
head=False` with TWO FILESYSTEM PATHS on it, none gained a True, and
`remote_key`, `remote_is_a_path`, `redacted`, `join_remote` and
`resolved_remote` answer identically to `main` for every input.

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 13, 2026 03:04
@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 1 day and 14 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Sep 13, 2026

Copy link
Copy Markdown

Reviewer's Guide

Changes repository identity semantics so two filesystem remotes match only when their normalized paths are equal, while retaining forge-based fallback matching. Symlink equivalence is intentionally resolved only by shape-doctor and siblings, which own the relevant disk, with shared pure path classification and regression tests covering both behaviors.

Sequence diagram for disk-aware symlink comparison

sequenceDiagram
    participant Caller as ShapeDoctorOrSiblings
    participant Pure as repo_shape
    participant Disk as LocalFilesystem
    participant Identity as same_repository
    Caller->>Pure: remote_local_path(origin)
    Caller->>Pure: remote_local_path(mount)
    Pure-->>Caller: Absolute paths or None
    Caller->>Disk: os.path.exists(path)
    Disk-->>Caller: Path exists
    Caller->>Disk: os.path.realpath(path)
    Disk-->>Caller: Symlink-resolved spelling
    Caller->>Identity: same_repository(resolved_origin, resolved_mount)
    Identity-->>Caller: Compare normalized path keys
Loading

Flow diagram for repository identity comparison

flowchart TD
    A["same_repository(one, two)"] --> B["remote_key(one) == remote_key(two)"]
    B -->|yes| C["True"]
    B -->|no| D{"Both remotes are filesystem paths?"}
    D -->|yes| E["False"]
    D -->|no| F["Compare trailing owner/repo case-insensitively"]
    F --> G["Forge or path-to-forge match result"]
Loading

File-Level Changes

Change Details Files
Restrict repository tail matching so filesystem paths require exact normalized-key equality while preserving forge and path-to-forge matching behavior.
  • Return false for unequal path-vs-path keys before applying the owner/repository suffix fallback.
  • Keep case-insensitive suffix matching when at least one remote is a forge name or host remote.
  • Add a pure helper that identifies absolute and file-URL filesystem spellings without resolving paths or touching disk.
scripts/repo_shape.py
Move symlink-aware filesystem identity handling into the two disk-owning callers.
  • Add caller-local spelling helpers that apply realpath only to existing absolute local paths.
  • Normalize both origin and mount paths before sibling and working-clone comparisons.
  • Preserve original Git origin spellings in findings and JSON output.
templates/family-root/scripts/siblings.py
shape-doctor.py
Expand regression coverage for path identity boundaries and caller-level symlink resolution.
  • Assert distinct filesystem roots no longer match, including file-URL and Windows spellings, while forge cases remain unchanged.
  • Verify both tools share the pure helper and agree on a real symlinked directory.
  • Verify host, forge, relative, nonexistent, and empty remotes remain untouched by local resolution.
tests/test_shape_doctor.py

Assessment against linked issues

Issue Objective Addressed Explanation
#157 Prevent same_repository from treating unrelated filesystem paths with the same trailing owner/repo components as the same repository. ✅
#157 Preserve the existing forge-name and path-versus-forge fallback behavior, including matching mirror paths against bare repository references and matching repositories across different forge hosts. ✅
#157 Preserve recognition of one physical repository reached through different filesystem prefixes, such as macOS symlinked paths, in both siblings verification and shape-doctor reporting. ✅

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 findings and one test-coverage nit remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR prevents distinct filesystem paths from being treated as the same repository while preserving forge matching and handling symlinked local paths.

Changes:

  • Restricts filesystem comparisons to exact normalized paths.
  • Adds caller-side local path resolution for sibling and doctor checks.
  • Expands path, URL, Windows, and symlink test coverage.
File summaries
File Changes Findings
tests/test_shape_doctor.py Adds repository identity and symlink tests. Nit (3 votes): Does not exercise working_clone or verify_sibling end to end.
templates/family-root/scripts/siblings.py Resolves local paths before sibling verification. Moderate (1 vote): Gate inspection with os.path.isabs() to avoid treating Windows paths as relative on POSIX.
shape-doctor.py Resolves local paths before working-clone comparison. Moderate (1 vote): Gate inspection with os.path.isabs() to avoid treating Windows paths as relative on POSIX.
scripts/repo_shape.py Adds pure local-path extraction and exact filesystem identity matching. Moderate (2 votes): Normalize Windows file:///D:/... URLs and add regression coverage.
Review details

Suppressed comments (2)

shape-doctor.py:2275

  • remote_local_path deliberately returns Windows drive spellings even when the pure rule is exercised on POSIX, but on POSIX os.path.exists('D:/...') treats that value as a relative path. If the current directory contains a matching D: tree, this can resolve an unrelated local path and change the report; gate this with os.path.isabs(path) so only paths absolute for the running platform are inspected.
    if path and os.path.exists(path):

templates/family-root/scripts/siblings.py:245

  • remote_local_path deliberately returns Windows drive spellings even when the pure rule is exercised on POSIX, but on POSIX os.path.exists('D:/...') treats that value as a relative path. If the current directory contains a matching D: tree, this can resolve an unrelated local path and change the origin decision; gate this with os.path.isabs(path) so only paths absolute for the running platform are inspected.
    if path and os.path.exists(path):
  • Files reviewed: 4/4 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 scripts/repo_shape.py Resolved
Comment thread tests/test_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: db7323669b

ℹ️ 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".

# `repository:` is a bare `Org/Repo` and names no directory to resolve.
here, mount = local_spelling(origin), local_spelling(url)
if not same_repository(here, mount) and not (
repository and same_repository(here, repository)):

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 Preserve the original path for the repository fallback

When an existing member clone uses a symlinked mirror whose target has a different tail—for example, /mirrors/InkRouter/IRRS.git points to /storage/uuid-123.git—local_spelling(origin) removes the InkRouter/IRRS identity before this manifest fallback runs. The previous comparison accepted that clone through the row's repository: InkRouter/IRRS, but this now marks it WRONG ORIGIN; make siblings, park/resume dispatch, and the doctor consequently skip or omit a valid working clone. Use the canonicalized value only for the path-to-path comparison and retain the original origin for the repository-name fallback.

AGENTS.md reference: AGENTS.md:L383-L387

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 c3a0b4d — this was real, and it is the finding that changed the shape of the fix.

A mirror is allowed to BE a symlink onto a storage path whose own tail is a serial number, and the row's repository: InkRouter/IRRS is matched BY the origin's tail, so resolving the origin before that fallback threw the name away and called a good clone WRONG ORIGIN.

Rather than resolve one side and not the other, the two callers now hold ONE function, same_repository_here, which asks repo_shape.same_repository FIRST and the disk only when it has said no. Resolution can therefore only ADD an answer and never take one away, which is the property that makes it safe to apply at all. The repository: comparison beside it is asked of the origin exactly as git reported it — which is also the spelling the WRONG ORIGIN finding quotes back to the human.

tests/test_shape_doctor.py::test_working_clone_and_verify_sibling_ACCEPT_a_symlinked_mirror is your scenario, built: <tmp>/B/mirrors/InkRouter/IRRS.git is a symlink onto <tmp>/B/storage/uuid-123.git, the mount names a path that is not on the disk at all, and both working_clone and verify_sibling must still accept the clone through the row. Mutation-checked: asking that fallback with a resolved origin fails exactly that case.

…er that asks the STRING rule first, so resolving a symlink can add an answer and never take one away, and `file:///D:/mirrors/Fam.git` folds to the Windows path it names (#157)

Three findings from the first review round, all taken.

CODEX (P2, `siblings.py`): a mirror is allowed to BE a symlink onto a storage
path whose own tail is a serial number -- `/mirrors/InkRouter/IRRS.git` ->
`/storage/uuid-123.git` -- and the row's `repository: InkRouter/IRRS` is
matched BY the origin's tail. Resolving the origin before that fallback threw
the name away and called a good clone `WRONG ORIGIN`. The two callers now
hold ONE function, `same_repository_here`, which asks `same_repository` first
and the disk only when it has said no; the `repository:` comparison beside it
is asked of the origin exactly as git reported it. Resolution can therefore
only ADD an answer, which is the property that makes it safe to apply at all.

COPILOT (moderate, both callers): on POSIX `os.path.exists("D:/mirrors/x.git")`
asks about a directory named `D:` under whatever the process is standing in,
so a `realpath` there could resolve an unrelated local path. Only a path that
`os.path.isabs` calls absolute ON THIS PLATFORM is inspected now.

COPILOT (moderate, `repo_shape.py`): `file:///D:/mirrors/Fam.git` is the file
url RFC 8089 blesses and git accepts, and stripping `file://` left
`/D:/mirrors/Fam.git` -- a leading `/` that belongs to the url, not to the
path. It was the one spelling of a Windows remote that did not fold to
`D:\mirrors\Fam.git`'s key. `_remote_body` drops it, so every question below
it -- `_remote_names_a_host`, `remote_key`, `remote_local_path` -- answers
about the same path, and `same_repository`'s answer for every pair is
unchanged (`main` reached the same True through the tail).

COPILOT (nit, tests): the regression test called the helper and never the
callers. `test_working_clone_and_verify_sibling_ACCEPT_a_symlinked_mirror`
drives `shape-doctor.py::working_clone` and
`siblings.py::verify_sibling` over both shapes a symlink makes -- a mirror
reached through a symlinked PREFIX, which only the disk can accept, and a
mirror that IS a symlink onto a storage path, which only the unresolved
`repository:` fallback can accept -- and asserts both callers refuse a
stranger at the same path. Mutation-checked: with the disk half removed both
cases fail, and with the `repository:` fallback asked of a resolved origin
the second one fails.

Differentially against `main` at b83ba5c over every ordered pair of 59 remote
spellings: 66 of 3481 differ, every one `main=True head=False` with TWO
FILESYSTEM PATHS on it, none gained a True. `remote_key` differs for exactly
the four empty-authority-drive spellings and for nothing else;
`remote_is_a_path`, `redacted`, `join_remote` and `resolved_remote` are
identical for every input.

Lane: openreposhape-2 (openRepoShape-2)

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

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

Drive-prefix normalization can conflate distinct filesystem paths, and the documented parity claim also needs correction.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (1)

scripts/repo_shape.py:1804

  • The PR description says the differential found only path/path answer changes and that remote_key is identical to main for every input. This hunk changes _remote_body for file:///D:/..., so remote_key now returns D:/... instead of the old /D:/... for those spellings; same_repository may still return the same boolean via its fallback, but the claimed pure-function parity is not true. Please update the proof/description to account for this additional behavior change.
    if text[:1] == "/" and REMOTE_DRIVE_RE.match(text[1:3]):
        text = text[1:]                  # file:///D:/mirrors/Fam.git
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread scripts/repo_shape.py Resolved
brettheap and others added 2 commits September 12, 2026 23:53
…ows drive, so a POSIX directory called `D:` stays the path it is rather than folding into the drive of the same three characters (#157)

Copilot, round 2: the normalisation `_remote_body` gained for
`file:///D:/mirrors/Fam.git` was applied to EVERY body that began `/<drive>:`,
not only to one a scheme had just been taken off. `/D:/mirrors/IRRS.git`
written as a path is a directory called `D:` under a POSIX root -- absurd, and
somebody's -- and folding it into the Windows drive `D:/mirrors/IRRS.git`
would have reported two paths that no single machine could even both hold as
one repository.

The `/` that comes off is the URL's, so it comes off only when there was a
scheme to leave it behind. Two rows say so: `/D:/mirrors/IRRS.git` is neither
`D:/mirrors/IRRS.git` nor `file:///D:/mirrors/IRRS.git`.

The differential against `main` at b83ba5c over every ordered pair of 59
spellings now reads: 74 of 3481 differ, every one `main=True head=False` with
TWO FILESYSTEM PATHS on it, 72 of them a TAIL match `main` made over unequal
keys and the other 2 the `/D:/` versus `file:///D:/` pair in both orders,
which `main` called equal keys. No pair gained a True. `remote_key` differs
for exactly the three `file:///<drive>:/` spellings and for nothing else;
`remote_is_a_path`, `redacted`, `join_remote` and `resolved_remote` are
identical for every input.

Lane: openreposhape-2 (openRepoShape-2)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
… template) into fix/same-repository-path-tail

CLEAN, AND BOTH SIDES OF THE TWO FILES THAT OVERLAP ARE KEPT. `#159` (ba14e1d)
moved `shape-doctor.py`'s behind-pin clause into `what_a_re_pin_would_move`
and appended a test to `tests/test_shape_doctor.py`; this branch adds
`same_repository_here` beside `working_clone` in the same file and rows plus
two tests to the same suite. The hunks do not touch each other, so git merged
them and every test from both sides runs below.

Merged rather than rebased: the branch is pushed and the repository ruleset
refuses a force-push.

Lane: openreposhape-2 (openRepoShape-2)

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

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

Correct the Windows drive-letter test to construct file:///C:/... and cover the intended normalization.

Get a fresh assessment by requesting another Copilot review.

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

Comment thread tests/test_shape_doctor.py Resolved
…actually exercises the `file:///C:/...` fold it claims to, and `_remote_body` asks `startswith` rather than a slice (#157)

Copilot, round 3, and it is right about what the assertion was worth on
Windows: `"file://" + through_link` builds `file:///tmp/...` on POSIX and
`file://C:/...` on Windows -- a url with `C:` for an AUTHORITY, which is not
the empty-authority spelling 8a7c042's fold is about. That body reaches
`_remote_body` with no leading slash at all, so it took the other road
through the same function and the assertion passed on `windows-latest`
without exercising the line it exists for.

The url is built as `"file:///" + <path with any leading slash stripped>` now,
which is `file:///tmp/...` on POSIX and `file:///C:/Users/...` on Windows --
both the empty-authority form -- and the test asserts the three slashes are
there before it asks the question, so a future edit to that expression fails
here rather than quietly stopping covering anything.

And SonarCloud's python:S6659 on the PR (MINOR, `scripts/repo_shape.py`): the
scheme guard asks `text.startswith("/")` rather than slicing one character
off it. Same answer, one open issue fewer, and the PR-scoped query is clean
again.

Lane: openreposhape-2 (openRepoShape-2)

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

🔵 Needs a closer look

The two moderate findings require Windows directory symlink creation to pass target_is_directory=True.

Review details

Suppressed comments (2)

tests/test_shape_doctor.py:1851

  • On Windows, os.symlink defaults target_is_directory=False, but this source is a directory. The test can therefore create a file symlink (or fail when traversing link/remotes) instead of exercising the path comparison; pass target_is_directory=True (which is ignored on POSIX).
        os.symlink(tmp_path / "private", link)

tests/test_shape_doctor.py:1934

  • Both symlink targets here are directories, but Windows needs target_is_directory=True when creating directory symlinks. Without it, this end-to-end regression can fail on Windows after the symlink call or cannot traverse the created link, so it does not provide the claimed cross-platform coverage.
        os.symlink(prefix, tmp_path / "A-link")
        os.symlink(serial / "storage" / "uuid-123.git",
                   serial / "mirrors" / FAMILY_NAME / f"{FAMILY_MEMBER}.git")
  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

…s too, which is the only kind either fixture can be walked through (#157)

Copilot, round 4 (two suppressed findings, both real). `os.symlink` defaults
`target_is_directory=False`, and on Windows that writes a FILE symlink: a
mirror tree reached as `link/remotes/IRRS.git` and a bare repository reached
as `mirrors/InkRouter/IRRS.git` are then not reachable at all, so a runner
that HAS the privilege would fail these tests rather than ask their question.
The argument is ignored on POSIX, where a symlink is a symlink, so this costs
the two legs that run today nothing.

Today both tests SKIP on `windows-latest` -- creating one needs Developer Mode
or an elevated shell, and the skip says so -- which is why this has never
shown. It is still what the tests claim, and a claim that is only true on two
of three platforms is the thing this repository's suite is not allowed to
make.

Lane: openreposhape-2 (openRepoShape-2)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 13, 2026 07:01
@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openreposhape-2 (openRepoShape-2)

Copilot's latest round raised two findings as SUPPRESSED comments (no inline threads to reply on), so the answer is here: both taken, in b731d96.

os.symlink defaults target_is_directory=False, and on Windows that writes a FILE symlink — a mirror tree reached as link/remotes/IRRS.git and a bare repository reached as mirrors/InkRouter/IRRS.git are then not reachable at all. All three symlinks in the two tests now pass target_is_directory=True, which is ignored on POSIX.

Worth recording what the state actually was: both tests SKIP on windows-latest today, because creating a symlink there needs Developer Mode or an elevated shell and the except OSError arm says so. So this was never a false green — it was a claim that would have turned RED on the day a runner gained the privilege. It is still what the tests claim, and this suite does not get to make a claim that holds on two platforms out of three.

Suite on the merged tree after the change: 1191 passed, 1 skipped, 0 failed.

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

🟡 Changes recommended

Fix the critical Windows file-URL normalization defect before approval.

Get a fresh assessment by requesting another Copilot review.

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

Comment thread scripts/repo_shape.py
Comment on lines +1811 to +1813
if text != stripped and text.startswith("/") and REMOTE_DRIVE_RE.match(
text[1:3]):
text = text[1:] # file:///D:/mirrors/Fam.git

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)

Declined — this one does not reproduce, and the row at tests/test_shape_doctor.py:1750 is green on all three platforms at b731d96.

The step the reading skips is remote_key's scp-colon replacement, which happens AFTER _remote_body and only when the first component carries a colon. Asked of the head of this branch:

_remote_body('/D:/mirrors/IRRS.git')          = '/D:/mirrors/IRRS.git'
_remote_body('file:///D:/mirrors/IRRS.git')   = 'D:/mirrors/IRRS.git'
remote_key('/D:/mirrors/IRRS.git')            = 'D:/mirrors/IRRS'
remote_key('file:///D:/mirrors/IRRS.git')     = 'D//mirrors/IRRS'
same_repository(one, two)                     = False

For the URL form the fold leaves D:/…, whose first component IS D:, so remote_key turns that one colon into a / — the same arithmetic that has always given D:\\mirrors\\IRRS.git the key D//mirrors/IRRS, which is exactly why the url and the backslash spelling are one repository. For the raw POSIX path the first component is EMPTY (the string starts with /), no colon is replaced, and .strip("/") leaves D:/mirrors/IRRS with its colon intact. Two different keys, and the discriminator you ask for is the colon itself.

tests/test_shape_doctor.py::test_the_doctor_and_siblings_run_ONE_definition_of_one_repository asserts both rows (/D:/mirrors/IRRS.git is neither D:/mirrors/IRRS.git nor file:///D:/mirrors/IRRS.git, while file:///D:/mirrors/IRRS.git is still D:\\mirrors\\IRRS.git) and passes; a False row that answered True would fail there rather than be believed. No code change.

@brettheap
brettheap merged commit 71cf5de into main Sep 13, 2026
6 checks passed
@brettheap
brettheap deleted the fix/same-repository-path-tail branch September 13, 2026 07:32
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