Skip to content

adopt-project.py: under a one-byte locale such as Latin-1, a clone check makes again for a plan's clone record that neither spelling names is compared with both, so it is kept and the next run reads it rather than cloning again (#1112) - #1153

Merged
brettheap merged 7 commits into
mainfrom
l3-1112-at-the-record-both-spellings
Nov 8, 2026

Conversation

@brettheap

@brettheap brettheap commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #1106: its base is #1106's branch. Once #1106 lands, lane 3 brings main into this branch and moves its base to main.

What changed

A follow-up outside v1.2.0 (Brett Heap, 2026-10-21T10:32:04Z). It lands only after the v1.2.0 tag, on a later merge word.

The bug (#1112). Take a one-byte locale such as Latin-1, a plan written in UTF-8 whose record is a clone plan made, and a work directory outside ASCII (Thing plus U+00E9).

The fix (adopt-project.py), following the issue's Direction:

  • A new helper, _recorded_paths(recorded). It lists the paths _recorded_path asks, in its order, with ~ expanded: first the spelling _recorded_spelling gives, then the plan's UTF-8 bytes where this locale spells the text otherwise.
  • _recorded_path now asks its paths through _recorded_paths. Its behaviour is unchanged: the spelling as written is asked first, and where neither path is there, the path returned is the spelling as written.
  • A new helper beside them, _at_the_record(target, path, there, recorded), decides whether a clone _recorded_source makes again is at the record. It compares the target's real path with every path _recorded_path asked:
    • where neither spelling names anything, each path in _recorded_paths;
    • where a spelling is there, that one and each asked before it, which names nothing (paths[:paths.index(path) + 1]).
  • _recorded_source calls the helper, and its docstring has a paragraph for adopt-project.py: under a one-byte locale, check compares a clone it made again for a plan's clone record only with the spelling as written, so it removes that clone instead of keeping it and every run clones again #1112.

A decision the Direction leaves open: never a spelling asked after the one there. The Direction says to compare with both spellings. Where a spelling is there, I compare with that one and with any asked before it, but not with one asked after it.

Tests (tests/test_adopt_one_byte_locale.py). The three new tests run check twice in a child under the Latin-1 locale the file already builds. A new gh stand-in clones a repository on disk.

Fix round

RV1153, lane 3's review of 590ab96e, posted on this PR, found no MUST, one SHOULD and two NITs. This round, ff33ba12, takes all three:

Measurements

Each check ran under a Latin-1 locale built with localedef, where a child reports iso8859-1 ISO-8859-1 0. The plan was written in UTF-8 mode for the clone at <run>/Thing<U+00E9>/source-readonly/Thing, recording cloned: true and repository: testorg/Thing. The clone was then moved away. Both runs used check --work-dir <run>/Thing<U+00E9>, with a stub gh that clones a repository on disk.

Code Run 1 Run 2
#1106's head 504a1dd6 exit 0, NOTE "no longer exists ... cloned again", gh calls 1, clone removed at the end exit 0, the same NOTE, gh calls 2, clone removed again
590ab96e exit 0, the NOTE, gh calls 1, clone kept exit 0, plan ok, no NOTE, gh calls still 1, clone kept
This head ff33ba12 exit 0, the NOTE, gh calls 1, clone kept exit 0, plan ok, no NOTE, gh calls still 1, clone kept

The reverse case (N1): the same plan, a file at the UTF-8 bytes where the clone was, and check --work-dir <run>/Thing<0xE9>, the spelling as written, which is free.

Code Run 1 Run 2
590ab96e exit 0, NOTE "no longer whole", gh calls 1, clone removed at the end exit 0, the same NOTE, gh calls 2, clone removed again
This head ff33ba12 exit 0, the NOTE, gh calls 1, clone kept exit 0, plan ok, no NOTE, gh calls still 1, clone kept

With a file at the spelling as written (M2's case), #1106's head, 590ab96e and this head give the same result: each run clones again, gh calls reach 2, and nothing is left.

Out of scope

#1112 has no "Needs a ruling" or "Documented limit" section. Nothing else was changed.

Tests

Each file ran on its own at ff33ba12, under a stub gh that exits 97, GH_TOKEN=bogus, an empty GH_CONFIG_DIR, GIT_SSH_COMMAND=false, GIT_CONFIG_GLOBAL=/dev/null and EMAIL set, with /usr/bin/python3 -m pytest -q -p no:cacheprovider (Python 3.12.3):

Test file Result
tests/test_adopt_one_byte_locale.py (-rs) 13 passed in 17.83s, none skipped
tests/test_adopt_unenterable_source_and_locale.py 13 passed in 10.15s
tests/test_adopt_c_locale_bytes.py 17 passed in 39.87s
tests/test_adopt_source_clone_record.py 100 passed in 38.11s
tests/test_scaffold_leg_path_collisions.py 104 passed in 4.84s
tests/test_repo_hygiene.py 100 passed in 2.82s
tests/test_shape_doctor.py 445 passed, 3 skipped in 767.13s (the counts of the run at 590ab96e)
tests/test_path_guard_hygiene.py, at the merge of this head into origin/main 038dafba 49 passed in 11.75s
tests/test_adopt_one_byte_locale.py (-rs), at that merge 13 passed in 17.43s, none skipped
tests/test_adopt_unenterable_source_and_locale.py, at that merge 13 passed in 9.02s

Mutants

Each mutant was applied to adopt-project.py, and tests/test_adopt_one_byte_locale.py was run. The file was then restored, and cmp found it identical.

Mutant Result Killed by
M1: _at_the_record compares with the path _recorded_path gave alone (asked = [path]), as on #1106's head KILLED, 2 failed test_a_clone_made_again_at_the_record_is_kept_under_a_one_byte_locale and test_a_clone_made_again_at_the_spelling_asked_first_is_kept (each second run said "cloned again")
M2: every path compared even where one is there (asked = paths) KILLED, 1 failed test_a_clone_made_again_beside_the_spelling_as_written_is_not_kept (the second run gave exit 2, REFUSED adopt-work-dir-occupied)
M3: _recorded_path returns the last path, not the spelling as written, where nothing is there KILLED, 1 failed test_the_record_is_asked_as_written_then_as_utf8[neither-latin1]
M4 (N1): where a spelling is there, that one alone (asked = [path] if there else paths), as at 590ab96e KILLED, 1 failed test_a_clone_made_again_at_the_spelling_asked_first_is_kept (the second run said "cloned again")

#1106's M4 (_keep_the_clone_at_the_record) is unchanged by this PR.

Merges

git merge-tree --write-tree at this head, ff33ba12:

Closes #1112

Lane: openreposhape-3 (openRepoShape-3)

🤖 Generated with Claude Code

Summary by Sourcery

Fix clone-record matching for non-UTF-8 locales so regenerated clones are retained and reused on subsequent checks.

Bug Fixes:

  • Prevent check from repeatedly recloning source repositories under one-byte locales by recognizing equivalent recorded path spellings when deciding whether a newly made clone is at the plan’s recorded location.

Enhancements:

  • Preserve the existing path-selection behavior while consistently handling both locale-specific and UTF-8 path representations, including occupied and previously queried spellings.

Tests:

  • Add Latin-1 integration coverage for retaining regenerated clones at the recorded path, removing clones beside an occupied spelling, and retaining clones at a spelling queried first.

Brett Heap and others added 3 commits October 21, 2026 11:05
…ads a plan written in UTF-8 whose source is there, asking the plan's UTF-8 bytes where the spelling as written names nothing, rather than refusing `plan-source-gone` (#1078)

Under a locale of one byte to a character, Latin-1 say, with
`PYTHONUTF8=0`, `os.fsencode` spells every character of a plan's
non-ASCII `source.local_path`, so #1072's `_recorded_spelling` asked the
path only as written: the e-acute of `Thing` + U+00E9 as the one byte
0xE9, where the name `plan` read in UTF-8 is 0xC3 0xA9. `check` refused
`plan-source-gone`, "names nothing that exists", of a source that is
there; recorded as a clone `plan` made, it "no longer exists" and `gh
repo clone` was asked.

`_recorded_path` now asks the spelling as written first and, where that
names nothing, the plan's UTF-8 bytes too. `_recorded_source` and
`_keep_the_clone_at_the_record` both ask it, so a clone `check --source`
made at the record is kept under Latin-1 as under C. Under C and POSIX
the lookup is #1072's, and every refusal's words are unchanged: where
neither spelling names anything, the path is the spelling as written.

The new tests build a Latin-1 locale with `localedef` from a charmap and
a locale source they write, and skip with localedef's words where none
can be built.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…source_and_locale.py: the clone at the record is asked under the C locale and Latin-1 through one helper, `kept_clones` (#1078)

SonarCloud counted the Latin-1 test's body as a 14-line copy of the C
test's: both built the record and a clone elsewhere, ran
`KEEP_THE_CLONE` in a child and parsed its answer. `kept_clones` does
that once, in the file that holds `KEEP_THE_CLONE`, and returns whether
the locale spells the record, the clones left and the one made
elsewhere. Each test keeps its own premise and its assert.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…heck` makes again for a plan's clone record that neither spelling names is compared with both spellings, so the clone at the plan's UTF-8 bytes is kept and the next run reads it rather than cloning again (#1112)

`_recorded_source` decided whether the clone it makes again is the plan's
record by comparing its target with the spelling as written alone. Under
Latin-1, a plan written in UTF-8 whose clone was in a work directory
outside ASCII was cloned again at the UTF-8 bytes `--work-dir` names, put
on the list of clones to remove, removed when `check` ended, and cloned
again by every run.

The new `_recorded_paths` lists the paths `_recorded_path` asks, in its
order, and `_recorded_path` now asks them through it. Where neither names
anything, the target's real path is compared with each of them. Where one
is there, the comparison is with that one alone, as before: a clone kept
beside a spelling as written that is there would be refused as
`adopt-work-dir-occupied` by the next run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Factor the recorded-path spellings into _recorded_paths, reuse that ordering in _recorded_path, and add _at_the_record so a recreated clone is retained when its real path matches a spelling _recorded_path asks, but not one asked after the spelling that is already there.

  • adopt-project.py L1949-1964, L1982-2012, L6852-6863 (+1 small edits)

Tests

Add Latin-1 regression coverage for retaining recreated clones at either spelling _recorded_path asks first, while confirming a clone beside an occupied spelling is not retained.

  • tests/test_adopt_one_byte_locale.py L22-28, L51-60, L261-378 (+2 small edits)

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-3, 2026-10-22T15:38:24Z) Lane 3's independent review of #1153 (RV1153), head 590ab96. PARTIAL: stopped at a usage checkpoint. No MUST so far.

SHOULD

  • S1. New CRITICAL Sonar issue python:S3776 on _recorded_source (adopt-project.py:6567), cognitive complexity 16 > 15, caused by the conditional at :6681. The gate still passes. Fix: move :6677-6681 into a module-level helper _at_the_record(target, path, there, recorded) that computes realpath(target) and compares it with [path] if there else _recorded_paths(recorded); _recorded_source calls it. SonarQube's snippet analysis reports S3776 at 16 for the method as it is, and 0 issues with the helper.

NIT

Checked

Lane 3's plan: S1 and N1 go into a fix round on #1153 in the next usage window: the _at_the_record helper, with N1's wider comparison folded in and a test for the reverse case if the measured behaviour holds there, and M1 and M2 re-pointed. N2: the Sourcery block comes off and #1154 joins the merge list. RV1153 then finishes test_shape_doctor.py and the merged-tree tests. #1153 lands only after #1106, after the v1.2.0 tag.

Lane: openreposhape-3 (openRepoShape-3)

…plan's UTF-8 bytes hold its clone no longer whole and `--work-dir` names the free spelling as written, the clone `check` makes again there is kept and the next run reads it, and the comparison moves into `_at_the_record` (#1112)

The fix round on #1153 from its review, RV1153:

- S1: the comparison of a clone made again with the record moves out of
  `Plan._recorded_source` into a module-level helper, `_at_the_record`,
  beside `_recorded_paths`, so the method's cognitive complexity falls
  from 16 back to 15 (SonarQube python:S3776).
- N1: the helper compares the clone's target with every path
  `_recorded_path` asked: where a spelling is there, that one and each
  asked before it, which names nothing. Under Latin-1, the UTF-8 bytes
  holding a file where the clone was and `--work-dir` naming the free
  byte 0xE9, the clone made at 0xE9 was removed when `check` ended and
  every run cloned it again; now it is kept and the next run reads it.
  A spelling asked after the one there is still not the record (M2's
  case, a file at 0xE9, is unchanged).
- A test of that reverse case: `check` run twice clones once and keeps
  the clone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@brettheap

Copy link
Copy Markdown
Contributor Author

(lane openRepoShape-3, 2026-10-22T19:46:27Z) Lane 3's independent review of #1153, delta round (RV1153), head ff33ba1. Verdict: READY. No new MUST or SHOULD.

Lane 3's plan: #1153 is READY. It lands only after #1106, which lands after the v1.2.0 tag on a later word. Then lane 3 brings main into this branch, moves its base to main, and lands it by the stacked-PR merges.

Lane: openreposhape-3 (openRepoShape-3)

This was referenced Oct 22, 2026
@brettheap brettheap added this to the v1.2.1 milestone Oct 23, 2026
This was referenced Oct 23, 2026
Brett Heap and others added 2 commits November 8, 2026 18:18
#1153 (for #1112) was stacked on PR #1106's branch. #1106 has landed on main as the squash 801a7d6, and its final head bd97901 is 504a1dd with main be21751 merged in by update-branch. This is the first of the estate's three stacked-PR merges: it brings that final head in, so the branch holds everything #1106 held at the end. #1153's own change is not touched.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…anch's side of #1106's files

#1106 landed on main as the squash 801a7d6. This branch already holds #1106's change, through its final head bd97901, so where a hunk conflicts in adopt-project.py or tests/test_adopt_one_byte_locale.py (two of #1106's three files; the third, tests/test_adopt_unenterable_source_and_locale.py, merged clean) this merge takes this branch's side (-X ours), which is #1106's change plus #1153's. Every other hunk of main comes in as main has it. This is the second of the estate's three stacked-PR merges; it makes the branch a descendant of main again, so the pull request shows only #1153's own change.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@sonarqubecloud

sonarqubecloud Bot commented Nov 8, 2026

Copy link
Copy Markdown

@brettheap
brettheap marked this pull request as ready for review November 8, 2026 20:46
@sourcery-ai

sourcery-ai Bot commented Nov 8, 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 6 days by commenting @sourcery-ai review. Upgrade to get a review now.

@brettheap
brettheap merged commit 27397a4 into main Nov 8, 2026
5 checks passed
@brettheap
brettheap deleted the l3-1112-at-the-record-both-spellings branch November 8, 2026 20:46
brettheap added a commit that referenced this pull request Nov 9, 2026
…encode, so it passes under Latin-1 where it ended in a traceback, and 45 rows in 11 test files that cannot judge under a one-byte locale skip there on their own premise (#1214) (#1258)

## Goal

#1214 counts 50 tests in 12 files that fail under a Latin-1 locale before and after #1209, and asks of each whether it is a test that cannot judge under a one-byte locale, or a tool that misbehaves there. All 50 are settled here:

- **3 are a tool defect, fixed:** a family holder's `scripts/validate-family.py` ended in a `UnicodeEncodeError` traceback, exit 1, on any stdout that cannot hold U+2026, when the holder passed.
- **45 cannot judge under Latin-1,** and now skip there on their own premise, which the skip reason states. 18 fail in the test process itself, before the tool runs. In the other 27 the tool answers rightly for the bytes Latin-1 gives, and the row expects UTF-8's.
- **2 judge under Latin-1 as they are written, and carry no guard:** `test_a_utf8_source_directory_still_adopts_with_local_remotes` (it passes with the pip-installed git-filter-repo, and fails with a `python -E` one on #1247's tool defect; see "Left") and `test_surrogateescape_reads_the_issues_branch_as_caf_and_u_dce9` (its `if` asks the one thing its assertion needs). Both came out of RV1258's review of the first commit.

Under Latin-1 with the pip-installed git-filter-repo, none of the 50 fails on this head. Under UTF-8 every row keeps its outcome, and the rows added pass.

The classification is W1214's: lane 4's first writer of #1214, who read each test's code and stopped at a checkpoint with half the guards written and nothing run. This branch finishes the guards, runs every gate below, and measures each row. RV1258 reviewed the first commit; the second answers it (next section).

## The second commit

RV1258 reviewed the first commit, `c8641c691` (NOT READY: two SHOULDs, three NITs, no MUST; #1258 (comment)). The second commit, `cd9f3cfd1`, answers it on top of the first, with no rebase. It changes four test files and no tool:

- **S1, a premise guard on a row that passes:** the guard on `test_a_utf8_source_directory_still_adopts_with_local_remotes` is gone, and so is the `A_NAME_HELD_AS_UTF_8` import it alone used in `tests/test_adopt_template_values.py`.
  - The guard skipped a row that passes: on main under Latin-1, with CI's pip-installed git-filter-repo, the row passes. Its skip reason (the tool "names it as" a name that is not UTF-8) was false for it, because `execute` adopts the source.
  - The row now runs under Latin-1 and passes with the pip launcher. With a launcher started as `python -E` it fails on #1247's tool defect (git-filter-repo's `UnicodeEncodeError` on U+FFFD) until #1251 lands. That is a failure of the tool, and #1214's rule sends such a row to an issue of its own, not to a skip.
  - **#1258 and #1251 are now independent of each other.** This PR carries no guard for #1251 to drop, so the earlier plan, that whichever of the two lands second drops this PR's guard, is void. Neither waits for the other.
- **S2, nothing CI runs held the helper's answers:** `tests/test_non_utf8_name_helpers.py` gets 20 rows, written as that file writes its Windows rows: `os.fsencode`, `os.fsdecode` and `sys.getfilesystemencoding` are replaced for one test by UTF-8, Latin-1 and ASCII as POSIX has them.
  - 15 rows (five texts, three locales) hold which question skips the text (none, "cannot spell", "writes" or "reads"), and that the reason names the encoding, ends with the row's premise, and is ASCII.
  - 5 rows hold the emulation to this run's real locale: the helper answers the same with the real `os` as with the emulation of its file system encoding.
  - RV1258's mutant A5 (UTF-8 bytes built with `surrogatepass` instead of `surrogateescape`) now fails 3 rows under CI's UTF-8 locale; before, it made 11 rows skip silently. The mutants that survived, A1, A2 and A4, now fail 5, 1 and 6 rows (see the mutants below).
- **N1:** the first-statement row of `tests/test_bootstrap_spelling.py` also reads `templates/family-root/scripts/validate-family.py`, so RV1258's mutant D3 (the `escape_unencodable_stdout()` call moved after `parse_args`) fails it.
- **N3:** `test_surrogateescape_reads_the_issues_branch_as_caf_and_u_dce9` no longer asks the helper. Its `if` also asks `os.fsdecode(b"\xe9") == chr(0xDCE9)`, so under Latin-1 the row runs its first assertion and passes where it skipped, and under UTF-8 and ASCII it asserts as before.
- **N2, known and left:** under emulated Windows codecs the helper skips the U+DCE9 rows that carry no Windows mark, with a premise that is false on Windows. That is reasoned and emulated, not run on Windows, and CI runs Linux only (#597).

## The 50, by file

Kinds:
- **a1:** the test process itself cannot make or pass the name under Latin-1, so it raises `UnicodeEncodeError` before the tool runs. Guard: the existing `skip_where_the_environment_cannot_carry`.
- **a2:** the tool runs and answers rightly for the bytes Latin-1 gives, and the row expects UTF-8's reading or spelling. Guard: the new `skip_where_the_locale_does_not_spell_it_as_utf_8(text, premise)`, asked only of the text the row's premise is about.
- **b:** a tool defect.
- **c:** the row judges under Latin-1 as it is written, and runs there with no guard.

`test_stdout_encoding.py` comes first, as #1214 asks. 18 a1 + 27 a2 + 3 b + 2 c = 50.

| File | Rows | Kind | Why it fails under Latin-1 | Guard |
|---|---|---|---|---|
| `tests/test_stdout_encoding.py` | 10: `test_plan_reports_every_name_whatever_its_stdout_can_encode` (3), `test_plan_on_the_posix_default_stdout`, `test_every_tool_exits_alike_whatever_its_stdout_can_encode` (6) | a1 | The test makes a file or directory named U+65E5 U+672C, or passes that name on a command line, and Latin-1 cannot encode it. | `skip_where_the_environment_cannot_carry`, in `plan_arguments` and in each of the six builders. (`bump-leg-dry-run` writes the name as bytes and passes, so it has none.) |
| `tests/test_adopt_pins.py` | 5 `[zwj]` rows | a1 | U+200D cannot go on the command line, or through `copytree`. | `skip_where_the_environment_cannot_carry(name)` |
| `tests/test_adopt_pins.py` | 4 `[not-utf-8...]` rows | a2 | The byte 0xFF is read as U+00FF, printable text the tool takes, so `plan` goes on where UTF-8 gives U+DCFF and a refusal. | `A_BYTE_READ_AS_A_SURROGATE`, where the name holds U+DCFF |
| `tests/test_adopt_pins.py` | 5 rows that compare a `pin` or `write` line | a2 | A Latin-1 stdout has no U+2026, so the tool prints the digest's ellipsis as `\u2026`, as #214 designed. | `PRINTED_AS_ITSELF`, just before the line is compared |
| `tests/test_pin_source_unreadable.py` | 3 `[not-ascii-*]` | a1 | The path U+65E5 U+672C `-missing` cannot go on the command line. | `skip_where_the_environment_cannot_carry` |
| `tests/test_pin_source_unreadable.py` | 3 `[not-utf-8-*]` | a2 | `miss<0xFF>ing` reaches the tool as text, and is printed as itself, not as `\udcff`. | `A_BYTE_READ_AS_A_SURROGATE` |
| `tests/test_family_tracking_branch.py` | `test_each_act_refuses_the_tracking_branch_then_lands_on_a_branch` `[add]`, `[bump]`, `[remove]` | **b** | Each act passes until `validate(holder)`. The holder's `validate-family.py` prints `members/X: tree digest recomputes (<12 hex>...)`, ending in U+2026, and never escaped its stdout, so it ended in a traceback, exit 1. | none: the tool is changed |
| `tests/test_family_tracking_branch.py` | `test_a_branch_ending_in_a_no_break_space_is_pushed_as_itself` | a2 | `git switch -c feat<U+00A0>` writes the single byte 0xA0, so the branch is not UTF-8, and the tool rightly refuses it (#765). | `A_NAME_HELD_AS_UTF_8` |
| `tests/test_adopt_template_values.py` | the `--elected-by` and `--reference` rows of `test_plan_refuses_a_flag_no_file_can_hold` whose value holds U+DCE9, and `test_plan_and_check_say_the_same_sentence` | a2 | 0xE9 is read as U+00E9, text `plan` takes. | `A_BYTE_READ_AS_A_SURROGATE` (in the flag test, only where the value holds U+DCE9) |
| `tests/test_adopt_template_values.py` | `test_a_utf8_source_directory_still_adopts_with_local_remotes` | **c** | With the pip launcher it does not fail under Latin-1 on this head or on main: its `caf<U+00E9>` directory is the single byte 0xE9, and `execute` adopts the source all the same. It fails only where git-filter-repo is started as `python -E`, on #1247's tool defect (see "Left"), which is an issue of its own and not a premise to skip on. | none (a guard was here in the first commit, and RV1258's S1 took it out) |
| `tests/test_clone_url_bytes.py` | the 4 `[bidi-override-*]` rows | a2 | The directory is made from U+202E's UTF-8 bytes E2 80 AE. Latin-1 reads them as three characters, one of them the C1 control U+0080, so the tool rightly says "a control character". | `A_NAME_READ_AS_UTF_8`, in `skip_where_this_system_cannot_name` |
| `tests/test_bump_leg_branch_and_push_line.py` | 2 | a2 | The branches `feat<U+00A0>` and `main<U+00A0>` hold the single byte 0xA0. | `A_NAME_HELD_AS_UTF_8` |
| `tests/test_bootstrap_leg_moves.py` | 2 | a2 | `bootstrap.py` prints U+2014 escaped on a Latin-1 stdout. | `PRINTED_AS_ITSELF`, just before the assert |
| `tests/test_update_shape_apply_lines_and_headers.py` | 1 | a2 | The branch `feat<U+00A0>`. | `A_NAME_HELD_AS_UTF_8` |
| `tests/test_adopt_spelled_names.py` | 1 | a2 | The test writes `caf<U+00E9>.md` as 0xE9, so git holds a name that is not UTF-8, and the C-locale child prints `caf\udce9.md`, not `caf\xe9.md`. | `A_NAME_HELD_AS_UTF_8`, after its C-locale probe |
| `tests/test_family_member_branch_not_utf8.py` | `[trailing-no-break-space]` | a2 | `_member_head` reads the byte 0xA0 as U+DCA0, which is the branch git wrote. | `A_NAME_HELD_AS_UTF_8`, only where the branch is not `NOT_UTF_8_BRANCH`: `[not-utf8]` passes under Latin-1 and still runs there |
| `tests/test_family_head_by_hand_bytes.py` | 1 | **c** | Its `if`, `os.fsencode(chr(0xDCE9)) == b"\xe9"`, holds under Latin-1 too, and its assertion, `os.fsdecode(LATIN_1) == branch`, holds only where the locale reads 0xE9 as U+DCE9 (UTF-8, ASCII). Its first assertion holds in every locale. | none (RV1258's N3): the `if` also asks `os.fsdecode(b"\xe9") == chr(0xDCE9)`, so under Latin-1 the row runs its first assertion and passes |

## What changed, file by file

18 files: one tool, `tests/conftest.py`, and 16 test files.

- **`templates/family-root/scripts/validate-family.py`** (the tool):
  - `main`'s first statement is now `escape_unencodable_stdout()`, imported from `repo_shape`, as in `siblings.py` and both roots' `bootstrap.py` (#391, #454).
  - That call adds no version-skew risk. The function shipped in the same commit as `spelled` (ec4a7a0), which the file already imports, and it is not in `test_pinned_copy_text.py`'s `NEWER_THAN_A_KEPT_LIBRARY`.
  - The holder's shape-pin digests are written by `init`, so there is no static digest to move.
- **`tests/test_family.py`:** one new row, `test_the_gate_passes_on_a_stdout_that_cannot_hold_its_notes`. It runs the holder's gate with `PYTHONIOENCODING=latin-1` and expects exit 0, no traceback, and the two notes ending in `\u2026)`.
- **`tests/conftest.py`:**
  - The new helper, `skip_where_the_locale_does_not_spell_it_as_utf_8(text, premise)`, asks three questions, each through `os` at call time: whether `os.fsencode` can spell the text, whether it gives UTF-8's bytes, and whether `os.fsdecode` reads those bytes back as the text.
  - Four premise sentences go with it: `A_BYTE_READ_AS_A_SURROGATE`, `A_NAME_HELD_AS_UTF_8`, `PRINTED_AS_ITSELF` and `A_NAME_READ_AS_UTF_8`. Every skip reason is ASCII.
  - It is never asked inside `skip_where_a_name_cannot_be_not_utf_8`. A branch whose bytes are not UTF-8 is one in every locale, so those rows still judge under Latin-1, and this takes none of #1224's N1 over-skip.
- **The 11 files with guards** are the files of the table above that name a guard. Each guard sits just before the first line that needs its premise. `tests/test_family_head_by_hand_bytes.py` has none: its `if` is narrowed (N3).
- **`tests/test_non_utf8_name_helpers.py`** (the second commit): 20 rows hold `skip_where_the_locale_does_not_spell_it_as_utf_8` under emulated UTF-8, Latin-1 and ASCII (S2, above).
- **`tests/test_bootstrap_spelling.py`** (the second commit): the first-statement row takes `validate-family.py` as a third file (N1).
- **`tests/test_non_utf8_name_callers.py`:** `windows_names_it` now emulates Windows' `os.fsdecode` too (UTF-8 with `surrogatepass`, `windows_fsdecode`).
  - Without it, the bidi guard in `skip_where_this_system_cannot_name` asked this run's real Latin-1 `os.fsdecode` under an emulated Windows.
  - Measured: `test_where_windows_holds_a_bidi_override_the_name_check_does_not_skip` then failed under Latin-1 (1 failed, 35 passed), where it passes on main. With the emulation, the file gives 36 passed in both locales.
  - Real Windows reads UTF-8 in every locale, which is what that row's own reasoning ("NTFS holds U+202E, so the `bidi-override` row ... runs on Windows as it does here") assumes.

## Runs

**Environment.** One runner for every run: `/usr/bin/python3 -m pytest -p no:cacheprovider` (Python 3.12.3).
- A stub `gh` first on PATH, a bogus `GH_TOKEN` and an empty `GH_CONFIG_DIR`.
- `GIT_CONFIG_GLOBAL` an empty file, `GIT_CONFIG_NOSYSTEM=1`, the test identity, and `EMAIL` set.
- `GIT_ALLOW_PROTOCOL`, `GIT_SSH_COMMAND` and the `LANES_*` variables unset.
- **Every run counted here had git-filter-repo 2.47.0 on PATH** (`git filter-repo --version`: `a40bce548d2c`, CI's pin, pip-installed in a venv). An earlier pair of head runs without it skipped 58 adoption rows, and is not counted.
- That git-filter-repo's launcher is the pip one, with no `python -E`, so a test's own `PYTHONIOENCODING` reaches it. The `-E` comparison is the last paragraph of this section.

**Locales.**
- UTF-8: `LC_ALL=C.UTF-8`.
- Latin-1: built with `localedef -c`, as #1153's `test_adopt_one_byte_locale.py` builds one; then `LOCPATH`, `LC_ALL=en_US.ISO-8859-1`, `PYTHONUTF8=0`. Python reports `iso8859-1` and reads 0xFF as U+00FF.
- ASCII: `LC_ALL=C PYTHONUTF8=0 PYTHONCOERCECLOCALE=0`.

**Round one's gate** (the first commit, `c8641c691`, on main `bd3e9c148`, 27 files, F1214's runs): UTF-8 1520 passed and 1 skipped on main, 1521 and 1 on the head; Latin-1 123 failed, 1373 passed, 25 skipped on main, and 44 failed, 1404 passed, 74 skipped on the head. RV1258 re-ran it on 35 files (main `5926ccca`, merge `103ada82`) and got the same transitions. The gate below replaces it.

**The gate: 29 files, on a scratch merge.** The merge is this head (`cd9f3cfd1`) into `origin/main` `46fe6ac19` (local, never pushed, clean); the baseline is `46fe6ac19` itself. Both with the pip launcher.
- The 27 files of round one: the 23 files on main that use `skip_where_a_name_cannot_be_not_utf_8` or `on_a_branch_that_is_not_utf_8`, with `test_repo_hygiene.py` (W1196's 24, less the two files #1209 adds, plus `test_family_leg_path_by_hand_bytes.py`), and four more that run the changed code: `test_family.py`, `test_pinned_copy_text.py`, `test_update_shape_kept_helper.py` and `test_local_remote_dir_urls.py`. They include `test_non_utf8_name_helpers.py`.
- Two more for the second commit: `test_path_guard_hygiene.py` (the second hygiene file) and `test_bootstrap_spelling.py`.

| Run | main `46fe6ac19` | scratch merge with this head |
|---|---|---|
| 29 files, UTF-8 | 1873 passed, 1 skipped | 1895 passed, 1 skipped |
| 29 files, Latin-1 | 128 failed, 1721 passed, 25 skipped | 49 failed, 1775 passed, 72 skipped |
| the 50, UTF-8 | 50 passed | 50 passed |
| the 50, Latin-1 | 49 failed, 1 passed | **0 failed**, 5 passed, 45 skipped |
| the 50, Latin-1, `-E` launcher | 50 failed (on `bd3e9c148`, round one) | 1 failed, 4 passed, 45 skipped |

The 5 that pass under Latin-1 are the 3 tracking-branch rows (the tool fix), `test_a_utf8_source_directory_still_adopts_with_local_remotes` and `test_surrogateescape_reads_the_issues_branch_as_caf_and_u_dce9`.

Main moved twice while this was gated, none of its commits touching a file of the gate or of this PR. The merge was run again on each: on `9729315f1` the same 29 files, with identical outcomes by test id in both locales (1895 passed, 1 skipped; 49 failed, 1775 passed, 72 skipped); on `801a7d6d0` the 50 and the four files the second commit changes (`test_non_utf8_name_helpers.py`, `test_bootstrap_spelling.py`, `test_family_head_by_hand_bytes.py`, `test_adopt_template_values.py`). The 50 give the same as above in all three modes (UTF-8 50 passed; Latin-1 pip 0 failed, 5 passed, 45 skipped; Latin-1 `-E` 1 failed, 4 passed, 45 skipped), the four files give 385 passed under UTF-8, and 6 failed, 371 passed, 8 skipped under Latin-1: the 5 `test_bootstrap_spelling.py` rows and `test_execute_refuses_a_local_source_directory_that_is_not_utf8`, all of which fail on main too.

**By test id, from main to the scratch merge:**
- **UTF-8:** 22 new rows, all passed: the 20 of `test_non_utf8_name_helpers.py`, the `[validate-family]` row of the first-statement test, and the first commit's `test_the_gate_passes_on_a_stdout_that_cannot_hold_its_notes`. Nothing else changes: no new skip, no row from passed to failed. The one skip is `test_stdout_encoding.py`'s Windows default-stdout row, on both.
- **Latin-1:**
  - 0 rows from passed to failed.
  - 0 from passed to skipped. (The first commit had one, the S1 row; it passes now.)
  - 32 from failed to passed: the 3 tracking-branch rows and `test_surrogateescape_reads_the_issues_branch_as_caf_and_u_dce9` of the 50, and 28 other rows of `test_family.py` whose holder's gate ended in the same traceback.
  - 47 from failed to skipped: 45 of the 50, and the 2 bidi rows of `test_local_remote_dir_urls.py`, which share `BAD_DIRECTORIES`.
  - 22 new rows, passed.
  - Each of the 49 failures fails on main too: the rows #1209 settles, the rows under "Left", and 5 rows of `test_bootstrap_spelling.py` (see "Left").

**On a scratch merge with #1209** (main `46fe6ac19`, #1209 at `13a2c58cb`, then this head; local, never pushed, both merges clean). #1209 shares four files with this PR: `tests/conftest.py`, `tests/test_non_utf8_name_callers.py`, `tests/test_non_utf8_name_helpers.py` and `tests/test_stdout_encoding.py`. Run on 8 files: the three test files among those four, #1209's `test_adopt_plan_paths_spelled.py` and `test_run_script_encoding.py`, and `test_adopt_template_values.py`, `test_family_head_by_hand_bytes.py` and `test_bootstrap_spelling.py`. Against main plus #1209 alone:
- UTF-8: 483 passed and 1 skipped, then 504 passed and 1 skipped: the 21 new rows (the 20, and the `[validate-family]` row), nothing else.
- Latin-1: 19 failed, 411 passed, 54 skipped, then 5 failed, 433 passed, 67 skipped: 21 new rows passed, 1 failed to passed, 13 failed to skipped. The 5 failures are the `test_bootstrap_spelling.py` rows, which fail on both. Of the 50, the 15 in these files give 13 skipped and 2 passed, none failed.

**The other 59 test files that name `validate-family`** (round one, on the first commit, UTF-8): 3374 passed, 28 skipped, 0 failed. The second commit changes no tool.

**The same launcher started as `python -E`** (W1247's copy of it with `-E` added, used read-only), Latin-1, the 50: on main `bd3e9c148`, **50 failed**, the 50 exactly as #1214 lists them. On the first commit, 0 failed. On this head, **1 failed**, 4 passed, 45 skipped: the S1 row, `test_a_utf8_source_directory_still_adopts_with_local_remotes`, on #1247's traceback (`UnicodeEncodeError` on U+FFFD in `git_filter_repo.py`'s `_migrate_origin_to_heads`, then `REFUSED extracting the spec leg`). It stays red with that launcher until #1251 lands, and the other 49 rows are as with the pip launcher.

## The new rows, and mutants

Each mutant was made in a scratch worktree at the head and restored afterwards, with each file's sha256 checked. "UTF-8" and "Latin-1" name the locale of the run.

**The second commit's rows.** The helper's own rows run in CI's UTF-8 locale, with the three locales emulated.

| Mutant | Run | Result |
|---|---|---|
| none (the head), `test_non_utf8_name_helpers.py` | UTF-8 | 39 passed (19 before, 20 new) |
| the new rows against main's `tests/conftest.py`, which has no helper | UTF-8 | the file does not import: `cannot import name 'skip_where_the_locale_does_not_spell_it_as_utf_8'` |
| A5: the helper's UTF-8 bytes built with `surrogatepass` | UTF-8 | **3 failed**: the `byte-e9` row in each of the three locales. Before, the same mutant made 11 rows skip silently under UTF-8 and failed none (RV1258). |
| A1: the first question's skip taken as UTF-8's bytes | UTF-8 | **5 failed**: `iso8859-1` and `ascii` for `bidi-override` and `ellipsis`, and `ascii-e-acute` |
| A2: the second question dropped | UTF-8 | **1 failed**: `iso8859-1-e-acute` (it reads the bytes back and says "reads", not "writes") |
| A4: only the third question | UTF-8 | **6 failed**: the rows A1 and A2 fail, together |
| A3: the third question dropped | UTF-8 | **1 failed**: `iso8859-1-byte-e9` |
| A6: the third question inverted | UTF-8 | **9 failed** |
| the encoding in the reason named `utf-8` always | UTF-8 | **7 failed** |
| the row's premise left out of the first question's reason | UTF-8 | **5 failed** |
| the UTF-8 bytes built with `strict` | UTF-8 | **4 failed**: the three `byte-e9` rows, and the row that holds the emulation to the real locale |
| the second and third questions swapped | UTF-8 | **1 failed** |
| the first question catching any exception | UTF-8 | survives, and is equivalent: `os.fsencode` of a str raises only `UnicodeEncodeError` |
| D3: `validate-family.py`'s `escape_unencodable_stdout()` moved after `parse_args` | UTF-8 | **1 failed**: the `[validate-family]` row |
| main's `validate-family.py` under the head's tests | UTF-8 | **2 failed**: the `[validate-family]` row and `test_the_gate_passes_on_a_stdout_that_cannot_hold_its_notes` |
| N3's narrowed `if` taken out (main's `if`, with no helper call) | Latin-1 | **1 failed**: `test_surrogateescape_reads_the_issues_branch_as_caf_and_u_dce9` (it passes under UTF-8) |

On the 50 under Latin-1 the helper's mutants are as in round one, re-measured on this head: A3 gives **10 failed** (it was 11; the N3 row no longer asks the helper), the first question unguarded gives **11 failed**, and A1, A2 and A4 survive (5 passed, 45 skipped), because on Linux the third question alone decides there, as RV1258 found. Only the new rows tell them apart.

**The first commit's rows** (mutants made on `c8641c691`, which the second commit does not change):

| Mutant | Run | Result |
|---|---|---|
| none (the head), the new row of `test_family.py` | UTF-8 | 1 passed |
| main's `validate-family.py` under the head's tests (the new row on main) | UTF-8 | **1 failed**: the new row |
| `validate-family.py`'s `main` without the `escape_unencodable_stdout()` call (import kept) | Latin-1 | **4 failed**: the new row, and the `[add]`, `[bump]`, `[remove]` rows of `test_each_act_refuses_the_tracking_branch_then_lands_on_a_branch` |
| the bidi guard taken out of `skip_where_this_system_cannot_name` | Latin-1 | **6 failed**: the 4 bidi rows of `test_clone_url_bytes.py` and the 2 of `test_local_remote_dir_urls.py`, the same `BAD_DIRECTORIES` |
| `windows_names_it` without the `os.fsdecode` emulation | Latin-1 | **1 failed**: `test_where_windows_holds_a_bidi_override_the_name_check_does_not_skip` |
| the guard of `test_the_member_head_is_the_branch_git_wrote` asked of every branch (its `branch != NOT_UTF_8_BRANCH` dropped) | Latin-1 | `[not-utf8]` goes from passed (the head) to skipped; no row fails. A skip fails no run, so only a comparison of outcomes sees this one. |

## Merge-trees

`git merge-tree --write-tree` of the head (`cd9f3cfd1`):
- against `origin/main` `46fe6ac19`: clean;
- against #1209 `13a2c58cb`, #1185 `d193617c7`, #1154 `8a7828332`, #1251 `abeac66de` and #1198 `d38e4e36d`: each clean;
- against the other open PRs that touch any of these 18 files, at their heads: #1263 `9ef8f0ab5`, #1246 `0deac3a65`, #1231 `aca00dfd9`, #1227 `2d56c1906`, #1178 `c4beba193`, #1172 `2eabec8e0` and #1125 `9549006fe` are clean. #1201 `eac177af9` conflicts at `docs/handbook.html`, which this branch does not touch, and conflicts there against `origin/main` alone too.

#1209 changes `skip_where_a_name_cannot_be_not_utf_8` and the callers fixture `a_system_that_carries_the_byte`. The new helper sits more than 100 lines from the first, and `windows_names_it` 65 lines from the second. #1209 also edits `tests/test_non_utf8_name_helpers.py`, where the second commit adds its rows at the end of the file; the two merge without a conflict, and the merged file's rows pass (see "Runs").

## Left, and outside this issue

- **W1214's filter-repo defect is filed separately, as #1247**, and #1251 (a draft for it) is independent of this PR.
  - What W1214 found: `adopt-project.py execute` fails for a Latin-1 user whose source path holds U+00E9. The leg clone's `remote.origin.url` holds the byte 0xE9, git-filter-repo decodes it with `errors='replace'` and prints U+FFFD to a Latin-1 stdout, and `execute` stops at `REFUSED extracting the spec leg`.
  - **Which launcher runs git-filter-repo decides it.** One started as `python -E` ignores the `PYTHONIOENCODING` the tool gives its children; a pip-installed one, as CI installs it, is not started that way. Measured here (see "Runs"): `test_a_utf8_source_directory_still_adopts_with_local_remotes` passes on main under Latin-1 with the pip launcher, and fails there with a `-E` copy of the same launcher. W1196's list of 50 has this row failing, which this bench gives only with the `-E` launcher.
  - **Independent of #1251.** This PR no longer guards that row (RV1258's S1), so it carries nothing for #1251 to drop, and the earlier plan, that whichever of the two PRs lands second drops this PR's guard, is void. #1251 changes `_extract_leg` in `adopt-project.py` and adds `tests/test_adopt_filter_repo_origin_url.py`, and touches none of these 18 files (`git merge-tree` against its head `abeac66de` is clean). The row passes under Latin-1 with the pip launcher whichever lands first. With a `-E` launcher it fails on #1247's traceback until #1251 lands, which is the tool's failure showing, not a premise this PR can judge.
- **N2 (RV1258), known and left:** under emulated Windows codecs, the helper skips the U+DCE9 rows that carry no Windows mark, with a premise that is false on Windows. It is reasoned and emulated, not run on Windows; CI runs Linux only (#597).
- **5 rows of `tests/test_bootstrap_spelling.py` fail under Latin-1** on main, on this head and on the merge with #1209 alike. It is a file #1214 does not list, read from the failure messages only: four rows end in a `UnicodeEncodeError` on U+2028, which Latin-1 cannot encode, and `test_a_branch_name_is_spelled_in_every_line_that_names_it` fails its assertion. They are left for an issue of their own.
- **8 rows in two files #1214 does not list fail under Latin-1** on main, on this head and on the merge with #1209 alike:
  - 6 rows of `test_pinned_copy_text.py`: the tool prints U+2014 or U+2026 escaped on a Latin-1 stdout, and the row compares the character.
  - `test_family.py`'s `test_init_writes_the_holders_agent_files`: it reads the UTF-8 file it checks in the locale's encoding.
  - `test_family.py`'s `test_commit_one_refuses_a_trailer_that_is_no_text_before_it_stages`: `DID NOT RAISE Refusal`, a byte Latin-1 reads as text.
  - These are read from their failure messages only, not classified per test. They are left for an issue of their own.
- **The fourth row of `tests/test_adopt_template_values.py` that fails under Latin-1 on main** is `test_execute_refuses_a_local_source_directory_that_is_not_utf8`. It is not one of the 50, and this PR leaves it alone.
  - It asks `skip_where_a_name_cannot_be_not_utf_8`, and #1209 gives that helper the locale question. So it skips at #1209's head, where the 50 were counted, and it skips on the scratch merge with #1209.
  - It fails on main and on this head alike, so it is #1196's (#1209's) row, not #1214's.
  - The other three rows of that file that fail on main are among the 50: the two U+DCE9 flag rows and `test_plan_and_check_say_the_same_sentence`. Each skips here.
- **#1224 is untouched.** This helper takes none of N1's over-skip; N2 to N5 stay #1224's.

Closes #1214

Lane: openreposhape-4 (openRepoShape-4)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Nov 9, 2026
… `--local-remote-dir` path in `execute`'s `bare`, leg and `split` lines, are named with `_shown`, as #1154 names `--out` and `--work-dir`, so a bidi control, an escape, a line feed or a byte that is not UTF-8 in either no longer reaches the terminal as it was typed (#1152) (#1177)

## What

#1154 (#1115) names `--out` and `--work-dir` in `plan`'s and `check`'s report with `_shown`. #1152 lists the two groups of paths it leaves raw: the `--plan` path in `check` and `execute`, and the `--local-remote-dir` path in `execute`. A bidi control (U+202E), an ESC or a line break in either reached the terminal as it was typed, where the other plan lines name a path with `_shown`.

This change spells each of the 21 sites with `_shown(str(...))`, in `adopt-project.py` only. A path with a character that is not printable is named as `_spelled` names it, between backticks. Every other path prints byte for byte as it did, and no refusal code is new.

The `--plan` path, 16 sites:
- the five `N finding(s) in <plan>` lines: `_refuse_a_mistyped_plan`, `_refuse_what_check_finds`, the `plan-split-branch-taken` refusal, and `cmd_check`'s two branches;
- the `<plan>: ...` refusals: `plan-wrong-kind`, `plan-unsupported-mode`, `plan-unreadable`, `plan-no-source`, the three `plan-bad-id` ones, `plan-not-the-source`, `adopt-topic-too-long`, and the `legs.assembly` and `org:` ones.

The `--local-remote-dir` path, 5 sites:
- the `<bare> already exists` refusal;
- the `  bare  <bare>` line;
- the two leg lines, in `_extract_leg` and `_seed_leg`, which end `-> <url>`;
- the `split <commit> on <branch> -> <url>` line. It names the source's directory under `--local-remote-dir`.

The `NEXT:` clone command is not touched. It already quotes the url with `shlex.quote`, and a row pins that it still does.

## Behaviour change

A path that is not UTF-8 now prints `\udcff` between backticks, as #1154's paths do, where it printed raw before. A plain path prints as it did.

## Names

#1152 calls the wrong-kind refusal `plan-bad-kind`. The code's name for it is `plan-wrong-kind`, and that is the code this change spells. No refusal was renamed.

## Not in this PR

`repo_shape.load_yaml`'s own refusals, `yaml-unreadable`, still print a path raw. They live in `scripts/repo_shape.py`, and they are a separate follow-up: see #1168.

## Proof

`tests/test_adopt_plan_and_remote_paths_spelled.py` is new, ASCII only and POSIX only, with every non-ASCII character written as an escape.

- **Rows: 148.**
  - 135 plan rows: 14 refusal families (27 family and command pairs) by 5 path forms (U+202E, ESC, a line feed, the byte `\xff` through `surrogateescape`, and a plain control).
  - 5 `--local-remote-dir` rows for the `bare` and leg lines (the code leg is extracted, the spec leg seeded).
  - 3 `split` rows. `execute` refuses a source path that holds U+202E, ESC, a line feed or `\xff` as `adopt-unwritable-value` before any leg exists, so these rows use U+200B in the parent directory and a name that ends in a space, and a plain control.
  - 5 in-process rows for `{bare} already exists`, which call `_create_leg_remote`.
- **On main's `adopt-project.py`: 118 failed, 30 passed.** Each failure is the raw path where the spelled one was expected. The 30 that pass are exactly the 30 plain controls.
- **On this head: 148 passed.**
- **Mutants: 23, all killed.** 21 put one spelling back to raw, one at a time, and 2 swap `_shown` for `_spelled` at one site. Each was restored with its sha256 checked.
- **Gate:** a scratch merge of this head with main `961640c68` (tree `61063bb76`, which is the tree of this PR merged into that main). Targeted files only: the new file, `test_stdout_encoding.py`, `test_non_utf8_name_callers.py`, `test_adopt_plan_escapes.py`, `test_path_guard_hygiene.py`, `test_repo_hygiene.py`, `test_scaffold_leg_path_collisions.py`, and every test file that greps for `finding(s) in` or `already exists` (47 files), in 6 shards, and `test_shape_doctor.py` (448 ids) in 8 shards. Every shard exited 0, with 0 failed.

  | Shard | Result |
  | --- | --- |
  | g0 | 617 passed |
  | g1 | 344 passed |
  | g2 | 439 passed |
  | g3 | 605 passed |
  | g4 | 902 passed |
  | g5 | 764 passed, 1 skipped |
  | d0 | 56 passed |
  | d1 | 56 passed |
  | d2 | 56 passed |
  | d3 | 55 passed, 1 skipped |
  | d4 | 55 passed, 1 skipped |
  | d5 | 55 passed, 1 skipped |
  | d6 | 56 passed |
  | d7 | 56 passed |

  That is 3671 passed and 1 skipped in the file shards, and 445 passed and 3 skipped in the doctor shards. The skips are Windows-only rows.
- **Merge-trees** (`git merge-tree --write-tree`, this head against each), all clean:
  - `origin/main` `961640c68`;
  - #1154's head `8a782733`: clean, so this PR is based on main and not stacked on it;
  - the other 15 open PRs that touch `adopt-project.py`, at their heads: #1171 `159815d75`, #1170 `4df784ac4`, #1169 `b8e63bcf0`, #1153 `ff33ba12a`, #1143 `7af5fabc3`, #1141 `7a2711d03`, #1125 `9549006fe`, #1123 `5c3908f8d`, #1122 `c01c4d73d`, #1121 `1c5173758`, #1120 `c55e55e33`, #1119 `bba168bdd`, #1118 `2307036ab`, #1106 `504a1dd65`, #1105 `b28f40de0`.

  The other open PRs do not touch `adopt-project.py`. None of the 16 that do adds a line that names `plan.path`, `{bare}`, `finding(s) in` or `already exists`, apart from a tuple in #1121 that is not printed.

Closes #1152

Lane: openreposhape-4 (openRepoShape-4)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Nov 9, 2026
…: a kept `GNUmakefile/` is a directory GNU make stops at, `python3 scripts/bootstrap.py` names `python` on Windows, and the template says what to run where `make` reads another file (#1207)

**#1132, the parts that hold on main: the assembly-root template says what to run where GNU make reads a kept `GNUmakefile` or `makefile` first; a kept DIRECTORY of either name is named as one GNU make stops at, in the `CONTRACTS_DIR` line and in `execute`'s NEXT; every sentence that names `python3 scripts/bootstrap.py` for a person to run names `python` on Windows too; and two follow-up texts no longer say more than is true (RV1105b's NIT-2 and NIT-3a).**

This PR was built on main `961640c6`. Lane 4's #1121 (#1047) landed as `0ed3e57f8` at 21:37Z, and this round merged it in (`6fa1edd56`): NEXT now words a kept file (#1121's) and a kept directory (this PR's) through one lookup and one clause. #1105 landed as `12122952b` on 2026-11-08, and this PR merges it in (see "Main merge after #1105"). The items that live only in #1105's code, and the parts of #1121's that this merge does not do, are in their own issue, #1240 (see "Left"). Item 5 is #1206.

Lane 4's #1105 (#1048) landed as `12122952b` at 16:45Z. This round merges main into the branch with `git merge origin/main`, never a rebase, and does it twice:
- main `46fe6ac19` as merge `7b0192bde`;
- then NIT-A in its own commit, `e5e077940`;
- then main `9729315f1` as merge `01e93b6d1`, the head. Lane 1's #1123 had landed meanwhile, and one of its rows meets this PR's directory line (see "The second merge, after #1123").

The first merge conflicted in `scripts/shape_materialize.py` only: 3 hunks, all in `collision_follow_up`, as "Landing order" said. `adopt-project.py` and `templates/assembly-root/AGENTS-shape.md` merged with no conflict.

Both sides' behaviour stays: #1105's second `GNU_MAKE_READS`, its `_predict_collisions` lookup and its collision line, and this PR's `_make_reads_first`, `_make_reads_first_clause` and NEXT. None of #1240's unification is done here (one tuple, one lookup).

### The three hunks

| hunk | this PR (`6fa1edd56`) | main (`46fe6ac19`, #1105) | resolution |
|---|---|---|---|
| 1. The docstring's NIT-4 sentence | "This said "both callers say it", and `execute` calls it nowhere" | "`Materialized.follow_ups()` would say this of them, and nothing calls it" | **Main's.** Both sides rewrote the same sentence for the same finding. Main's also names `Materialized.follow_ups()`, which #1240's item G changes. So this PR no longer touches that sentence, and the last `scripts/shape_materialize.py` bullet under "What changed" is #1105's text now. |
| 2. The docstring's Makefile paragraphs | the `BOOTSTRAP_COMMAND` sentence and NIT-2's tail | the heading "WHERE `make` READS THE MERGED FILE", and the "BUT GNU MAKE READS" paragraph | **Both.** Main's heading and both paragraphs. This PR's sentences on `BOOTSTRAP_COMMAND` and on NIT-2's tail go in the first paragraph, and one new sentence goes in the second: "Both name that command as `BOOTSTRAP_COMMAND` does, `python` on Windows as well (#1132)." |
| 3. The returns | two `return`s, each one sentence | `arrive`, `joint`, `meanwhile` and `until` set per branch, then one pair of `return`s | **#1105's structure, with a per-branch `then` in place of `until`.** With no `reads_first`, the line is this PR's, byte for byte. With one, it is #1105's, byte for byte, except that the command a person runs is `BOOTSTRAP_COMMAND`, both in `meanwhile` and in "and then ... runs it". |

- **Hunks 1 and 2 carry no code.** In the merged file they sit at lines 1022-1023 and 1032-1070, inside `collision_follow_up`'s docstring (lines 1014-1084).
- **The rendered lines.** I loaded the function from `6fa1edd56`, from main, and from the merge, and rendered each `reads_first` (none, `GNUmakefile`, `makefile`) with and without `scripts/bootstrap.py` aside.
  - With no `reads_first`, the merge equals `6fa1edd56` (2 of 2).
  - With one, it equals main with " (`python` on Windows)" after `python3 scripts/bootstrap.py` in those two places (4 of 4). For a root that keeps `Makefile` and `GNUmakefile`, the line now ends "...; until then `python3 scripts/bootstrap.py` (`python` on Windows) is what the shape's `make bootstrap` runs".
- **NIT-2's tail where `make` reads another file** stays #1105's own: "neither `make bootstrap` nor `python3 scripts/bootstrap.py` runs the shape's bootstrap until then, and then `python3 scripts/bootstrap.py` (`python` on Windows) runs it". #1105's review fixed that branch for the same finding, so it needs nothing more.
- **Of #1240's list,** this round does item C for #1105's collision line, as #1240 asks a resolution to say. So the "with `python3`" part of "Left"'s second bullet is done. Item B, the kept directory, stays: #1105's lookup asks `_root_keeps`, so a root that keeps `Makefile` and `GNUmakefile/` is told GNU make "reads the source's `GNUmakefile`". Mutant U3 below shows that no row pins this line for a directory.

### #1105's test pins

`tests/test_adopt_collision_make_reads.py` is #1105's file, and it pins the texts this PR changes, as "Landing order" expected.
- **Four pins move.** `MERGE_IS_ENOUGH` and `BOTH_MERGES` (no `reads_first`) move to this PR's words. `MEANWHILE` and `SCRIPT_MERGED` (with one) move to `python` on Windows. All four go through a new `COMMAND`.
- **One comment changes.** The comment on the `Makefile+scripts` row now says what NIT-2's tail says.
- **Measured:** before the move, the six adopt and pin files gave 11 failed and 242 passed, and the 11 are exactly the rows that use those four pins. After the move, 253 passed.
- **On main's code:** main `46fe6ac19`'s four production files (`adopt-project.py`, `scripts/shape_materialize.py`, `templates/assembly-root/AGENTS-shape.md` and `README.md`) were swapped into the mutant worktree at `e5e077940`. 64 of the three files' 106 rows fail:
  - in this file, exactly those 11 rows, and the other 20 pass;
  - in the new file, 34 of 35, as before (NIT-4's row passes);
  - in `tests/test_adopt_next_make_reads_first.py`, 19 of 40, as before.

  The four files were then restored, each matched the head by sha256 (4 of 4), and the tree was clean.

### NIT-A

`tests/test_adopt_next_make_reads_first.py:64` called #480's NOTE "unchanged", but the merge of #1121 moved that pin to `python` on Windows. The comment now says the NOTE "names `python` on Windows too since #1132". The change is a comment only, in its own commit.

### The second merge, after #1123

Lane 1's #1118 and #1123 landed while the first merge was being gated: `9ec0dc79c` at 17:30Z and `9729315f1` at 17:47Z. Both merge with `e5e077940` with no conflict in the text. The predicted merge with `9ec0dc79c` passed (gate P below). The predicted merge with `9729315f1` failed 1 row of 254 (gate P2):
- **The row:** #1123 adds `test_a_name_only_a_disk_that_ignores_case_takes_for_makefile[makefile-directory]` to `tests/test_adopt_make_reads_first.py`. For a kept DIRECTORY `makefile/`, it expects the `CONTRACTS_DIR` line a kept `makefile` FILE gets ("only once `makefile` does"). #1123's own message says that line is not true for a directory, and that the row works as a crash guard for `twins` in `_makefile_follow_up`. This PR changes exactly that line: a kept directory is one GNU make stops at.
- **The fix, in the merge `01e93b6d1`:** the row now expects `SHAPES + written_as("makefile")`, as #1123 wrote it, which is the part that guards `twins`. This PR's directory clause follows, through a new `stops_at` helper beside `reads`. The comment above `ANSWERED` and the row's docstring now say so. Nothing else changes in the merge.
- **Mutants on the row.** Each ran alone in the mutant worktree at `01e93b6d1` against `tests/test_adopt_make_reads_first.py` (34 rows). Each was restored with `git checkout` and matched by sha256 (`adopt-project.py` `3c2cb5f5bea5`), and the tree was clean after each.

| id | mutant | rows failing | result |
|---|---|---|---|
| D1 | `_make_reads_first` drops a directory's `/`, so the line is the one #1123's row pinned | 1 of 34, the row | killed |
| D2 | #1123's R10: `twins` reads the entry with its slash | 1 of 34, the row, with `IndexError` | killed |

### Mutants on the resolution

H3a-H3g and U1-U3b are the first merge's. All ran in the mutant worktree at `e5e077940`.
- **Method:** each mutant was applied alone, then restored with `git checkout`. Each restore matched by sha256 (`shape_materialize.py` `b18f09d7c396`, `adopt-project.py` `2055a81acdc6`), and the tree was clean after each.
- **Rows:** H3a-H3g, U3 and U3b ran against 93 rows: `tests/test_adopt_collision_make_reads.py` (31), the new file (35) and `tests/test_adopt_e2e.py` (27). U1 ran against the new file, `tests/test_adopt_make_reads_first.py` (33) and `tests/test_adopt_collision_make_reads.py`, 99 rows. U2 ran against the new file and `tests/test_adopt_next_make_reads_first.py` (40), 75 rows.
- **Unmutated,** every row passes (gate A below).

| id | mutant | rows failing | result |
|---|---|---|---|
| H3a | hunk 3, no `reads_first`: `meanwhile` back to main's plain `python3` | 4 of 93 | killed |
| H3b | hunk 3, no `reads_first`: the script tail back to main's "before both merges are made" | 4 of 93 | killed |
| H3c | hunk 3, with `reads_first`: `meanwhile` without `BOOTSTRAP_COMMAND` (main's) | 5 of 93 | killed |
| H3d | hunk 3, with `reads_first`: "and then ... runs it" without `BOOTSTRAP_COMMAND` (main's) | 3 of 93 | killed |
| H3e | hunk 3, with `reads_first`: this PR's tail in place of #1105's | 3 of 93 | killed |
| H3f | hunk 3: `reads_first` ignored, so the resolution is this PR's side whole | 15 of 93 | killed |
| H3g | hunk 3, with `reads_first`: #1105's `joint` ("; and") lost | 3 of 93 | killed |
| U1 | `_makefile_follow_up` drops `_make_reads_first` (`first = None`) | 31 of 99 | killed |
| U2 | `_next_steps` drops `_make_reads_first` (`first = None`) | 35 of 75 | killed |
| U3 | `_predict_collisions` asks `_make_reads_first` in place of #1105's lookup | 0 of 93 | **survived** |
| U3b | `_predict_collisions` passes no `reads_first`, so #1105's lookup is lost in the merge | 15 of 93 | killed |

- **H3c and H3d** are killed only by rows that use the moved `MEANWHILE` and `SCRIPT_MERGED`. Those pins are what hold `BOOTSTRAP_COMMAND` in #1105's branch.
- **U3 survives,** and that is #1240's item B. For a kept file, both lookups give the same name. They differ only for a kept directory, where `_make_reads_first` adds the `/`, and no row runs `_predict_collisions` on a root that keeps `Makefile` and `GNUmakefile/`. A row now would pin the line #1240 is to correct, so this round adds none.

### Runs

Each run went through the lane's runner, with git-filter-repo 2.47.0 (CI's pin) on PATH, on a commit with a clean tree.

| run | git | files | passed | failed | skipped |
|---|---|---|---|---|---|
| gate A2 | 2.43.0 | `01e93b6d1`, the head: the 12 files below | 1096 | 0 | 3: the PowerShell rows (`test_shape_doctor.py:10516`), which run only on a Windows host |
| gate B2 | 2.47.1 | `01e93b6d1`: the same 12 files | 1096 | 0 | 3: the same |
| gate A | 2.43.0 | `e5e077940`, after the first merge: the 12 files below | 1095 | 0 | 3: the same |
| gate B | 2.47.1 | `e5e077940`: the same 12 files | 1095 | 0 | 3: the same |
| gate P | 2.43.0 | the predicted merge of `e5e077940` with main `9ec0dc79c` (#1118; tree `ba3f3c1f3`, a local commit object, not pushed): the six adopt and pin files, plus #1118's `tests/test_adopt_root_shape_paths.py` and `tests/test_adopt_symlink_target_bytes.py` | 509 | 0 | 0 |
| gate P2 | 2.43.0 | the predicted merge of `e5e077940` with main `9729315f1` (#1123; tree `0eb290ae2`, a local commit object): the six adopt and pin files | 253 | 1: #1123's `makefile-directory` row, which the second merge moves | 0 |
| gate P4 | 2.43.0 | the predicted merge of `01e93b6d1` with main `801a7d6d0` (#1106; tree `25bc27d39`, a local commit object): the six adopt and pin files, plus #1106's `tests/test_adopt_one_byte_locale.py` and `tests/test_adopt_unenterable_source_and_locale.py` | 277 | 0 | 0 |

The files are the six adopt and pin files (`tests/test_adopt_collision_make_reads.py`, `tests/test_pinned_copy_text.py`, the new file, `tests/test_adopt_next_make_reads_first.py`, `tests/test_adopt_e2e.py` and `tests/test_adopt_make_reads_first.py`, 253 rows), plus `tests/test_shape_doctor.py` and `tests/test_scaffold_leg_path_collisions.py`, which adopt changes need, plus the hygiene five (`test_path_guard_hygiene.py`, `test_repo_hygiene.py`, `test_agents_md_codes.py`, `test_cli_reference.py` and `test_pinned_copy_text.py`). That is 1098 rows in one run at `e5e077940`, and 1099 at `01e93b6d1`, where #1123 adds one row.

All of this was measured on main `961640c68` with GNU make 4.3, offline.

| item | on main |
|---|---|
| 1, the template | `AGENTS-shape.md` (the "Work from here" paragraph and the five-commands table) and `README.md` (Get started, and the parking steps) give `make bootstrap` with no caveat. With the template's own `Makefile` beside a plain `GNUmakefile` or `makefile`, `make -n bootstrap` exits 2, `No rule to make target 'bootstrap'`. |
| 2, a kept directory | With `GNUmakefile/` or `makefile/` beside `Makefile`, `make bootstrap` exits 2 with `make: *** GNUmakefile: Is a directory.  Stop.`, or the same with `makefile`. It does this for every target, and for each directory alone too. Main's `CONTRACTS_DIR` line says "`make` there exports `CONTRACTS_DIR` only once `GNUmakefile` does". NEXT prints `make bootstrap` for a root that keeps only `GNUmakefile/`. Beside a kept `Makefile`, it prints #480's NOTE that the targets "arrive only once the follow-up merges the two". Rendered by the lane's `probe_texts.py` on main. |
| 3, `python3` | The template's `scripts/bootstrap.py` says `python3 scripts/bootstrap.py (python on Windows)`. #480's NOTE and the Makefile collision follow-up's "until then" name `python3` alone. |
| NIT-2 | The no-`reads_first` script-aside tail says "neither `make bootstrap` nor `python3 scripts/bootstrap.py` runs the shape's bootstrap before both merges are made". In a root that keeps its own `Makefile` and `scripts/bootstrap.py`, merging the script alone makes `python3 scripts/bootstrap.py` print the shape's `SHAPE-BOOT`, while `make bootstrap` still exits 2. Measured again by a row below. |
| NIT-3a | `_predict_collisions` says the wording comes from "the same function `execute` reports its actual collisions through", and `collision_follow_up` says "Both callers say it". `execute` never calls `collision_follow_up`: it carries the plan's stored `follow_ups:` into the split message. |

`adopt-project.py`:
- **`_make_reads_first(surviving)`** gives the first of `GNUmakefile` and `makefile` the root keeps. It reads `GNU_MAKE_READS`' order, asks the way `_root_keeps` asks, and adds a `/` for a DIRECTORY. **`_make_reads_first_clause`** words the clause. For a file, the words are main's, byte for byte. For a directory, it says: "GNU make at the root stops at the source's directory `GNUmakefile/`, the first of `GNUmakefile`, `makefile` and `Makefile` it finds (`GNUmakefile: Is a directory.`), so ... only once the root keeps no directory of that name".
- **`_makefile_follow_up`** (the `CONTRACTS_DIR` line) asks both. A kept file's line is unchanged: `tests/test_adopt_make_reads_first.py` passes as it is.
- **`_next_steps`** takes `surviving=`, the plan's root paths, which `cmd_execute` passes as `paths_for["root"]`, as #1121 does.
  - Where a kept DIRECTORY stops make, the command is `python3 scripts/bootstrap.py`. The NOTE says GNU make stops there. Beside a kept `Makefile`, it also says the targets run there once the follow-up merges the two, and only once the directory is gone. Where the script went aside too, alone or with the `Makefile`, the NOTE names that command after the merges.
  - Since the merge of #1121, a kept FILE goes through the same lookup and the same clause. For a file the clause gives #1121's words byte for byte, and its NOTEs end in `BOOTSTRAP_COMMAND` too.
- **`BOOTSTRAP_COMMAND`** is in every NOTE: #480's, #1121's and the directory's. Each command line a person pastes stays `python3 scripts/bootstrap.py`.
- **`_predict_collisions`' docstring** says what the plan stores and what `execute` carries (NIT-3a).

`scripts/shape_materialize.py`:
- **`BOOTSTRAP_COMMAND`** = "`python3 scripts/bootstrap.py` (`python` on Windows)", as the template's script names it.
- **The Makefile collision follow-up** says "until then `python3 scripts/bootstrap.py` (`python` on Windows) is what `make bootstrap` runs".
- **Where the script went aside too,** the follow-up says "so `python3 scripts/bootstrap.py` (`python` on Windows) runs the shape's bootstrap once the script is merged, and `make bootstrap` once both merges are made" (NIT-2).
- **The docstring's "Both callers say it"** paragraph says what is true (NIT-3a's twin, #1105's review NIT-4). #1105 made the same fix, and the merge keeps main's text (see "Main merge after #1105").

`templates/assembly-root/`:
- **`AGENTS-shape.md`:** the "Work from here" paragraph adds "; where the root keeps a `GNUmakefile` or a `makefile`, which GNU make reads before `Makefile`, run `python3 scripts/bootstrap.py` (`python` on Windows), which is what the shape's `make bootstrap` runs." A sentence after the five-commands table says they are the shape's Makefile's targets, which `make` at the root reaches only where the file it reads first holds them, or includes a Makefile that does.
- **`README.md`:** one sentence after Get started covers `make bootstrap` "here and below". A second says `make park` and `make resume` below work there only where that file holds them, or includes a Makefile that does.
- **This is a template byte change, so every project re-pins.** No digest of either file is stored in this repository. `tests/` was grepped for every changed line, and only this PR's own rows pin them (see "Template pins").

Tests:
- **`tests/test_adopt_e2e.py`:** two pins move to the new words, at :312 (the "until then" sentence) and at :447-450 (NIT-2's tail).
- **`tests/test_adopt_next_make_reads_first.py`** (#1121's): the merge moves three pins, `OWN_MAKEFILE_NOTE`, `RUNS` and `script_aside`, to `python` on Windows. #480's NOTE merged with no textual conflict, so without them its rows fail.
- **The new file `tests/test_adopt_make_bootstrap_followups.py`** has 35 rows:
  - the template's sentences, held to its `Makefile` (`PYTHON ?= python3`, `bootstrap:` runs `$(PYTHON) scripts/bootstrap.py`) and to `scripts/bootstrap.py`'s own words;
  - `make -n bootstrap` against the template's `Makefile` beside each kept name, each row asserting the `AGENTS-shape.md` caveat that measurement backs;
  - `_make_reads_first` (10 roots);
  - the `CONTRACTS_DIR` line for 4 directory roots;
  - NEXT for a directory, beside a kept `Makefile` (both names), after both merges, and after the script's merge alone;
  - #480's NOTE, called both as main's signature allows and with `surviving=`;
  - the collision follow-up's two sentences;
  - NIT-2 measured with the template's `Makefile` and stand-in scripts, and tied to the follow-up's new tail;
  - three real adoptions of a source holding `GNUmakefile/rules.mk`. One is kept by a `--path-policy` rule, so `plan` writes the line, `check` prints it and the split message carries it. One is answered `root`. In both, NEXT is asserted, `make -n bootstrap` in the pasted clone exits 2 with `GNUmakefile: Is a directory.`, and the printed command exits 0. In the third, the question is answered `code`: NEXT names `make bootstrap`, and that command runs in the pasted clone.

### This round (#1207's review, issuecomment-6374516382)

| finding | what changed |
|---|---|
| SHOULD-1 | A row pins NEXT where only `scripts/bootstrap.py` went aside beside a kept `GNUmakefile/` (`test_next_after_the_script_merge_names_python3_where_make_stops`). It fails under the review's mutant X1. |
| SHOULD-2 | The "Left" list is one issue, #1240. |
| SHOULD-3 | "Landing order", below. #1121 landed while this round ran, and is merged and resolved here. |
| NIT-1 | `AGENTS-shape.md`'s sentence after the table loses "(above)": nothing above names a Makefile that includes another. |
| NIT-2 | `README.md` names `make park` and `make resume`. |
| NIT-3 | Beside a kept `Makefile`, the directory NOTE names the merge as well as the directory. Its row is parametrized over `GNUmakefile/` and `makefile/`. |
| NIT-4 | An adoption sends `GNUmakefile/` to the code leg, and NEXT names `make bootstrap`. It fails under the review's mutant X6. |
| NIT-5 | The notes for the squash message at landing, below. |

Measured at the merge head `6fa1edd56`, in a scratch worktree:
- main `0ed3e57f8`'s bytes of the four production files (`adopt-project.py`, `scripts/shape_materialize.py`, `templates/assembly-root/AGENTS-shape.md`, `templates/assembly-root/README.md`) were checked out over the head;
- the new file (35 rows) and `tests/test_adopt_next_make_reads_first.py` (40 rows) ran through the lane's runner;
- the four files were restored with `git checkout`, and each matched the head by sha256 (`c94bd19b`, `12555f39`, `8660bafb`, `b3f9409b`).

| file | fail on main | pass on main |
|---|---|---|
| the new file | 34 | 1: `test_an_adoption_sending_a_gnumakefile_directory_to_a_leg` |
| `tests/test_adopt_next_make_reads_first.py` | 19 | 21 |

Main now has #1121, so its `_next_steps` takes `surviving=`. The NEXT rows for a kept directory therefore fail on their words, not on a `TypeError`. Main reads `GNUmakefile/` as a file: "then run `python3 scripts/bootstrap.py`; GNU make at the root reads the source's `GNUmakefile`, ...". This is the case for the SHOULD-1 row, the after-the-merges row, both directory rows, and NIT-3's `makefile/` row.

The new file's other rows fail on main for these reasons:
- the template rows: main's `AGENTS-shape.md` and `README.md` lack the sentences;
- `_make_reads_first`: main has no such helper;
- the `CONTRACTS_DIR` line: "only once `GNUmakefile` does";
- the NOTE and collision rows: plain `python3`, and NIT-2's old tail;
- the two adoptions that keep the directory.

The one new row that passes on main is NIT-4's. It sends `GNUmakefile/` to the code leg, and there main's NEXT is already `make bootstrap`. It guards what main has: under the review's mutant X6, which hands NEXT every leg's paths, it is the row that fails.

The 19 rows of #1121's file that fail on main are exactly the rows that use the three pins this merge moved (`OWN_MAKEFILE_NOTE`, `RUNS`, `script_aside`). The 21 that pass use none of them.

Earlier heads, on main `961640c68` and with the same method: `1c7ca5c6d` failed 29 of 35 rows, and `8b499842f` failed 34 of 35 (the new file plus the three `tests/test_adopt_e2e.py` rows the mutants use).

**This round**, at `75c90b6db`, in a scratch worktree. Each mutant was applied alone and restored, and each file's sha256 was checked against the commit (4/4 every time). Each ran against 95 rows: the new file (35), `tests/test_adopt_e2e.py` (27) and `tests/test_adopt_make_reads_first.py` (33). Unmutated, all 95 pass.

| id | mutant | rows failing (of 95) | result |
|---|---|---|---|
| X1 | the review's: the script-only NOTE names `make bootstrap` after the merge (`if stops and makefile`) | 1 | killed |
| X6 | the review's: `cmd_execute` passes every leg's paths | 1 | killed |
| N1 | NIT-3 undone: beside a kept `Makefile`, no merge named | 2 | killed |
| N2 | the merge named where the script went aside too | 1 | killed |
| N3 | the merge named where no `Makefile` was kept | 4 | killed |
| T1 | NIT-1 undone: "(above)" back | 1 | killed |
| T2 | NIT-2 undone: README's `make park` / `make resume` sentence removed | 1 | killed |

The merge with #1121 rewrote the clause code that N1-N3 mutate (`stopped` became `reads`, and the merge condition gained `stops`). The mutants were not run again at `6fa1edd56`.

**Earlier,** 18 mutants at `1c7ca5c6d` against 43 rows, each applied alone in a scratch worktree and restored with its sha256 checked:

| id | mutant | rows failing (of 43) | result |
|---|---|---|---|
| M1 | `_make_reads_first` drops the `/` of a directory | 14 | killed |
| M2 | the clause's directory branch never taken | 10 | killed |
| M3 | NEXT ignores a kept directory (`stops = None`) | 6 | killed |
| M4 | NEXT's command stays `make bootstrap` for a directory | 4 | killed |
| M5 | `cmd_execute` passes `surviving=()` | 2 (the two adoptions) | killed |
| M6 | `BOOTSTRAP_COMMAND` without `(python on Windows)` | 12 | killed |
| M7 | NIT-2's tail back to "neither ... before both merges are made" | 2 | killed |
| M8 | `AGENTS-shape.md`'s "Work from here" caveat removed | 1 | killed |
| M9 | the sentence after the five-commands table removed | 1 | killed |
| M10 | `README.md`'s sentence removed | 1 | killed |
| M11 | #480's NOTE back to plain `python3` | 1 | killed |
| M12 | the collision follow-up's "until then" back to plain `python3` | 2 | killed |
| M13 | after the merges, NEXT says `make bootstrap` where a directory stops make | 1 | killed |
| M14 | the lookup takes the LAST kept name (`reversed`) | 4 | killed |
| M15 | the directory NOTE's lead ignores a kept `Makefile` | 1 | killed |
| M16 | the lookup folds case (`fold=True`) | 4 | killed |
| M17 | the clause drops GNU make's own words (`GNUmakefile: Is a directory.`) | 10 | killed |
| M18 | the file clause says `does` whatever `has` is | 0 | **survived** |

M18 was equivalent before the merge: the file clause's only caller was the `CONTRACTS_DIR` line. Since the merge, #1121's NOTE calls it with `has them`, and `tests/test_adopt_next_make_reads_first.py` pins that wording. M18 was not run again.

Each run went through the lane's runner: `gh` stubbed first on PATH with a bogus token, `GIT_SSH_COMMAND=false`, `GIT_CONFIG_GLOBAL=/dev/null`, `EMAIL` set, `-p no:cacheprovider`, and `tmp_path_retention_policy=failed`. Each run is on a commit, with a clean tree.

| run | commit | git | files | passed | failed |
|---|---|---|---|---|---|
| gate M | `6fa1edd56`, the merge | 2.43.0 | the new file, `test_adopt_next_make_reads_first.py`, `test_adopt_e2e.py`, `test_adopt_make_reads_first.py`, `test_path_guard_hygiene.py`, `test_repo_hygiene.py`, `test_agents_md_codes.py`, `test_cli_reference.py`, `test_pinned_copy_text.py`, `test_scaffold_leg_path_collisions.py` | 618 | 0 |
| gate N | `6fa1edd56` | 2.47.1 | the new file and `test_adopt_next_make_reads_first.py` (75), then `test_adopt_e2e.py` (27), run one after the other | 102 | 0 |
| gate H | `6fa1edd56` | 2.47.1 | the hygiene five | 379 | 0 |
| gate A2 | `75c90b6db` | 2.43.0 | the new file, `test_adopt_e2e.py`, the hygiene five (`test_path_guard_hygiene.py`, `test_repo_hygiene.py`, `test_agents_md_codes.py`, `test_cli_reference.py`, `test_pinned_copy_text.py`), `test_adopt_make_reads_first.py`, `test_adopt_contracts_dir.py`, `test_adopt_printed_sentences.py`, and the template's readers: `test_scaffold_e2e.py`, `test_scaffold_free_text_values.py`, `test_free_plan_hint.py`, `test_template_quoted_values.py`, `test_template_values_single_pass.py`, `test_template_text_placeholders.py`, `test_bootstrap_placement_texts.py`, `test_park_resume_targets.py`, `test_update_shape_hardlink.py` | 1128 | 0 |
| gate A | `1c7ca5c6d` | 2.43.0 | 17 files (the new file, `test_adopt_e2e.py`, the hygiene five, `test_scaffold_leg_path_collisions.py`, `test_adopt_make_reads_first.py`, `test_adopt_contracts_dir.py`, `test_adopt_printed_sentences.py`, `test_adopt_attributes_eol_block.py`, `test_adopt_leg_path_collisions.py`, `test_scaffold_e2e.py`, `test_bootstrap_placement_texts.py`, `test_park_resume_targets.py`, `test_template_text_placeholders.py`) | 966 | 0 |
| gate B | `1c7ca5c6d` | 2.47.1 | the new file, `test_adopt_e2e.py`, `test_path_guard_hygiene.py`, `test_repo_hygiene.py` | 209 | 0 |
| doctor | `1c7ca5c6d` | 2.43.0 | `test_shape_doctor.py`, `test_scaffold_leg_path_collisions.py` | 549 (3 skipped: the PowerShell rows, which run only on a Windows host) | 0 |

`tests/` was grepped for every line this PR changes in `templates/assembly-root/` ("They are the shape", "reads first holds", "includes a Makefile that", "(above)", "here and below", "Where this root keeps", "it is what the shape", "before `Makefile`", "`python` on Windows"). Only `tests/test_adopt_make_bootstrap_followups.py` pins them. Four other files read the README as a whole, and each passes in gate A2:
- `test_scaffold_free_text_values.py` counts its lines against the template;
- `test_free_plan_hint.py` looks for "Free plan" and `--repo`;
- `test_template_quoted_values.py` and `test_template_values_single_pass.py` render it.

`git merge-tree --write-tree` of the head `01e93b6d1`, on git 2.43.0, at 18:11Z.
- **Main** `9729315f1`, fetched again at 18:11Z, is the main this round merged last. The merge-tree is clean, and its tree is the head's own, `f6488542f`.
- **Main moved to `801a7d6d0`** at 18:14Z, when lane 3's #1106 landed (`adopt-project.py` and two locale test files). The merge with it is clean, tree `25bc27d39`, and gate P4 passed on it. It was not merged in: it touches none of the code this round resolves, and landing refreshes the branch anyway.
- **The open PRs:** one `gh pr list --state open --limit 100 --json number,headRefName,headRefOid,files` read at 18:11Z returned 51 open PRs. 26 of them touch one of this PR's paths. That includes `tests/test_adopt_collision_make_reads.py` and `tests/test_adopt_make_reads_first.py`, which this PR now changes. 25 merge cleanly: #1106, #1120, #1122, #1125, #1141, #1143, #1153, #1154, #1170, #1171, #1177, #1178, #1186, #1189, #1194, #1198, #1210, #1225, #1244, #1249, #1251, #1252, #1253, #1265 and #1268. #1106 has landed since (above).
- **Lane 1's #1189** (`472944b5d`, read fresh at 18:11Z) edits three test files that this round changes too: `tests/test_adopt_next_make_reads_first.py`, `tests/test_adopt_collision_make_reads.py` and `tests/test_adopt_make_reads_first.py`. The merge is clean, tree `7fd030b29`. #1189's hunks are in the imports, in the clone rows' parameter lists and docstrings, and in a new refusal row, away from the moved pins, the `makefile-directory` row and NIT-A's comment. On that predicted merge, a local commit object, the three shared files pass on git 2.43.0: `tests/test_adopt_make_reads_first.py` and `tests/test_adopt_collision_make_reads.py` give 62 passed, and `tests/test_adopt_next_make_reads_first.py` gives 38 passed. There are fewer rows than at this head because #1189 leaves out the clone rows that keep case twins.
- **#1237** (`b557859fd`) conflicts in `tests/test_adopt_check_throwaway_repos.py`, a file this PR does not change. Main conflicts with #1237 in that file too, while `6fa1edd56` did not, so the conflict is main's, carried in by the merge.
- **Main moved again after the round** (rv1207e, at 19:25Z): lane 1's #1143 landed as `81eaf757c` (`adopt-project.py`) and lane 4's #1117 as `9252ef208` (README, the handbook and `scripts/family.py`). The head merges clean with both (trees `e40373967` and `279f8c6ce`), and rv1207e's gate P passed on the predicted merge with `9252ef208` (359 passed). At 19:22Z, 48 PRs were open, 24 touch this PR's files, and 23 merge clean; #1237's conflict is main's, as above.
- **No longer on the list:** #1105, #1121, #1118 and #1123 are on main. Since `6fa1edd56`, #1104, #1160, #1169, #1180, #1190 and #1223 landed too.

The conflicts are the same in every order, measured offline both ways round and with predicted squashes:
- **#1121:** 4 hunks, 84 lines, in `adopt-project.py`'s `_next_steps` and `cmd_execute`'s comment.
- **#1105:** 3 hunks, 65 lines, in `scripts/shape_materialize.py`'s `collision_follow_up`: its docstring's NIT-4 sentence, its paragraph on the Makefile's merge, and its two `return`s.
- #1121 and #1105 merge with each other cleanly, and so do #1104 and this PR.

So the order decides only who resolves them. **Both have landed**, and lane 5 resolved both on this branch:
- **#1121** (merge `6fa1edd56`). The resolution is one lookup and one clause, `BOOTSTRAP_COMMAND` in #1121's NOTEs, and #1121's three test pins moved.
- **#1105** (merge `7b0192bde`, see "Main merge after #1105"). The resolution keeps #1105's `reads_first` branch and runs `BOOTSTRAP_COMMAND` through it. NIT-2's tail is this PR's where `make` reads the merged `Makefile`, and #1105's where `make` reads another file. Four of #1105's test pins moved: `MERGE_IS_ENOUGH`, `BOTH_MERGES`, `MEANWHILE` and `SCRIPT_MERGED`.

Main was merged in once more after lane 1's #1123 (merge `01e93b6d1`): one of #1123's rows pinned the line this PR changes for a kept `makefile/` directory, and it moved (see "The second merge, after #1123").

No other PR has to land first now. `6fa1edd56` was re-checked READY (rv1207b, rv1207c and rv1207d, issuecomment-6722602375). The head, `01e93b6d1`, needs a check of its delta since then: the two merges' resolutions, the four moved pins in #1105's file, #1123's moved row, and NIT-A.

#1240 tracks what this PR leaves:
- #1132's item 4 (one `GNU_MAKE_READS`, one lookup);
- #1105's collision line, for a kept directory (its `python3` part is done here: see "Main merge after #1105");
- #1121's file NOTE beside a kept `Makefile`, which does not name the merge (as this PR's directory NOTE now does);
- #1105's second review's NIT-1, NIT-3b, NIT-3c, NIT-4 and NIT-5;
- `_make_reads_first_clause`'s `has` argument, now live;
- rv1207e's NIT-1: the docstring sentence "With none, the Makefile's follow-up is what it was, byte for byte" (`scripts/shape_materialize.py` about :1067), kept from #1105, is no longer true, since this PR changes the line with no `reads_first`. It sits beside #1240's items F and G, which reword the same docstring.

The local branch `fix/1132-template-bootstrap-stacked` (`9eb5cce0b`, never pushed and never tested) is a model of the end state on #1105 + #1121 + main.

- **Item 5,** follow-ups that go stale after a hand edit of the plan, is its own issue, filed as #1206. It also holds the three related cases this work found:
  - a kept `makefile/` directory gets "until the two are merged";
  - a directory kept only through deeper entries is not seen by `_root_keeps`;
  - a kept `Makefile/` directory is treated as a Makefile.
- **This PR's `answered-root` row meets item 5 too.** `plan` asks about `GNUmakefile/`, and its stored `CONTRACTS_DIR` line, written before the answer, names no directory. The row asserts what NEXT and `make` do there, and not that line.
- **Not measured:** a disk that ignores case, and GNU make other than 4.3.

Review: rv1207b and rv1207c, lane 5's independent opus reviewers, and rv1207d, lane 5's independent sonnet reviewer, none of which wrote #1207: READY at `6fa1edd5` (issuecomment-6722602375). Then rv1207e, lane 5's independent opus reviewer, which wrote none of it: READY at `01e93b6d`, H0 of this landing, after the main merges past #1105 and #1123 (issuecomment-6726033282), with no MUST or SHOULD; its three NITs are answered in the body. CI (Brett Heap's ruling 27 and his fast-refresh ruling of 2026-10-15T22:48:35Z): H0 01e93b6 passed tests, tests-git-bash and SonarCloud; the head c9be952 is a clean update-branch merge of main 9cb156a, with tests-git-bash and SonarCloud green; and the local gate passed on its predicted squash tree 0a01d35 over main 9cb156a: the adopt_collision_make_reads, adopt_e2e, adopt_make_bootstrap_followups, adopt_make_reads_first, adopt_next_make_reads_first, repo_hygiene, agents_md_codes, cli_reference sets, 333 passed. Landed on Brett Heap's word of 2026-10-23T13:10:26Z, relayed to every lane by lane 3 (#473 issuecomment-6365697123): "merge v1.2.1 PRs once reviewed and green".

Closes #1132

Lane: openreposhape-5 (openRepoShape-5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Nov 10, 2026
…r own premise or read their UTF-8 file as UTF-8, and the 13th, the assembly root bootstrap.py saying it could not create a branch it made, is left failing for its own issue (#1259) (#1278)

 This PR settles 12 of its 13 rows. The 13th row is a tool defect (kind c below), left failing on purpose, and it is now #1283, the issue of its own that #1259's first "Done when" box asks for, so nothing in #1259 is left open.

## Goal

#1259 counts 8 rows of `tests/test_pinned_copy_text.py` and `tests/test_family.py`, and its comment 5 rows of `tests/test_bootstrap_spelling.py`, that fail under a Latin-1 locale and pass under UTF-8. None had a kind. Each is measured here, by test id, into #1214's kinds:

- **a, cannot judge under a one-byte locale (11 rows):** each skips there on its own premise, which the skip reason states.
- **b, the test reads wrongly (1 row):** corrected; it now runs and passes under Latin-1.
- **c, a tool defect a Latin-1 user would meet (1 row):** not fixed, and the row is untouched. The evidence is under "The tool defect".

Main is `42308f26b`, which holds #1258 (the helper `skip_where_the_locale_does_not_spell_it_as_utf_8` and its premise sentences). This branch is one commit on it. It changes three test files and no tool.

## The 13 rows

| # | Test id | Kind | Measured under Latin-1 | Change |
|---|---|---|---|---|
| 1 | `test_pinned_copy_text.py::test_the_variable_the_warning_offers_reads_the_later_link` | a | Exit 0 and no WARNING, as the row asserts. Stdout reads `openXdox \u2192 openYdox \u2192 openInk`: `scaffold-project.py` calls `escape_what_stdout_cannot_encode()` (#214) at the start of `main`, so the arrow is printed escaped by design. | `skip_where_the_locale_does_not_spell_it_as_utf_8("\u2192", PRINTED_AS_ITSELF)`, after the exit and WARNING asserts |
| 2, 3 | `test_pinned_copy_text.py::test_an_unused_pin_source_is_named_spelled[esc]`, `[forged-line]` | a | Exit 0 and no ESC, as asserted. The note reads `not used \u2014 each declared pin ...`. The root's `validate-pins.py` makes a `strict` or `surrogateescape` stdout `backslashreplace` in `_emit_report` (#295), the reconfigure `escape_unencodable_stdout` does, written there because that file imports nothing but `repo_shape`. | the same guard on `"\u2014"`, after the ESC assert |
| 4 | `test_pinned_copy_text.py::test_a_replaced_pin_source_and_its_replacement_are_spelled` | a | The same: both notes read `not used \u2014 the later ...`. | the same |
| 5 | `test_pinned_copy_text.py::test_a_key_read_as_a_path_is_spelled` | a | The same. | the same |
| 6 | `test_pinned_copy_text.py::test_a_printable_pin_source_is_named_as_typed` | a | The same. | the same, after the exit assert |
| 7 | `test_family.py::test_init_writes_the_holders_agent_files` | **b** | `init` writes the holder's `AGENTS.md` as UTF-8 under Latin-1 too: its first line holds `e2 80 94` for U+2014. The row read it with `read_text()`, in the locale's codec, so U+2014 came back as three characters. | its four `read_text()` calls take `encoding="utf-8"` |
| 8 | `test_family.py::test_commit_one_refuses_a_trailer_that_is_no_text_before_it_stages` | a | `os.fsdecode(b"Co-Authored-By: Jos\xe9")` is `...Jos\xe9` (U+00E9), and `_commit_one` commits the trailer as `Co-Authored-By: Jos\xc3\xa9`, the text a Latin-1 terminal typed. Under UTF-8 the same bytes read as `...Jos\udce9`, and `_commit_one` refuses `trailer-not-utf8` with `a.txt` still untracked. The tool is right in both. | `skip_where_the_locale_does_not_spell_it_as_utf_8("Co-Authored-By: Jos\udce9", A_BYTE_READ_AS_A_SURROGATE)`, before the `pytest.raises` |
| 9 | `test_bootstrap_spelling.py::test_a_register_and_its_path_are_spelled_when_it_cannot_be_read` | a | The TEST raises `UnicodeEncodeError` on U+2028 in `os.mkdir`, before any tool runs. | `skip_where_the_environment_cannot_carry("sp\u2028ec")` |
| 10 | `test_bootstrap_spelling.py::test_a_roots_own_directory_name_is_spelled` | a | The test raises in `os.rename` (`shutil.move`). | `skip_where_the_environment_cannot_carry(renamed.name)` |
| 11 | `test_bootstrap_spelling.py::test_a_family_roots_own_directory_name_is_spelled` | a | The same. | the same |
| 12 | `test_bootstrap_spelling.py::test_a_members_row_and_the_make_target_are_spelled` | a | The test raises in `open` (`write_bytes`) of `ta\u2028rget.py`. | `skip_where_the_environment_cannot_carry(target)` |
| 13 | `test_bootstrap_spelling.py::test_a_branch_name_is_spelled_in_every_line_that_names_it` | **c** | The assembly root's `bootstrap.py` makes the branch and then says it could not. See "The tool defect". | none |

**Why rows 9 to 12 take `skip_where_the_environment_cannot_carry`.** The four `UnicodeEncodeError`s that #1259's comment reads are the test's own: `os.mkdir`, `os.rename` and `open` of a name holding U+2028, which Latin-1 cannot encode. The docstring of #1258's helper gives such a row to that guard ("A name the TEST cannot make or pass at all is `skip_where_the_environment_cannot_carry`'s"), as #1258 did for its 18 "a1" rows. Its reason names the encoding and the name, for example `this system's file name encoding (iso8859-1) cannot spell 'At\u2028las'`.

**No tool traceback hides behind them.** I ran both roots' `bootstrap.py` under Latin-1, with the row's `PYTHONIOENCODING=utf-8:strict`, on the manifests those rows had written before they raised: the leg path `"sp\u2028ec"`, the member path `"members/Ir\u2028s"` and the project `"Bo\u2028x"`. Neither printed a traceback. The assembly root printed `[spec] sp\u2028ec: NOT INITIALIZED ...` and `bootstrap ok`, exit 0. The family root spelled both members and ended at its own `family bootstrap FAILED` for the two members whose `make` the probe ran, exit 1.

**The guards ask only of the text their premise is about,** just before the first line that needs it, as #1258's do. The asserts before each guard still judge under Latin-1 (exit code, no ESC, no WARNING). Under UTF-8 no guard skips. Every skip reason states its premise, for example `this locale's encoding (iso8859-1) cannot spell '\u2014': the row reads this character as itself in what the tool prints, and a stdout in this encoding writes it as an escape (#214)`.

## The tool defect (row 13, kind c): not fixed here

**This defect is #1283.** Lane 4 filed it from the evidence below, as #1259's first "Done when" box asks. This PR changes no tool, and row 13 stays failing and untouched until #1283 is mended.

**What a Latin-1 user meets.** Take a project whose `project.yaml` says `tracking_branch: "tb\udcffx"`, the spelling `bootstrap.py` takes for a branch holding the byte 0xFF (#715). Under Latin-1, `make bootstrap` makes that branch in each leg, with HEAD on it at the pin, then prints:

```
  [spec] spec: could not create branch 'tb\udcffx' at the pin f6d8ff445a2d; leaving detached
          `git checkout -b` exited 0, and HEAD is not on the branch at the pin
          nothing else is tried; the recorded pin is authoritative. Deal with what git said and run bootstrap again.
```

Every later run prints `branch tb\udcffx is at the pin f6d8ff445a2d, and git refused to check it out:` with the same two lines, and exits 0. Both claims are false.

**Measured** in the tree the failed Latin-1 run kept, before and after a second run:
- `git symbolic-ref HEAD` in `spec` and in `code` gives `refs/heads/tb\377x`;
- `git rev-parse HEAD` gives the pin, `f6d8ff44...` and `ce229835...`, which equal `git rev-parse HEAD:spec HEAD:code` in the root.

Under UTF-8 and ASCII the same manifest gives `branch tb\udcffx created at <pin>` and, on the next run, `on tb\udcffx at <pin> (branch tip == pin)`. The row passes in both.

**The code at fault** (`templates/assembly-root/scripts/bootstrap.py`, at main `42308f26b`; on `2fde6c3d0` the same lines are :841, :857, :922, :1505 and :1755):
- `_head_of` (:782) returns HEAD's ref as `os.fsdecode(ref.rstrip(b"\r\n"))` (:798). Its docstring says such a name "reads back as the `refs/heads/<branch>` built from the same name". That holds only where `os.fsdecode(os.fsencode(name)) == name`.
- Under Latin-1, `os.fsencode("tb\udcffx")` is `b"tb\xffx"` (surrogateescape), which is what git is handed. `os.fsdecode(b"tb\xffx")` is `"tb\xffx"` (U+00FF), not `"tb\udcffx"`.
- So the text comparisons of `(pin, f"refs/heads/{branch}")` with `_head_of(sub)` fail with HEAD on the branch:
  - the creation step, `if _head_of(sub) != (pin, f"refs/heads/{branch}")` (:1696), which prints `could not create branch` (:1698);
  - `_check_out`, `if _head_of(sub) == (pin, f"refs/heads/{branch}")` (:863), which returns "`git checkout` exited 0, and HEAD is not on the branch at the pin" (:866), and its caller prints "git refused to check it out" (:1446).

## Runs

The commands, the environment and the logs are W1259's. Pytest is `/usr/bin/python3 -m pytest -p no:cacheprovider` on Python 3.12.3. The environment for every run:
- a stub `gh` first on PATH, `GH_TOKEN=bogus`, an empty `GH_CONFIG_DIR`;
- `GIT_CONFIG_GLOBAL` an empty file, `GIT_CONFIG_NOSYSTEM=1`, the test identity, `EMAIL` set;
- `GIT_ALLOW_PROTOCOL`, `GIT_SSH_COMMAND` and `LANES_*` unset;
- git-filter-repo 2.47.0 (`a40bce548d2c`, pip launcher) first on PATH.

The locales:
- UTF-8 is `LC_ALL=C.UTF-8`.
- Latin-1 is built with `localedef -c` as #1153's `test_adopt_one_byte_locale.py` builds one, then `LOCPATH`, `LC_ALL=en_US.ISO-8859-1`, `PYTHONUTF8=0`. Python reports `iso8859-1`.
- ASCII is `LC_ALL=C PYTHONUTF8=0 PYTHONCOERCECLOCALE=0`.

**The gate: 22 test files, on main `42308f26b` and on this head.** They are:
- the three files of the 13 rows;
- the other 14 test files #1258 changed;
- `tests/test_adopt_one_byte_locale.py`;
- the 4 more test files that use a name this PR calls (`skip_where_the_locale_does_not_spell_it_as_utf_8`, `PRINTED_AS_ITSELF`, `A_BYTE_READ_AS_A_SURROGATE`, `skip_where_the_environment_cannot_carry`): `test_adopt_git_reads.py`, `test_non_utf8_git_failures.py`, `test_non_utf8_git_reads.py`, `test_non_utf8_oserror_sites.py`.

The 71 other test files that import from one of the three changed files were collected in each locale, on main and on the head. Each run collects 3782 tests with no error, and the per-file counts are identical.

| Run | main `42308f26b` | this head |
|---|---|---|
| 22 files, Latin-1 | 35 failed, 1144 passed, 87 skipped | 23 failed, 1145 passed, 98 skipped |
| 22 files, UTF-8 | 1265 passed, 1 skipped | 1265 passed, 1 skipped |
| 22 files, ASCII | 52 failed, 1120 passed, 94 skipped | 41 failed, 1121 passed, 104 skipped |
| the three files, Latin-1 | 13 failed, 394 passed | 1 failed (row 13), 395 passed, 11 skipped |
| the three files, UTF-8 | 407 passed | 407 passed |
| the three files, ASCII | 27 failed, 380 passed | 16 failed, 381 passed, 10 skipped |

**By test id, from main to the head:**
- **Latin-1:** 12 rows change, and nothing else: rows 1 to 6 and 8 to 12 go from failed to skipped, and row 7 from failed to passed. No row goes from passed to failed or to skipped. Each of the head's 23 failures fails on main too: row 13, and 22 rows in other files of the gate, which are not among #1259's 13 (see "Left").
- **UTF-8:** nothing changes. The one skip is `test_stdout_encoding.py`'s Windows default-stdout row, on both.
- **ASCII:** 11 rows change, and nothing else: 10 go from failed to skipped and row 7 from failed to passed. Rows 8 and 13 pass under ASCII on main and still do. No row goes from passed to failed or to skipped.

**#1259's "Done when", on a scratch merge.** The merges are main `42308f26b` with #1209's head `13a2c58cb` (`bad3de928`), then with this head (`20fcb11e1`). Both are local, never pushed, and both merged clean.

| Run | main + #1209 | main + #1209 + this head |
|---|---|---|
| `test_pinned_copy_text.py` and `test_family.py`, Latin-1 | 8 failed, 192 passed | **0 failed**, 193 passed, 7 skipped |
| the same two, UTF-8 | 200 passed | 200 passed |
| the same two, ASCII | 23 failed, 177 passed | 16 failed, 178 passed, 6 skipped |
| with `test_bootstrap_spelling.py`, Latin-1 | 13 failed, 394 passed | 1 failed (row 13), 395 passed, 11 skipped |
| with `test_bootstrap_spelling.py`, UTF-8 | 407 passed | 407 passed |
| with `test_bootstrap_spelling.py`, ASCII | 27 failed, 380 passed | 16 failed, 381 passed, 10 skipped |

By test id on the merges: UTF-8 changes nothing; Latin-1 and ASCII change exactly the rows above. The 16 ASCII failures are not among the 13, and fail on main + #1209 as well (see "Left").

**Main moved after these runs**, to `2fde6c3d0`. That commit makes both roots' `bootstrap.py`, `validate-family.py` and `siblings.py` refuse `git-repo-unreadable` where the root's `.git` cannot be read, and changes `tests/test_validate_family_unreadable.py` (one of the 71 files collected above) and adds `tests/test_pinned_root_git_unreadable.py`. It touches none of this PR's three files, and `git merge-tree` of this head with it is clean. The runs above were not repeated on it. Main then moved again, to `674077657` (#1120, `adopt-project.py`). RV1278 re-ran a 20-file gate (the three files, #1258's other 14 test files, `test_adopt_one_byte_locale.py` and #1172's two test files) on a scratch merge of this head with `674077657`: Latin-1 20 failed, 1142 passed, 84 skipped (main: 32 failed, 1141 passed, 73 skipped); UTF-8 1245 passed, 1 skipped on both; ASCII 41 failed, 1124 passed, 81 skipped (main: 52 failed, 1123 passed, 71 skipped). By test id only the rows above change, and every remaining failure fails on main too.

## Mutants

Each mutant was applied in a scratch worktree at the head, inside the one test function named. Its row ran under Latin-1 and ASCII. The file was then restored from HEAD and its sha256 checked equal; all 14 were.

| Mutant | Row | Latin-1 | ASCII |
|---|---|---|---|
| M1: the `PRINTED_AS_ITSELF` guard dropped | 1 | **1 failed** | 1 failed |
| M2: the same | 2, 3 | **2 failed** | 2 failed |
| M3: the same | 4 | **1 failed** | 1 failed |
| M4: the same | 5 | **1 failed** | 1 failed |
| M5: the same | 6 | **1 failed** | 1 failed |
| M6: the `A_BYTE_READ_AS_A_SURROGATE` guard dropped | 8 | **1 failed** | 1 passed: ASCII reads 0xE9 as U+DCE9, so the guard does not skip there and the row judges |
| M7: `AGENTS.md` read in the locale's codec again | 7 | **1 failed** | 1 failed |
| M8: the first read of `AGENTS-shape.md` in the locale's codec | 7 | 1 passed | **1 failed** (`UnicodeDecodeError`) |
| M9: the second read of `AGENTS-shape.md` the same | 7 | 1 passed | **1 failed** |
| M10: the read of `CLAUDE.md` the same | 7 | 1 passed | 1 passed |
| M11: the `skip_where_the_environment_cannot_carry` guard dropped | 9 | **1 failed** | 1 failed |
| M12: the same | 10 | **1 failed** | 1 failed |
| M13: the same | 11 | **1 failed** | 1 failed |
| M14: the same | 12 | **1 failed** | 1 failed |

- **M8 and M9 survive under Latin-1, as expected.** Latin-1 decodes every byte, and the text those two reads are checked for is ASCII. They are killed under ASCII, where #1259 asks the run to be looked at, and where the row now passes.
- **M10 is equivalent in every locale.** `CLAUDE.md` is the 16 ASCII bytes `Read AGENTS.md.\n`, which every codec reads alike. It is changed with the other three, so the row reads every file `init` wrote in one way.

## Merge-trees

`git merge-tree --write-tree` of this head is clean against:
- `origin/main` `42308f26b`;
- #1209 `13a2c58cb`;
- #1282 `f71c28978` (checked by RV1278 on 2026-11-09);
- the two open PRs that touch these files: #1201 `24b6a0af6` (`tests/test_family.py`) and #1171 `8162b874e` (`tests/test_pinned_copy_text.py`).

Neither of those two changes a row this PR touches. #1201's hunks are at an import and `test_add_refuses_a_spelling_of_a_member_the_family_already_pins`; #1171's are at `PINNED_IMPORTERS`.

## Left, and outside this issue

- **Row 13's tool defect**, above. It is #1283, the issue of its own that lane 4 filed for it. Once #1283 is mended, the row passes under Latin-1 as it is written.
- **Under ASCII, 16 rows of the two files still fail,** on main and here alike. #1259 asked that this run be looked at. None of these rows is among the 13, and each passes under Latin-1 and UTF-8. Read from their failure messages only:
  - 15 rows of `tests/test_family.py` read a UTF-8 file the tool wrote (`family.yaml` and others) with `read_text()` and no encoding, and end in `UnicodeDecodeError`: row 7's kind b. They are `test_init_copies_the_siblings_utility_and_the_makefile_target`, `test_the_holder_says_what_its_bytes_are`, the five `test_validate_finds_*` and `test_validate_accepts_*` rows, three `test_bump_*` rows, three `test_update_shape_*` rows, `test_no_members_still_finds_an_edited_copy` and `test_siblings_skips_a_clone_whose_project_id_is_not_the_rows`.
  - `tests/test_pinned_copy_text.py::test_a_printable_pin_source_that_is_not_a_repository_is_named_as_typed[caf\xe9]`: the test itself cannot make `caf\u00e9` under ASCII (`os.mkdir` raises `UnicodeEncodeError`), rows 9 to 12's kind.
- **22 other Latin-1 failures in the gate's other files** fail on main and here alike, and are not #1259's. They are 12 rows of `test_clone_url_bytes.py`, 2 each of `test_family_member_branch_not_utf8.py`, `test_non_utf8_git_reads.py` and `test_stdout_encoding.py`, and one each of `test_adopt_git_reads.py`, `test_adopt_pins.py` (`[not-utf-8]`), `test_adopt_template_values.py` and `test_bootstrap_leg_moves.py`. They were not run on the merge with #1209.

Closes #1259

Lane: openreposhape-4 (openRepoShape-4)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Nov 10, 2026
…not text as `_read_as` says what the plan's reader read, "records `commit:` as the number 7", where it spelled it as Python does, `commit: 7` and `True`, so `check` and `execute` name it in the words the plan's other refusals use under the same `plan-pin-malformed` (#1114) (#1198)

This PR lands only after the v1.2.0 tag, on Brett's word.

## What

`_pin_row_problem` holds each of a pin's five fields (`product`, `repository`, `commit`, `tree_sha256`, `digest_source`) to text. A value that is not text it spelled with Python's `repr`: a number as `commit: 7`, a boolean as `True`, a list as `['a', 'b']` and a mapping as `{'k': 'v'}`. Every other refusal of a plan's value says what the reader read, with `_read_as`: "the number 7", "the boolean true", "a list of 2 item(s)", "a mapping of 1 key(s)". W1020 found the gap while working on #1020.

It says it that way now, field by field, in `adopt-project.py`'s `_pin_row_problem`, in the `not_text` branch only:

- one field: ``records `commit:` as the number 7, which is not text``
- two or more: ``records `commit:` as the number 7, `tree_sha256:` as the boolean true, which are not text``

What stays as it was:

- the code, `plan-pin-malformed`, the remedy, and the sentence's ending, `which is not text`;
- every text value's spelling, byte for byte (`commit: '7'`, which is not 40 hex);
- a null or a blank: it is "records no `commit:`" under the code it has always had, and no value is spelled there.

Every field takes the one site (`PIN_FIELDS`). The docstring and a comment say so. The change is 13 lines added and 4 removed in `adopt-project.py`.

## Behaviour change

A pin field that is a number, a boolean, a list or a mapping is named by what it was read as, where it was named as Python spells it. A text value, a null and a blank print as they did.

## Rows

`tests/test_adopt_pin_row_values.py` is new, ASCII only, with 45 rows. Each runs `check` and then `execute --yes`, with a stub `gh` first on PATH and `--local-remote-dir`, and asserts one finding, `execute` refusing with that same finding, an empty `gh` log, no remotes directory made and no Traceback.

| Group | Rows | On main's code | On this head |
| --- | --- | --- | --- |
| The matrix: 5 fields by number, boolean, list, mapping | 20 | 20 failed | 20 passed |
| The whole sentence: `commit: 7`, and a boolean `digest_source` | 2 | 2 failed | 2 passed |
| Edge forms: 0, false, 7.5, -3, 007, `[]`, `{}`, `[a]` | 8 | 8 failed | 8 passed |
| Two fields at once, a non-text commit beside bad text, entry 2 | 3 | 3 failed | 3 passed |
| Null and blank controls | 6 | 6 passed | 6 passed |
| Text controls (`commit: "7"` and `"true"`, another product, no owner, short digest, source by hand) | 6 | 6 passed | 6 passed |
| **All** | **45** | **33 failed, 12 passed** | **45 passed** |

Every one of the 33 failures is the finding text holding the repr spelling (``records `commit: 7` ``, `True`, `['a', 'b']`, `{'k': 'v'}`, `{}`, `[]`). There is no crash or other cause. The 12 that pass on main are the controls, which pin what must not change.

Two existing rows pinned the old spelling, and no others did. Each now expects the new one, and both pass on this head (2 passed):

- `tests/test_adopt_pins.py`, the `a-number-commit` row: `` `commit:` as the number 1234567 ``;
- `tests/test_adopt_plan_value_order.py`, the `not-text` row: `` `digest_source:` as the number 7 ``.

## Mutants

19 mutants of this head's `adopt-project.py`, all killed. Each was run against the new file (first failure with `-x`, or a whole run where the table says so), and each run was restored with its sha256 checked.

| Mutant | Result |
| --- | --- |
| M1: main's repr form put back | killed, 33 failed and 12 passed |
| M2: `!r` inside the new "as" form | killed, 33 failed and 12 passed |
| M3: `str()` in place of `_read_as` | killed |
| F-repr-product, F-repr-repository, F-repr-commit, F-repr-tree_sha256, F-repr-digest_source: repr put back for one field only | 5 of 5 killed, each by that field's own rows |
| M4: "is" in place of "as" | killed |
| M5: singular and plural swapped | killed |
| M6: only the first field named | killed |
| M7: `missing` takes any falsy value (an existing guard; the zero, false and empty rows pin it) | killed |
| M8: only a list and a mapping counted as not text | killed |
| M9: the ending without "how it was read" | killed |
| M10: the code `plan-pin-unrecorded` | killed |
| T1 to T4: the text branches unquoted (commit, product and repository, digest, source) | 4 of 4 killed |

## Gate

A scratch merge of this head `d38e4e36d` with main `961640c68`: commit `1ef3f0783`, tree `b12197610`, which is this head's own tree. Targeted files only, in the landing gate's environment (a stub `gh` first on PATH, `GH_TOKEN=bogus`, an empty `GH_CONFIG_DIR`, an empty global git config). The set is 47 test files: every one that names `plan-pin-malformed`, `plan-pin-unrecorded`, `_pin_row_problem`, `_read_pins` or `pins:`, the new file, and `test_path_guard_hygiene.py`, `test_repo_hygiene.py` and `test_scaffold_leg_path_collisions.py`; and `test_shape_doctor.py` (448 ids, each in exactly one shard, run from a script that reads each list into an array because 25 ids hold spaces). Every chunk exited 0, with 0 failed.

| Chunk | Files | Result |
| --- | --- | --- |
| f01 | `test_adopt_pins.py` | 150 passed |
| f02 | `test_adopt_plan_yaml_quoting.py`, `test_adopt_plan.py` | 606 passed, 1 skipped |
| f03 | `test_adopt_execute_refusals.py`, `test_adopt_pin_row_values.py`, `test_adopt_plan_escapes.py`, `test_adopt_plan_value_order.py`, `test_adopt_reencoded_files.py`, `test_adopt_root_symlinks.py`, `test_adopt_shape_pin_and_work_dir.py`, `test_adopt_template_values.py` | 661 passed, 3 skipped |
| f04 | `test_bump_remedies_family_root.py`, `test_chain_link_fold.py`, `test_chain_pin_sources.py`, `test_chain_remedy_callers.py`, `test_doctor_gitlink_repairs.py`, `test_doctor_recorded_answers.py`, `test_family_add_member_id.py`, `test_family_makefile_siblings.py` | 255 passed |
| f05 | `test_family_tracking_branch.py`, `test_legs_not_a_list.py`, `test_link_source_chain_defaults.py`, `test_manifest_validator.py`, `test_naming_policy.py`, `test_neutral_pin_entry_one_spelling.py`, `test_neutral_pin_validator.py`, `test_non_list_project_fields.py` | 757 passed |
| f06 | `test_path_guard_hygiene.py`, `test_pin_annotated_tag.py`, `test_pin_source_env_collisions.py`, `test_pinned_copy_text.py`, `test_reader_refusals_named.py`, `test_repo_hygiene.py`, `test_scaffold_e2e.py`, `test_scaffold_leg_path_collisions.py` | 599 passed |
| f07 | `test_scaffold_pin_and_reuse.py`, `test_scaffold_pin_collisions.py`, `test_scaffold_referent_chain_links.py`, `test_setup_project_py.py`, `test_template_text_placeholders.py`, `test_update_shape_add_ignored.py`, `test_update_shape_landing.py`, `test_validate_pins_named_and_spelled.py` | 1078 passed |
| f08 | `test_yaml_flow_brackets.py`, `test_yaml_flow_quotes.py`, `test_yaml_indicator_openers.py`, `test_yaml_reader_spaces.py` | 813 passed |
| d01 | `test_shape_doctor.py`, 56 ids | 56 passed |
| d02 | the same, 56 ids | 56 passed |
| d03 | the same, 56 ids | 56 passed |
| d04 | the same, 56 ids | 56 passed |
| d05 | the same, 56 ids | 56 passed |
| d06 | the same, 56 ids | 56 passed |
| d07 | the same, 56 ids | 56 passed |
| d08 | the same, 56 ids | 53 passed, 3 skipped |

The file chunks hold 4919 passed and 4 skipped (f02: `SHAPE_MEDXEHR_CLONE` is unset; f03: the reftable backend needs git 2.45). The doctor shards hold 445 passed and 3 skipped (d08: the PowerShell line is printed only on a Windows host). In all, **5364 passed, 7 skipped, 0 failed.**

**Run on the merge with #1125's head.** A scratch merge of this head with #1125's head `9549006fe`: commit `8a291d8b2`, tree `88530bb7`. The new file (45), `test_adopt_pins.py` (150), `test_adopt_plan_value_order.py` (40), `test_adopt_execute_refusals.py` (181) and `test_adopt_check_plan_name.py` (45): **461 passed.**

## Merge-trees

`git merge-tree --write-tree`, this head against each, all clean (exit 0), at the heads of 2026-10-23T08:20Z:

- `origin/main` `961640c68`;
- the 23 open PRs that touch `adopt-project.py`: #1194 `900f77af9`, #1190 `00f959c61`, #1189 `4d40ce9fd`, #1186 `07486a498`, #1180 `b316f4157`, #1178 `c4beba193`, #1177 `5208e874e`, #1171 `8162b874e`, #1170 `24ee133aa`, #1169 `258051022`, #1154 `8a7828332`, #1153 `ff33ba12a`, #1143 `7af5fabc3`, #1141 `7a2711d03`, #1125 `9549006fe`, #1123 `5c3908f8d`, #1122 `c01c4d73d`, #1121 `1c5173758`, #1120 `c55e55e33`, #1119 `bba168bdd`, #1118 `2307036ab`, #1106 `504a1dd65`, #1105 `b28f40de0`;
- #1126 `4c1f80cf4`, which touches `tests/test_adopt_pins.py`.

## This PR needs no #1125

#1125 (for #1020) makes `_read_pins` say an entry that is not a pin as `_read_as` says it. Its `adopt-project.py` hunks are at the `_read_pins` docstring and at the non-dict entry's `{row!r}` (about line 625 on main), and they do not touch `_pin_row_problem`. Its test hunks do not overlap the lines this change edits. The two are textually independent: this PR is based on main, not stacked, the merge-tree with #1125's head is clean, and the run above on the merge with its head passed.

An entry that is neither a name nor a mapping stays #1020's, in #1125.

## Not in this PR

The other `repr` in the pin rows are on a value that is text by then: the later branches of `_pin_row_problem` (spelled as before), a text product in an entry's name, and an entry that is a name. They are not gaps.

`docs/release-notes/v1.2.0.md` is left alone. Its lines 297 to 299 mention #901's pins wording, and the release owner may want a line there.

## Out of scope

Four other places in `adopt-project.py` put a plan value of any type into a refusal with `!r`, as the pin rows did: `plan-wrong-kind`, `plan-unsupported-mode`, `plan-bad-leg` and `plan-bad-id`. They are not pin rows, so this change leaves them. They were found by reading the code, not by running it. They are filed as #1199, with each site's line and what it would print.

Closes #1114

Lane: openreposhape-4 (openRepoShape-4)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Nov 10, 2026
…blems against its source, in the order a person mends them (another repository, a refused name, a moved source, an unanswered entry), so `check`'s first finding is `execute`'s refusal for each pair (#1113) (#1210)

**Stacked on #1125.** This PR's base is `fix/1020-bad-id-first-problem` (#1125's branch, head `9549006f`). It lands after #1125 and stays a draft until then. #1125 makes `check`'s first finding `execute`'s first refusal for a bad `id:` or `org:`. This PR extends that rule to the four pairs #1113 measured, which have neither.

**Fix round.** The first gate failed six rows of `tests/test_adopt_relative_submodule_url.py` that pinned `check`'s old order on a plan hand-edited into another organisation, the relative url before `plan-not-the-source`, a plan `execute` already refused `plan-not-the-source` first on #1125's head; they now expect `plan-not-the-source` first, and a new row asserts that both commands name it first.

## The rule and the order

One generator, `_against_its_source`, asks a plan's four problems against its source in one order, and both commands read it. `execute` refuses its first problem. `check` lists each one, in that order and in its own words, before the split branch and the entries.

The order is the one a person mends them in:
1. a plan for another repository (`plan-not-the-source`);
2. a name the naming policy refuses (`naming-unclassified`, or `naming-role-mismatch`);
3. a source that has moved on since `plan` (`plan-stale`);
4. an unanswered entry (`plan-unresolved`).

Why this order:
- **An unanswered entry last.** Each of the first three is mended by running `plan` again, as its remediation says, and a fresh plan takes back every answer given before. An answer given first would be lost.
- **Another repository first.** Nothing in such a plan is this source's own: it is mended by `plan` under the source's own name, or from the source it is about. And `execute` must ask the naming policy nothing about the plan's names, and no remote anything, before it refuses it (#499). `_against_its_source` is a generator, so `execute` asks nothing after the first problem, and that still holds.
- **A refused name before a moved source.** The name is mended by `plan` given another `--project`, or after the source is renamed on GitHub. That run reads the source as it is now, so it mends the moved source too. `plan` run again as it was, for the moved source, would leave the name to mend.
- **The least change to each command.** The order keeps `execute`'s order for the plan's names (#499, #716) and `check`'s order of a moved source before its entries. Only the pairs that disagreed change.

## Before and after

Measured on #1125's head `9549006f` and on this head, with a stub `gh` (exit 97), `GH_TOKEN=bogus`, an empty `GH_CONFIG_DIR`, `GIT_SSH_COMMAND=false`, a proxy that goes nowhere, an empty global git config and `--local-remote-dir`. No run made a leg. `check` exits 1 and `execute` exits 2 in every row.

| The plan holds | `check` before | `execute` before | both, here |
|---|---|---|---|
| a moved source and an unanswered entry (#1113) | `plan-stale` | `plan-unresolved` | `plan-stale` |
| another repository and an unanswered entry (#1113) | `plan-unresolved` | `plan-not-the-source` | `plan-not-the-source` |
| another repository and a moved source (#1113) | `plan-stale` | `plan-not-the-source` | `plan-not-the-source` |
| a refused name and an unanswered entry (#1113) | `plan-unresolved` | `naming-unclassified` | `naming-unclassified` |
| a refused name and a moved source (not in #1113's table) | `plan-stale` | `naming-unclassified` | `naming-unclassified` |
| all four | `plan-stale` | `plan-not-the-source` | `plan-not-the-source` |
| another repository and a refused name | `plan-not-the-source` | `plan-not-the-source` | `plan-not-the-source` (unchanged) |

The fifth row is not in #1113's table, but the two commands disagreed there too, and the same rule decides it.

The same probe, comparing each command's output before and after, with paths and hashes masked:
- A plan with one of the four problems: both commands print the same stderr and stdout before and after.
- Both commands' stdout is the same before and after in every row.
- `check`'s stderr in each pair row holds the same lines as before, reordered: the same findings and the same remediation lines.
- `execute`'s stderr changes in one row only, a moved source beside an unanswered entry: `REFUSED plan-stale`, in its own words, where it said `REFUSED plan-unresolved`.

No refusal's code or wording changes, and no code is added. Re-run on this head after the fix round, the probe gives the same: the 24 plans (these 11, and the 13 of the next section) each get one first problem from both commands, no run makes a leg, and the comparison with #1125's head is the one above, line for line.

## #1113's suspected case: a `--work-dir` that cannot be written

Measured on #1125's head and on this head, the two commands agree in every row, and nothing here changes it:
- **A bad `id:` or `org:` beside a `--work-dir` this user cannot write in** (`chmod 500`): `plan-bad-id` or `unsafe-value` to both. #1125's review round 1 (RV1125's SHOULD-1) made both commands ask the two before `_work_root`, which settled this case.
- **Each of the 11 plans above beside the same `--work-dir`:** `adopt-work-dir-unwritable` first to both.

## What changed, in `adopt-project.py`

- **`_against_its_source` and `_Unmended` (new).** `_against_its_source` is the rule. It asks:
  - `_refuse_a_plan_for_another_repository`;
  - `_check_names`, given the source only where the plan names no other repository, as `check` gave it (#716);
  - `_refuse_an_unrunnable_plan`.

  It yields each problem as an `_Unmended`: the `Refusal` `execute` refuses it with, and `check`'s FINDING lines and remediation for it, in `check`'s words as they were. `check` lists an unanswered entry with the entries, each by its path (`_leg_findings`), after the rule's problems.
- **`cmd_execute`.** It refuses the first problem, `next(_against_its_source(...))`. Before, it called `_refuse_a_plan_for_another_repository`, `_check_names` and `_refuse_an_unrunnable_plan` in turn.
- **`cmd_check`.** It lists the rule's findings right after the Triad advisory, where it listed a moved source. Another repository and the names are no longer listed after the entries. Three things are still asked where they were, and only where no name was refused:
  - the names' classification lines on stdout;
  - the findings about what the disk or GitHub will not hold (#863);
  - the leg question (#798).

  The remediation lines it prints after its findings follow the findings' order, so the rule's come first.
- **`_refuse_an_unrunnable_plan`.** It asks a moved source before an unanswered entry. Its docstring says why.
- **`_refuse_a_plan_for_another_repository`.** Unchanged. The rule calls it.

## Tests

`tests/test_adopt_plan_against_its_source.py` (new, ASCII only), 11 rows. Each runs `check` and then `execute --yes` on one hand-edited plan, both with the same `--local-remote-dir`, and asserts that no leg is made.
- **7 pair rows** (the six pairs and all four). Each asserts:
  - `check` exits 1 and `execute` exits 2;
  - both name first the same code, the rule's first;
  - `check` lists every problem the plan holds, in the rule's order.
- **4 controls**, one per code: the plan holds that problem alone, and both commands name it.
- **Against #1125's head `9549006f`:**
  - the 6 pair rows that disagreed fail, each because the two commands named different codes, for example `('plan-stale', 'plan-unresolved') != ('plan-stale', 'plan-stale')`;
  - the `another-and-name` guard row and the 4 controls pass.
- **Here:** 11 passed.

`tests/test_adopt_relative_submodule_url.py`, 6 rows changed and 1 new (the fix round):
- **The 6 rows** are `test_check_keeps_a_relative_url_its_github_leg_resolves_alike` for `[https]`, `[scp]`, `[scp-other-case]`, `[ssh-port]` and `[ssh-github-443]`, and `test_a_credential_in_the_source_remote_is_never_printed`.
  - Each hand-edits the plan's `org:` to `otherorg`, so the plan names `otherorg/Thing` and the source is `testorg/Thing`: a plan for another repository.
  - Each expected `check` to list the relative url first and `plan-not-the-source` after it, `check`'s old order. They now expect `plan-not-the-source` first. Their other assertions are unchanged; the credential is still printed nowhere.
- **The new row,** `test_check_names_another_repository_first_as_execute_refuses_it`, runs one such plan. It asserts that `check`, with and without `--local-remote-dir`, lists `plan-not-the-source` and then the url, that `execute` refuses `plan-not-the-source`, and that no leg is made.
- **Measured on #1125's head** for the six source remotes: `execute` already refused each such plan `plan-not-the-source`, and its output is the same on both heads. Only `check`'s order changed. No spelling of the source's `origin` reads as another repository: with `org:` left as the source's, `check` passes on both heads, as the rows assert.

Both files together, 46 rows:
- **Against #1125's head:** 13 failed, 33 passed. The 13 are the 6 pair rows above and the 7 relative-url rows, each on the order: `plan-not-the-source` where the url was expected first, or the url first in the new row.
- **Here:** 46 passed.

## Mutants

Each was applied to `adopt-project.py`, run against both files (46 rows), and restored, with its sha256 checked (`4c8c1c9e`, the same after each one). Unmutated, the 46 pass. M1-M6 are the first round's; M7 and M8 are the fix round's.

| Mutant | Killed by |
|---|---|
| M1, `execute`: `_refuse_an_unrunnable_plan` asks an unanswered entry before a moved source (pair 1) | 2: `moved-and-unanswered`, `all-four` |
| M2, `check`: lists another repository after the entries (pair 2) | 11: `another-and-unanswered`, `another-and-moved`, `another-and-name`, `all-four`, and the 7 relative-url rows |
| M3, `check`: lists a moved source before another repository (pair 3) | 3: `another-and-moved`, `name-and-moved`, `all-four` |
| M4, `check`: lists a refused name after the entries (pair 4) | 3: `name-and-unanswered`, `name-and-moved`, `all-four` |
| M5, `check`: lists a moved source before a refused name (pair 5) | 2: `name-and-moved`, `all-four` |
| M6, the rule: asks a refused name before another repository (both commands) | 2: `another-and-name`, `all-four` |
| M7, `execute`: asks `_refuse_what_check_finds` before the rule | 8: the pair rows but `another-and-name`, the `plan-stale` control, and the new relative-url row |
| M8, `check`: lists all the rule's problems after the entries | 14: the pair rows but `another-and-name`, the `plan-stale` control, and the 7 relative-url rows |

## Gate

Run on the scratch merge `743ebe176`: `origin/main` `961640c68` plus this head `90eca4144` (tree `d71d6f00a`, never pushed). It ran in the landing gate's own environment (a stub `gh`, `GH_TOKEN=bogus`, an empty global git config, `EMAIL` set, the `LANES_*` and `GIT_SSH_COMMAND` variables unset), one shard at a time, each started with at least 19G free. The ids were collected from that tree, 4405 + 448 = 4853, and each is in exactly one shard. The file list is the 46 test files W1113's gate named and four more, added in the fix round (50 in all): `test_adopt_c_locale_bytes.py` and `test_adopt_submodule_url_answers.py` (they import helpers and the module-scoped `adopter` fixture from the changed test file, so they sit in its shard, r03), `test_reader_refusals_named.py` (it hand-edits a plan's `org:` and checks `check`'s exact findings) and `test_github_name_limits.py`. Every shard exited 0.

| Shard | Result |
|---|---|
| r01 | 600 passed |
| r02 | 613 passed |
| r03 | 464 passed, 1 skipped (`test_adopt_plan.py::test_plan_on_medxehr_matches_the_rulings`) |
| r04 | 547 passed |
| r05 | 599 passed, 19 skipped (all in `test_family_init_values.py`) |
| r06 | 542 passed |
| r07 | 489 passed |
| r08 | 531 passed |
| d01 to d07 | 56 passed each (`test_shape_doctor.py`) |
| d08 | 53 passed, 3 skipped (`test_shape_doctor.py`) |

- **r01 to r08:** 4385 passed, 20 skipped (4405 ids).
- **d01 to d08:** 445 passed, 3 skipped (448 ids).
- **Total:** 4830 passed, 23 skipped, none failed, none errored.

Main has moved since this gate: `origin/main` is `ac5f28d2a` (#1188, #1130 and #1098 landed). They change `scaffold-project.py`, `scripts/family.py` and four test files. None of them is a file this PR changes, a module `adopt-project.py` imports, or one of the 50 gated test files, so the gate was not run again on that tip. The merge-trees below were.

## Merge-trees

`git merge-tree --write-tree`, run again on 2026-10-23 at 15:31Z against the current `origin/main`, every one clean:
- **`origin/main` `ac5f28d2a`:** clean, tree `1a65ab9bd`.
- **#1125 `9549006fe`:** clean. This branch is on it.
- **#1177 `5208e874e`** (`fix/1152-plan-and-remote-paths-spelled`, which edits a line of `_refuse_a_plan_for_another_repository`): clean, with this head and three-way on the scratch merge.
- **Every open PR that touches `adopt-project.py` or either test file, 25 of them, #1125 and #1177 among them:** clean, both with this head and three-way on the scratch merge of `ac5f28d2a` and this head, `98afb128a` (`git merge-tree --write-tree <that merge> <its head>`). Since the first run, #1207 is new, and #1119, #1189 and #1190 have moved; all four are clean. No open PR touches either test file. The list is in a code block, so that it does not mention each PR:

```
PR     head       with this head              on the scratch merge
#1105  b28f40d  clean (tree 32fce74c6)   clean (tree 490f555f9)
#1106  504a1dd  clean (tree 3abfa1b6a)   clean (tree db57682e9)
#1118  2307036  clean (tree 79a3888bf)   clean (tree 629f167ca)
#1119  195d993  clean (tree a2926127e)   clean (tree 6aec4c863)
#1120  c55e55e  clean (tree 6171a52f8)   clean (tree 0cb310664)
#1121  1c51737  clean (tree 3acb80467)   clean (tree 2771fbfd0)
#1122  c01c4d7  clean (tree af9a4c414)   clean (tree ef00f52f7)
#1123  5c3908f  clean (tree eb7cb34b3)   clean (tree 4c311748b)
#1125  9549006  clean (tree 239df6d)   clean (tree 1a65ab9bd)
#1141  7a2711d  clean (tree e1c8f7169)   clean (tree 3afeda790)
#1143  7af5fab  clean (tree 35cd165de)   clean (tree aae00cfc7)
#1153  ff33ba1  clean (tree 57da668e8)   clean (tree f91ce3d8d)
#1154  8a78283  clean (tree 28699ba0c)   clean (tree 3e6b1ae98)
#1169  1e958ca  clean (tree e3ef802be)   clean (tree f4566b2c4)
#1170  24ee133  clean (tree 94b9291c8)   clean (tree 848bb0ed0)
#1171  8162b87  clean (tree 65ca8196d)   clean (tree f15571ef3)
#1177  5208e87  clean (tree 08e3d6a62)   clean (tree 111f3c238)
#1178  c4beba1  clean (tree 646f02266)   clean (tree eae3b5996)
#1180  b316f41  clean (tree 25b3d4b6f)   clean (tree 85a559171)
#1186  07486a4  clean (tree d0fe77836)   clean (tree 849f0ef41)
#1189  a131fc2  clean (tree 5b1ab0620)   clean (tree 9851d22b7)
#1190  91a937e  clean (tree aa83fae05)   clean (tree 18101f50b)
#1194  900f77a  clean (tree 9d74efa35)   clean (tree 46317beae)
#1198  d38e4e3  clean (tree 87ca21b8c)   clean (tree 7fc45a875)
#1207  1c7ca5c  clean (tree 1dbab659d)   clean (tree 1e44c98f0)
```

## Left for a follow-up (outside #1113)

- **An unanswered entry beside an uncovered path still gives two first problems,** filed as #1197. `check` lists `plan-uncovered` first and `execute` refuses `plan-unresolved` first. Measured the same on #1125's head and on this head. `execute` refuses an unanswered entry before `_refuse_what_check_finds`, while `check` lists it in `_leg_findings`, after the paths and the coverage. Other entry findings ahead of it in `_entry_findings` are likely the same (`plan-unsafe-path` among them), and so is the taken split branch, but those were not measured.

Closes #1113

Lane: openreposhape-4 (openRepoShape-4)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Nov 10, 2026
…cter a terminal acts on in the command, its directory and what it printed, as `_first_said` spells gh's, so `--local-remote-dir` no longer reaches the terminal raw there; a NOTE before `NEXT:` says when the source's path in its clone command holds a character a terminal does not show as itself; and rows pin six sites #1177's 148 left to chance (#1195) (#1225)

This PR was stacked on #1177, which landed as `8bcdb2c`. RS1225 then restacked it onto `main` with three merges (#1177's final head, its squash, then `main`), which carry exactly the reviewed change (#1225 issuecomment-6752574422).

## What

#1195 follows RV1177's review of #1177 (for #1152). It names two raw routes, N3 and N4, and six mutants, K1, K2, K4, K5, K6 and K7, that all 148 rows of #1177's `tests/test_adopt_plan_and_remote_paths_spelled.py` let through.

Three files change: `adopt-project.py`, that test file, and `tests/test_adopt_github_exits.py`.

### N3: a refused command no longer names `--local-remote-dir` raw

`CommandFailed.loudly` belongs to `scripts/shape_materialize.py`, and every tool shares it. It printed the command, its `(in <cwd>)` line and its output as they were. So when a `pre-receive` hook refused a leg push under `--local-remote-dir <D>/re<U+202E>mote`, the raw U+202E was printed three times: in the command, and in git's own `To` and `error:` lines.

The change is in `adopt-project.py` only. `shape_materialize.py` is unchanged.
- `_unacted(text, kept="")` writes each character that `str.isprintable` refuses, other than those in `kept`, as `_spelled_character` spells it, with no backticks. That is what `_first_said` does to the line gh said.
- `_loudly(exc, step)` builds the same REFUSED block from the command's arguments, its directory and its output, each passed through `_unacted`.
  - The output keeps its line breaks (`kept="\n"`), so it still reads one line per line.
  - This settles the point the issue left open: `loudly` prints the whole output, while `_first_said` keeps one line.
- The leg push (`_push_the_leg`), `_failed_loudly` and `main`'s catch-all now print a refused command through `_loudly`, not `exc.loudly`.
- A printable character prints as it is, so a command with plain paths prints the same block as before.

I measured it with a real `execute --allow-empty-leg spec` and a global `pre-receive` hook that refuses every push:
- **U+202E.** On `5208e874e`, U+202E in `--local-remote-dir` reaches stderr raw 3 times. On this head it reaches stderr 0 times. The command, the `(in ...)` line and git's `To` line each name it as `\u202e`, six ASCII characters.
- **ESC.** ESC behaves the same way. git itself writes ESC as `?` in its `error:` line.
- **Byte 0xff.** It was already printed as `\udcff` before this change, because stderr is `backslashreplace`. git's own lines hold U+FFFD for it, the character `run` decodes that byte to.

### N4: a NOTE says when `NEXT:`'s clone command holds a character a terminal does not show

#1195 asks for a ruling: refuse such a source, as the README's clone line does, or add a note under `NEXT:`. The code settles it in favour of the note:
- **Such a source is writable.** `_refuse_an_unwritable_clone_url` asks `unwritable_reason`. Since #255, that lets through a `Cf` character other than the nine bidi controls. Its docstring in `scripts/shape_materialize.py` says such a character "is invisible, not unwritable", and that a Persian name joins its parts with U+200C.
- **The tests pin it.** `tests/test_adopt_template_values.py` lists `Ali<U+200C>Reza`, `a<U+200E>b`, `a<U+200F>b` and `a<U+061C>b` as `WRITABLE`. Refusing the source would reverse #255.
- **Spelling breaks pasting.** Spelling the command instead would break `_branch_deletion`'s rule that a printed command pastes as it is. `sh` reads a quoted path, not a spelled one.

I measured the old behaviour on `5208e874e`, with a full `execute --local-remote-dir` of a source under `<D>/so<c>urce/Thing`. U+200B, U+200F, U+200C and U+00A0 each pass, and the `split` line spells them. `NEXT:` prints each one raw, once, inside `shlex.quote`'s single quotes.

On this head, the clone command is unchanged. When the url is not `str.isprintable`, this line prints just before the `NEXT:` block:

```
NOTE the path in the clone command below holds a character a terminal does not show as itself, so it can read as another path: it is `<D>/so\u200burce/Thing`, as the `split` line names it.
```

A url whose every character is printable gets no NOTE. A source name that ends in a space shows between the quotes, so it gets none either.

**Where the NOTE goes differs from the issue's wording; please weigh it.**
- The issue says a note *under* `NEXT:`.
- #1121 and #1207 each add lines right after the `print` of the `NEXT:` block. With the NOTE printed under the block, this branch conflicted with #1121 (`git merge-tree` exit 1).
- Printed just before the block, the NOTE merges cleanly with both. It is also read before the command a person would paste.
- Mutant M14 (the NOTE after the block) fails 2 rows, so the placement is pinned.
- Moving it under the block means moving one `print` and flipping the row's order check. It would then need a rebase over whichever of #1121 and #1207 lands first.

### The new rows

The new file goes from 148 to 188 rows, 40 of them new. `tests/test_adopt_github_exits.py` keeps its 23 rows, with one assertion tightened.
- **K1, K2.** `test_a_printable_plan_is_named_as_typed_unless_900_spells_it` runs `check` on the uncovered plan, in the plan's own directory, four ways. `run_adopt` now takes `cwd=` and `over=`.

  | `--plan` given | Named as |
  |---|---|
  | absolute, ending in a space | `` `<D>/plan.yaml ` `` |
  | `` `plan.yaml` ``, relative, between backticks | `` `\x60plan.yaml\x60` `` |
  | `plan.yaml`, relative | `plan.yaml` |
  | `./plan.yaml` | `plan.yaml` |

- **K4, K5.** Two new `ROWS` entries. Each runs under `check` and `execute`, with the plan at each of the five path forms.
  - `plan-wrong-kind-a-placement-plan` expects `kind is 'placement-plan', expected 'adoption-plan'`.
  - `org-too-long`, with an `org:` of 40 `o`, expects `` `org:` is oooooooooooo...oooooooooooo, 40 characters ``.
  - The issue read both expected lines from the code. Both rows pass on `5208e874e`, which confirms them.
- **K6.** `printable-U+00E9` is added to the remote-dir test. `re<U+00E9>mote` prints as typed, with no backticks.
- **K7.** In `tests/test_adopt_github_exits.py`, the GitHub-mode `split` line must now match in full: `  split <12 hex> on adopt/three-repo-shape -> https://github.com/testorg/Northwind.git`.
- **N4.** `SPLIT_SOURCES` gains `right-to-left-mark` (U+200F). Every split row checks either that the NOTE comes before `NEXT:`, or that there is no NOTE.
- **N3.** Three tests:
  - `test_a_refused_command_names_the_remote_and_work_dirs_spelled` is the probe above as a test. The character goes in both `--local-remote-dir` and `--work-dir`, for U+202E, ESC, byte 0xff and a plain control. The line feed is left out, because git's own output names the path and the output's line breaks are kept.
  - `test_a_late_refused_command_is_said_spelled` checks `_failed_loudly`, in process, for all five `CHARACTERS`.
  - `test_a_refused_command_no_step_said_is_said_spelled` checks `main`'s own block, in process, with `cmd_check` replaced, for all five.

## Proof

### Before and after

| Code | The new file (188 rows) and `tests/test_adopt_github_exits.py` (23 rows) |
|---|---|
| #1177's head `5208e874e` | 12 failed, 199 passed |
| This head `73c9f57e8` | 211 passed |

- **What fails on `5208e874e`.** The 12 failures are all N3 and N4 rows:
  - 2 split rows (U+200B and U+200F);
  - 2 refused-push rows (U+202E and ESC);
  - 4 `_failed_loudly` rows;
  - 4 `main` rows.
- **The K rows** pass on `5208e874e`, because its code is right there. Each one fails on its mutant (below).
- **Two N3 controls** pass on both heads: byte 0xff, because stderr already wrote `\udcff`, and the plain control.

### Mutants

All 20 were killed. Each was applied to `adopt-project.py` on this head and restored with `git checkout`. After every restore, the file's sha256 was `163c692aff5b076410bde27740439070f2b9a4c62b4a7dc9510199cb0a7f890a`.
- For K1 to K6, the whole new file was run (188 rows). For K7, `tests/test_adopt_github_exits.py` was run too (211 rows).
- Under every K mutant, only new rows failed, so the old 148 stayed green.
- M1 to M14 ran the N3 or N4 rows.

| Mutant | What it does | Rows failed |
|---|---|---|
| K1 | `check`'s last count line names `--plan` by `isprintable()` alone | 2 of 188 |
| K2 | that line names `plan.path.absolute()` | 3 of 188 |
| K4 | the PLACEMENT plan's `plan-wrong-kind` names the plan raw | 8 of 188 |
| K5 | `adopt-org-too-long` names the plan raw | 8 of 188 |
| K6 | the extracted leg line spells every url outside ASCII | 1 of 188 |
| K7 | the `split` line names the source's own path | 2 of 211 |
| M1 | `_loudly` leaves the arguments raw | 10 of 14 |
| M2 | `_loudly` leaves the working directory raw | 10 of 14 |
| M3 | `_loudly` leaves the output raw | 8 of 14 |
| M4 | the output's line breaks are spelled too | 14 of 14 |
| M5 | the arguments are wrapped in backticks | 14 of 14 |
| M6 | the leg push goes back to `exc.loudly` | 2 of 14 |
| M7 | `_failed_loudly` goes back to `exc.loudly` | 4 of 14 |
| M8 | `main` goes back to `exc.loudly` | 4 of 14 |
| M9 | `_unacted` keeps every whitespace character | 2 of 14 |
| M10 | no NOTE | 2 of 4 |
| M11 | a NOTE wherever the `split` line spells the path | 1 of 4 |
| M12 | the NOTE names the path raw | 2 of 4 |
| M13 | the clone command is spelled, not quoted | 4 of 4 |
| M14 | the NOTE prints after the block, not before it | 2 of 4 |

### Gate

The gate ran on the scratch merge `37c65a609` of `origin/main` `961640c68` and this head `73c9f57e8`, in the landing gate's environment:

| Shards | Tests | Result |
|---|---|---|
| g0 to g5: the 52 files listed below | 3,250 | 3,246 passed, 4 skipped |
| d0 to d7: `tests/test_shape_doctor.py` | 448 | 445 passed, 3 skipped |

- The shard lists hold each collected id exactly once. Every shard exited 0.
- **The 7 skips are environment skips.** Three `tests/test_adopt_root_symlinks.py` rows need git 2.45 for the reftable backend. One `tests/test_stdout_encoding.py` row and the three doctor rows run only on Windows.
- **g1 ran twice.** A host reboot killed its first run part way. It was re-run whole: 542 passed.

<details><summary>The 52 files in g0 to g5</summary>

`tests/test_adopt_attributes_eol_block.py`, `tests/test_adopt_c_locale_bytes.py`, `tests/test_adopt_clone_template.py`, `tests/test_adopt_contracts_dir.py`, `tests/test_adopt_e2e.py`, `tests/test_adopt_entry_paths.py`, `tests/test_adopt_execute_refusals.py`, `tests/test_adopt_filter_repo_failure.py`, `tests/test_adopt_git_reads.py`, `tests/test_adopt_git_rm_bytes.py`, `tests/test_adopt_github_exits.py`, `tests/test_adopt_late_failure.py`, `tests/test_adopt_leg_keys.py`, `tests/test_adopt_mount_ignored.py`, `tests/test_adopt_pins.py`, `tests/test_adopt_plan_and_remote_paths_spelled.py`, `tests/test_adopt_plan_escapes.py`, `tests/test_adopt_reencoded_files.py`, `tests/test_adopt_relative_submodule_url.py`, `tests/test_adopt_root_manifest.py`, `tests/test_adopt_root_shape_paths.py`, `tests/test_adopt_root_symlinks.py`, `tests/test_adopt_spec_only.py`, `tests/test_adopt_spelled_names.py`, `tests/test_adopt_split_branch.py`, `tests/test_adopt_submodule_url_answers.py`, `tests/test_adopt_submodules.py`, `tests/test_adopt_temp_work_roots.py`, `tests/test_adopt_template_values.py`, `tests/test_adopt_tracking_branch.py`, `tests/test_adopt_unsearchable_source.py`, `tests/test_adopt_values_as_typed.py`, `tests/test_adopt_verify.py`, `tests/test_doctor_next_is_a_command.py`, `tests/test_dry_run_asks_remotes.py`, `tests/test_family_add_refusals.py`, `tests/test_git_output_decoding.py`, `tests/test_github_limits_init_check_org.py`, `tests/test_github_name_limits.py`, `tests/test_non_utf8_name_callers.py`, `tests/test_path_guard_hygiene.py`, `tests/test_refusal_default_remediation.py`, `tests/test_repo_hygiene.py`, `tests/test_ruleset_hint_tracking_branch.py`, `tests/test_scaffold_leg_path_collisions.py`, `tests/test_scaffold_manifest_values.py`, `tests/test_scaffold_reuse_seeded_legs.py`, `tests/test_stdout_encoding.py`, `tests/test_template_values_single_pass.py`, `tests/test_update_shape.py`, `tests/test_update_shape_add.py`, `tests/test_update_shape_merged_away.py`

</details>

**`main` has moved since the gate's base, and it touched `adopt-project.py`.**
- `origin/main` is now `50ce8ab15`. Of the 15 commits since `961640c68`, one touches `adopt-project.py`: `b7edd8816` (#1119, for #1083), with 279 lines added and 78 removed. None touches either test file.
- `git merge-tree` of this head with `50ce8ab15` is clean. In the merged `adopt-project.py`:
  - the file parses;
  - `_unacted` and `_loudly` are each defined once;
  - `.loudly(` is called only inside `_loudly`, so #1119 adds no new `exc.loudly(` call.
- The gate above did not run on `50ce8ab15`. The landing gate re-tests this head on its own merge.

### Merge-trees (2026-10-23T20:14Z)

`git merge-tree --write-tree <X> 73c9f57` exits 0 (clean) for every `<X>` below:
- `origin/main` at `50ce8ab15`;
- #1177's head, `5208e874e`;
- each of the 24 open PRs that touch `adopt-project.py`: #1210, #1207, #1198, #1194, #1190, #1189, #1186, #1180, #1178, #1171, #1170, #1169, #1154, #1153, #1143, #1141, #1125, #1123, #1122, #1121, #1120, #1118, #1106 and #1105.

No other open PR touches either test file. #1121, which adds lines after `NEXT:`, has not landed, and it merges cleanly.

Each of the 24 was also merged against a scratch merge of `origin/main` and this head:
- 21 merge cleanly.
- #1169, #1180 and #1190 conflict in `tests/test_adopt_check_throwaway_repos.py`, and #1169 also conflicts in `adopt-project.py`.
- Those three conflict with `origin/main` alone, in the same hunks byte for byte: 6 in `adopt-project.py` for #1169, and 13, 8 and 8 in the test file. So this head adds no conflict.

## Not in this PR

These are outside #1195, which covers `adopt-project.py`'s `--local-remote-dir`:
- `scaffold-project.py`, `update-shape.py`, `scripts/family.py` and `scripts/bump-leg.py` still print `CommandFailed.loudly` as it is.
- `_init_refused` prints `git init`'s argument list raw, and those arguments hold the `--work-dir` path.
- The `adopt-remote-unreadable` and `source-unclonable` refusals print git's or gh's output raw.
- `_unacted` and the NOTE test `str.isprintable`, as `_first_said` does. So the default-ignorable characters that #1171 (#1128) adds to `_shown` get no NOTE, and are not spelled in a REFUSED block. They belong with `_first_said` under #1165.

Closes #1195

Lane: openreposhape-4 (openRepoShape-4)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Nov 10, 2026
… repository over 100, so `plan --source <50 b's>/Thing` never asks `gh` for a name GitHub cannot hold, no remedy offers `--org <50 b's>`, and `check` and `execute` never clone such a record again (#1129) (#1194)

Lane 4's W1129 for #1129, RV1122's NIT-1 on #1122 (#1122 issuecomment-6319493639). RV1194 reviewed it READY at `900f77af` (#1194 issuecomment-6365280794).

**It was stacked on #1122,** which landed as `ebb8716`. RS1194 then restacked it onto `main` with three merges (#1122's final head, its squash, then `main`), which carry exactly the reviewed change (#1194 issuecomment-6751617746). "Why stacked" below says why it was stacked.

**A fix round followed #1268.** Since #1268, `Source.clone` hands `gh repo clone` `-- --quiet --origin origin`. So FX1194 merged `main` (`106f92ff`) and changed only the rows' helper `cloned_by_gh` to expect that line (+4 -2, #1194 issuecomment-6769522297). RVD1194b reviewed the round READY at `ddc21fb5`: the reviewed change's lines are byte-equal, and the 14 rows fail before the fix and pass after it (#1194 issuecomment-6772772773).

## What

`adopt-project.py`, `_github_name`: an owner of more than `GITHUB_OWNER_MAX` (39) characters, or a repository of more than `GITHUB_NAME_MAX` (100), counted once the trailing `.git` is dropped, names no `owner/repo`. The file already imports both limits from `shape_materialize`.

```python
    if len(owner) > GITHUB_OWNER_MAX or len(repo) > GITHUB_NAME_MAX:
        return None
```

Every reader of `_github_name` now gives the same answer for such a spelling:

| Reader | Used by | Before | Now |
|---|---|---|---|
| `_source_spec` | `plan`, `check` and `execute` `--source` | taken as GitHub's name: `gh repo clone` asked, or `source-ambiguous` beside a directory of that spelling | a path: read in place where it is one, `source-unresolvable` ("neither a path that exists nor an `org/repo` name") where it is not |
| `_repository_in_url` | a url `--source`, `github.com/...` too | `gh repo clone` asked | `source-unresolvable`, "names no `owner/repo` on github.com", before any `stat` |
| `_recorded_repository` | `check` and `execute`, a plan's clone gone (`cloned: true`) | "is cloned again from GitHub", `gh repo clone` asked | `source-unresolvable`, "the plan's `source.repository`, ..., names no `owner/repo` on github.com" |
| `_held_repository` | `check` and `execute`, a source with no `origin` | held to the record: `plan-not-the-source`, remedy `--org <40 c's>` | holds the plan to nothing, as a record that names no `owner/repo` does |
| `_source_there` | beside a directory this user cannot search | #1122: no url | unchanged: no url (the name is None now) |

`_refuse_another_repository`'s remedy (`adopt-not-the-source`) is reached only after `_source_spec`, so it never offers `--org <a name GitHub cannot hold>` for an `org/repo` `--source` now.

**#1122's guard in `_source_there` is redundant, and is folded in.** `_source_there` is called only by `_source_spec` and `_repository_in_url`, and both take `name` from `_github_name`. So a name past the limits now arrives as None, and the `name is None` branch gives the same refusal #1122's guard gave. The guard is gone, `if name is None:` is back, and the docstring says the limits are asked in `_github_name`. The merge with `main` and with #1122 is clean (see "Merges").

**Why stacked.** The textual merge with #1122 is clean, but the two do not hold together as they stand. A `github.com/` spelling past the limits is now refused by `_repository_in_url` before any `stat`, so four of #1122's rows, which expected `source-unreadable` from `_source_there`, fail on the combination:
- `[bare-github-url]`;
- `[www-github-url]`;
- `[bare-github-url-owner-one-over-EIO]`;
- `[bare-github-url-owner-one-over-EACCES]`.

This PR moves those three params out of #1122's `_source_there` tests, with a comment pointing to the new file. There they assert the new answer (`source-unresolvable`, no url), with the control at the limit kept: two readings and the url.

No refusal code is new or changed, and no help text or `docs/cli.md` sentence changes: `--source`'s help already says `source-unresolvable` refuses "one that is neither a path that exists nor an `org/repo`".

## Behaviour that changes besides the refusal

- **A directory here spelled `<40 c's>/Thing`** (or `testorg/<101 r's>`) is read in place, and the plan is written, recording that directory and no repository. Before, it was `source-ambiguous`, which named a GitHub repository that cannot exist. At the limit, it is still `source-ambiguous`.
- **A plan whose source has no `origin`, and whose `source.repository` records `<40 c's>/Thing`,** is held to nothing. `check` says `plan ok`, and `execute` goes on. Before, it was held to that record, and the remedy said `--org <40 c's>`, which `execute` then refuses as `adopt-org-too-long`. A record at the limit still holds the plan.
- **`github.com/<300 a's>/Thing` beside a `./github.com`** is `source-unresolvable`, "names no `owner/repo` on github.com". #1122 made it `source-unreadable`, "whether a repository is there cannot be told". Both offer no url.

## Before and after

Probed with a `gh` first on PATH that logs each call and refuses it (exit 4), and with:
- `GH_TOKEN=bogus`, an empty `GH_CONFIG_DIR`;
- `GIT_SSH_COMMAND=false`, `GIT_CONFIG_GLOBAL` an empty file, `GIT_CONFIG_NOSYSTEM=1`;
- uid 1000, Python 3.12.3, run in an empty directory.

Each row is `plan --source <it> --project <repo> --org <owner>`, except where `--org` is said. `main` `961640c6` gave the same answers as #1122's head on every row.

| `--source` | #1122 head `c01c4d73` | this head |
|---|---|---|
| `<50 b's>/Thing`, `--org <50 b's>` (the issue's) | `gh repo clone <50 b's>/Thing` (1 call), `source-unclonable` | `source-unresolvable`, 0 calls |
| `<50 b's>/Thing`, `--org testorg` (the issue's) | `adopt-not-the-source`, remedy `--project Thing --org <50 b's>`, 0 calls | `source-unresolvable`, no `--org` offered, 0 calls |
| `<40 c's>/Thing` | 1 call | `source-unresolvable`, 0 calls |
| `testorg/<101 r's>`, and with `.git` | 1 call each | `source-unresolvable`, 0 calls |
| `<40 c's>/<101 r's>` | 1 call | `source-unresolvable`, 0 calls |
| `https://github.com/<40 c's>/Thing`, `github.com/<40 c's>/Thing` | 1 call each | `source-unresolvable` ("names no `owner/repo` on github.com"), 0 calls |
| `<39 c's>/Thing`, `testorg/<100 r's>`, `testorg/<100 r's>.git` (controls) | 1 call each (`.git` dropped) | the same |
| `<39 c's>/Thing`, `--org testorg` (control) | `adopt-not-the-source`, remedy `--org <39 c's>` | the same |

## Tests

The landing gate's environment throughout:
- `/usr/bin/python3 -m pytest -p no:cacheprovider`, Python 3.12.3;
- a stub `gh` first on PATH, `GH_TOKEN=bogus`, an empty `GH_CONFIG_DIR`;
- `GIT_CONFIG_GLOBAL` set to an empty file, `GIT_CONFIG_NOSYSTEM=1`;
- the test author and committer variables, and `EMAIL`;
- `GIT_SSH_COMMAND`, `GIT_ALLOW_PROTOCOL` and the `LANES_*` variables unset.

**New file `tests/test_adopt_source_github_limits.py`, 48 rows,** ASCII only. It skips on Windows: the logging `gh` is a `/bin/sh` script, and the moved rows need a POSIX `File name too long`. Each child puts the logging `gh` ahead of the suite's guard, and every `execute` gets `--local-remote-dir`.

| Test | Rows | What it asserts | #1122 head | main | this head |
|---|---|---|---|---|---|
| `test_plan_asks_gh_for_a_name_github_can_hold` (control) | 6 | owner 39, repository 100, 100 + `.git`, both at, a url and a bare url: `gh` logged exactly `repo clone <name> <work>/source-readonly/<repo> -- --quiet --origin origin`, once | 6 pass | 6 pass | 6 pass |
| `test_plan_never_asks_gh_for_a_name_github_cannot_hold` | 9 | owner 40 and 50, repository 101 and 101 + `.git`, both over, and four url spellings: the `gh` log empty, exit 2, the `source-unresolvable` line, no plan, no work directory | 9 fail at the `gh` log (`cloning ...`) | 9 fail, the same | 9 pass |
| `test_a_github_url_past_the_limits_is_refused_before_any_stat` (moved from #1122) | 4 | `[www.]github.com/<300 a's>/Thing` with a real `File name too long`; `github.com/<40 a's>/Thing` with `stat` refused (EIO, EACCES): `source-unresolvable`, no url; control at 39, both readings and the url | 4 fail at the code (`source-unreadable`, "cannot be told") | 4 fail, the same | 4 pass |
| `test_no_remedy_offers_an_org_github_cannot_hold` | 3 | `--org testorg` with owner 40, 50, both over: no `--org <owner>`, no `adopt-not-the-source`; control at 39 offers `--org <39 c's>` | 3 fail at `--org <owner>` offered | 3 fail, the same | 3 pass |
| `test_a_directory_github_cannot_name_is_read_in_place` | 2 | `./<40 c's>/Thing`, `./testorg/<101 r's>` repositories here: exit 0, recorded in place, no repository, 0 `gh` calls; control at the limit is `source-ambiguous` | 2 fail at the exit (`source-ambiguous`) | 2 fail, the same | 2 pass |
| `test_a_recorded_name_github_can_hold_is_cloned_again` (control) | 4 | `check`, `execute`: the NOTE and 1 `gh` call | 4 pass | 4 pass | 4 pass |
| `test_a_recorded_name_github_cannot_hold_is_never_cloned_again` | 6 | `check`, `execute`; owner 40, repository 101, both: the `gh` log empty, the `source-unresolvable` line, no "cloned again" | 6 fail at the `gh` log (the NOTE, "cloned again") | 6 fail, the same | 6 pass |
| `test_check_and_execute_read_a_source_name_as_plan_reads_it` | 10 | `check`, `execute` with `--source`: 4 controls at the limits (1 `gh` call), 6 past them (0 calls, `source-unresolvable`) | 6 fail at the `gh` log; 4 pass | the same | 10 pass |
| `test_a_record_github_cannot_hold_offers_no_org` | 4 | `check`, `execute` (no `--yes`); a source with no `origin`, record owner 40 and 50: no `--org <owner>`, no `plan-not-the-source`; `plan ok` / `adopt-unconfirmed`; control at 39 keeps `plan-not-the-source` and `--org <39 c's>` | 4 fail at `--org <owner>` offered | 4 fail, the same | 4 pass |

Totals for the 48 rows:
- **#1122's head:** 34 failed, 14 passed;
- **main:** 34 failed, 14 passed;
- **this head:** 48 passed.

Every row that is not a control fails on both bases, at the assertion that names the defect, not at a setup step. The 14 controls pass on all three.

**#1122's file** `tests/test_adopt_unsearchable_source.py`: 40 rows at this head, from 44. Three params moved out: the two url rows, and the url row's EIO and EACCES variants. Before the move, those four rows failed at this head (`source-unresolvable` against `source-unreadable`), and the other 40 passed.

## Mutants

Each was applied to this head's `adopt-project.py` (sha256 `d494ba0e...`) by exact substitution of the new guard line, and run against this file, `test_adopt_unsearchable_source.py` and `test_adopt_unenterable_source_and_locale.py` (101 tests). After each one the file was restored from its saved bytes and its sha256 checked. Unmutated, all 101 pass. All 8 were killed.

| Mutant | Killed by |
|---|---|
| M1: owner limit one lower (`> GITHUB_OWNER_MAX - 1`) | 24: the owner-39 controls (plan, `--source`, the recorded clone, the remedy, the directory, the held record, the moved rows' controls), and #1122's 5 owner controls at 39 |
| M2: owner limit one higher (`+ 1`) | 15: every owner-40 row (plan, url, `--source`, the recorded clone, the remedy, the directory, the held record, the 2 moved EIO/EACCES rows), and #1122's 2 `owner-one-over` rows |
| M3: repository limit one lower (`- 1`) | 15: the repository-100 controls, and #1122's 5 repository controls at 100 |
| M4: repository limit one higher (`+ 1`) | 11: every repository-101 row, and #1122's 2 `repository-one-over` rows |
| M5: owner limit removed | 25 |
| M6: repository limit removed | 15 |
| M7: both limits removed (no guard anywhere, since #1122's is folded in) | 46: every refused row here, and 12 of #1122's |
| M8: the repository counted with its `.git` (`len(segments[1])`) | 1: `test_plan_asks_gh_for_a_name_github_can_hold[repository-100-dot-git]` |

## Gate

Run on the scratch merge `w1129-gate` at `ca06ad25a`: a merge of `main` `961640c6` and this head `900f77af`. Its tree, `90fbea0e`, is the one `git merge-tree --write-tree origin/main HEAD` gives, and `main` has not moved since. The environment is the one under "Tests"; targeted files only, never the full suite. Every run ended with rc=0.

**Test files, 23:**

| File | Passed | Skipped |
|---|---|---|
| `test_adopt_source_github_limits` (new) | 48 | 0 |
| `test_adopt_unsearchable_source` | 40 | 0 |
| `test_adopt_unenterable_source_and_locale` | 13 | 0 |
| `test_adopt_check_plan_name` | 45 | 0 |
| `test_adopt_source_clone_record` | 100 | 0 |
| `test_adopt_template_values` | 78 | 0 |
| `test_adopt_work_dir_refusal` | 53 | 0 |
| `test_windows_paths` | 46 | 0 |
| `test_adopt_clone_claimed` | 42 | 0 |
| `test_adopt_late_failure` | 88 | 0 |
| `test_adopt_plan_flag_refusals_first` | 89 | 0 |
| `test_adopt_temp_work_roots` | 9 | 0 |
| `test_adopt_origin_repository` | 30 | 0 |
| `test_adopt_plan` | 66 | 1 |
| `test_adopt_project_is_the_source` | 23 | 0 |
| `test_adopt_relative_submodule_url` | 34 | 0 |
| `test_adopt_split_branch` | 47 | 0 |
| `test_adopt_values_as_typed` | 40 | 0 |
| `test_adopt_plan_escapes` | 59 | 0 |
| `test_path_guard_hygiene` | 49 | 0 |
| `test_repo_hygiene` | 101 | 0 |
| `test_scaffold_leg_path_collisions` | 104 | 0 |
| `test_github_name_limits` | 64 | 0 |
| **Total** | **1268** | **1** |

**`tests/test_shape_doctor.py`, all 448 collected ids, in 8 shards of 56** (the shard lists together hold every collected id exactly once; every `adopt-project.py` change is gated with it):

| Shard | Ids | Passed | Skipped |
|---|---|---|---|
| d01 | 56 | 56 | 0 |
| d02 | 56 | 56 | 0 |
| d03 | 56 | 55 | 1 |
| d04 | 56 | 55 | 1 |
| d05 | 56 | 55 | 1 |
| d06 | 56 | 56 | 0 |
| d07 | 56 | 56 | 0 |
| d08 | 56 | 56 | 0 |
| **Total** | **448** | **445** | **3** |

**Totals: 1713 passed, 4 skipped, 0 failed, 0 errors.** The skips are the host's: three `test_shape_doctor.py` rows that print the PowerShell line and need `powershell.exe` on a Windows host, and one `test_adopt_plan.py` row that needs `SHAPE_MEDXEHR_CLONE`, a read-only clone of MedxSoft/MedxEHR.

The gate paused after d02 for disk space and ran d03 to d08 later, on the same scratch merge, whose head did not change.

## Merges

`git merge-tree --write-tree`, this head `900f77af` against each of these; all are clean (rc=0, no conflict):

| Against | Head | Tree |
|---|---|---|
| `main` | `961640c6` | `90fbea0e` |
| #1122, the base | `c01c4d73` | `e2cea9b3` (this head's own tree) |
| #1186 | `07486a49` | `78702414` |
| #1180 | `6cd96b8b` | `eff9e4db` |
| #1178 | `c4beba19` | `b79abc31` |
| #1177 | `5208e874` | `91156ae6` |
| #1171 | `8162b874` | `87e2ce31` |
| #1170 | `24ee133a` | `f001382d` |
| #1169 | `25805102` | `b58ed451` |
| #1154 | `8a782833` | `2e67c977` |
| #1153 | `ff33ba12` | `070c39b2` |
| #1143 | `7af5fabc` | `7237b405` |
| #1141 | `7a2711d0` | `c0bcaf88` |
| #1125 | `9549006f` | `c16ff99a` |
| #1123 | `5c3908f8` | `aba16ad4` |
| #1121 | `1c517375` | `6e1f5cb9` |
| #1120 | `c55e55e3` | `845f0ab5` |
| #1119 | `bba168bd` | `ab6af7c8` |
| #1118 | `2307036a` | `1d53a9d9` |
| #1106 | `504a1dd6` | `60cd4c67` |
| #1105 | `b28f40de` | `b5f065ec` |
| #1189 | `8684af86` | `352b9e86` |
| #1190 | `00f959c6` | `6335ed44` |

These are the open PRs that touch `adopt-project.py`, and #1122 also touches `tests/test_adopt_unsearchable_source.py`. #1189 and #1190 opened, and #1169 and #1171 moved, after the first run of these; the four were merged again at the heads shown, just before the push, and the other heads were read again and had not moved. The merge with #1122 is clean as text, and see "Why stacked" for what it does not settle.

## Out of scope

- **The origin url has its own reader.** A local source whose `origin` is `https://github.com/<40 c's>/Thing` is read by `url_repository` in `scripts/repo_shape.py`, a pinned script that shares the reading with `shape-doctor.py`, and not by `_github_name`. It still records that name, and `--org testorg` would be told `--org <40 c's>`. I read this in the code and did not measure it.
- **Owner characters.** `_github_name` takes owner characters GitHub gives no owner: `.`, a trailing `-`, and `--`. `_` is let by on purpose, for GitHub Enterprise Managed Users (#863's `GITHUB_OWNER_CHARACTERS`). The brief limited this change to the two lengths.
- **The refusal's wording.** `source-unresolvable` for a spelling past the limits says "neither a path that exists nor an `org/repo` name", which is true now, but does not say which limit it broke.

Closes #1129

Lane: openreposhape-4 (openRepoShape-4)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Nov 10, 2026
…able character, which a terminal draws as nothing, is spelled by its code point in `plan`'s lines and in the `unsafe-value` refusal, so a branch `ma<U+034F>in` no longer prints as `main` (#1128) (#1171)

**It was stacked on #1120,** which landed as `6740776`. RS1171 then restacked it onto `main`: it merged #1120's final head, then its squash, then `main` as `main` moved, and the result carries exactly the reviewed change (#1171 issuecomment-6752897940).

## What was wrong

`_shown` printed a name as it is wherever `str.isprintable()` passed it, and `_spelled_character` wrote such a character as it is. `str.isprintable()` passes 267 of Unicode's Default_Ignorable_Code_Point characters, which a terminal draws as nothing: 263 combining marks, among them U+034F and the variation selectors, and the four Hangul fillers, among them U+3164. Git takes each in a branch or a path, so a source on `ma<U+034F>in` printed in `plan`'s `source` line (#1120's) as `(main)`. `checked_value`'s `unsafe-value` refusal names the value with `repr`, which printed U+3164 raw on stderr the same way. RV1120 found both (#1120 issuecomment-6319321596).

## What changed

- `scripts/repo_shape.py`:
  - `DEFAULT_IGNORABLE_RANGES`: the property's 27 lines of `DerivedCoreProperties.txt`, joined into 17 ranges, 4174 code points. The table is the same in Unicode 14.0.0, 16.0.0 and 17.0.0, and is written into the code with a citation, not asked of `unicodedata`. CI runs Python 3.14 and the bench 3.12, and their `unicodedata` differ.
  - `DEFAULT_IGNORABLE`, one character of the table as a pattern.
  - `code_point_escaped`, taken out of `_escaped`, which writes exactly what it wrote before.
  - `visible_repr`: `repr` with each default-ignorable character written as its code-point escape.
  - `checked_value`'s `unsafe-value` refusal names the value with `visible_repr`: `'ma\u3164in'`, where it said `'ma<U+3164>in'`.
- `adopt-project.py`:
  - `_shown` spells a name that holds a default-ignorable character, whatever `str.isprintable()` says of it: `` `ma\u034fin` ``.
  - `_spelled_character` writes one as its code-point escape, which the plan's reader reads back as the character.
  - `_shown`'s signature, and its output for every other character, are unchanged, so #1120's and #1154's rows still pass.

`scripts/repo_shape.py` is a shape copy that every root digest-pins, so this change shows every project an `upstream-changed` row, as every change to it does. The new names are used inside the file itself: `checked_value` calls `visible_repr`. No pinned copy calls `checked_value` (`validate-family.py` only names it in a comment); the change is in `scripts/repo_shape.py` because `checked_value` lives there, so its refusal cannot change without the `upstream-changed` row. No pinned script imports a new name, so the skew rule in `test_pinned_copy_text.py` holds, and its list of names a kept `repo_shape.py` may lack, `NEWER_THAN_A_KEPT_LIBRARY`, now holds the four, so it refuses a pinned script that imports one. No sentence in README.md, AGENTS.md or the handbook describes these helpers.

## Tests

`tests/test_adopt_shown_default_ignorables.py` (new, 48 rows, ASCII only; every character outside ASCII is written as an escape):

- The table against `DerivedCoreProperties.txt`, listed again line by line in the test, so no row depends on the Python's Unicode data.
- The compiled `DEFAULT_IGNORABLE` against the table, over all 0x110000 code points: not one more, not one fewer (RV1171's N1).
- All 4174 code points through `_shown`, `_spelled_character` and `checked_value`'s refusal.
- A value that holds three, `m` U+034F `a` U+3164 `in` U+FE0F, through `checked_value`'s refusal and `_shown`: each is written as its escape and none is raw (RV1171's S1).
- The issue's characters (U+034F, U+3164, U+FE0F, and the controls U+200B, U+2060 and U+180E, which were spelled already) through `_shown`, through a read back of the plan, and end to end through `plan`. In `plan`, they appear in the `source` line, the tracking-branch NOTE, a path in the table, and the `unsafe-value` refusal on stderr.
- The rows RV1120 asked for on #1120's `source` line (#1128 items 2 and 3):
  - `feat/caf\u00e9` prints as it is;
  - a branch named `` `main` ``, backticks included, is spelled `` `\x60main\x60` ``;
  - the branch that is not UTF-8 is spelled `` `caf\udce9` `` under a `utf-8:surrogateescape` stdout, where main wrote the byte 0xE9 itself.

`tests/test_adopt_spelled_unambiguous.py`: its two sweeps of every character take the default-ignorables apart and hold each to its escape.

`tests/test_pinned_copy_text.py`: `NEWER_THAN_A_KEPT_LIBRARY` holds the four new names, so the skew rule refuses a pinned script that imports one (RV1171's N3).

Counts for the new file:

| Code | Result |
|---|---|
| main `961640c68` | 28 failed, 20 passed |
| #1120 alone `c55e55e3` (the 10 `source`-line and item 2-3 rows) | 3 failed, 7 passed |
| this head | 48 passed |

- On main, every failure is for the right reason:
  - the table is missing;
  - 267 characters come back raw from `_shown`, `_spelled_character` and the refusal, and the three in one value are raw in both;
  - the compiled pattern is missing too;
  - the raw bytes are in the `source` line, the NOTE, the table and stderr;
  - `` (`main`) `` is printed as it is;
  - `caf\xe9` is on stdout.
- The 20 rows that pass on main are the controls: the three format characters, the printable names and `feat/caf\u00e9`.
- On #1120 alone, the 3 failures are U+034F, U+3164 and U+FE0F in the `source` line. **Items 2 and 3's three rows pass on #1120 alone: they pin #1120's code**, which is right in each case. They kill RV1120's mutants E (`_spelled` for every branch outside ASCII) and N (`str.isprintable()` alone, with no backtick rule).

## Sweep

Run with `/usr/bin/python3` 3.12.3 (Unicode 15.0.0), against #1120's head `c55e55e3`, whose helpers are main's:
- Of the 4174 default-ignorable code points, 267 pass `str.isprintable()` (263 Mn, 4 Lo). Raw on the base: 267. Raw on this head: 0.
- Of the 148731 printable code points that are not default-ignorable, none is spelled on this head.
- For every code point that is not default-ignorable, `_shown`, `_spelled_character` and `visible_repr` give the same output as the base's `_shown`, `_spelled_character` and `repr`: 0 differ.

## Mutants

Each ran against the new file, `test_adopt_spelled_unambiguous.py` and #1120's `test_adopt_plan_source_branch_shown.py` (212 rows). Each file was restored afterwards and its sha256 checked.

| Mutant | Result |
|---|---|
| The table empty | killed: the pattern no longer compiles, so every row errors |
| The table's pattern matches nothing | killed, 20 rows fail |
| The range U+115F-U+1160 dropped | killed, 3 rows fail |
| The range U+1D173-U+1D17A dropped | killed, 1 row fails (the table row) |
| The escape removed from `_spelled_character` | killed, 18 rows fail |
| `checked_value` back on `repr` | killed, 4 rows fail |
| The compiled pattern runs one past each range, the table unchanged | killed, 1 row fails (the compiled-pattern row) |
| `visible_repr` escapes only the first match (`count=1`) | killed, 1 row fails (the three-in-one row) |
| A pinned script (`validate-family.py`) imports `visible_repr` | killed, 1 row fails (the skew rule's `validate-family` row); passes on the old list |

## Gate

On a scratch merge commit of `origin/main` `038dafba9`, #1120's `c55e55e3` and this head (`39cb15180`), in the landing gate's environment with a stub `gh`:
- 94 test files, 9806 ids, in 6 shards: every test file that mentions `_shown`, `_spelled` or `unsafe-value`, with `test_tracking_branch_ref.py`, `test_pinned_copy_text.py`, `test_adopt_plan_escapes.py`, `test_stdout_encoding.py`, `test_non_utf8_name_callers.py`, `test_path_guard_hygiene.py`, `test_repo_hygiene.py` and `test_scaffold_leg_path_collisions.py`. 9777 passed, 29 skipped, 0 failed.
- `test_shape_doctor.py`, 448 ids in 8 shards from `mapfile` lists: 445 passed, 3 skipped, 0 failed.
- On a merge of main, #1120, this head and #1154, the rows of #1154, of #1120 and of this PR: 166 passed, 1 skipped.
- Fix round 1 (RV1171's S1, N1 and N3), test-only, so no doctor shards: on a scratch merge `331dc93c7` of `origin/main` `961640c68` and `8162b874e`, `test_adopt_shown_default_ignorables.py`, `test_adopt_spelled_unambiguous.py`, `test_pinned_copy_text.py`, `test_adopt_plan_source_branch_shown.py`, `test_stdout_encoding.py`, `test_path_guard_hygiene.py` and `test_repo_hygiene.py`: 496 passed, 1 skipped, 0 failed.

## Merge-trees

`git merge-tree` of this head with `origin/main` is clean. So is each of the 13 other open PRs that touch `adopt-project.py` or `scripts/repo_shape.py`, against both this head and the scratch merge: #1154, #1153, #1143, #1141, #1126, #1125, #1123, #1122, #1121, #1119, #1118, #1106 and #1105.

Fix round 1: `git merge-tree` of `8162b874e` with `origin/main` and with #1105 (the one other open PR that touches `tests/test_pinned_copy_text.py`) is clean, and so is the scratch merge with #1105.

## Out of scope: filed separately by the lane

The other helpers that test only `str.isprintable()`, or use `repr`, let the same characters through. They are:
- the `repr`-based `_shown` copies in `validate-repository-naming.py`, `validate-manifest.py` and `validate-pins.py`, and `repo_shape.shown_path`;
- `shape_materialize.py`'s `-`-leading `unsafe-value` refusal;
- `repo_shape.double_quoted`, which writes them raw into the plan file;
- `adopt-project.py`'s `_worded`, `_line_shown`, `unwritable_values` and `_refuse_an_unwritable_clone_url`.

They are filed separately by the lane as #1165 (see #1165), and are untouched here.

Closes #1128

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