Skip to content

adopt-project.py and scaffold-project.py: a --pin naming an annotated tag's own id pins the commit the tag names, and one naming a tree or a blob is refused, so a pin file no longer records a tag's id under "A COMMIT, NEVER A TAG" (#651) - #725

Merged
brettheap merged 3 commits into
mainfrom
fix/651-adopt-annotated-tag-pin
Oct 16, 2026

Conversation

@brettheap

@brettheap brettheap commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openreposhape-1 (openRepoShape-1)
Claim: #651 (comment)

What

git rev-parse v1.2 prints a release tag's own object id, 40 hex, and a person can pass it as --pin openGlass@<id>. Both tools read a --pin through declared_pin_values (scripts/shape_materialize.py). That function now asks what the id names before it reads the digest, in the same place it reads the digest:

  • with --pin-source, git cat-file -t in that clone;
  • without it, the forge, through gh api graphql and repository.object(oid:), whose __typename names the same four kinds.

Peeled, not refused. An annotated tag's own id, or a tag of a tag, is peeled to the commit it names, and one line on stdout says so, ahead of the plan either tool prints:

--pin opensoft/openGlass @ 1b15ec63f4e8 is an annotated tag; it names commit 747de8661206, which is what the pin records

Every value after it is the commit's: the digest, plan's pins: entry, the pin line, and the pin file execute and the scaffold write. This follows bump-leg.py --to (#534), family.py add --at, and family.py bump --to (#541, on Brett Heap's ruling of 2026-10-14). A tag object's id fixes its content, so it names one commit for ever and, unlike a tag name, cannot be moved. That makes it as exact a pin as the commit is, so refusing it would only make the person look the commit up by hand.

Refused: an id that names no commit. A tree's id, a blob's id, or an annotated tag of either is refused by both tools as pin-not-a-commit, before any digest is read. The words are bump-leg.py's:

REFUSED pin-not-a-commit: --pin openGlass@2e4e5c34a7a9aac02cef750da9eea1ef35655580 names a tree in the clone at /…/openGlass, not a commit
Remediation: pass a commit -- `git log --format=%H` in a clone of the product lists them -- or an annotated tag of one, whose own id is peeled to the commit it names, as `bump-leg.py --to` peels one. A tree's or a blob's id is part of a commit and never one, and a pin is a commit or it is nothing.

On the forge path, the refusal says in opensoft/openGlass on the forge. An id the forge holds no object for is pin-unreadable, with the same remediation that refusal always had: `gh api` could not read opensoft/openGlass @ <id>: the forge holds no object <id> in opensoft/openGlass.

check asks the recorded clone (#589's recheck). Where the clone plan read a digest from is still on this machine, and is not a partial clone, check now asks it the same question before it recomputes the digest. A recorded commit: the clone holds as an annotated tag, a tree or a blob becomes a new finding, plan-pin-not-a-commit, and execute refuses it before any leg. Such a plan comes from a plan run before this fix, or from a hand edit. For a tag, the finding names the commit the tag names:

FINDING plan-pin-not-a-commit: `pins:` entry 1 ('openGlass') records `commit: <tag id>`, which is an annotated tag of commit <commit> in the clone `plan` read its digest from, /…/openGlass-clone, not a commit. The pin file `execute` writes from it says `revision_kind: commit`, and `plan` records the commit an annotated tag names and refuses an id that names none: re-run `plan` with `--pin opensoft/openGlass@<40 hex commit>`, …

The riders in the same block (#457's lines):

Why (repro on main a524542, and again on main de92614)

Measured on a524542, and again on main de92614 by the reviewer, with the same results; the reviewer also ran the scaffold's real run with a tag of a tag, which writes the outer tag's id the same way. Each probe ran with a stub gh first on PATH, GH_TOKEN=bogus-w651, an empty GH_CONFIG_DIR, GIT_CONFIG_GLOBAL=/dev/null and GIT_ALLOW_PROTOCOL=file. The product was a local stand-in for openGlass whose commit was tagged with git tag -a v1.2. The stub's log stayed empty: no gh ran.

--pin openGlass@<id>, with --pin-source adopt-project.py plan scaffold-project.py --dry-run scaffold-project.py (real)
the tag's own id (git rev-parse v1.2) exit 0, records commit: "<tag id>" exit 0, pin … @ <tag id> exit 0, writes commit: "<tag id>" under revision_kind: commit and "A COMMIT, NEVER A TAG"
a tag of that tag exit 0, records the outer tag's id exit 0 not run
the commit's tree id exit 0, records the tree's id as commit: exit 0 not run
a blob's id exit 2, pin-source-unreadable, in git ls-tree's words exit 2, the same not run

The new tests reproduce every row above on the same main: through plan for every row, through the scaffold for the tag, the tree and the blob, and on the forge path through the stub. They also show that check passes a plan recording a tag's id: the digest recomputes, because git ls-tree peels the tag.

How

Tests

New, failing on main a524542 and passing here:

  • tests/test_pin_annotated_tag.py, 21 tests:
    • plan with a tag and with a tag of a tag;
    • the scaffold's dry run and its real run, whose pin file the root's own validate-pins.py recomputes;
    • refusals of a tree, a blob and a tag of a tree, by both tools;
    • the forge path: two peels, three refusals, and the forge holding no object;
    • check and execute on a recorded tag, tag of a tag, tree, blob and tag of a tree.
  • tests/test_adopt_shape_pin_and_work_dir.py, 3 tests: L1-06 for a product named Shape and for two products at one file, and L1-07.

Changed, because the first gh call is now the forge's GraphQL question:

  • test_with_no_pin_source_plan_reads_the_digest_from_gh (tests/test_adopt_pins.py). Its stub now answers gh api graphql from a file (GH_STUB_OBJECTS), and the test asserts that question and then the tree read.
  • The three no-gh-before-the-refusal tests, in tests/test_scaffold_leg_path_collisions.py, tests/test_scaffold_pin_collisions.py and tests/test_pin_source_env_collisions.py.
    • Each refused run is unchanged: no gh at all before the refusal.
    • Each control, the same run made to reach gh, asserted that its first call started with api repos/opensoft/<product>, the tree read. It now asserts that the stub's whole log is one call: the read-only GraphQL query asking what the pin's id names (asked_what, tests/test_adopt_pins.py). The stub refuses that call, so no other gh command runs.
    • The first of the three was missed at e731b66 and fixed at bd5eead; see "Targeted runs".

Revert table. Each change was reverted alone in a scratch clone at 3723d493, then tests/test_pin_annotated_tag.py and tests/test_adopt_shape_pin_and_work_dir.py in full and the changed test_adopt_pins.py test were run, 42 in all, the 24 new tests among them. 3723d493's tree differs from the head's only in the three no-gh-before-the-refusal controls (tests/test_scaffold_leg_path_collisions.py, tests/test_scaffold_pin_collisions.py and tests/test_pin_source_env_collisions.py), which the table does not run. Every new test fails under at least one row.

reverted alone fails
R1. declared_pin_values asks nothing (_pinned_commit not called) 17: the 16 plan, scaffold and forge tests of tests/test_pin_annotated_tag.py, and test_with_no_pin_source_plan_reads_the_digest_from_gh
R2. The --pin-source clone is not asked 10: plan with a tag and with a tag of a tag, the scaffold's dry and real runs, and both tools' refusal of a tree, a blob and a tag of a tree
R3. The forge is not asked 7: the forge's two peels, its three refusals, the forge holding no object, and test_with_no_pin_source_plan_reads_the_digest_from_gh
R4. check does not ask the recorded clone 5: test_check_finds_a_recorded_id_that_is_no_commit, for a tag, a tag of a tag, a tree, a blob and a tag of a tree
R5. _pin_files is keyed by product again (L1-06) 2: test_a_kept_file_two_pins_are_written_at_is_named_once, both cases
R6. The shape pin's copy is asked about again (L1-07) 1: test_the_shapes_pin_and_its_copy_kept_are_one_finding
R7. The literal "config" again (L1-05) none: the argv is the same, so it is a naming nit with no behavior to test

L1-63 is a docstring.

Targeted runs on head e731b66, dirty 0, with /usr/bin/python3 -m pytest over 108 files:

  • every test file that runs or imports adopt-project.py (grep -l -E 'adopt-project|adopt_project|\bADOPT\b' tests/*.py, 88 with the new file);
  • every file that runs the scaffold (54);
  • tests/test_shape_doctor.py, tests/test_scaffold_leg_path_collisions.py and tests/test_git_output_decoding.py.

The results at e731b66. Each log names the head and dirty 0, before and after:

mode result
git-filter-repo on PATH 1 failed, 7542 passed, 13 skipped (1:08:37), EXIT=1
git-filter-repo hidden (PATH=<stub gh>:/usr/local/bin:/usr/bin:/bin) 1 failed, 7198 passed, 357 skipped (0:57:25), EXIT=1

The one failure in each mode was the same test, tests/test_scaffold_leg_path_collisions.py::test_no_gh_command_runs_before_the_refusal. It was a fourth no-gh-before-the-refusal control whose first-call assertion I missed. It expected api repos/opensoft/openGlass and found the new api graphql … -f oid=… question. No other test failed.

bd5eead fixes it, a new commit with no amend, and changes nothing outside these three test files. It also makes the two controls e731b66 had changed assert the stub's whole log exactly, through the same helper.

To find any other assertion that #651 could move:

Re-runs at bd5eead, dirty 0 before and after, of 8 files:

  • tests/test_scaffold_leg_path_collisions.py;
  • the three pin files: tests/test_adopt_pins.py, tests/test_scaffold_pin_collisions.py, tests/test_pin_source_env_collisions.py;
  • tests/test_pin_annotated_tag.py;
  • the sweep's other stub-gh files: tests/test_doctor_validator_rows.py, tests/test_neutral_pin_validator.py, tests/test_setup_project_py.py.
mode result
git-filter-repo on PATH 650 passed (0:07:10), EXIT=0
git-filter-repo hidden 626 passed, 24 skipped (0:06:11), EXIT=0

The reviewer's runs on a local merge with main de92614 (merge-tree clean), of the six files above that this PR changes, tests/test_shape_doctor.py, tests/test_git_output_decoding.py and tests/test_neutral_pin_validator.py: 958 passed, 3 skipped with git-filter-repo on PATH, and 929 passed, 32 skipped with it hidden, EXIT=0 in both.

The full 108-file set was not re-run at bd5eead. Its tree differs from e731b66's only in the three test files above, and those were re-run in both modes.

Every run here had a stub gh first on PATH, GH_TOKEN set to a bogus value, an empty GH_CONFIG_DIR, and no GIT_ALLOW_PROTOCOL.

Windows

CI is Linux only (#597), so no Windows run applies. The new tests read files back with read_text(). The tag names and paths they create (v1, v1-again, a-tree) are legal on NTFS. The forge-path tests carry WINDOWS_SKIP, like every test using the stub gh, which is a #! script.

Not in this PR

  • L1-04. The issue's case is a directory that is not a clone, inside a partial clone. The proposed fix asks whether the recorded path is a clone's top level before reading its config, but plan reads a --pin-source through git's own repository discovery. Measured on a524542:

    • plan --pin-source glass/sub, a directory inside a full clone, is accepted, and check then recomputes the digest there: digest recomputes … in the clone … glass/sub.
    • The same inside a partial clone gets the partial-clone NOTE.

    If the partial-clone question returned "not a clone" for a subdirectory, check would recompute in the enclosing partial clone, whose git can fetch what it lacks over the network, and "check reads no network" would no longer hold. Answering "unreadable" there instead would contradict plan, which read the same path, and a re-run of plan would accept it again. The NOTE is the safe side, as the line itself says. Making it exact means holding --pin-source to a clone's top level in plan, the scaffold and check alike. That changes what both tools accept, beyond this block.

  • The root's own validate-pins.py still passes a pin file whose commit: is a tag's id, because ls-tree peels it. That file and COMMIT_RE live in scripts/repo_shape.py and the copied validator, which are pinned shape copies, and a project receives a change to them only through update-shape.py. After this PR, neither tool writes such a pin. A hand-edited one is still the validator's to find.

  • AGENTS.md still says a pin needs "a full 40-character commit — a tag can be moved and a commit cannot", and both tools' --pin help asks for openGlass@<40 hex>. Both stay true of a tag name. Saying that a tag object's own id is peeled, as bump-leg.py --to's help does, would change that help and regenerate docs/cli.md, and is left for a docs pass.

Known limits

  • The forge question was run against github.com once, read-only, by the reviewer, with the query exactly as the code holds it (GH_OBJECT_QUERY): gh api graphql -f query=… -f owner=opensoft -f name=openRepoShape -f oid=cc96c67d2e04e4833043c2153b1d478078a82c6e, the annotated tag v1.0.0. It exited 0 and answered {"data":{"repository":{"object":{"__typename":"Tag","target":{"__typename":"Commit","oid":"bfed143e89f97d3480cf5373051cb1ace82db312"}}}}}, the commit git rev-parse v1.0.0^{} names, and that answer, replayed through a stub, peels in both tools. How gh exits on a GraphQL error (a missing repository, a rate limit) is as documented, not measured here; replayed through a stub, each such exit, and each malformed answer, is pin-unreadable with no traceback.
  • check asks nothing of a pin whose digest gh api read. It reads no network, so a plan recording a tag's id with digest_source: gh-api-tree-recursive gets the existing NOTE that its digest was not rechecked. The same holds where the recorded clone is gone or is a partial clone.
  • The forge path makes one more gh call per pin, two for a tag of a tag. Its failures are the existing gh-not-found and pin-unreadable, in the same words.

Closes #651

🤖 Generated with Claude Code

Summary by Sourcery

Resolve each pin ID to a commit before recording or validating it, while consolidating related pin-file findings.

New Features:

  • Resolve pinned object IDs to the commits they name, peeling annotated tags and rejecting trees, blobs, and tags that do not name commits.
  • Validate recorded pin IDs during check and report plans whose pins do not identify commits.

Bug Fixes:

  • Prevent pin files and plans from recording annotated tag, tree, or blob IDs as commits.
  • Ensure forge-backed pin resolution reports unreadable or missing objects consistently before attempting to read digests.

Enhancements:

  • Deduplicate pin-file path findings and avoid duplicate root findings when a shape pin and its copy are both retained.
  • Reuse the shared Git configuration constant when detecting partial clones.

Tests:

  • Add coverage for annotated tags, nested tags, non-commit objects, forge resolution, scaffold execution, and rechecking legacy plans.
  • Update forge stubs and collision tests for the preliminary GraphQL object-type query.

Brett Heap and others added 2 commits October 16, 2026 12:16
…ed tag's own id pins the commit the tag names, and one naming a tree or a blob is refused, so a pin file no longer records a tag's id under "A COMMIT, NEVER A TAG" (#651)

`declared_pin_values` (scripts/shape_materialize.py), which both tools
read a `--pin` through, now asks what the id names before it reads the
digest: `git cat-file -t` in the `--pin-source` clone, or, with none,
the forge's GraphQL `object(oid:)`. An annotated tag's own id, or a tag
of a tag, is peeled to the commit it names, as `bump-leg.py --to` (#534)
and `family.py add --at` and `bump --to` (#541) peel one, and one line
says so; a tree, a blob or a tag of either is refused
`pin-not-a-commit`. `check` asks the clone `plan` read a digest from the
same question, so a recorded id that is no commit is
`plan-pin-not-a-commit`, and `execute` refuses it before any leg.

Riders from #457: `_pin_files` names each pin file once (L1-06); a kept
shape pin is one finding, not also `plan-root-blocks-shape-copy` for
its copy (L1-07); `_a_partial_clone` uses `GIT_CONFIG` (L1-05); and a
test docstring no longer says `place` finds a case twin on every disk
(L1-63).

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ons.py and test_pin_source_env_collisions.py: each control that reaches `gh` after a refusal asserts its one call is the read-only GraphQL query #651 asks first, so the leg-path control no longer expects the tree read first (#651)

The targeted runs at e731b66, in both modes, failed one test each, the
same: `test_no_gh_command_runs_before_the_refusal` in
tests/test_scaffold_leg_path_collisions.py, whose control asserted that
the first stub-`gh` call starts `api repos/opensoft/openGlass`. Since
#651 the first call is the forge's GraphQL `object(oid:)` question. Its
refused run is unchanged: no `gh` at all before the refusal. Its control
now asserts the stub's whole log is that one read-only query, which the
stub refuses, so no other `gh` command runs. The two controls e731b66
changed (test_scaffold_pin_collisions.py, test_pin_source_env_collisions.py)
assert the same, exactly, through `asked_what` (tests/test_adopt_pins.py),
where they matched only the end of the first call.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Oct 16, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR makes pin IDs resolve to immutable commits before digesting: annotated tag IDs are peeled through tag chains, non-commit objects are rejected, and legacy plans are diagnosed during check. It also deduplicates related pin-file collision findings and expands local/forge and scaffold/adoption test coverage.

Sequence diagram for pin ID resolution and digesting

sequenceDiagram
    participant User
    participant Tool as adopt-project_or_scaffold
    participant Pins as declared_pin_values
    participant Source as LocalClone_or_Forge
    participant Digest as DigestReader

    User->>Tool: --pin product@object_id
    Tool->>Pins: _pinned_commit(args, raw, repository, typed)
    Pins->>Source: Identify object kind
    alt annotated tag
        Source-->>Pins: Tag target commit
        Pins-->>User: Print peeled commit message
    else commit
        Source-->>Pins: Commit ID
    else tree, blob, or tag of non-commit
        Source-->>Pins: Non-commit object
        Pins-->>Tool: Refusal pin-not-a-commit
    end
    Pins->>Digest: Read digest for resolved commit
    Digest-->>Tool: Digest and recorded commit
Loading

Sequence diagram for legacy plan validation

sequenceDiagram
    participant User
    participant Check as adopt-project_check
    participant Finding as _recomputed_pin_finding
    participant Clone as RecordedClone
    participant Execute as execute

    User->>Check: check plan
    Check->>Finding: Validate recorded commit ID
    Finding->>Clone: commit_in_clone(commit)
    alt annotated tag
        Clone-->>Finding: Tag naming commit
        Finding-->>Check: plan-pin-not-a-commit finding
    else tree, blob, or tag of non-commit
        Clone-->>Finding: Non-commit object
        Finding-->>Check: plan-pin-not-a-commit finding
    else commit
        Clone-->>Finding: Commit ID
        Finding->>Clone: Recompute pin digest
        Clone-->>Finding: Digest
        Finding-->>Check: Digest result
    end
    Check-->>Execute: Refuse execution when finding remains
Loading

File-Level Changes

Change Details Files
Resolve pin object IDs before computing digests, peeling annotated tags to commits and rejecting non-commit objects consistently across local and forge-backed flows.
  • Added local git cat-file/rev-parse resolution and GitHub GraphQL object-type resolution, including nested annotated tags.
  • Records the peeled commit and emits an explanatory stdout line; refuses trees, blobs, and tags of either with pin-not-a-commit.
  • Centralized forge error handling while preserving existing gh-not-found and pin-unreadable behavior.
  • Updated shared pin processing so both adopt-project.py plan and scaffold dry-run/real execution use the same resolution path.
scripts/shape_materialize.py
adopt-project.py
Validate recorded plan pins against the source clone before digest recomputation and execution.
  • Added plan-pin-not-a-commit findings for recorded tags, trees, blobs, and invalid annotated-tag targets.
  • Ensures execute refuses affected plans before creating legs while allowing legacy tag IDs to be diagnosed with their named commit.
adopt-project.py
Deduplicate pin-file collision findings and avoid reporting the shape-pin copy as a separate root conflict.
  • Keyed generated pin-file paths by path so each kept file is reported once.
  • Suppresses the shape-copy finding when the root already holds the shape pin itself.
  • Reused GIT_CONFIG for partial-clone detection and clarified related test documentation.
adopt-project.py
tests/test_adopt_shape_pin_and_work_dir.py
Added comprehensive coverage for tag peeling, invalid object rejection, forge resolution, legacy-plan checks, and collision reporting.
  • Added local-clone and stubbed-forge tests for commits, annotated tags, tag chains, trees, blobs, and tags of trees.
  • Verified scaffold dry-run and real pin-file output, check findings, and pre-leg execution refusal.
  • Updated forge-call assertions to account for the new GraphQL object query.
tests/test_pin_annotated_tag.py
tests/test_adopt_pins.py
tests/test_adopt_shape_pin_and_work_dir.py
tests/test_pin_source_env_collisions.py
tests/test_scaffold_leg_path_collisions.py
tests/test_scaffold_pin_collisions.py

Assessment against linked issues

Issue Objective Addressed Explanation
#651 Ensure adopt-project.py plan and scaffold-project.py --pin do not record an annotated tag’s object ID as a commit: peel annotated tags to the commit they name, and refuse IDs that do not resolve to a commit. ✅
#651 Have adopt-project.py check revalidate recorded pin IDs against the clone used to read the digest, and report/refuse recorded tags, trees, or blobs rather than treating them as commits. ✅

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

@sourcery-ai

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

@sonarqubecloud

Copy link
Copy Markdown

@brettheap
brettheap merged commit 2d98820 into main Oct 16, 2026
5 checks passed
@brettheap
brettheap deleted the fix/651-adopt-annotated-tag-pin branch October 16, 2026 19:18
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]>
brettheap added a commit that referenced this pull request Oct 17, 2026
…efusals and `family-operation-in-progress` name a path as `shown_source` names it, so an ESC or a line break in a path no longer reaches the terminal (#692) (#731)

#622's folder refusals printed a path as it was. `family.py init --into <a file named wd-ESC[31mRED> --dry-run` gave `REFUSED family-folder-cannot-be-made: the family folder .../wd-^[[31mRED/Orbit cannot be made: ...` through `cat -v`. A name with a line break and then `WARNING forged-line: pwned` printed that line as a line of its own. R612's `family-operation-in-progress` printed the mark's path across two lines for a holder whose path holds a newline.

Each path is now spelled as `shape_materialize.shown_source` spells a `--pin-source`: as it is, and as Python's `repr` spells it where a character in it is not printable.

- `scripts/shape_materialize.py`: both answers of `folder_cannot_be_made` (a file or a bad stat in the way, and a folder this user cannot write in), the folder in `refuse_unmakeable_folder`, and the folder in `make_folder`.
- `scaffold-project.py`: `scaffold-target-exists`.
- `scripts/family.py`: `family-target-exists`, and the mark's path in `family-operation-in-progress` (`where.as_posix()`).

A printable path is named byte for byte, so no existing row changes and `why.endswith(CANNOT_WRITE_IN)` in `refuse_unmakeable_folder` still holds. No help text changed, so `docs/cli.md` is untouched. No README, handbook or template sentence says how a refusal names a path (`git grep` of `shown_source`, `target-exists` and `folder-cannot-be-made` in AGENTS.md, README.md, `docs/handbook.html` and the templates found none), so no doc changes.

- **`shown_source`, not `shown_path`.** Since #634, `shape_materialize.shown_source` returns `repo_shape.shown_path(source)` (`scripts/shape_materialize.py`: `return shown_path(source)`), so the seven call sites this change adds (four in `shape_materialize.py`, one in `scaffold-project.py` and two in `family.py`) spell a path as `shown_path` does. Renaming them to `shown_path` stays out of this PR: it would only move imports in `scaffold-project.py` and `family.py` and reword docstrings in `family.py`, `shape_materialize.py` and the test file, and the review's N1 left it optional. I did not take it. The predicted merge with main works with the alias: `family.py --help` and `scaffold-project.py --help` exit 0 on it, and `shown_source` and `shown_path` return the same string for an ESC name, a line-break name and a plain path.
- **`shown_source` is imported by name into each file's existing `from shape_materialize import (...)` block.** The first commit put it on a line of its own after the block; lane 4's #660, #688 and #693 add an import at that same place, and `merge-tree` reported add/add conflicts in `scripts/family.py` and `scaffold-project.py`. The second commit moves the name into the block, and those conflicts are gone.
- **"The holder in the other refusals of the same block" is one refusal.** The `# What the holder is in the middle of, and what its sparse checkout leaves out` block holds `family-operation-in-progress`, `family-sparse-excluded` and `member-path-unaddable`. Only the first prints a path of the holder's. `family-sparse-excluded` names `members/<Project>` and `.gitmodules`, and `member-path-unaddable` names `members/<Project>`.
- **No scaffold row for `--local-remote-dir`.** A control character there is refused earlier as `scaffold-unwritable-value`, which already names the path with `repr`. The unit test covers `make_folder`, which only a race reaches by the command line.

`tests/test_dry_run_parity.py`:
- `SCAFFOLD_CASES` gains five rows: ESC and line break in the `--work-dir` name, ESC in a folder name above it, and ESC and line break in a work dir that holds a file named `Atlas` (`scaffold-target-exists`).
- `FAMILY_CASES` gains five rows: ESC and line break in `--work-dir`, ESC in `--into` (`the family folder`), and ESC and line break in a work dir that holds a file named `Orbit` (`family-target-exists`).
- Two rows join `UNWRITABLE_FOLDER_AT` (ESC in the scaffold's and in `init`'s `--work-dir`, a folder this user cannot write in).
- Rows named `ESC-...` and `line-break-...` are skipped on Windows, whose file names cannot hold them (`POSIX_NAMES`, `case_params`). Every expectation spells the path with `repr`, and not with `shown_source`.
- `assert_refused` now fails any stderr line that starts with `WARNING forged-line`.
- Three unit tests: `test_each_folder_question_spells_a_name_that_is_not_printable` (ESC, line break; `folder_cannot_be_made`, `refuse_unmakeable_folder` and `make_folder` by themselves), `test_a_folder_this_user_cannot_write_in_is_spelled_safe_to_show`, and `test_a_printable_name_is_named_byte_for_byte` (a name with a space and an accented letter stays unquoted).

`tests/test_family_refuse_up_front.py`: `test_a_holder_path_with_a_newline_still_shows_its_merge` asserted the raw newline in the refusal (`"Ink\nRouter/.git/worktrees/" in ran.stderr`). It is now `test_a_holder_path_with_a_control_character_still_shows_its_merge`, over a line break, an ESC and a forged line, and asserts the one-line `repr` form (`refusal()` fails unless the stderr is two lines). It is the one existing test this change had to edit.

Results at head `ab55c29f` (Python 3.12.3, Linux):
- `tests/test_dry_run_parity.py tests/test_dry_run_asks_remotes.py tests/test_family_dry_run.py tests/test_family_init_landing.py tests/test_repo_hygiene.py tests/test_pin_source_unreadable.py tests/test_scaffold_leg_path_collisions.py tests/test_scaffold_reuse_seeded_legs.py`: **494 passed**.
- `tests/test_family.py tests/test_family_refuse_up_front.py tests/test_family_init_values.py tests/test_family_add_refusals.py`: **356 passed, 19 skipped** (the skips are `test_family_init_values.py:219` and `:291`, template-quoting premises).
- Not run: the full suite (the coordinator's gate), and macOS and Windows (CI is Linux-only since #597). The new hostile-name rows are POSIX only by design.

On the base code: the review overlaid this head's two test files on main `2fac9790` and ran `tests/test_dry_run_parity.py` and `tests/test_family_refuse_up_front.py` with `-k "dry_run_parity or control_character"`. The result is **20 failed, 87 passed** (76 deselected, 43.5 s). The 20 are exactly the new and edited tests: the 5 scaffold and 5 `init` rows, the 4 unwritable-folder rows, the 3 unit tests (`test_each_folder_question_spells_a_name_that_is_not_printable` in two cases, and `test_a_folder_this_user_cannot_write_in_is_spelled_safe_to_show`), and the 3 cases of the edited `test_a_holder_path_with_a_control_character_still_shows_its_merge`. The one new test that passes on main's code is `test_a_printable_name_is_named_byte_for_byte`, by design: a printable name is named byte for byte on both. An earlier draft of this body said 21 failed, 2 passed. That run was on `8062810d` with a wider selection, and it held a scaffold row for ESC in the local remote dir's name (`ESC-in-the-local-remote-dir-name`) that this head's tests no longer have; its second pass was the existing `test_the_refusal_quotes_gh_s_first_line_and_escapes_what_is_unprintable`, which also passes in the new run, one of the 87.

`family.py init` and `scaffold-project.py --dry-run` against a file named `wd-ESC[31mRED`, a file named `wd-\nWARNING forged-line: pwned`, and a work dir with a file `Atlas` or `Orbit` in it, run with a stub `gh` and no real `gh`:
- On main, through `cat -v`: `... the family folder /.../wd-^[[31mRED/Orbit cannot be made: /.../wd-^[[31mRED is a file, not a folder`, and a stderr line `WARNING forged-line: pwned cannot be made: ...` of its own.
- On this head: `REFUSED family-folder-cannot-be-made: the family folder '.../wd-\x1b[31mRED/Orbit' cannot be made: '.../wd-\x1b[31mRED' is a file, not a folder`, and one line for the forged name: `--work-dir '.../wd-\nWARNING forged-line: pwned' cannot be made: '...' is a file, not a folder`. `scaffold-target-exists` and `family-target-exists` are one line each in the same form.

Each spelled site reverted alone in a throwaway clone at `19d126cd` (the call sites are the same at `ab55c29f`); the new tests that fail for each:
- `folder_cannot_be_made`, the `_not_a_folder` answer: 8 failed (six CLI rows and the two unit tests).
- `folder_cannot_be_made`, the `CANNOT_WRITE_IN` answer: 5 failed (the four unwritable rows and the unit test).
- `refuse_unmakeable_folder`: 12 failed.
- `make_folder`: 2 failed (the unit test only).
- `scaffold-target-exists`: 2 failed (its two rows).
- `family-target-exists`: 2 failed (its two rows).
- `family-operation-in-progress`: 3 failed (line break, ESC, forged line).

`git merge-tree --write-tree` of this head `ab55c29f` against origin/main `20c8873b` and against every ref on origin that could meet it, fetched 2026-10-16: the 41 branches (`fix/*`, `l3-*`, `wip/*`, `docs/*` and `release/v1.0`) and the 55 PR heads from #630 up. That is 96 refs. (The same list was run for #730's head `7f2bb36b`.)
- **origin/main `20c8873b`: clean** (the predicted tree `00b5b24c`, which differs from main in these five files only: 216 lines added, 25 removed).
- **#630's head `6fd33a93`: clean.** It conflicted with main in `docs/handbook.html` when this body was first drafted, and no longer does, with or without this change. This change touches no README or handbook.
- **The refs that edit one of this change's five files**, and so could meet it, all merge clean with this head: `fix/646`, `fix/651`, `fix/654`, `fix/660`, `fix/661`, `fix/684`, `fix/686`, `fix/688`, `fix/689` and `fix/693`, the heads of #670, #725, #728, #743 and #744, and the heads of the landed #634, #638, #639, #640, #643 and #671. #634 has landed (`30676c90`), so the `fix/660` note about a conflict with it is gone.
- **Four refs conflict with origin/main on their own**, and so with this head: `docs/release-notes-v1.0.0` and `release/v1.0`, and the pre-squash heads of the landed #637 and #641. Their conflicts do not come from this change. Every other ref, 92 of the 96 in all, is clean with this head, including the refs that conflict with main in `templates/family-root/scripts/validate-family.py` (#682, #745, #747, `fix/648`, `fix/681`, `fix/704`) or in `shape-doctor.py` (#742, `l3-683`) on their own. So do the old heads of the landed #638 and #639, and lane 3's `l3-677-pins-hand-step-wip` branch, and each of them merges clean with this head too.
- **Tests on the predicted merge**, run by the review on the merge with main `2fac9790`: `test_dry_run_parity`, `test_family_refuse_up_front`, `test_pinned_copy_text`, `test_pin_source_unreadable`, `test_dry_run_asks_remotes`, `test_family_dry_run` and `test_family_init_landing`: 445 passed in 215 s. `test_family`, `test_family_init_values`, `test_family_add_refusals`, `test_derived_id_refusals`, `test_repo_hygiene`, `test_naming_policy`, `test_scaffold_leg_path_collisions` and `test_scaffold_reuse_seeded_legs`: 758 passed, 19 skipped in 243 s. I did not re-run them on `20c8873b`; the merge is clean, and the two commits since `2fac9790` (#700 and #702) change only `shape-doctor.py`, `templates/assembly-root/scripts/validate-pins.py` and four test files, none of them a file of this change.
- Before the second commit, `fix/660`, `fix/688` and `fix/693` each conflicted with this head in the import region of `scripts/family.py` or `scaffold-project.py` (a separate import line each side added at the same place). That is why the import joins the existing block.

#634 is on main, and this change does not edit `shown_source` or its docstring in `scripts/shape_materialize.py`.

The review approved with nits. Its S1, the stale base-run numbers and merge lines, is taken here, in this body: no code changed, and the head is still `ab55c29f`. Its N1, renaming the call sites to `shown_path`, is not taken (see "Decisions and their evidence"). It also re-ran 5 of the 7 mutation probes on `ab55c29f` and got the same failure counts as above (12, 2, 3, 2 and 2), and ran 144 hostile-name dry runs (16 names in 9 scenarios): on main 69 rows put a control character on stderr and 6 print a forged line of their own; on this head all 144 exit 2 with no traceback, no control character and no forged line.

- `scripts/family.py` `init`'s plan prints `folder` and `landing` lines with the path raw (`print(f"landing      {holder}   ...")`, `print(f"folder       {folder}   ...")`). On a dry run or a refused run the plan is on stdout before the refusal, so `WARNING forged-line: pwned/Orbit   (--work-dir: no family folder)` still appears there. It is the plan, not a refusal, and not one of the issue's lines.
- Other refusals that name a holder or folder path raw, none of them in the issue's lines: `family-holder-detached` and `family-on-tracking-branch` (`{family.root}`), `family-index-locked` (`lock.as_posix()` in the detail), `family-landing-in-standard` (`{holder}`, `{checkout}`, `{beside / family / family}`), `family-holder-already-here` (`{into}`), and `family-remote-exists` and `scaffold-remote-exists` (`{target}`, a local remote path).

1. **family.py `init`'s plan prints the holder and folder paths raw.** `scripts/family.py` `landing` and `folder` rows (about :1756-1759) print `holder` and `folder` as they are, so a forged line or an ESC reaches stdout in a `--dry-run` and in a run refused after the plan. Direction: spell them with `shown_source`.
2. **The same raw spelling in the refusals listed above.** `family-holder-detached`, `family-on-tracking-branch`, `family-index-locked`, `family-landing-in-standard`, `family-holder-already-here`, `family-remote-exists` and `scaffold-remote-exists` each print a path the person supplied or git keeps. Direction: the spelling this change gives its sites.

Review: rv692, lane 5's independent review, approved ab55c29 with nits, and its body fix (S1) is published. CI (Brett Heap's ruling 27 and his fast-refresh ruling of 2026-10-15T22:48:35Z): H0 ab55c29 passed tests, tests-git-bash and SonarCloud; the head 13f643d is a clean update-branch merge of main 431c8cf, with tests-git-bash and SonarCloud green; and the local gate passed on its predicted squash tree 4327947 over main 431c8cf: the dry_run_parity, family_refuse_up_front, repo_hygiene, agents_md_codes, cli_reference sets, 330 passed. Landed on Brett Heap's word of 2026-10-17T10:59:39Z, relayed by lane 3 on #473: "merge lane 5's approved v1.1.0 drafts".

Closes #692

Lane: openreposhape-5 (openRepoShape-5)
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