Skip to content

test_adopt_partial_clone_source.py: a partial clone whose recorded .git this user cannot read is pinned source-unreadable in check and execute, never source-partial-clone, with no gh call and no upload-pack run (#1262) - #1289

Merged
brettheap merged 2 commits into
mainfrom
fix/1262-partial-clone-unreadable-git
Nov 10, 2026

Conversation

@brettheap

@brettheap brettheap commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Goal

Pin, in tests/test_adopt_partial_clone_source.py, that a partial clone whose recorded .git this user cannot read is refused source-unreadable, naming that .git, and never source-partial-clone, in check and execute alike, with no gh call, no upload-pack run and no remotes directory made. RD1141's NIT-1 on #1141 (for #1099) asked for it, and #1262 is that follow-up.

This is a test gap only, and the behaviour is right. The PR changes one file, tests/test_adopt_partial_clone_source.py (+117 -15). No production file, refusal code, remediation or doc changes. Milestone v1.2.1, as #1262.

What held on main

Plan._recorded_source (reached through open_source) asks _git_refused(path) ahead of everything that reads the clone (adopt-project.py:7064 at 4552efa6a), in check and execute alike, and _refuse_a_partial_clone_short runs after the source is opened. #1141's 9 refused-by-name rows (tests/test_adopt_unreadable_clone_git.py) build a plain clone, and this file's rows build partial clones with a readable .git: no row built a partial clone whose .git is at mode 000. RD1141's probe (not in the repository) measured 16 such rows at 0b8fb320, all REFUSED source-unreadable naming <it>/.git, none source-partial-clone, with 0 gh calls and 0 upload-pack runs. RD1141 measured why a reorder cannot flip that answer: through a .git at mode 000 _promisor_remotes is [] and _objects_lacking is None, where they are ['origin'] and 28 while it is readable, so the partial-clone rule's own questions see nothing there. What no row pinned is a change that left such a clone to that rule.

The rows

In tests/test_adopt_partial_clone_source.py, reusing Source, made and planned_once, and needs_a_mode, recording_gh, at_mode_000, the_refusal and CURES from the files that own them (functions only, no fixture is imported):

  • test_a_partial_clone_whose_recorded_git_is_unreadable_is_source_unreadable: 16 rows, [nocheckout|checkout]-[check|execute]-[given|cloned]-[directory|file]. Each makes a --filter=blob:none clone (with a checkout, and with --no-checkout; source.lacking() > 0 is asserted), records it as the plan's source.local_path (cloned false, or source.cloned: true with a source.repository), makes its .git a directory or a gitdir: file (git clone --separate-git-dir), and puts that .git at mode 000 for the with (at_mode_000: the mode is asserted to bite and is given back in a finally). It skips as root and on Windows (needs_a_mode). It asserts:
    • exit 2 and the_refusal(...) in stderr: REFUSED source-unreadable: the .git in the plan's source.local_path, <path>/.git: cannot be read (Permission denied), so ... cannot be told, with the cure for a directory or for a file (CURES[kind]);
    • source-partial-clone in neither stream, and no plan ok;
    • the gh log from recording_gh empty (no gh call);
    • no remotes directory;
    • source.untouched(): no upload-pack ran, and objects/ hashes as it did before.
  • test_the_same_partial_clones_with_a_readable_git_are_source_partial_clone: 8 control rows, [nocheckout|checkout]-[given|cloned]-[directory|file], check only. The same clones with a readable .git are refused source-partial-clone with its cure, never source-unreadable, with no gh call and nothing fetched. They show the 16 rows read the .git's mode and not a clone the rule would let by. They run as root and on Windows too.

The helpers, none of which changes an existing row: Source takes apart (the git directory beside a .git file); objects_dir(path) finds objects/ through that file (a function of the path alone, because tests/test_adopt_plan_partial_clone.py calls Source.store(SimpleNamespace(path=...))); check and execute take an env; recorded_as_a_clone is the cloned edit at_the_side_commit made inline, made alone and called from there. tests/test_adopt_plan_partial_clone.py reuses Source, made and planned_once, and keeps its outcomes (run G below). No assert joins conditions with and or or.

The rows failing before #1141

The detached tree n1262-mut at main 4552efa6a, this branch's test file, adopt-project.py and docs/cli.md (#1141's two production files) taken from 26cc80bd2^, then restored and compared by sha256 (adopt-project.py eb5f181b... at the base, a8f76e66... before #1141). -k "unreadable or readable_git", git 2.43.0: 16 failed, 8 passed.

rows before #1141 at the head
the 8 given rows (2 clones x 2 verbs x 2 kinds) 8 fail: REFUSED git-failed (git rev-parse --is-inside-git-dir says not a git repository), no gh call pass
the 8 cloned rows (the same 8) 8 fail: gh repo clone testorg/Elsewhere asked, REFUSED source-unclonable pass
the 8 control rows (readable .git) pass pass

This is what RD1141 measured for the same 16 rows on main b66d8f0cc.

The mutants

Each applied alone to adopt-project.py in n1262-mut at 4552efa6a, the 24 rows run, and the file restored and compared by sha256 each time (script mutate.py; the control rows pass in every run).

mutant the change rows failed
RD1141's MR4 refused = _git_refused(path) if there else None becomes refused = None 16 of 16
the guard asked after the cloned: false branch has read the clone the three guard lines moved below that branch, before _not_a_whole_clone 8: the 8 given rows (git-failed from _top_level); the cloned rows still reach the guard
extra: a .git file left unguarded a_file = False in _git_refused 8: every file row
extra: a recorded clone left unguarded the guard asked only where source.cloned is not true 8: every cloned row

No survivor. The two named in #1262 are killed, and each axis of the 16 rows (directory or file, given or cloned) carries a mutant of its own.

The runs

Head 2e0d2d237, Python 3.12.3, git-filter-repo 2.47.0 (tools/venv247), through run10.sh (a stub gh first on PATH that refuses and logs every call, GH_TOKEN=bogus-l5, an empty GH_CONFIG_DIR, GIT_SSH_COMMAND=false, GIT_CONFIG_GLOBAL=/dev/null), at most 100 tests a run, -rs alone. Each ran on git 2.43.0 and on git 2.47.1 (tools/git247/bin/git, git --version printed first in each log):

run files rows 2.43.0 2.47.1
A test_adopt_partial_clone_source.py, test_adopt_unreadable_clone_git.py, test_adopt_unenterable_source_and_locale.py 93 93 passed 93 passed
G test_adopt_partial_clone_source.py and test_adopt_plan_partial_clone.py in one pytest (the second imports the first's fixtures) 77 77 passed 77 passed
B test_agents_md_codes.py, test_cli_reference.py 70 70 passed 70 passed
C test_pinned_copy_text.py 87 87 passed 87 passed
D test_no_auto_maintenance.py 60 58 passed, 2 skipped 58 passed, 2 skipped
E1, E2 test_path_guard_hygiene.py in two halves 61 + 60 all passed all passed
F1, F2 test_repo_hygiene.py in two halves 51 + 50 all passed all passed

The only skips, named: tests/test_no_auto_maintenance.py:222 x2 on each git, "the session began with GIT_CONFIG_GLOBAL set, and its file includes that one". Run G first failed 10 rows on an earlier head cd8b4f3fe (a git_dir attribute Source.store(SimpleNamespace(path=...)) does not have); objects_dir replaced it and every run above was repeated at 2e0d2d237.

Pre-test of the merge: the predicted merge of the head into main 9cb156a98 (85f8744b4, a local commit never pushed), git 2.43.0: G 77 passed, and test_adopt_unreadable_clone_git.py with test_adopt_unenterable_source_and_locale.py 31 passed.

Refreshed on 2026-11-10 at 12:19Z as 305021ef3: one merge of main 3add78e1c into the reviewed head 2e0d2d237, made by gh pr update-branch. The old head's tests run had failed only on #1189's 13 rows in tests/test_adopt_symlink_target_bytes.py, which #1293 fixed on main. A re-run would have tested the stale merge again. CI's tests runs on the refreshed head, and lane 5's pilot gates the predicted squash again at this PR's turn.

Merges

git merge-tree --write-tree at the refreshed head 305021ef3, heads read fresh at 12:23Z (27 open PRs). No other open PR touches tests/test_adopt_partial_clone_source.py or tests/test_adopt_plan_partial_clone.py. Against the PR's base the head changes one file, tests/test_adopt_partial_clone_source.py (+117/-15).

against result
main 3add78e1c clean, tree 8327064c7, the head's own tree (the head holds main)
#1210 (791106c2b, 16th) clean, tree 00f6a02ac
#1194 (fix/1129-github-name-limits, 906172b41, 17th) clean, tree b0eac8e04
#1209 (fix/1196-paths-spelled-locale-and-env, 13a2c58cb) add/add conflict in tests/test_adopt_plan_paths_spelled.py, a file this PR does not touch; the same conflict arises between #1209 and main alone

The earlier rows (main 3ee5bb4d9 and 9cb156a98, and #1282, which has landed as b607223b4) are superseded by this table (rv1289's NIT 1).

Closes #1262

Lane: openreposhape-5 (openRepoShape-5)

🤖 Generated with Claude Code

Summary by Sourcery

Strengthen partial-clone adoption tests to pin unreadable recorded .git sources to source-unreadable without side effects.

Enhancements:

  • Expand partial-clone source coverage to verify unreadable recorded .git paths are classified as source-unreadable before partial-clone handling, for both check and execute.
  • Cover directory and separate-git-dir .git layouts, checkout variants, and sources recorded as given or cloned, while preserving controls for readable partial clones.

Documentation:

  • Document the expected refusal behavior for partial clones whose recorded .git is unreadable.

Tests:

  • Add coverage asserting unreadable partial clones make no GitHub calls, remote-directory creation, or upload-pack runs and leave source objects unchanged.

…git` this user cannot read is pinned `source-unreadable` in `check` and `execute`, never `source-partial-clone`, with no `gh` call and no `upload-pack` run (#1262)

No row built a partial clone whose recorded `.git` is at mode 000 (RD1141's
NIT-1 on #1141, for #1099): #1141's rows and this file's each covered one of
the two rules, and the two now share `--source`'s help and the `check` and
`execute` path. 16 rows (2 clones x 2 verbs x `cloned` false and true x a
`.git` directory and a `gitdir:` file) put the `.git` at mode 000 under
`needs_a_mode` and assert exit 2, `REFUSED source-unreadable` naming that
`.git` with its cure, no `source-partial-clone`, no `plan ok`, no `gh` call
(`recording_gh`), no `upload-pack` run, `objects/` as it was and no remotes
directory. 8 control rows give the same clones a readable `.git`: refused
`source-partial-clone` with its cure, never `source-unreadable`.

`Source` takes `apart` (the git directory beside a `.git` file) and `objects_dir`
finds its `objects/` through that file, `check` and `execute` take an `env`, and
`recorded_as_a_clone` is `at_the_side_commit`'s `cloned` edit made alone; no
existing row changes, and `tests/test_adopt_plan_partial_clone.py`, which reuses
`Source`, keeps its outcomes.

Before #1141 (26cc80b^, production files) the 16 rows fail: the 8 `given`
rows with `git-failed`, the 8 `cloned` rows with `source-unclonable` after
`gh repo clone` was asked; the 8 control rows pass. With the guard removed
(`refused = None`) 16 fail; with it asked after the `cloned: false` branch
has read the clone, the 8 `given` rows fail.

Closes #1262

Lane: openreposhape-5 (openRepoShape-5)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@brettheap brettheap added this to the v1.2.1 milestone Nov 9, 2026
@sourcery-ai

sourcery-ai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Tests

Add parameterized unreadable-.git cases and readable controls to pin the refusal behavior across clone layouts, plan recording modes, and check/execute.

  • tests/test_adopt_partial_clone_source.py L153-166, L252-271, L377-443 (+7 small edits)

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

@brettheap

Copy link
Copy Markdown
Contributor Author

Independent review of #1289 (#1262) for lane openRepoShape-5, by rv1289 (opus), at 2e0d2d2: READY

The PR meets every point of #1262's "Done when". I found no MUST and no SHOULD, and there are two NITs. I wrote nothing to the PR, the branch or GitHub. The PR head read back as 2e0d2d2372b4aaa8327a4ca7ff180687c2f4950a at 21:57Z from both gh pr view and ls-remote. It is still a draft, and closingIssuesReferences is [1262].

Setup: detached trees /workspace/projects/openRepoShape-worktrees/rv1289-review and /workspace/projects/openRepoShape-worktrees/rv1289-mut at 2e0d2d23, both clean at the end. Every run used L/tools/run10.sh, as uid 1000, Python 3.12.3, git-filter-repo 2.47.0 from venv247 (it prints a40bce548d2c). The diff is tests/test_adopt_partial_clone_source.py only, +117/-15.

1. The rows against "Done when"

24 new ids collected: 16 rows [nocheckout|checkout]-[check|execute]-[given|cloned]-[directory|file] and 8 controls [nocheckout|checkout]-[given|cloned]-[directory|file].

2. The helper changes

  • tests/test_adopt_plan_partial_clone.py is the only importer, on the head and on main 8cf6477fe.
  • It calls Source.store(SimpleNamespace(path=...)), and objects_dir(path) supports that call. No name collides.
  • run_script(env=None) behaves exactly as before.
  • No existing test function changed, and every imported name is a constant, a function or a mark (no fixture, nothing named test_*).
  • The two files in one pytest pass: 77 on each git.

3. Failing before

I swapped in adopt-project.py from 26cc80bd2^ (sha a8f76e66...). docs/cli.md is not needed: it is regenerated help text and the tool never reads it.

  • Result: 16 failed, 8 passed.
    • The 8 given rows fail with REFUSED git-failed (git rev-parse --is-inside-git-dir).
    • The 8 cloned rows fail with REFUSED source-unclonable, after the recording gh was asked ("w430h: gh is not to be asked here").
  • The file was restored with sha256 eb5f181b....

4. Mutants

Each was applied alone to adopt-project.py, run on the 24 rows with git 2.43.0, and restored by sha256 to eb5f181b every time. Scripts: L/work/rv1289/mutate.py and mutrun.sh.

mutant rows failed
MR4 refused = None 16 of 16
guard after the cloned: false branch 8 (the given rows)
n1262's NO-FILE (a_file = False) 8 (the file rows)
n1262's GIVEN-ONLY 8 (the cloned rows)
own NAME (the .git dropped from the name) 16
own CURE-SWAP 16
own UNTOLD-SWAP 16
own CODE-SWAP (the guard raises source-partial-clone) 16
own REMOTES-EARLY (--local-remote-dir made before the source is opened) 8 (the execute rows)
own GH-EARLY (a gh call before the guard) 12: the 8 cloned rows and the 4 cloned controls, on the gh-log assert alone
own EMPTY-TREE (no guard where the work tree holds only .git) 8 (the nocheckout rows)
own PARTIAL-FIRST (the partial-clone rule asked before the guard) 0: equivalent at mode 000

5. Gates at 2e0d2d2

Logs are L/work/rv1289/logs/g243-* and g247-*.

run files git 2.43.0 (/usr/bin/git) git 2.47.1 (L/tools/git247/bin/git)
G test_adopt_partial_clone_source.py + test_adopt_plan_partial_clone.py, one pytest 77 passed 77 passed
U test_adopt_unreadable_clone_git.py + test_adopt_unenterable_source_and_locale.py 31 passed 31 passed
B test_agents_md_codes.py + test_cli_reference.py 70 passed 70 passed
C test_pinned_copy_text.py 87 passed 87 passed
E1, E2 test_path_guard_hygiene.py in two halves 61 + 60 passed 61 + 60 passed
F1, F2 test_repo_hygiene.py in two halves 51 + 50 passed 51 + 50 passed
D test_no_auto_maintenance.py 58 passed, 2 skipped 58 passed, 2 skipped
  • The only skips: tests/test_no_auto_maintenance.py:222 x2 on each git, "the session began with GIT_CONFIG_GLOBAL set, and its file includes that one".
  • Predicted merge with fresh main 8cf6477fe: the merged tree 64d26e4f is main plus blob ca4d890be. On it, G passed 77 on 2.43.0 and 77 on 2.47.1, and U passed 31 on 2.43.0.

6. Merge-trees

Heads read fresh at 21:48Z, 39 open PRs (L/work/rv1289/merge-trees.txt). No open PR touches either of the two test files. I also checked the PRs that touch the helper modules this file imports from.

against result
main 8cf6477fe clean, tree 64d26e4f
#1194 906172b41 (touches test_adopt_unsearchable_source.py) clean, tree 77f8480e
#1282 e91c57e96 (touches conftest.py) clean, tree e9dd8be0
#1209 13a2c58cb (touches conftest.py) add/add conflict in tests/test_adopt_plan_paths_spelled.py; the same conflict arises against main alone and against #1289's base 4552efa6a, so it is not #1289's

None of those PRs changes needs_a_mode, recording_gh, run_script, git or spelled.

7. The body

  • One Closes #1262 and no other closing keyword. body-guard exits 0 on the live body.
  • Every count in its tables matches what I measured: rows, gates, mutant shas, adopt-project.py:7064, and the tree ids e03005d5e and b84ec1676.
  • The commit subject is 232 characters, the commit is ASCII, and it ends with the Closes, Lane and Co-Authored-By lines.

Findings

My notes and logs are in /workspace/projects/.lane-worktrees/openRepoShape-5/work/rv1289/ (STATE.md, logs/, mutate.py, tmutate.py, skip_probe.py, merge-trees.txt).

Lane: openreposhape-5 (openRepoShape-5)

@sonarqubecloud

Copy link
Copy Markdown

@brettheap
brettheap marked this pull request as ready for review November 10, 2026 14:11
@sourcery-ai

sourcery-ai Bot commented Nov 10, 2026

Copy link
Copy Markdown

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant