Repository navigation
A configured entry may not share a clone under another remote - #1548
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
zlareb1
left a comment
There was a problem hiding this comment.
Two spellings of one clone path still let different remotes share that clone.
zlareb1
left a comment
There was a problem hiding this comment.
The relative-path collision is fixed and all five clone configuration tests passed. The same directory can still be assigned to different case-sensitive remotes.
34f2f55 to
046dd75
Compare
|
Fixed in 046dd75 (rebased on main): |
zlareb1
left a comment
There was a problem hiding this comment.
The case-sensitive path and clone-path spelling regressions are fixed. The configuration probe still accepts two distinct SSH remotes for the same clone.
|
Thanks for the review. Converting to draft while I address it; a new head and the replies will follow, so no need to look at this head again. |
zlareb1
left a comment
There was a problem hiding this comment.
The two SCP forms now differ. The SSH URL form still aliases the home-relative form.
|
Thanks, I've seen the new comments. Back to draft while I address them; a new head and the replies will follow. |
zlareb1
left a comment
There was a problem hiding this comment.
The absolute SSH path test passes. The clone guard still accepts distinct home-relative remotes when their SSH users differ.
zlareb1
left a comment
There was a problem hiding this comment.
The two-user home-relative SSH regression passes. The clone guard still treats different SSH endpoints on a custom host as one repository.
zlareb1
left a comment
There was a problem hiding this comment.
The code.read fixture passes valid ranges where the test expects a rejection. The same assertion fails on clean main without the clone guard changes. PR shard · Main shard · Existing repair
|
The |
zlareb1
left a comment
There was a problem hiding this comment.
The previous SSH port pair now yields distinct keys. The guard still accepts two default-port web endpoints on one clone.
|
I think it's somewhat wrong to treat Git repositories on the same URL as different, depending on the http or https flag. I also think it was wrong to make the SSH vs HTTP(s) treating them differently, but it's done already. I'm somewhat unwilling to keep this running onwards, unless this is the confirmed Product Management decision. I've invested a lot in the PR set, so I will do the extra step to complete it. Yet I wouldn't treat them different from PM perspective. |
|
@KaloyanNaumov what do you mean? I think this is a really edge scenario |
I agree this is an edge case. The fork and upstream sharing a clone is worth fixing. I'd drop the changes to When two entries resolve to the same |
|
The MCP integration job expects a retry example for a request that supplies its organization. Clean |
zlareb1
left a comment
There was a problem hiding this comment.
The two unit failures also reproduce on the exact clean base. The range fixture sends line pairs that code.read now accepts, and the tunable-constant check flags the fixed documentation cap. Both checks pass on current main after the fixes in #1634. Range job · Cap job · Passing main CI
A derived clone dir names the repository alone, so a fork and its upstream resolve to one bare clone and each fetch moves the other's branch refs. When two LOOM_CODE_REPOS_JSON entries resolve to the same git_dir, the parser compares their git_remote values after the defaults and skips the later entry if they differ, with a git_dir configuration error that names the holder and says to use one spelling of the remote or set a separate git_dir. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
A relative git_dir and its absolute path, or a symlink to a held clone, are one bare clone; compared as written, two remotes could still fetch into it. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
c063229 to
cd1401e
Compare
Done in cd1401e, as you proposed. |
zlareb1
left a comment
There was a problem hiding this comment.
Comparing the final remote strings fixes the earlier endpoint cases. The clone guard still admits different remotes for one directory on a case-insensitive volume.
`_clone_taken` keyed its holders by `realpath(git_dir)`, which keeps the spelling it is given. On a case-insensitive volume `Widget.git` and `widget.git` are one directory under two keys, so two entries with different remotes both loaded and their fetches moved the same refs. Each entry is now held under its canonical path and, once `git_dir` exists, also under its `(st_dev, st_ino)`; it collides with a holder when either key is held. Keying by identity alone would let a directory that does not exist yet (`missing/../widgets.git`) and an existing `widgets.git` slip past each other, as a path key and an identity key never compare. The cost is one `realpath` per entry plus one `os.stat` while the directory exists, no walk over the held clones. A stat that raises OSError (directory missing, or removed while the config is parsed) leaves the path key alone. An entry with the held remote still shares the clone; one with another remote is skipped with the `git_dir` error. Two entries naming a directory that is not created yet, with spellings that differ in case, are still told apart until the first clone creates it. `known_repo_count` no longer says it does no I/O. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
zlareb1
left a comment
There was a problem hiding this comment.
The inode check catches the earlier case once the clone directory exists. The same entries still pass validation on a fresh volume before either clone has been created.
There was a problem hiding this comment.
The format and unit jobs reproduce the adoption formatting and docstring cap failures from clean main. Both checks pass with the tracked repair. Format job · Unit job · Repair #1706
Two entries whose git_dir differ only in the case of the last component passed validation on a fresh volume, because no directory existed yet to compare by identity. Hold each clone dir under its canonical path with the last component lowercased as well, so they collide with the existing error. On a case-sensitive host this also refuses two distinct directories spelled Widget.git and widget.git with different remotes; the error says to set a separate git_dir. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
|
You're right: on a fresh volume neither directory exists, so the inode key has nothing to compare. The clone dir is now also held under its canonical path with the last component lowercased, so |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit c97ad5e. Configure here.
zlareb1
left a comment
There was a problem hiding this comment.
The clone guard still accepts fresh aliases when a parent directory differs in case. I also verified the case-sensitive volume finding. The same comparison rejects two distinct destinations there.
zlareb1
left a comment
There was a problem hiding this comment.
The tunable-constant check flags _COVERAGE_ROWS and DOCSTRING_MAX_LINES on this head and on clean main. The same test passes with both repairs applied. PR job · Coverage repair #1722 · Docstring repair #1706
… limit The lowercased last component made two clone paths that differ only in case collide, which also refused two distinct directories on a case-sensitive volume. A clone dir is held under its canonical path and, once it exists, under its (st_dev, st_ino), so case-sensitive volumes accept both spellings and a case-insensitive volume is caught as soon as the directory exists. Before the first clone, two spellings of one path on a case-insensitive volume still pass. The operations guide names this and asks for clone paths that differ by more than capitalization. The test creates both directories and asserts both entries load; it is skipped on a case-insensitive volume. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
zlareb1
left a comment
There was a problem hiding this comment.
The fork and upstream no longer share the derived clone path. I checked recovery of existing case aliases on a case-insensitive volume and ran the clone-collision suite. Eight tests passed and the case-sensitive-only case was skipped. The operator guide records the bootstrap limitation before a directory exists.

