Repository navigation
adopt-project.py: a source symlink whose target begins with a NUL byte is check's plan-empty-symlink, which execute refuses before any leg, so \0spec.md no longer fails the first clone after both legs exist, or verifies over a spec leg no clone can check out (#388) - #720
Merged
Merged
Conversation
…symlink whose blob is not empty, in one `git cat-file --batch`, and report one that begins with a NUL byte as `plan-empty-symlink`, so `\0spec.md` no longer checks ok and then fails `execute`'s first clone after both legs exist, or verifies over a spec leg no clone can check out (#388) #303's `plan-empty-symlink` found an empty symlink by its blob's size alone. A `120000` blob that begins with a NUL byte (`\0spec.md`, 8 bytes) is not empty, but git hands the target to `symlink(2)` as a C string, which ends at its first NUL, so Linux reads it as the empty target. On main da48256, `check` said `plan ok`; with symlinks on, `execute` created both leg repositories and failed at its first clone of the source (`unable to create symlink docs/odd-link: No such file or directory`); with `core.symlinks` false it said `adoption verified` over a spec leg whose own clone exits 128. - `symlink_targets(source, tree)`: one `git cat-file --batch` over the blob ids `Source.tree()` lists for every symlink of size 1 or more, each id once, cut by the size git prints, so a line feed in a target is read whole; a link of size 0 is not read, and a source with none starts no process. - `empty_symlinks(tree, targets)`: size 0, or a target that begins with NUL. Its callers, `_source_path_findings` (so `check` and `execute`'s `_refuse_what_check_finds`) and `plan`'s `_empty_symlink_notes`, pass the targets. The finding is the same code, worded for its blob ("begins with a NUL byte ...; a symlink's target ends at its first NUL, so this one is empty too", held "as a plain file" where `core.symlinks` is false), and the "... and N more" tail now says "empty or begins with a NUL byte". - The walk of #183 (`_PlannedRoot._through`) takes a NUL-led target as it takes an empty one, so a link kept in the root at or above a shape path is this one finding and not also `plan-root-symlink`, whose fix (send it to a leg, or `drop` it) is none for it. On main that link was refused only as `plan-root-symlink`. A NUL later in the target (`spec\0.md`) and a target too long for the platform are not this change's; both still fail after both legs exist. Lane: openreposhape-1 (openRepoShape-1) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThe PR makes source symlinks whose blob begins with a NUL byte fail early as Sequence diagram for batched symlink validationsequenceDiagram
participant Plan
participant Source
participant Git
participant Findings
Plan->>Source: tree()
Plan->>Git: cat-file --batch(blob ids)
Git-->>Plan: symlink target bytes
Plan->>Findings: empty_symlinks(tree, targets)
Findings-->>Plan: plan-empty-symlink notes
participant Check
Check->>Source: tree()
Check->>Git: cat-file --batch(blob ids)
Git-->>Check: deduplicated target bytes
Check->>Findings: _empty_symlink_findings(tree, targets)
Findings-->>Check: findings and remediation
State diagram for root traversal of NUL-led symlinksstateDiagram-v2
[*] --> FollowingSymlink
FollowingSymlink --> EmptyTarget: target is empty
FollowingSymlink --> EmptyTarget: target starts with NUL
EmptyTarget --> PlanEmptySymlink: _root_symlink_findings
PlanEmptySymlink --> [*]
Flow diagram for early NUL-led symlink refusalflowchart TD
A[Source tree contains symlink] --> B{Blob size is zero?}
B -- Yes --> D[plan-empty-symlink]
B -- No --> C[Read target with cat-file --batch]
C --> E{Target begins with NUL?}
E -- Yes --> D
E -- No --> F[Continue normal planning]
D --> G[check fails]
G --> H[execute refuses before creating leg repositories]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
brettheap
marked this pull request as ready for review
October 16, 2026 17:37
|
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 hours and 14 minutes by commenting |
|
brettheap
pushed a commit
that referenced
this pull request
Oct 17, 2026
main gained 25 pull requests since de92614: #634, #699, #671, #719, #701, #717, #700, #702, #722, #720, #725, #721, #728, #705, #727, #718, #744, #743, #749, #740, #737, #734, #742, #751 and #736. No conflict: AGENTS.md, adopt-project.py and docs/cli.md merged as text, and README.md and docs/handbook.html are unchanged by the merge. README.md is 1473 lines, its cap; AGENTS.md 494, its cap; every handbook marker is current; `render-cli-reference.py --check` is ok. Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap
pushed a commit
that referenced
this pull request
Oct 17, 2026
…es every reason THIS checkout cannot answer, and the notes are current to main bf1f099 with the 25 pull requests since de92614 (#563, #683) - W683 and RV-f's N4 on #742: README's exit-3 list (Keeping a project's shape current, :1208-1220) and its handbook twin (`doctor`) named only a pin whose commit this checkout does not carry. They now say, as shape-doctor.py's EXIT CODES does: a pin's commit it lacks, a partial clone missing what is compared (#683), a read that fails (`update-upstream-unreadable`), a crashed validator of its own (#278, #410), or its own naming policy not loading (#678). +1 line, with tests/readme-cap.d/683.txt; README.md is 1474, its cap (1422 + 2 + 5 + 12 + 22 + 10 + 1). The two `Keeping a project's shape current` markers move: `doctor` text and marker, `current` marker only. - The notes, "What changed since v1.0.1", one entry per pull request from `git log --first-parent de92614..bf1f099`, each from its squash commit and the issues GitHub says it closes: - adopt-project.py: #699, #719, #749, #727, #717, #728 (with #621's hint), #743 + #720 + #718, #722, #721; - update-shape.py, bump-leg.py and a project's own scripts: #702 (with the pinned validators), #634; - scaffold, setup, family and the shared readers: #725, #671, #744; - shape-doctor.py: #742, #701, #737, #751, #736, #734, #700 + #705, #740; - install, CI and the docs: the exit-3 sentence above. - Counts (99 pull requests since bfed143; 109 of 135 milestone issues closed at 10:28Z), the "current to main" sha and the open list (26) are at main bf1f099, still placeholders for tag time. Left for round B: lane 5's eight lines (#630 issuecomment-6227129879), whose pull requests #726, #747, #682, #724, #746, #745 and #738 are open drafts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Lane: openreposhape-1 (openRepoShape-1)
Claim: #388 (comment)
What
A symlink in the source whose target begins with a NUL byte is now
check'splan-empty-symlink, as an empty target has been since #303.executerefuses it before any leg exists, andplannotes it while it still writes the plan.Read the targets once.
planandcheckread the target of every source symlink whose blob is not empty, with onegit cat-file --batchover the blob idsSource.tree()already lists (symlink_targets). Each id is read once, however many links share it. Each object is cut by the size git prints, so a target that holds a line feed is read whole. A link of size 0 is known to be empty without reading it, and a source with no symlink of size 1 or more starts no process for this.One finding. The new link uses the same code, worded for its blob. A target that begins with NUL is empty to Linux, it fails the same way at the same place, and its remediation is the same:
An empty target's sentence is unchanged. Past the twentieth link, the count line now reads
… and N more symlinks whose target is empty or begins with a NUL byte.One link, one finding, in the root too. A NUL-led link the plan keeps in the root at or above a path the shape writes (
.github,CLAUDE.md) gets this finding alone. On main it was refused only asplan-root-symlink, "leads to\x00ci, which is not in the source tree", whose fix ("send it to a leg ordropit") does not help it with symlinks on. The walk of materialize_assembly_root writes the shape files through a root-kept symlink to anywhere on disk, and crashes with a traceback on a link loop, after both legs are pushed #183 (_PlannedRoot._through) now takes a NUL-led target as it takes an empty one, so_root_symlink_findingsleaves the link toplan-empty-symlink, as test_adopt_root_symlinks.py already asserts for an empty target.Why (reproduced on main da48256)
The issue's script, with
docs/odd-linka120000blob holding\0spec.md, every repository local, the stubghfirst on PATH:With
core.symlinks=falsefor the whole run, on the same source:The same runs on this branch (939623b). Symlinks on and off print the same finding, and no leg is made:
The control,
docs/odd-link->spec.md(7 bytes), still checksplan okand endsadoption verified, with symlinks on and off.How
symlink_targets(source, tree) -> dict[str, bytes]: target bytes by blob id, for every120000row of size 1 or more. It makes onegit cat-file --batchcall, with the ids on stdin. An id git reports asmissingis left out, and that link is judged by its size alone. A failedcat-fileraises the samegit-failedrefusalgit_outdoes, with git's words.empty_symlinks(tree, targets): a size of 0, or a target intargetsthat begins with\0. It takes the targets as a mapping, not aSource, so the in-memory tests stay in memory and say which targets they hand in._source_path_findings(plan, tree, targets)servescheckandexecute's_refuse_what_check_findsthrough_entry_findings._empty_symlink_findings(tree, targets)is the second.plan's_empty_symlink_notes(tree, targets)is the third._empty_symlink_sentenceswords each link: one that has a size is there for its NUL._PlannedRoot._through:if not target or target.startswith("\0")marks the walkempty.checkpasses a source whose tree holds a symlink with an empty target, so with symlinks onexecutecreates both leg repositories and then fails cloning the source (on main with exit 2 and nothing on stderr, #171), and withcore.symlinks=falseit saysadoption verifiedover a leg or root that no clone with symlinks on can check out #303 section's comment no longer says "No target is read". It now says why this is the same finding, and that size 0 is never read.executeneeds no change of its own:_refuse_what_check_findsrefuses everycheckfinding before_create_leg_remotes.Tests
tests/test_adopt_empty_symlinks.py: 28 cases on main, 53 on this branch. Five tests are now parametrized over both targets,emptyandnul-led: theplanNOTE,checkin each place and withcore.symlinks=false, andexecutein-process and end to end.test_each_link_is_namedandtest_it_comes_after_the_unsafe_paths_and_before_coveragekeep the empty target. A new place inPLACES,.githubkept in the root, runs the #183 walk.test_a_symlink_whose_target_begins_with_nul_is_empty_toocovers a file whose blob begins with NUL, a link to a name and an unread link.test_the_finding_says_where_a_nul_led_target_endschecks the words.test_the_targets_are_read_in_one_pass_and_only_where_there_is_oneexpects exactly[["git", "cat-file", "--batch"]], two links sharing one blob, and a target holding a line feed.test_a_source_whose_links_are_all_empty_reads_no_targetexpects no process at all.nul-ledruns of theplanNOTE, ofcheckin six places, ofcheckwithcore.symlinks=false, and ofexecutein-process in six places. The end-to-endexecuteruns with symlinks on and off,docs/and top-leveldrop. The controltest_the_link_given_a_target_adopts_end_to_endnow runs with symlinks on and off.{}(no target read) for the new argument.test_a_source_with_none_has_no_finding_and_no_remediationhands in its link's target,spec.md.test_past_twenty_the_rest_are_countedmakes its last link NUL-led and expects the widened count line.Revert table. Each change was reverted alone in adopt-project.py, with the final tests, and
tests/test_adopt_empty_symlinks.pyrun in full (git-filter-repo on PATH):nul-ledcase (18), the 4 new tests,test_past_twenty_the_rest_are_counted, and the 4 existing in-memory tests (only for the new argument)empty_symlinksby size alonenul-ledcase (18),..._begins_with_nul_is_empty_too,..._says_where_a_nul_led_target_ends,test_past_twenty_the_rest_are_countedsymlink_targetsreturns{}nul-ledcase (18),..._read_in_one_pass_......_read_in_one_pass_...,..._all_empty_reads_no_target_throughtestsnot targetalonetest_check_reports_what_it_passed[above-a-shape-path-kept-in-the-root-nul-led],test_execute_refuses_it_before_any_leg_exists[above-a-shape-path-kept-in-the-root-nul-led]..._says_where_a_nul_led_target_endsand everynul-ledcase that reads the words (18)test_past_twenty_the_rest_are_countedThree new cases pass with the change reverted, by design. They are
test_check_reports_what_it_passedandtest_execute_refuses_it_before_any_leg_existsatabove-a-shape-path-kept-in-the-root-empty, which #303 already handles, and the controltest_the_link_given_a_target_adopts_end_to_end[symlinks-off].Targeted runs. These covered every test file that runs or imports adopt-project.py (
grep -l -E 'adopt-project|adopt_project|\bADOPT\b' tests/*.py: 86 files on da48256), test_shape_doctor.py and test_scaffold_leg_path_collisions.py among them. They ran on head 939623b with dirty 0, with git-filter-repo on PATH and with it hidden:Windows
CI is Linux only (#597). The tests still run anywhere. Every link is made in the index from bytes on
git hash-object --stdin, so no symlink is made on a disk to build a source. The only test that checks a link out with symlinks on is the control'ssymlinks-oncase, which keeps itsneeds_disk_symlinksskip. Every path a test makes is legal on NTFS. Theline\nbreaktarget lives only in a blob and is never checked out. No test counts bytes of a file a helper wrote withwrite_text.Not in this PR
spec\0.md). Measured on this branch:checksaysplan ok, andexecutemakes both legs, then fails atgit --literal-pathspecs rm -r -q -- docsin its work clone (error: the following file has local modifications: docs/odd-link), because git made a link tospec. The issue puts it outside adopt-project.pycheckpasses a source whose tree holds a symlink whose target begins with a NUL byte (\0spec.md, a120000blob of size 8), so with symlinks onexecutecreates both leg repositories and then fails cloning the source, exit 2 with nothing on stderr, and #303'splan-empty-symlink, which tests the blob's size, does not find it #388.plan ok, thenexecutemakes both legs and fails at the first clone (unable to create symlink docs/odd-link: File name too long). It is the wider question adopt-project.pycheckpasses a source whose tree holds a symlink with an empty target, so with symlinks onexecutecreates both leg repositories and then fails cloning the source (on main with exit 2 and nothing on stderr, #171), and withcore.symlinks=falseit saysadoption verifiedover a leg or root that no clone with symlinks on can check out #303 leaves as a note: an entry git cannot check out whereexecuteruns.docs/release-notes/v1.0.0.mdkeeps its adopt-project.pycheckpasses a source whose tree holds a symlink whose target begins with a NUL byte (\0spec.md, a120000blob of size 8), so with symlinks onexecutecreates both leg repositories and then fails cloning the source, exit 2 with nothing on stderr, and #303'splan-empty-symlink, which tests the blob's size, does not find it #388 known-limit line: it describes the released v1.0.0.Known limits
git cat-file blob(_PlannedRoot._link), as on main. Only theemptytest there changed.git ls-tree -lfails and the run is refused asgit-failed. In a repository that has lost it,ls-tree -lprints its size asBADand exits 0, andSource.tree()ends in aValueErrortraceback, on main and on this branch alike. So themissingreply thatsymlink_targetsleaves out, judging that link by its size alone, is not reached throughplan,checkorexecute.checkpasses a source whose tree holds a symlink with an empty target, so with symlinks onexecutecreates both leg repositories and then fails cloning the source (on main with exit 2 and nothing on stderr, #171), and withcore.symlinks=falseit saysadoption verifiedover a leg or root that no clone with symlinks on can check out #303's did. Whether macOS or Windows can make such a link is not asked. The finding is reported on every platform, because the assembly's ownvalidateworkflow runs on Linux.Closes #388
🤖 Generated with Claude Code
Summary by Sourcery
Reject source symlinks with empty or NUL-terminated targets before adoption can create unusable leg repositories.
New Features:
Bug Fixes:
Enhancements:
Tests: