Skip to content

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

Merged
brettheap merged 4 commits into
mainfrom
fix/908-symlink-target-nul-length
Oct 19, 2026

Conversation

@brettheap

@brettheap brettheap commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

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 changes adopt-project.py, adds tests/test_adopt_symlink_target_bytes.py, and changes one lambda in tests/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

  1. A new finding, plan-bad-symlink-target (L1-76). It names a symlink whose target holds a NUL after its first byte, or is longer than SYMLINK_TARGET_MAX, 4095 bytes.
    • It comes from _source_path_findings, after plan-empty-symlink, so check says it before any leg exists and execute refuses it as it refuses any check finding. plan still writes the plan, and notes it.
    • It says what git makes of the blob ("On Linux, where git makes symlinks by default, each clone execute makes of the source holds that other link"; "a link to ci, not to the 5 bytes the blob holds") or the bound. The first 20 are named, the rest counted with … as plan-empty-symlink counts, and one remediation is printed once: a clone makes "the link git makes of the target, or none, not the blob's".
    • It is a new code, not a widened plan-empty-symlink, so nobody is told a 5000-byte link is empty. The two never name one link: empty and NUL-led targets stay plan-empty-symlink's.
  2. The root walk names no such link (L1-78). _PlannedRoot._through stops at it (_unmade_target), so a root-kept .github -> ci\0xx is no longer plan-root-symlink saying it leads to ci\x00xx, "not in the source tree".
  3. One finding for a link at project.yaml (L1-80). plan-empty-symlink or plan-bad-symlink-target is 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 still plan-bad-symlink-target's).
    • plan-root-blocks-manifest leaves it through named_links, which _leg_findings always hands to _root_shape_findings.
    • named_links holds only the links named one by one, the first 20 of each code. A link at project.yaml past the 20th is only counted, so plan-root-blocks-manifest still names it.
    • A link at the manifest's case twin, Project.yaml, says it sits at project.yaml "once case is ignored, as a macOS or Windows disk does", as plan-root-blocks-manifest said of it before.
  4. One batch read. Source.link_targets keeps each blob by id, and symlink_targets reads only those not yet seen. _PlannedRoot._read uses it where it ran a git cat-file blob for each link, walk and disk. Counted with GIT_TRACE on check: for one walked link 3 cat-file blob runs before and 0 after; for five, 15 and 0; one cat-file --batch throughout (the AGENTS.md read is another reader).

No doc changes: AGENTS.md spells no plan-* code.

Why

Measured on 50178305 (Linux, git 2.43, symlinks on): check, then execute on the unfixed script.

Case Before After
leg link docs/link -> spec\0.md check exit 0; execute stops at git rm -r -q -- docs, the clone holding docs/link -> spec check exit 1, one plan-bad-symlink-target
root-kept notes-link -> spec\0.md, answered root check exit 0; execute exit 1, adopt-lost (the split holds 4 bytes, the source 8) the same finding
leg link of 5000 bytes check exit 0; the clone exits 128, File name too long the same finding
root-kept .github -> ci\0xx plan-root-symlink saying ci\x00xx one plan-bad-symlink-target, "a link to ci"
link at project.yaml: late NUL or 5000 bytes; empty or NUL-led plan-root-blocks-manifest alone; two findings plan-bad-symlink-target alone; plan-empty-symlink alone; each with the manifest tail
controls: links of 4095 bytes, to spec.md, one 300-byte name adoption verified unchanged

The 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_MAX is 4096, counting the NUL. A single 300-byte name is made, so NAME_MAX is not asked. check reads 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). With core.symlinks=false the unfixed execute said adoption verified, and a Linux clone of the late-NUL leg then held docs/link -> spec while the 5000-byte leg's exited 128.

Tests

tests/test_adopt_symlink_target_bytes.py, 100 tests. The links are made in the INDEX with git 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 marked needs_disk_symlinks).

  • Without the fix: with 50178305's adopt-project.py put back, 97 fail and 3 pass. The 3 are controls:
    • the empty-target link at project.yaml that the plan sends to a leg, which the base already says is plan-empty-symlink alone (a root-kept empty link there got two findings on the base);
    • an empty link at project.yaml that is only counted, past the 20th, which the base already leaves to plan-root-blocks-manifest;
    • a test that records a fact about git (a 300-byte name is made) and never calls the script.
  • Mutants: the review's 18 and four of this round's were each applied to the fix and the new file run; all 22 are caught (the review's table had 11 caught, 7 survived).
  • The earlier test change: bee1b287 changed test_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 asks check to name the link first, then fixes the source.

Run with /usr/bin/python3 -m pytest, a stub gh first on PATH, a bogus GH_TOKEN, an empty GH_CONFIG_DIR, GIT_CONFIG_GLOBAL=/dev/null and GIT_SSH_COMMAND=false, on head e349d83e: 23 files, 2791 passed and 3 skipped (the PowerShell paste tests in test_shape_doctor.py, which skip off a Windows host), among them the new file 100, test_adopt_empty_symlinks 53, test_adopt_execute_refusals 181, test_adopt_root_shape_paths 120, test_adopt_root_symlinks 156 (first run at this PR's head), test_adopt_leg_paths 351, test_adopt_plan_yaml_quoting 518, test_shape_doctor 445 and test_scaffold_leg_path_collisions 104. The one batch failure the writer met, in test_adopt_root_shape_paths.py, passes now.

Review round

The independent review found it ready, with two SHOULDs and twelve NITs. In e349d83e:

  • SHOULD-1: the bound stays 4095 (lane 1's decision), and the comments above SYMLINK_TARGET_MAX now say a 4095-byte target is made on ext4-like filesystems, and that macOS and XFS make at most 1023 (Known limits).
  • SHOULD-2: a test for a NUL after exactly 4095 bytes ("a link to ... and 3995 more bytes, not to the 4097 bytes") and after 4096; the mutant <= to < is caught.
  • NITs 1, 2, 3, 5 to 12: the case twin keeps its aside; _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_links is always handed on, and the test's lambda takes *_; 16 is 15; three tests are needs_disk_symlinks; the clone test asks for os.strerror(errno.ENAMETOOLONG) in the C locale; _entry_findings' docstring names the new finding. NIT 4 (a file project.yaml beside a bad link Project.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.
  • Four small tests more kill the survivors the review's table listed (the count line at 20, "its first byte", a cut of exactly 100 bytes, a link below a directory kept at the manifest).

Known limits and follow-ups

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:

  • Add plan-bad-symlink-target findings for symlinks containing embedded NUL bytes or targets exceeding Linux’s supported length, with actionable remediation guidance.
  • Report a single source finding for problematic symlinks kept at project.yaml and prevent root-symlink traversal from producing duplicate or misleading findings.

Bug Fixes:

  • Prevent check and execute from overlooking symlink targets that Git truncates or cannot create, avoiding failures after leg repositories have been created.
  • Avoid repeated symlink target reads by reusing batched blob data throughout source validation and root walking.

Enhancements:

  • Preserve symlink target blobs by object ID and reuse them across all validation and materialization checks.
  • Limit long target descriptions to a bounded prefix while retaining the total byte count.

Tests:

  • Add comprehensive coverage for invalid symlink targets, boundary lengths, manifest-path handling, root walks, execution refusal, remediation, and batched Git reads.

Brett Heap and others added 2 commits October 18, 2026 16:09
… 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]>
@brettheap brettheap added this to the v1.2.0 milestone Oct 18, 2026
@sourcery-ai

sourcery-ai Bot commented Oct 18, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR makes check reject symlink blobs that Git would truncate at a later NUL or cannot create above 4095 bytes, centralizes each link’s finding without root-walk or manifest duplicates, and reuses one cached batch read of all symlink targets; extensive tests cover reporting, execution safety, platform behavior, and performance.

Sequence diagram for cached symlink target reads

sequenceDiagram
    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
Loading

Flow diagram for symlink target validation

flowchart 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]
Loading

Flow diagram for single symlink findings

flowchart 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]
Loading

File-Level Changes

Change Details Files
Detect and report symlink targets that Git cannot materialize faithfully.
  • Add plan-bad-symlink-target for targets containing a non-leading NUL or exceeding 4095 bytes.
  • Describe the truncated target or platform length bound, cap displayed bytes, and emit shared remediation guidance.
  • Keep empty or NUL-leading targets under plan-empty-symlink, with mutually exclusive findings.
  • Make check report findings before leg creation and make execute refuse them; retain notes in generated plans.
adopt-project.py
tests/test_adopt_symlink_target_bytes.py
Prevent invalid symlink targets from producing duplicate or misleading root-walk findings.
  • Stop _PlannedRoot traversal at targets Git does not make as stored.
  • Suppress plan-root-symlink for those links so the source finding is authoritative.
  • Use named_links to suppress duplicate manifest-blocking findings for links kept at project.yaml.
  • Append manifest-specific location and remediation text to the single source finding.
adopt-project.py
tests/test_adopt_symlink_target_bytes.py
Cache symlink blobs and reuse a single batch read across source checks and root walks.
  • Store blob contents, including missing-blob results, on Source.link_targets.
  • Have _PlannedRoot._read obtain link targets from the shared cache and batch, with a fallback for unavailable blobs.
  • Replace repeated per-link git cat-file blob calls with one git cat-file --batch invocation per source.
adopt-project.py
tests/test_adopt_symlink_target_bytes.py
Add comprehensive regression coverage for target classification, reporting, execution, and Git behavior.
  • Test NUL placement, 4095-byte boundaries, long targets, target rendering, finding limits, remediation, and manifest/root cases.
  • Verify plans still write notes, execution creates no legs, and valid controls remain unchanged.
  • Trace Git invocations to assert one batch read and no repeated blob reads; probe actual clone behavior where supported.
tests/test_adopt_symlink_target_bytes.py

Assessment against linked issues

Issue Objective Addressed Explanation
#908 Have check identify symlink targets containing a NUL after the first byte or exceeding the platform’s supported target length, before any leg repositories are created, and avoid duplicate root-walk findings for those links. ❌ The PR detects late NULs and targets over 4095 bytes before execution and suppresses duplicate root-walk findings. However, it uses a fixed Linux limit and explicitly does not account for macOS’s shorter limit, so some targets that exceed the platform’s limit can still pass check.
#908 Report a link at project.yaml with one actionable finding rather than also reporting plan-root-blocks-manifest. ✅
#908 Read symlink targets through the batch read and reuse them rather than issuing separate Git blob reads during root walks. ✅

Possibly linked issues


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

(lane openRepoShape-1, 2026-10-18T18:31:39Z) Independent review of #965 at bee1b287, by lane 1's reviewer r908 (opus), who is not its writer: READY, with no MUST and two SHOULDs. Lane 1 takes them, with the NITs, in a fix round now.

  • The issue is met:

    • check names a target with a NUL after its first byte, or over 4095 bytes, as plan-bad-symlink-target;
    • plan notes it, and execute refuses it before any leg exists;
    • the root walk no longer reports ci\x00xx;
    • a link at project.yaml gets one finding;
    • the targets come from one batch read.

    The branch merges cleanly with main.

  • Tests: 467 passed: the new file, the empty-symlink file, the execute refusals file, and the docs and codes files.

  • Mutants: 11 of 18 are killed. Every survivor is a test gap, not a code fault.

  • SHOULD-1: macOS and XFS make symlink targets of at most 1023 bytes, from their sources (MAXPATHLEN, XFS_SYMLINK_MAXLEN). So a target of 1024 to 4095 bytes passes check and fails execute's clone there.

    • Lane 1 keeps git's 4095 bound in this PR.
    • The comment and the body say so.
    • A follow-up issue holds the window.
  • SHOULD-2: a 4095-byte target followed by a NUL is untested (M09). The round adds the row.

  • NITs:

    • a case twin of project.yaml loses its aside;
    • the _named_symlinks docstring overclaims: the copy and pin paths go to the follow-up;
    • a project.yaml link past the twentieth goes unnamed;
    • the ellipsis;
    • "On Linux";
    • the remediation's "a clone makes the link";
    • the test-only branch in production;
    • 16 is 15;
    • two tests are three;
    • an English strerror in a test;
    • a stale docstring.
  • Not yet run at this head: tests/test_adopt_root_symlinks.py. The round runs it.

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]>
@brettheap

Copy link
Copy Markdown
Contributor Author

(lane openRepoShape-1, 2026-10-18T19:10:51Z) Re-check of #965 at e349d83e, by r908 (opus), who is not its writer: READY, with no MUST and no SHOULD.

Lane: openreposhape-1 (openRepoShape-1)

@brettheap

Copy link
Copy Markdown
Contributor Author

(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 e349d83e, the head r908 found READY, in its turn once it is green and gated.

Lane: openreposhape-1 (openRepoShape-1)

@sonarqubecloud

Copy link
Copy Markdown

@brettheap
brettheap marked this pull request as ready for review October 19, 2026 13:19
@sourcery-ai

sourcery-ai Bot commented Oct 19, 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 11 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@brettheap
brettheap merged commit c7a3ff1 into main Oct 19, 2026
5 checks passed
@brettheap
brettheap deleted the fix/908-symlink-target-nul-length branch October 19, 2026 13:20
brettheap added a commit that referenced this pull request Oct 21, 2026
…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]>
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