Closes: #1536
TL;DR: A fork and its upstream configured as two entries shared one clone directory, so one namespace indexed the other's commits. When two entries resolve to the same
git_dir, the parser now compares theirgit_remotevalues after the defaults and skips the later entry if they differ, with agit_dirconfiguration error naming the holder.Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
An entry in
LOOM_CODE_REPOS_JSONwhosegit_diran earlier entry holds with a differentgit_remote(a fork beside its upstream, or the same repository under a second spelling of its remote) is skipped with agit_dir:<namespace>configuration error instead of sharing that clone.Why
A derived clone directory names the repository alone (
<name>.git), so a fork and its upstream resolve to one bare clone, each fetch moves the other's branch refs, and one namespace indexes the other's commits. The parser keeps the first entry for agit_dirand skips a later entry whosegit_remoteis a different string. Both values are compared as_entry_clone_fieldsreturns them: an entry that names no remote getshttps://github.com/<repo>.git, and an entry for the scalar's repository inherits the scalar'sgit_dirandgit_remotefor the fields it does not set. The remotes are compared as strings; thegit_dirvalues are compared by canonical path (symlinks and..resolved) and by directory identity (st_dev,st_ino) once the directory exists, so a relativegit_dirand its absolute path, a symlink, and a case alias on a case-insensitive volume are one clone. Branches of one repository share their clone by spelling the remote the same way. The error names the holder and says to use one spelling of the remote or set a separategit_dir. It counts inloom.code.repos_config_errorsandloom codeprints it for the skipped namespace.Refusing keeps every existing deployment's clone where it is. Deriving the directory from host and owner, as
repo_registry.git_dir_fordoes for self-service entries, would avoid the error, but it would move the clone of every existing operator entry on upgrade.Known limit
On a case-insensitive volume, two spellings of one path that differ only in case pass the check before the clone exists, because neither a canonical path nor a directory identity tells them apart yet. Once the first clone exists, the identity check refuses the other spelling.
docs/operations/code-index-operations.mdsays to use clone paths that differ by more than capitalization. On a case-sensitive volume, paths that differ only in case are distinct clones and both load.Changed after review
The earlier revisions compared
repo_keyvalues and extendedrepo_key(SSH user, ports per scheme, path case per host, rooted paths) so that two spellings of one repository matched. Following the review, those changes are dropped andrepo_keyis as onmain. The check comparesgit_remotestrings after the defaults instead, sohttps://github.com/acme/widgets.gitandgit@github.com:acme/widgets.giton onegit_dirare now refused, and the error tells the operator how to fix it. The comparison ofgit_dirby canonical path stays, and a directory that exists is also compared by identity. A lowercased path key, added in an earlier revision for fresh case-insensitive volumes, is dropped: it also refused distinct directories on a case-sensitive volume. The limit above replaces it.Scope and risk
The operator-configuration parser only;
repo_key, the page-add duplicate checks and self-service entries are untouched. A deployment that has two entries on onegit_dirwith different remotes (a fork and its upstream, or one repository under two spellings) sees the later entry skipped and reported; any other deployment sees no change. A skipped entry is a configuration error, and any configuration error stops the mirror sweep on every host (it removes nothing whileloom.code.repos_config_errorsis not 0), so the mirrors, checkouts and lock files of removed repositories stay until the operator fixes the entry;docs/operations/code-index-operations.mdsays so. Only this check resolves two spellings of onegit_dir; mirror grouping and its lock files comparegit_diras written, as onmain, so the docs ask for one spelling of a sharedgit_dir.Compatibility, rollout and rollback
git_dir, or set a separategit_dirfor one entry. On a case-insensitive volume, use clone paths that differ by more than capitalization.Tests
tests/unit/test_repos_clone_dir_collision.py: a fork and its upstream on one derivedgit_dirare refused, and the error names the holder and the fix (test_a_fork_and_its_upstream_do_not_share_a_clone); two branches whose remotes are the same string after the defaults share their clone (test_branches_with_one_spelling_of_the_remote_share_their_clone);https://github.com/acme/widgets.gitandgit@github.com:acme/widgets.giton onegit_dirare refused with the message (test_two_spellings_of_one_remote_are_refused); a separategit_diradmits a fork and its upstream (test_a_separate_git_dir_lets_both_in); a relativegit_dirand its absolute path, and a symlink to a held clone, are each one clone and the later entry is refused (test_two_spellings_of_one_clone_are_one_clone,test_a_symlink_to_a_held_clone_is_the_same_clone); a case alias of a held clone and a missing spelling that resolves to a held clone are each one clone (test_a_case_alias_of_a_held_clone_is_the_same_clone,test_a_missing_spelling_of_a_held_clone_is_the_same_clone); two existing directories that differ only in case both load (test_clone_dirs_that_differ_only_in_case_stay_distinct_on_a_case_sensitive_volume, skipped on a case-insensitive volume). Onmainthe fork-and-upstream, two-remote-spellings and the fourgit_dirspelling tests fail (mainhas no check); the other three pass on both.tests/unit/*repo*,*remote*andtest_mirrors*file, plustest_doc_links.pyandtest_public_copy.py, pass.ruff check,ruff format --check, mypy onrepos.py, the mypy and function-length gates and the codegen checks (docs_reference,settings_example,settings_schema,op_reach_census) pass. The full unit suite runs in CI.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code wrote the diff and the tests. Checked: I reviewed the whole diff and its tests; the gate runs listed under Tests are the agent's, against
mainat the same commit.I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make test-unitand applicable integration results are reported by CI; a full local run is not required before pushing.docs/reference/configuration.mdand thedocs/reference/tables (python scripts/codegen/docs_reference.py), the reach manifest,schemas/schema.sql(make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).main; no merged migration is edited.hooks/,lib/,bin/,skills/,.mcp.json, the Codexplugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.npm --prefix frontend run build) and its tests pass, iffrontend/changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.tests/unit/test_public_copy.py).git commit -s), as CONTRIBUTING.md asks.Note
Medium Risk
Changes operator-config parsing only, but misconfigured fork/upstream pairs will see a later entry skipped and mirror sweeps paused while config errors remain; otherwise behavior is unchanged.
Overview
Fixes mis-indexing when two
LOOM_CODE_REPOS_JSONentries resolve to the same bare clone but point at different remotes (e.g. fork vs upstream both derivingwidgets.git).While parsing operator config, the server now tracks which namespace “holds” each
git_dirand skips later entries whose resolvedgit_remote(after defaults) does not match the holder, recording agit_dir:<namespace>config error that names the holder and tells operators to unify the remote spelling or use a separategit_dir. Same remote on one clone still allowed (release branches). Collision detection treats paths as one clone viarealpath, existing-directory(st_dev, st_ino), and related spellings (symlinks, case aliases).Operations docs now describe shared-clone rules, this error type, and that non-zero
loom.code.repos_config_errorsblocks mirror sweep cleanup until fixed. New unit tests cover fork/upstream, remote spelling mismatches, path aliases, and case-sensitive vs insensitive volumes.Reviewed by Cursor Bugbot for commit 553cbe2. Bugbot is set up for automated code reviews on this repo. Configure here.