Repository navigation
adopt-project.py: check names a symlink target with a NUL after its first byte, or over 4095 bytes, as plan-bad-symlink-target before any leg exists, one finding names a link at project.yaml, and the targets are read in one batch (#908) - #965
Conversation
… byte, or over 4095 bytes, as `plan-bad-symlink-target`, one finding for a link at `project.yaml`, targets read in one batch; not finished: fail-without-fix run, rerun of the adopt test batches after the last edit What was wrong, on 5017830 with git 2.43 on Linux. `check` read a symlink target only for a NUL as its FIRST byte (#388) and never asked its length, so `docs/link -> spec\0.md` and a 5000-byte target passed `check` and failed after both leg repositories existed: git makes the link `spec` from `spec\0.md`, and the `git rm` of the split (or the verification, for a link kept in the root) stops at it; a target of 4096 bytes or more is not made at all (`File name too long`), and the clone exits 128. A root-kept `.github -> ci\0xx` was refused as `plan-root-symlink` saying it led to `ci\x00xx`, "not in the source tree", where Linux makes `.github -> ci`. A link kept in the root AT `project.yaml` got two findings (`plan-empty-symlink` and `plan-root-blocks-manifest`) whose second remedy, `drop`, helps no link that cannot be made, and `_PlannedRoot._link` started one `git cat-file blob` per link, per walk and per disk. What happens now. A new code, `plan-bad-symlink-target` (a widened `plan-empty-symlink` would tell whoever relays it that a 5000-byte link is empty; the two never name one link), names each link whose target holds a NUL after its first byte or is longer than `SYMLINK_TARGET_MAX` = 4095 bytes, before any leg exists, and says what git makes of it (`a link to `ci``, or no symlink). `plan` notes it and `execute` refuses it before any leg, whatever the plan answers. The walk of #183 marks such a link as it marks an empty one and names none. A link kept AT `project.yaml` is named by `plan-empty-symlink` or `plan-bad-symlink-target` alone, whose sentence says where it sits and ends with the remedy that helps (remove or rename it in the source); `plan-root-blocks-manifest` leaves it. `_PlannedRoot._link` reads from the one `git cat-file --batch`, kept on `Source.link_targets`. Limit: 4095 measured here (4095 made, 4096 and 5000 refused, a single 300-byte name made); macOS and Windows are not asked (see the comment above `SYMLINK_TARGET_MAX`). Measured with GIT_TRACE on `check`: `git cat-file blob <id>` 3 for one walked link and 15 for five, before; 0 for both after; `git cat-file --batch` 1 before and after. Tests: tests/test_adopt_symlink_target_bytes.py, 85 tests (last whole-file run 84 passed and 1 failed on a counting helper, fixed, the 3 counting tests then passed); tests/test_adopt_root_symlinks.py 156 passed; batch of 5 adopt files 212 passed and 1 failed (a test patching `_root_shape_findings(plan, tree)`, answered by this commit passing the third argument only where there is one, not rerun); three more batches were stopped part way with no failure in 692, 772 and 250 tests. Not run: the fail-without-fix swap of the base script. Lane: openreposhape-1 (openRepoShape-1) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…check` to name the link before the fix, so it fails on a script that never names it (#908) Finishes the swap-cut #908 work (WIP 32bc3c5); adopt-project.py is unchanged by this commit. test_the_remediation_the_finding_names_makes_check_pass checked only that a source with no bad link passes, which any script does, so it passed on the v1.1.1 script (5017830). It now plans and checks the source as it is first, wants exit 1 and `plan-bad-symlink-target` naming `docs/link`, and then removes or retargets the link as before. Run on the unfixed script, the new file fails 83 of 85 cases; the two that pass are controls (an empty link sent to a leg says nothing of the manifest; git makes a link whose one name is over NAME_MAX). Run on the fix, the file passes 85 of 85, and so do the adopt batches 2 to 5, shape doctor and the hygiene tests. Lane: openreposhape-1 (openRepoShape-1) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Reviewer's GuideThe PR makes Sequence diagram for cached symlink target readssequenceDiagram
participant Check
participant Source
participant Git
participant PlannedRoot
Check->>Source: symlink_targets(tree)
Source->>Git: cat-file --batch(blob ids)
Git-->>Source: symlink target blobs
Source-->>Check: cached targets
Check->>PlannedRoot: walk source links
PlannedRoot->>Source: symlink_targets(tree)
Source-->>PlannedRoot: cached targets
PlannedRoot->>Source: _read(oid)
Source-->>PlannedRoot: target bytes
Flow diagram for symlink target validationflowchart TD
A[Source tree] --> B[symlink_targets]
B --> C{Target is empty or NUL-led?}
C -->|Yes| D[plan-empty-symlink]
C -->|No| E{Contains later NUL or exceeds 4095 bytes?}
E -->|Yes| F[plan-bad-symlink-target]
E -->|No| G[Normal symlink processing]
D --> H[check reports finding]
F --> H
H --> I[execute refuses plan]
Flow diagram for single symlink findingsflowchart TD
A[Source symlink at project.yaml] --> B[_named_symlinks]
B --> C{Target finding exists?}
C -->|No| D[plan-root-blocks-manifest]
C -->|Yes| E[plan-empty-symlink or plan-bad-symlink-target]
E --> F[Include manifest location and source remediation]
F --> G[Omit duplicate plan-root-blocks-manifest]
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-18T18:31:39Z) Independent review of #965 at
Lane 1's writer f908 makes the round, then r908 re-checks the new head. Lane: openreposhape-1 (openRepoShape-1) |
… and XFS take at most 1023 bytes, a link at `Project.yaml` keeps its case aside, a link past the 20th named is left to `plan-root-blocks-manifest`, the late-NUL sentence says "On Linux", and the 4095-byte boundary of a NUL cut is tested (#908) The review round of the independent review of the #908 fix. Behaviour changes: a link at `Project.yaml` (the manifest case twin) says it sits at `project.yaml` once case is ignored, as `plan-root-blocks-manifest` said before; `_named_symlinks` holds only the links named one by one, so a link at `project.yaml` that is only counted, past the 20th, is still named by `plan-root-blocks-manifest`; the count line uses the ellipsis the sibling findings use; the late-NUL sentence begins "On Linux, where git makes symlinks by default", and the remediation says a clone makes the link git makes of the target, or none, not the blob's; `_leg_findings` always hands `named_links` on. Comments and docstrings: a target of 4095 bytes is made on ext4-like filesystems, macOS (MAXPATHLEN 1024) and XFS (XFS_SYMLINK_MAXLEN 1024) make at most 1023, so 1024 to 4095 bytes passes `check` and fails `execute`'s first clone there, read from their sources and not measured (a follow-up); `_named_symlinks` says the shape copy and pin findings still name a bad link; five links took 15 processes, not 16; `_entry_findings` names `plan-bad-symlink-target`. Tests: the 4095-and-NUL boundary of the sentence, the case twin, the 20th and the 21st link at the manifest, a link below a directory kept at the manifest, the limit pinned for the copy and pin findings, the count line at 20, "its first byte", and a cut of exactly 100 bytes; the clone test asks for the errno's text in the C locale; the lambda that stands in for `_root_shape_findings` takes the third argument. The new file holds 100 tests: 97 fail and 3 pass on the v1.1.1 `adopt-project.py`, and the 22 mutants of the review and of this commit are all caught. Lane: openreposhape-1 (openRepoShape-1) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
(lane openRepoShape-1, 2026-10-18T19:10:51Z) Re-check of #965 at
Lane: openreposhape-1 (openRepoShape-1) |
|
(lane openRepoShape-1, 2026-10-18T19:42:20Z) #965's three comment NITs (r908's N1 to N3) are not taken in a round before landing. They are an item of #979, which already holds #908's follow-ups, so #965 lands at 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 4 days and 11 hours by commenting |
…ymlink-target` names is no longer named again by `plan-root-blocks-shape-copy` or `plan-root-holds-pin`, so it gets one finding, and the #908 comments say Linux's bound (#979) (#1070) Part of #979: part (b) and r908's round-2 comment wordings (N1-N3). Part (a), the 1024-4095-byte window on macOS and XFS, stays open for a measurement on those hosts; `SYMLINK_TARGET_MAX` stays 4095. ## What #965 (#908, L1-80) gave a bad link at `project.yaml` one finding: `_root_shape_findings` leaves out `plan-root-blocks-manifest` for a link that `plan-empty-symlink` or `plan-bad-symlink-target` names one by one. The same link at two other paths the shape writes still got a second finding. That finding's remedy ("send it to a leg, `drop` it, or rename it in the source") cannot help a link that no clone makes: - a bad link at `shape/README.md`, with `shape/` and `README.md` kept in the root, was also `plan-root-blocks-shape-copy`; - a bad link at `contracts/shape-pin.yaml`, with `contracts/` kept, was also `plan-root-holds-pin`. Now each such link gets one finding, its own, and #908's remediation is said once after the findings. - **`_root_shape_findings`:** the skip no longer asks `code == ROOT_BLOCKS_MANIFEST`, so a named link AT any copy under `shape/` is left out, as at the manifest. This is the review's mutant M04. - **`_kept_pin_findings`:** a new skip, fed from the same `named_links` through `_pin_findings` and `_leg_findings`. A named link AT a pin's file is left out, for the shape's own pin and for a declared pin's file. - **What is not left out:** - a link BELOW a directory kept at either place, because the directory is in the way whatever the link holds; - a link past the first 20, which is only counted, so nothing else would name it. - **Comments and docstrings:** `_leg_findings`, `_named_symlinks`, `_links_at_a_copy`, `_links_at_a_pin` and the copy, walk and #908 comment blocks now say this. - **N1-N3:** - "GIT'S AND LINUX'S" reads "LINUX'S: git sets no bound of its own". - "made on no host" reads "made on no Linux or macOS host", since NTFS is thought to take longer targets. - The 1024-4095-byte window comment and the named-link limit both name #979. README.md, AGENTS.md, `docs/` and the handbook state no manifest-only rule, so no doc changes. ## Decisions - **No location tail.** Unlike `project.yaml`'s finding (`_at_the_manifest`), the link's own finding does not say where it sits. If the link is given a target git makes and is still kept there, the next `check` names it by `plan-root-blocks-shape-copy` or `plan-root-holds-pin`, whose remedy then helps. - **The pin skip stops at the disk that keeps case.** When that disk finds a named link at a pin's file, the disk that ignores case is not asked about that file, as it never was after a finding there. `_links_at_a_pin` therefore reads the same disk. A case twin kept beside the link (`contracts/Shape-pin.yaml`) is named once the link is gone, and a test pins this. The copy's skip, like the manifest's, still asks both disks. ## Tests All runs used a stub `gh` first on PATH, `GH_TOKEN=bogus-w979`, an empty `GH_CONFIG_DIR`, `GIT_CONFIG_GLOBAL=/dev/null` and `GIT_SSH_COMMAND=false`. `tests/test_adopt_symlink_target_bytes.py`: - `test_only_the_manifest_finding_leaves_a_named_link_out` is removed on purpose. Both of its cases fail on this code. - 8 new functions, 32 cases: | Test | Cases | On `eee089ca`'s code | | --- | --- | --- | | one finding at the README copy, the Makefile copy and the shape pin, for empty, NUL-led, late-NUL and 5000-byte targets | 12 | fail | | the same at a case twin (`Shape/README.md`, `contracts/Shape-pin.yaml`) | 4 | fail | | left out only if named (20th named, 21st counted) | 4 | 2 fail; the 2 counted are controls | | a link below a directory kept there is not left out | 2 | controls | | a link whose target git makes is unchanged | 3 | controls | | in memory: any pin file, the shape's own and a declared pin's | 3 | fail | | in memory: no case twin is asked after a named link at the pin | 1 | fail | | `execute` refuses with the one finding before any leg exists | 3 | fail | On base, 25 of the 32 fail and the 7 controls pass. On this head the file gives 130 passed. Mutants of the change, each restored. All 9 are killed: | Mutant | Failed | | --- | --- | | the copy skip reverted to the manifest only | 13 | | the pin skip reverted | 12 | | `_leg_findings` passes no `named_links` | 8 | | `_pin_findings` passes no `named_links` | 12 | | pin skip without the AT check | 1 | | copy skip without the AT check | 2 | | pin skip goes on to the disk that ignores case | 1 | | copy skip for any symlink at the copy, named or not | 6 | | pin skip for any symlink at the pin's file, named or not | 6 | Gate on this tree: 30 files, run in 11 pytest calls with one basetemp, 3634 passed and 5 skipped. - The 2 skips in `test_no_auto_maintenance.py` come from the session's `GIT_CONFIG_GLOBAL`. - The 3 skips in `test_shape_doctor.py` run on Windows only. The files: - every adopt test file that names a touched function or code: `symlink_target_bytes`, `empty_symlinks`, `execute_refusals`, `finding_spelling`, `ignored_shape_files`, `leg_path_collisions`, `leg_paths`, `nested_attributes`, `pins`, `plan_yaml_quoting`, `question_and_submodule_spelling`, `reencoded_files`, `root_manifest`, `root_shape_paths`, `root_symlinks`, `shape_pin_and_work_dir`, `verify`; - `test_scaffold_leg_path_collisions.py`; - `test_shape_doctor.py`, in 4 shards; - the tests that read adopt-project.py's source: `repo_hygiene`, `shape_advisory`, `non_utf8_git_failures`, `ruleset_hint_tracking_branch`, `template_values_single_pass`, `doctor_next_is_a_command`, `openreposhape_package`, `no_auto_maintenance`, `agents_md_codes`, `git_output_decoding`, `cli_reference`. ## Merge with main `git merge-tree --write-tree` of this head with `main` at `06cbd478` is clean (tree `01c6fa16`). Since `eee089ca`, main has changed `adopt-project.py` twice (#1065 and #1064) and has not changed the test file. The review, r1070, ran the test file, the doctor and 15 more files on the merge with `5e539a87`: 2,151 passed, 3 skipped, 0 failed. The landing refresh merges main again. It lands by fast refresh (Brett Heap, 2026-10-15T22:48:35Z). Its reviewed head `20d2d4ba` is green on Linux and SonarCloud. The branch merged main once and was never rebased; the last merge is update-branch's, clean, giving c9a796b, which is green on SonarCloud and Git Bash. Lane 1's gate passed on its tree: the 34 test files that run the named-link findings, the pins, the root copies and the source scanners, and the doctor's, 3,934 passed and 3 skipped. Part of #979: part (b) and the #908 comment wording. Part (a) stays open for a measurement on macOS and XFS. Lane: openreposhape-1 (openRepoShape-1) Co-Authored-By: Claude Opus 5.5 <[email protected]>



Lane: openreposhape-1 (openRepoShape-1)
Claim: #908 (comment)
A v1.2.0 draft, authored on the v1.1.1 release commit
50178305. Lane 3 filed #908 from its triage of #457 (L1-76, L1-78 and L1-80). It changesadopt-project.py, addstests/test_adopt_symlink_target_bytes.py, and changes one lambda intests/test_adopt_root_shape_paths.py. The branch holds three commits: the fix, a test change from its verification, and a round for the independent review's findings.What
plan-bad-symlink-target(L1-76). It names a symlink whose target holds a NUL after its first byte, or is longer thanSYMLINK_TARGET_MAX, 4095 bytes._source_path_findings, afterplan-empty-symlink, sochecksays it before any leg exists andexecuterefuses it as it refuses anycheckfinding.planstill writes the plan, and notes it.executemakes of the source holds that other link"; "a link toci, not to the 5 bytes the blob holds") or the bound. The first 20 are named, the rest counted with…asplan-empty-symlinkcounts, and one remediation is printed once: a clone makes "the link git makes of the target, or none, not the blob's".plan-empty-symlink, so nobody is told a 5000-byte link is empty. The two never name one link: empty and NUL-led targets stayplan-empty-symlink's._PlannedRoot._throughstops at it (_unmade_target), so a root-kept.github -> ci\0xxis no longerplan-root-symlinksaying it leads toci\x00xx, "not in the source tree".project.yaml(L1-80).plan-empty-symlinkorplan-bad-symlink-targetis the one finding, and ends with where the link sits and what ends the manifest block, "remove the link or rename it in the source" (_at_the_manifest; a renamed link whose target git does not make is stillplan-bad-symlink-target's).plan-root-blocks-manifestleaves it throughnamed_links, which_leg_findingsalways hands to_root_shape_findings.named_linksholds only the links named one by one, the first 20 of each code. A link atproject.yamlpast the 20th is only counted, soplan-root-blocks-manifeststill names it.Project.yaml, says it sits atproject.yaml"once case is ignored, as a macOS or Windows disk does", asplan-root-blocks-manifestsaid of it before.Source.link_targetskeeps each blob by id, andsymlink_targetsreads only those not yet seen._PlannedRoot._readuses it where it ran agit cat-file blobfor each link, walk and disk. Counted withGIT_TRACEoncheck: for one walked link 3cat-file blobruns before and 0 after; for five, 15 and 0; onecat-file --batchthroughout (theAGENTS.mdread is another reader).No doc changes:
AGENTS.mdspells noplan-*code.Why
Measured on
50178305(Linux, git 2.43, symlinks on):check, thenexecuteon the unfixed script.docs/link -> spec\0.mdcheckexit 0;executestops atgit rm -r -q -- docs, the clone holdingdocs/link -> speccheckexit 1, oneplan-bad-symlink-targetnotes-link -> spec\0.md, answeredrootcheckexit 0;executeexit 1,adopt-lost(the split holds 4 bytes, the source 8)checkexit 0; the clone exits 128,File name too long.github -> ci\0xxplan-root-symlinksayingci\x00xxplan-bad-symlink-target, "a link toci"project.yaml: late NUL or 5000 bytes; empty or NUL-ledplan-root-blocks-manifestalone; two findingsplan-bad-symlink-targetalone;plan-empty-symlinkalone; each with the manifest tailspec.md, one 300-byte nameadoption verifiedThe limit is 4095, Linux's bound. Measured with git's own
symlink()on ext4, eight lengths: 255, 256, 300, 1000, 4090, 4093, 4094 and 4095 clone fine; 4096, 4097 and 5000 exit 128, "unable to create symlink link: File name too long".PATH_MAXis 4096, counting the NUL. A single 300-byte name is made, soNAME_MAXis not asked.checkreads the tree, never the disk, so one plan gets one answer on every machine. A target over 4095 bytes is made on no Linux or macOS host, and the finding speaks of Linux, so no finding is false; but 4095 is not the smallest bound a host has (see Known limits). Withcore.symlinks=falsethe unfixedexecutesaidadoption verified, and a Linux clone of the late-NUL leg then helddocs/link -> specwhile the 5000-byte leg's exited 128.Tests
tests/test_adopt_symlink_target_bytes.py, 100 tests. The links are made in the INDEX withgit update-index --cacheinfo, so no test builds a source on a disk that holds a NUL in a target; all but three run on Windows too (the three that ask git to check a link out are markedneeds_disk_symlinks).50178305'sadopt-project.pyput back, 97 fail and 3 pass. The 3 are controls:project.yamlthat the plan sends to a leg, which the base already says isplan-empty-symlinkalone (a root-kept empty link there got two findings on the base);project.yamlthat is only counted, past the 20th, which the base already leaves toplan-root-blocks-manifest;bee1b287changedtest_the_remediation_the_finding_names_makes_check_pass, whose two cases passed on the base since they only checked a source with no bad link. It now askscheckto name the link first, then fixes the source.Run with
/usr/bin/python3 -m pytest, a stubghfirst on PATH, a bogusGH_TOKEN, an emptyGH_CONFIG_DIR,GIT_CONFIG_GLOBAL=/dev/nullandGIT_SSH_COMMAND=false, on heade349d83e: 23 files, 2791 passed and 3 skipped (the PowerShell paste tests intest_shape_doctor.py, which skip off a Windows host), among them the new file 100,test_adopt_empty_symlinks53,test_adopt_execute_refusals181,test_adopt_root_shape_paths120,test_adopt_root_symlinks156 (first run at this PR's head),test_adopt_leg_paths351,test_adopt_plan_yaml_quoting518,test_shape_doctor445 andtest_scaffold_leg_path_collisions104. The one batch failure the writer met, intest_adopt_root_shape_paths.py, passes now.Review round
The independent review found it ready, with two SHOULDs and twelve NITs. In
e349d83e:SYMLINK_TARGET_MAXnow say a 4095-byte target is made on ext4-like filesystems, and that macOS and XFS make at most 1023 (Known limits).<=to<is caught._named_symlinks' docstring no longer claims no other finding names a link again, and a test pins the copy and pin findings as a known limit; the manifest finding is left out only for a link named one by one; the count line uses…; "On Linux, where ..."; "the link git makes of the target, or none, not the blob's";named_linksis always handed on, and the test's lambda takes*_; 16 is 15; three tests areneeds_disk_symlinks; the clone test asks foros.strerror(errno.ENAMETOOLONG)in the C locale;_entry_findings' docstring names the new finding. NIT 4 (a fileproject.yamlbeside a bad linkProject.yaml, both kept in the root, where the link's tail says "not said again here" and the file's finding is printed) is left: the source is contrived.Known limits and follow-ups
checkpasses a symlink target of 1024 to 4095 bytes that macOS and XFS cannot make, and a bad link atshape/README.mdorcontracts/shape-pin.yamlis also named byplan-root-blocks-shape-copyorplan-root-holds-pinwith a remedy that cannot help it (follow-ups of #908) #979). macOS (symlink(2)copies the target in withMAXPATHLEN, 1024) and XFS (XFS_SYMLINK_MAXLEN, 1024, the default of RHEL-family systems) make a target of at most 1023 bytes. Both are read from their sources and were not measured. So a target of 1024 to 4095 bytes passescheckand failsexecute's first clone there, after both leg repositories exist. This PR keeps Linux's bound and says so in the comment aboveSYMLINK_TARGET_MAX; the follow-up issue "adopt-project.py:checkpasses a symlink target of 1024 to 4095 bytes that macOS and XFS cannot make, ..." holds it. Windows asks nothing: it makes no symlink by default.shape/README.mdorcontracts/shape-pin.yaml(adopt-project.py:checkpasses a symlink target of 1024 to 4095 bytes that macOS and XFS cannot make, and a bad link atshape/README.mdorcontracts/shape-pin.yamlis also named byplan-root-blocks-shape-copyorplan-root-holds-pinwith a remedy that cannot help it (follow-ups of #908) #979) is also named byplan-root-blocks-shape-copyorplan-root-holds-pin, with a remedy (dropit, send it to a leg) that cannot help it. It is L1-80's defect at two other paths, outside adopt-project.pycheck: a symlink target with a NUL after its first byte, or longer than the platform takes, passescheckand fails after both legs exist #908's wording; the same follow-up holds it, andtest_only_the_manifest_finding_leaves_a_named_link_outpins today's behaviour._named_symlinksis asked twice percheck.project.yamland a bad linkProject.yaml, both kept in the root: the link's tail says "not said again here" while that finding is printed for the file.check: a root-kept symlink into the clone's.git, or through a kept link to a declared pin's file, passes, or is refused for a reason that is not true #904 touches the same symlink code and follows this.Closes #908
🤖 Generated with Claude Code
Summary by Sourcery
Detect and refuse symlink targets that Git cannot faithfully materialize while consolidating their reporting and reading all targets efficiently.
New Features:
plan-bad-symlink-targetfindings for symlinks containing embedded NUL bytes or targets exceeding Linux’s supported length, with actionable remediation guidance.project.yamland prevent root-symlink traversal from producing duplicate or misleading findings.Bug Fixes:
checkandexecutefrom overlooking symlink targets that Git truncates or cannot create, avoiding failures after leg repositories have been created.Enhancements:
Tests: