Repository navigation
adopt-project.py: plan asks whether it can write --out with its flags, before any work, and refuses a folder, a pipe, a missing folder or one nobody can write in as adopt-out-unwritable, and says plan written to once the plan is on disk, so a mistyped --out no longer ends in a traceback after the whole plan is built (#799) - #833
Conversation
…ect.py: `plan` asks `--out` with the flags and refuses a folder, a missing folder or one nobody can write in as `adopt-out-unwritable` before any work directory or clone, a write that fails anyway is the same refusal, and `plan written to` prints the moment the plan is on disk, so a bad `--out` no longer ends in a traceback after the whole plan is built and a later read no longer hides that the plan exists (#799) Lane: openreposhape-1 (openRepoShape-1) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Lane: openreposhape-1 (openRepoShape-1) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…, opens and removes nothing and refuses a pipe or a device by name, so a named pipe no longer blocks it and the check no longer leaves the real file where a later step refuses (#799) Lane: openreposhape-1 (openRepoShape-1) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Reviewer's GuideThe PR makes Sequence diagram for plan output validation and writingsequenceDiagram
actor User
participant CLI as adopt-project.py
participant FS as File system
participant Source
participant Report
User->>CLI: plan --out OUT
CLI->>FS: _refuse_an_unwritable_out(args)
FS-->>CLI: writable or refusal reason
alt OUT is unwritable
CLI-->>User: REFUSED adopt-out-unwritable
Note over CLI,FS: No work directory, source read, clone, or plan write
else OUT is acceptable
CLI->>Source: _work_root and source processing
Source-->>CLI: rendered plan text
CLI->>FS: _write_the_plan(args, out, text)
alt write fails
FS-->>CLI: OSError
CLI-->>User: REFUSED adopt-out-unwritable
else write succeeds
FS-->>CLI: plan on disk
CLI-->>User: plan written to OUT
CLI->>Report: _print_plan_report(...)
Report-->>User: plan report
end
end
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
(lane openRepoShape-1, 2026-10-17T19:15:03Z) Lane 1's independent review of #833 at 8295c1e: CHANGES NEEDED The Setup. Reviewed read-only at
Below, The issue's lines
Nothing runs before a refusal (attack 2)Each All 20 runs exited 2, with The FIFO returns at once on the merge. On main it blocks until killed ( Findings, rankedF1 (should fix). The Too wide.
W3 is left behind, empty; the clone is removed. So for the most natural slip, Too narrow. Each of these was allowed or got further on main:
Fix. Exempt only the folders the run makes:
F2 (should fix: false text in code and body).
As namespace root, On Linux, The false claim appears in four places: the F3 (low). The refusal can call an existing folder missing. Repro:
Fix: F4 (low). The backstop's remedy is off for a full disk. Repro: a 4 KiB tmpfs, a 15,014-byte plan, and an old plan already at
Suggested: add F5 (text). The change to every ordinary run's output is not stated plainly. I compared two sources byte for byte: the small
This is intended per the brief, but the body should say it. A nit: a local source's stdout now begins with an empty line. What is refused now that main allowed (attack 3)
Two further changes:
Tests, Sonar, Windows
Exact text replacements
For the checklist
Lane: openreposhape-1 (openRepoShape-1) |
…covers only the folders the run makes, `--out` that is the `--work-dir` is refused as a folder, the missing folder is named as typed, and only a write that fails for want of room says the file may be cut short, so `<work>/nope/plan.yaml` no longer clones first and `nope/..` no longer names a folder that exists as missing (#799) Lane: openreposhape-1 (openRepoShape-1) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
(lane openRepoShape-1, 2026-10-17T19:52:30Z) Lane 1's re-verification of #833 at ab5d46b: PR-READY The code, tests and texts are ready, and SonarCloud is green. One check is still open: the Setup. Head F1 to F5: all resolvedF1, the
The W3 refusal on the merge reads: These still work on the merge, each exit 0:
F2, the F3, the folder named in the refusal: resolved. The folder is spelled as typed ( F4, the backstop's remedy: resolved.
F5, texts: resolved. The Nothing runs before a refusal26 rows, each with a local source and with Every row exited 2 with one The diff changes nothing else
Revert rows and gateThree revert rows, re-run on the merge, all match the writer's table:
The gate ran on the merge, dirty 0, with git-filter-repo on PATH, over CI and the body
Optional text edits (not blocking)
For the checklist
Both optional text edits are applied (the PR body is edited; no push). Lane: openreposhape-1 (openRepoShape-1) |
|
(lane openRepoShape-1, 2026-10-17T19:53:06Z) Correction to issuecomment-6239966171: when that comment was posted, only optional text edit 1 was in the body. Edit 2, the Known-limits bullet on Lane: openreposhape-1 (openRepoShape-1) |
|
|
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 3 days and 16 hours by commenting |
Main at 3fb30a8, 37 commits past 24a977c, with #830 (#797, 51414d2) and #833 (#799, 3fb30a8). adopt-project.py conflicted in eight hunks; docs/cli.md merged by itself. Each keeps both sides: - `Source.open`, `Source.of` and `Source.in_place` take #797's `instead` and hand it on to `clone`, `in_place` and `_at`; `in_place` still takes the top level `_top_level` resolved. - `_source_named` (#796) and #799's `OUT_UNWRITABLE` block and `_write_the_plan` stand side by side. - `cmd_plan` asks `--out` first (#799: the flags and the file system alone), then `_source_spec` (#796), both before `_work_root`, and opens the source with `Source.of(named, ..., instead=args.tracking_branch)`. - `Plan.open_source` keeps `override is not None` and the empty `local_path` refusal (#796) and passes `self.read_at` (#797), and `_recorded_source` holds a path the person gave to `_top_level` and passes `self.read_at` at both `Source.in_place` calls. Lane: openreposhape-1 (openRepoShape-1) Co-Authored-By: Claude Opus 5.5 <[email protected]>
… names no repository's top level is refused by name before git reads anything else in it, so a file, a directory inside a repository, an unknown `~user`, an empty value, `owner/.git` and a lost blob no longer end in a traceback, plan a subtree or reach `gh` (#796) (#831) `adopt-project.py` took a `--source`, or a plan's `source.local_path`, that names no repository's top level as if it did (#796). Measured on main `24a977c0`: - a file (L1-64) ended in `NotADirectoryError`, exit 1, after `plan` had made its work directory; - a directory inside a repository, or `.` run in one (L1-88), planned only that subtree under the repository's name; a directory inside a git directory (`<repo>/.git/objects`, `<bare>.git/refs`) planned the whole repository and recorded the inner path, and `check` and `execute` then failed on it; - `~nouser/x` (L1-95) ended in `RuntimeError`; `--source ''` (L1-96) planned the directory `plan` ran in, and a plan recording `local_path: ""` had `check` clone the plan's repository from GitHub; - `owner/.git` in any case (L1-100) reached `gh repo clone`; `www.github.com/o/r` (L1-101) was refused; and a source that lost a blob (L1-77) ended in `ValueError` over git's `BAD` size. Now: - **`_top_level`**, new: a local source must be a directory; inside a git directory it must be that git directory itself; and `git rev-parse --show-prefix` must print nothing. Otherwise it is refused under a new code, `source-not-top-level`, which names what was given (a file, `src/` inside the repository at its top level, or the git directory it is inside), with the way out: pass the top-level directory, which `git rev-parse --show-toplevel` prints, or its `org/repo`. A git directory itself (`<repo>/.git`, a bare repository, `.git/modules/<m>`, `.git/worktrees/<w>`) is read whole, as on main. - **`_source_spec`** refuses an empty value, expands `~` with `os.path.expanduser` (so an unknown `~user` is `source-unresolvable`, not a traceback), and hands every path that exists to `_top_level`. `plan` reads `--source` before it makes its work directory; only the `--pin-source` refusals and `--out` (#833) come first. In `check` and `execute` the work directory is still asked first, as #650 ordered. - **A recorded `source.local_path`** the person gave is held to `_top_level` too, named by its key, and an empty one is `plan-source-gone`; nothing is cloned for it. A clone `plan` made keeps #749's handling. - **`_github_name`** refuses the repository `.git` in any case, with no `gh` call, and drops a trailing `.git` in any case; `www.github.com` is read as `github.com`. `scripts/repo_shape.py` is unchanged. - **`Source.tree`** refuses a size that is not `-` or digits as `git-failed`, naming the path, the blob and `git fsck`. - **The `source` report line** names the directory read, with the repository its `origin` names beside it; a clone `plan` made is still named by its repository. - **The help** of `plan`'s, `check`'s and `execute`'s `--source` names the new code, and docs/cli.md is regenerated. Review: lane 1's independent adversarial review found defects at `adbc5e37`. The fix round fixed them, and the re-verification found `2d51f181` PR-READY. Main was merged twice, the second time (`db202f53`) over #830's and #833's changes to `adopt-project.py`, and the re-verification found that head PR-READY too. It lands by fast refresh (Brett Heap, 2026-10-15T22:48:35Z). Its reviewed head is green on Linux and SonarCloud. The branch merged main three times and was never rebased; the last merge is update-branch's, clean, giving 7f4d015, which is green on SonarCloud and Git Bash. The full suite passed on its tree in lane 1's gate: 240 test files, 14,677 passed and 69 skipped. Closes #796 Lane: openreposhape-1 (openRepoShape-1) Co-Authored-By: Claude Opus 5.5 <[email protected]>
One conflict, in `Plan.open_source`'s `--source` branch. Main (#830 for #797, #831 for #796) passes `self.read_at` to `Source.open`, tests `override is not None`, and adds the docstring paragraph on an empty override; the branch keeps the clone made at the plan's own `source.local_path` (`_keep_the_clone_at_the_record`). Both are kept: main's docstring, condition and argument, then the branch's call, then `return source`. Auto-merged as both sides wrote it: main's `instead` reaches `Source._at` through the branch's rewritten `Source.clone`; `cmd_plan` asks `--out` (#833) and `_source_spec` (#831) before `_work_root`'s shared-chain check; both sides' identical `import errno` is one line. Lane: openreposhape-1 (openRepoShape-1) Co-Authored-By: Claude Opus 5.5 <[email protected]>



Lane: openreposhape-1 (openRepoShape-1)
Claim: #799 (comment)
v1.1.1, size S. Authored on
mainat 24a977c (merged into the branch), then changed for the review of 8295c1e (F1 to F5). It overlaps #796 (_source_spec,Source.open) and #803 (Source.clone,_leave_the_clones) only by position incmd_plan: this PR touches none of those functions.What
How
adopt-project.py plantreats--out(L1-89 of #457) and when it says the plan exists (L1-79).--outis asked first.cmd_planasks it with the flag-only refusals at its top, before_work_rootandSource.open, so a refused--outmakes no work directory and never callsgh. The question makes, opens and removes nothing: it isos.pathandos.accessalone. It refuses, each by name:--work-dir, which the run makes a folder;statfails for another reason);adoption-plan.yamlin an unwritable current directory;adopt-out-unwritable. One code, because the person's next act is the same for all of them: pass an--outthat names a file in a folder this user can write in, making the folder first if need be. The detail names which case it was, and spells the folder as it was typed (nope/..isnope/.., never the folder it would collapse to, which exists). It has theadopt-prefix ofadopt-work-dir-unwritableandadopt-unwritable-value, the refusalsplanmakes of a flag. Theplan-*codes arecheck's findings about a plan file, soplan-out-unwritablewould read as one.OSErrorfromwrite_lfis the same refusal. It is for what the question cannot see: a full disk or a quota, a folder that went after the question, a file name too long, a dangling symlink, and on Windows a folder's ACL (os.accessreads only the read-only attribute there). On Linuxos.accessis the kernel's own check, so a read-only mount is refused up front. Only a write that fails for want of room (ENOSPC,EDQUOT,EIO,EFBIG) says what lies at--outmay be cut short, and its way out is "Free space, or pass an --out on another file system."; any other failed write keeps the ordinary way out and says nothing of a cut file.--out /dev/nullexited 0 on main (plan written to /dev/null, the plan thrown away), and a named pipe blocked for ever. Both are now refused as not a regular file, as every pipe and device is.plan written to <out>is printed right afterwrite_lfsucceeds andargs.plan_writtenis set, before the report reads more of the source. A later read that fails (symlink_targets'git cat-file --batch) still leaves the line, and the exit code is unchanged (2)._print_plan_reportno longer takesoutand no longer prints the line; it prints a blank line before the questions, as the line did. So every plan's stdout now starts with a blank line andplan written to <out>, where main printed that line after the summary and before the questions. Nothing else printed or written changes (two sources compared byte for byte).--outhas--helpthat names the code on one line, and docs/cli.md is regenerated.Why (repro on main)
Probed on bf1f099 and again on 24a977c, with a stub
ghfirst on PATH that logs its calls,GH_TOKEN=bogus-w799, an emptyGH_CONFIG_DIR, and git 2.43.0. No realghwas run.write_lf(out, ...), exit 1, with noREFUSEDline and no remedy:--out <dir>/nope/adoption-plan.yaml:FileNotFoundError: [Errno 2];--out <an existing folder>:IsADirectoryError: [Errno 21];--out <a folder nobody can write in>/adoption-plan.yaml:PermissionError: [Errno 13].--work-dir Wgiven,Wwas made and stayed. With--source acme/Atlas, the stubghwas called withrepo clone acme/Atlas <W>/source-readonly/Atlas -- --quiet, and the plan was built before the write failed. That holds for--out W/plans/adoption-plan.yamltoo, the most natural slip, which the first version of this PR still let through.--outblockswrite_lffor ever, after the whole plan is built.git cat-file --batchmade to fail (agitwrapper first on PATH, a source holding a symlink whose target is not empty): the run exited 2 withREFUSED git-failed: ... cat-file --batch, the plan was on disk, and "plan written to" was never printed.How
All of it is in
adopt-project.py, anddocs/cli.md._refuse_an_unwritable_out(args)is called incmd_planstraight after the--pin-sourcerefusals. It asks_why_out_cannot_be_written, which asksos.path.isdir(or--outbeing the--work-dir), thenos.path.exists:_why_the_file_there_is_no_plan(a regular file this user can write, byos.access);_why_the_folder_holds_no_plan(os.statof the folder, thenos.access(folder, W_OK | X_OK)).os.pathis used and notPath.exists, because the second raises onEACCESwhere the first answers False.--work-direxemption covers only the folders the run makes (_out_is_made_by_this_run). A missing folder is left to the write when it is, read withos.path.realpathas_work_rootreads the directory:--work-dir, or a folder above it that_work_rootmakes with it (--work-dir Am/B/W --out Am/plan.yaml,Ammissing;--work-dir W --out W/../c-plan.yaml,Wmissing);W/source-readonly, or one folder below it, whichSource.clonemakes for anorg/reposource (a local source's is not told apart: nothing makes it, and the backstop refuses it).The folder, and the first part of it that is missing (walked as typed, so
nope/..counts as missing as long asnopeis), must both be among those. Anything else,W/nope/plan.yamlfirst, is refused before any clone, whetherWexists or not.test_a_plan_cut_short_after_it_is_written_keeps_its_clone(its--outis in the clone's own folder) and--work-dir W --out W/plan.yamlstill pass. The reviewer is asked to attack this._write_the_planis the backstop._out_foldernames the folder withPath.absolute, which does not collapse...--pin-sourceis still refused first.--outis asked after it and before--work-dirand--source, so a run with both a bad--outand a bad--sourcenames the--out.The refusal texts (
<f>is the folder, as typed and made absolute; every one begins with the first line and ends with the second, where<fix>is "Pass an --out that names a file in a folder this user can write in, making the folder first if it is not there." unless the row says otherwise):<why>the folder it goes in, <f>, does not exist--outis a folder, or the--work-dir(and--out '')it is a folder, and the plan is one file--outin an unwritable current directory includedthis user cannot write in the folder it goes in, <f>the folder it goes in, <f>, is a file or lies under onethe folder it goes in, <f>, cannot be reached (Permission denied)the file already there cannot be written: this user has no write permission on itwhat is already there is not a regular file, and the plan is onewriting it failed (<the system's reason>);<fix>is "Free space, or pass an --out on another file system. If the write began, what now lies at that path is cut short and is not a plan."writing it failed (<the system's reason>)Tests
New:
tests/test_adopt_plan_out_checked.py, 27 tests. Each fails with its change reverted; 23 of the 27 fail on main (the other four are controls main also passes: a plain run,--work-dir W --out W/plan.yaml,--work-dir Am/B/W --out Am/plan.yamland--out W/../c-plan.yaml).org/reposource: exit 2, the refusal alone on stderr, nothing on stdout, a--work-dirthat is not there before is not there after, and the suite'sghlog is empty;--outin an unwritable current directory;/dev/full(a named pipe with no reader would block an open, so these run with a timeout);--work-direxemption, both ways:W/nope/plan.yamlis refused before any clone (0ghcalls,Wnot made, and also withWthere),--out Wis refused as a folder,--work-dir Am/B/W --out Am/plan.yamland--out W/../c-plan.yamlare written,--out W/plan.yamlis, andnope/..is not mistaken for the work directory's parent and is named as typed;ENOSPC,EDQUOT,EIOandEFBIG(the room way out and the cut-short sentence), andENAMETOOLONG(the ordinary one);cat-file --batchmade to fail, "plan written to" printed once the plan is on disk and the run exits 2; and a run that reads fine says it once, before the report;--helpnames the code, and on one line.Revert table (
tests/test_adopt_plan_out_checked.py,tests/test_adopt_source_clone_record.pyandtests/test_cli_reference.py, on ab5d46b; unreverted: 100 passed):cmd_plan..._the_run_does_not_make_is_refused_before_any_clone,..._the_work_dir_is_already_there(and theghguard's teardown error on it, the clone having started),..._is_the_work_dir_is_refused_as_a_folder,..._dot_dot_through_a_folder_nothing_makes..._write_the_plan'stry..._goes_after_the_question..., the four..._for_want_of_room...,..._any_other_failed_write......_printed_though_a_later_read_fails,..._says_it_once_before_the_report_out_is_made_by_this_runis False)..._the_work_dir_the_run_makes_is_still_planned_into,..._beside_a_work_dir...,..._goes_back_out_of_the_work_dir..., andtest_adopt_source_clone_record.py::test_a_plan_cut_short_after_it_is_written_keeps_its_clone--work-dir)..._before_any_clone,..._the_work_dir_is_already_there,..._beside_a_work_dir...,..._goes_back_out_of_the_work_dir......_dot_dot_through_a_folder_nothing_makes...--outbeing the--work-dirnot asked..._is_the_work_dir_is_refused_as_a_folderos.path.abspathfor the folder's name..._dot_dot_through_a_folder_nothing_makes......_goes_after_the_question...,..._any_other_failed_write......_for_want_of_room...ones--outhelptest_cli_reference.pyadopt-project.pyand docs/cli.mdBoth modes, on head ab5d46b (tree bbbe3204), dirty 0, every log ending
EXIT=0: the 98 files ofgrep -l -E 'adopt-project|adopt_project|\bADOPT\b' tests/*.py(97, withtests/test_shape_doctor.pyandtests/test_scaffold_leg_path_collisions.pyamong them) plustests/test_cli_reference.py, in three shards of each mode with a stubghfirst on PATH,GH_TOKEN=bogus-w799and an emptyGH_CONFIG_DIR:git-filter-repoon PATHgit-filter-repohidden (PATH=<stub gh dir>:/usr/local/bin:/usr/bin:/bin)Totals: 6890 passed, 13 skipped, 1 xfailed with the filter; 6511 passed, 392 skipped, 1 xfailed without it. No test failed in either mode.
scripts/render-cli-reference.py --checksays docs/cli.md is what the generator produces.Windows: CI is Linux only (#597). The tests that need
chmodto remove write or search permission skip where it cannot (root, Windows), the pipe test skips where there is noos.mkfifo, and thegitwrapper test skips on win32. Every path is legal on NTFS.Not in this PR
_source_spec,Source.open,Source.in_place(adopt-project.py--source: a file, a directory inside a repository, an unknown~user/, an empty value andowner/.gitare not refused by name, soplanends in a traceback, plans only a subtree or the current directory, or handsgha name it cannot clone #796) andSource.clone,_leave_the_clones,_remove_a_tree(adopt-project.py: the cloneplanorcheckmakes and removes is claimed and checked by path, so a shared, writable--work-dirlets another local user turn the removal onto a directory of theirs, two runs on one--work-dirremove each other's clone, a skipped removal says nothing, and asource-readonlythat is a file ends in a traceback #803) are untouched.scripts/repo_shape.pyandscripts/shape_materialize.py(write_lf) are untouched, so the write is still not atomic: a full disk destroys an old plan at--out.Known limits (also on the #457 checklist):
os.accessanswers for the real user, so what it passes and the write still refuses (a full disk, a quota, a file name too long, a Windows ACL) is refused by the backstop after the work. A read-only mount is refused up front, and root writes where the mode bits say no, as on main.--out. The refusal says so; nothing removes it.--outfile name longer thanNAME_MAX, a dangling symlink into a missing folder, and a symlink loop are the backstop's, after the work.W/source-readonly/<name>/plan.yamlwith a local source passes the question (nothing makes that folder) and is the backstop's.--work-dir Work --out work/plan.yamlwith both missing is refused as "does not exist", where main wrote it; the paths are compared as spelled.org/reposource,--out W/source-readonly/<a misspelt repo>/plan.yamlpasses the question and is refused by the backstop after the clone.--out W/source-readonly/<repo>/<a folder the repository holds>/plan.yaml, which main wrote once the clone had made that folder, is now refused as "does not exist".Closes #799
🤖 Generated with Claude Code
Summary by Sourcery
Validate
planoutput paths before starting work and confirm the plan is written as soon as it reaches disk.New Features:
adopt-out-unwritablerefusals for invalid, inaccessible, or non-regular targets.Bug Fixes:
--outpoints to an unusable destination.Enhancements:
Documentation:
plan --outbehavior.Tests: