Skip to content

adopt-project.py: a refused command's --- output --- block spells each argument and directory that holds a line feed where git names it, adopt-mount-unaddable spells git's output, and rows pin mutants R1, R3 and R10 (#1233) - #1311

Open
brettheap wants to merge 17 commits into
mainfrom
fix/1233-rv1225-refused-block-nits

Conversation

@brettheap

@brettheap brettheap commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1233

Built on #1225 (lane openRepoShape-4's PR for #1195), as lane 4 asked (#473 issuecomment-6767262819). #1225 landed as dc9a0bc on 2026-11-10 at 16:54Z, and GitHub moved this PR's base to main. Lane openRepoShape-2 then restacked it with three merges: #1225's final head db92fb011; its squash dc9a0bcc7, taking this branch's side for the two files both PRs change, which equal the squash's; then main, already in. The changed lines against main equal the reviewed delta's.

What

#1233 holds RV1225's four NITs from its review of #1225 (#1225 issuecomment-6374508819). All four are done here. The line numbers below are at this head; the issue's are at 73c9f57e.

N1: a line feed in a path that git echoes no longer splits the --- output --- block

  • RV1225's change. A new _output_unacted(exc) works on git's output before _unacted(output, kept="\n") runs as before. _loudly calls it.
    • Each argument of the command, and its directory, that holds a line feed is replaced by its _unacted spelling wherever git's output names it, longest first.
    • Only a part that holds a line feed is ever replaced, so every other block prints exactly as before.
  • A path with byte 0xff before the line feed. git echoes the raw byte, and run decodes it as U+FFFD. So each part is also looked for as run reads it back, os.fsencode(part).decode("utf-8", "replace"), and is spelled whole there too.
  • Two more forms, from the fix rounds for RV1311 and RV1311b:
    • As git writes it. git's error: and fatal: lines write each control other than a tab and a line feed as ?. Measured on git 2.43, that is U+0001 to U+0008, U+000B to U+001F and U+007F (GIT_WRITES_AS_QUERY). A tab, a line feed, bytes 0x80 to 0xFF, U+202E and U+00E9 print as themselves. So each form is also looked for as git writes it, and is replaced by that form spelled: git's ? stays, and only the line feed is spelled, as in wo?\nrk.
    • As run reads it back. run reads git's output with universal newlines, so a CR+LF, or a lone CR, comes back as a line feed. git's To line does not sanitize the path, so each form is also looked for that way (_as_run_reads), and is spelled as the path holds it.
  • What is not looked for: a part that holds neither a line feed nor a CR, a part made only of line feeds and CRs, and git's form of a part made only of controls and line feeds, which could match any line that ends in ?.
  • The rows:
    • REFUSED_CHARACTERS now holds line-feed, byte-0xff-then-line-feed, escape-then-line-feed, carriage-return-then-line-feed and byte-0xff-then-escape-then-line-feed.
    • The refused-push row asserts that git's To line names the remote on one line, and that no line of the block begins mote/.
    • the_block_of expects the remote spelled in git's line too, so the two in-process rows over CHARACTERS agree with this choice.
    • Four in-process rows pin git's form, run's CR form and the two skips: test_a_path_is_spelled_as_git_writes_it_in_its_own_lines, test_a_path_with_a_carriage_return_is_spelled_as_run_reads_it, test_an_argument_of_nothing_but_line_feeds_spells_no_line_break and test_an_argument_of_only_controls_and_line_feeds_spells_no_question_mark.

Measured with a real refused push, through a global pre-receive hook that refuses every push. Every run exits 2, with no traceback.

Line feed in Before After
--local-remote-dir git's To and error: lines split at the line feed, so 2 lines of the block were the path's each git line names re\nmote on one line
--work-dir git's push output does not name it, and (in ...) was already spelled unchanged
both as the remote case as the remote case
the remote, with 0xff before the line feed split after re and U+FFFD one line each

The fix rounds measured two more cases with a real refused push. A path with ESC or CR before its line feed split git's error: line, which writes them as ?. A path with CR+LF split git's To line, which run reads with universal newlines. At this head each is one line, and REFUSED_CHARACTERS pins both.

N2: rows for R1, R3 and R10, the three mutants all 188 rows let through

These are RV1225's three rows:

  • SAID_CHARACTERS is CHARACTERS plus printable-U+00E9, for the two in-process rows (R1);
  • a tab in a_refused_push's output, which the_block_of expects as \t (R3);
  • a printable-U+00E9 source in SPLIT_SOURCES, with noted False, named as it is (R10).

N3: a spelled character and a typed backslash sequence read alike

Two sentences in _loudly's docstring say so: a path that holds the six characters \u202e prints as one that holds U+202E does, and a path such as C:\x1b... reads like a spelled ESC. The code is unchanged.

N4: adopt-mount-unaddable spells git's output

One more row

test_a_path_that_holds_another_is_spelled_whole_where_git_names_it pins the longest-first order. Mutant N1o below spells the paths shortest first, and this row kills it.

Proof

Mutants

Each mutant was applied to adopt-project.py at this head and run against the whole test file (199 rows). After each, the file was restored with git checkout, and its sha256 (4f429b83...) and a clean status were checked.

Mutant Change Rows that fail
R1 _unacted spells every printable character outside ASCII 2: the late-refused and no-step rows, each [printable-U+00E9]
R3 _output_unacted keeps a tab raw (kept="\n\t") 12: all six cases of both in-process rows
R10 the NOTE keyed on url.isascii() 1: the split row [printable-U+00E9]
N1o the paths spelled shortest first 1: the longest-first row

The fixes themselves, taken out again, fail rows too:

  • without the replace, or with the mount detail back to the raw exc.output: 5 rows;
  • without the 0xff form: byte-0xff-then-line-feed.

The fix rounds

  • Round 1 (8649430ce, for RV1311): its six new rows fail on ee535cf0e's adopt-project.py, restored with git checkout and its sha256 checked. On it, RV1311b's mutants fail rows too: dropping git's form fails 4, CR out of the class 1, dropping the line-feed-only skip 2, git's form replaced by the raw part spelled 3, and shortest first 1.
  • Round 2 (c7749c1cf, for RV1311b): 5 of its new rows fail on the restacked 447f8f7ee. Its byte-0xff-then-escape-then-line-feed case passes there, as RV1311b said, and fails under RV1311b's M5 (git's form of the typed part only), which no row had caught.

Runs at this head

Every run went through lane openRepoShape-2's runner: a stub gh, a blank git identity and global config, no ssh, no LANES_* variable, and CI's git-filter-repo 2.47.0.

Files Result
tests/test_adopt_plan_and_remote_paths_spelled.py 211 passed (188 at cc230f2f)
tests/test_adopt_github_exits.py 23 passed
the files that grep a changed string: test_adopt_late_failure.py, test_adopt_git_rm_bytes.py, test_adopt_filter_repo_failure.py, test_adopt_mount_ignored.py, test_adopt_leg_path_collisions.py and test_refusal_default_remediation.py 244 passed, at 8649430ce
tests/test_scaffold_leg_path_collisions.py 104 passed
tests/test_shape_doctor.py 446 passed, and 3 skipped (Windows-only PowerShell rows)
the in-process rows with LANES_LANE set 32 passed

Not in this PR

Review

  • RV1311, an independent Opus review at ee535cf0e by an agent that wrote none of this: READY AFTER FIXES (issuecomment-6769580868). Fix round 1 is 8649430ce.
  • RV1311b, its delta review: READY AFTER FIXES (issuecomment-6773755042). Fix round 2 is c7749c1cf, on the restacked head.
  • RV1311c, the delta review of round 2: READY, with no MUST and no SHOULD (issuecomment-6774275857). Its three NITs need unusual inputs and are listed under "Not in this PR".

Lane 3 places this PR in v1.2.1's order by its READY time.

Lane: openreposhape-2 (openRepoShape-2)

🤖 Generated with Claude Code

Summary by Sourcery

Keep Git-related refusal messages readable and accurately spelled when paths contain problematic characters.

Bug Fixes:

  • Preserve refused-command output as readable single lines when Git names paths containing line feeds, carriage returns, invalid UTF-8, or other control characters.
  • Apply consistent safe spelling to Git output included in adopt-mount-unaddable refusal details.

Enhancements:

  • Expand path-output handling to account for Git's control-character rendering and longest matching path forms.
  • Add regression coverage for refused commands, Git output variants, printable non-ASCII paths, and mutation cases.

Tests:

  • Add comprehensive tests covering line-feed and control-character path spelling, Git-rendered output, mount failures, and previously undetected mutants.

Brett Heap and others added 12 commits October 22, 2026 20:20
… `--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)

## What

#1154 (#1115) names `--out` and `--work-dir` in `plan`'s and `check`'s report with `_shown`. W1115 found two groups of paths it leaves raw (#1152): the `--plan` path, and the `--local-remote-dir` path. 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(...))`, so a path with a character that is not printable is named as `_spelled` names it, between backticks, and every other path prints byte for byte as it did.

The `--plan` path, 16 sites in `check` and `execute`:
- 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` (the code's name for it; the issue calls it `plan-bad-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 in `execute`:
- the `<bare> already exists` refusal;
- the `  bare  <bare>` line;
- the two leg lines, `_extract_leg` and `_seed_leg`, which end `-> <url>`;
- the `split <commit> on <branch> -> <url>` line, which 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.

A path that is not UTF-8 now prints as `\udcff` between backticks, where it printed raw before. No refusal code is new, and none changes its name or its exit code.

The changed lines that ran past 79 columns are rewrapped; the message text is unchanged.

`repo_shape.load_yaml`'s own refusals still print a path raw, as `yaml-unreadable`. They live in another file and are a separate follow-up (see #1168).

## Test

`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. It has 148 rows:
- 135 plan rows: 14 refusal families (27 family and command pairs) by 5 path forms (U+202E, ESC, a line feed, the byte `\xff`, 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 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 of the 148 fail, each for the raw path, and the 30 that pass are exactly the plain controls. On this commit all 148 pass. 23 mutants (each new spelling put back to raw, one at a time, and `_shown` swapped for `_spelled` at two sites) are each killed by the rows that name them.

Lane: openreposhape-4 (openRepoShape-4)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…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)

Follow-up of #1177 (for #1152), from RV1177's review: its N3, N4 and
the surviving mutants K1, K2, K4, K5, K6 and K7. Stacked on #1177's
branch, and lands after it.

- N3: `_loudly` builds `CommandFailed.loudly`'s block from the command's
  arguments, its directory and its output, each `_unacted`: a character
  `str.isprintable` refuses is spelled as `_spelled_character` spells it,
  with no backticks, and the output keeps its line breaks. The leg push,
  `_failed_loudly` and `main` say a refused command through it.
- N4: a source path that `_refuse_an_unwritable_clone_url` lets through
  (#255) but `str.isprintable` refuses, as U+200B and U+200F, gets a NOTE
  just before `NEXT:` naming it `_spelled`. The clone command stays as
  `sh` reads it. Refusing such a source would undo #255's ruling that a
  `Cf` character other than the nine bidi controls is text a file holds.
  The NOTE is printed before the block, so it touches none of the lines
  that #1121 and #1207 add after it.
- Rows: a `--plan` ending in a space, a relative one between backticks,
  a relative one and `./plan.yaml` (K1, K2); a PLACEMENT plan's
  `plan-wrong-kind` and `adopt-org-too-long` with the plan's path spelled
  (K4, K5); a printable `--local-remote-dir` outside ASCII (K6); the
  GitHub-mode `split` line matched in full (K7); and N3's and N4's rows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…leftovers

Step (a) of the restack after #1177's squash: the head F of the branch
#1225 was stacked on, merged as it stands, with no conflict.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…overs

Step (b) of the restack after #1177's squash: its two files, adopt-project.py
and tests/test_adopt_plan_and_remote_paths_spelled.py, are the same in the
squash as in the final head merged in step (a), so a conflict in them is
resolved by keeping this branch's bytes and the step changes none of them.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Step (c) of the restack after #1177's squash: main as it stands, past the
squash, merged with no conflict. The branch now differs from main in
adopt-project.py, tests/test_adopt_github_exits.py and
tests/test_adopt_plan_and_remote_paths_spelled.py only.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ants all 188 rows passed: a printable U+00E9 in a refused command prints as typed, a tab in what it printed is spelled `\t`, and a source path that holds U+00E9 gets no NOTE before `NEXT:` (#1233)

RV1225's N2, from its review of #1225 (#1195). Each mutant left behaviour
the head gets right, and no row held it:
- R1, `_unacted` spelling every character outside ASCII: the two
  in-process refused-command rows now run over `SAID_CHARACTERS`,
  `CHARACTERS` and `printable-U+00E9`, which the block names as typed.
- R3, `_unacted` keeping a tab raw in what a command printed:
  `a_refused_push`'s second line holds a tab, which `the_block_of`
  expects as `\t`.
- R10, the NOTE keyed on `url.isascii()`: `SPLIT_SOURCES` gains a
  `so\u00e9urce` parent, `noted` False, named as it is; a spelled parent
  and name of None now say "as it is", for it and the plain control.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Lane: openreposhape-2 (openRepoShape-2)
…hole each argument and directory of the command that holds a line feed where git names it, so `--local-remote-dir <D>/re<LF>mote` no longer splits git's `To` and `error:` lines into lines of the path's; and `_loudly` says a spelled character and a typed backslash sequence read alike (#1233)

RV1225's N1 and N3, from its review of #1225 (#1195).

N1. `_loudly` kept the line breaks of what a command printed
(`_unacted(exc.output, kept="\n")`), so git's own lines, which name the
remote a push was refused at, were split at a line feed the path held:
`To <D>/re`, then `mote/Thing-spec.git`. The new `_output_unacted(exc)`
replaces in the output each argument and the directory that holds a line
feed with its `_unacted` spelling, longest first, before the output is
`_unacted` with its own line breaks kept. A command none of whose
arguments holds a line feed prints the block it printed before.

Measured with a real `execute --allow-empty-leg spec --local-remote-dir`
and a global `pre-receive` hook that refuses every push (exit 2 each, no
traceback):
- the line feed in `--local-remote-dir`, and in both: before, 2 lines of
  the block began `mote/` and the raw `re<LF>mote` was on stderr twice;
  now `To <D>/re\nmote/Thing-spec.git` and `error: failed to push some
  refs to '<D>/re\nmote/Thing-spec.git'` are one line each, and the raw
  path is printed 0 times;
- in `--work-dir` alone: git's push output does not name it, before or
  after, and `(in <D>/wo\nrk/Thing-spec)` was spelled already.

`tests/test_adopt_plan_and_remote_paths_spelled.py`: `line-feed` is back
in `REFUSED_CHARACTERS`; the refused push's row asks that git's `To` line
names the remote on one line, that no line of the block begins `mote/`,
and, for the line feed, that neither typed path is printed raw. The two
in-process rows expect the remote spelled in git's line too.

N3. `_unacted` leaves a backslash as it is, so a path holding the six
characters backslash, `u`, `202e` prints as one holding U+202E does:
`_loudly`'s docstring says so. No code change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Lane: openreposhape-2 (openRepoShape-2)
…ed command's block says them, so a held `index.lock` under a `--work-dir` that holds U+202E or a line feed no longer prints the override raw or splits the line (#1233)

RV1225's N4, from its review of #1225 (#1195): `adopt-mount-unaddable`
printed `git will not add the leg mount path {path}: {exc.output}`, git's
output as it was, a route #1225's body did not list.

Measured first:
- The mount path cannot hold such a character. `leg_path_problem` holds
  `legs.spec_path` and `legs.code_path` to `checked_value`'s
  `SAFE_ARG_RE`, `^[A-Za-z0-9._/@+~-]{1,255}$`: a plan whose `spec_path`
  holds U+202E, ESC or a line feed is `plan-bad-leg-path` from `check`
  (exit 1) and from `execute --local-remote-dir` (exit 2, before any leg
  exists), in real runs of each. So `{path}` is left as it is, and a
  comment says why.
- git's output can. `git add --dry-run` takes the index's lock, and with
  it held git 2.43 says `fatal: Unable to create
  '<work>/Thing/.git/index.lock': File exists.`, naming the assembly,
  which is under `--work-dir`. git writes ESC as `?` there itself, but
  U+202E raw, and keeps a line feed.

So the output is `_output_unacted`, as `_loudly` says it: each character
`str.isprintable` refuses is spelled, git's line breaks are kept, and the
directory the command ran in is spelled whole where git names it.

`tests/test_adopt_plan_and_remote_paths_spelled.py`: the new
`test_a_mount_git_will_not_add_is_said_spelled` calls
`_refuse_an_unmountable_path` in this process, with the lock held, for
each of `CHARACTERS`: the U+202E and line-feed rows fail on the head
before this commit, the ESC, byte 0xff and plain rows pass on both. The
module docstring names #1233's follow-ups.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Lane: openreposhape-2 (openRepoShape-2)
…s paths that hold a line feed are spelled longest first in what it printed, so a remote under the directory the command ran in is spelled whole where git names it (#1233)

`_output_unacted` sorts the arguments and the directory longest first
before it spells each where the output names it. No row held that: in
every other row no path is in another. This one, in this process, runs
`_loudly` over a push from `/re<LF>mote` to `/re<LF>mote/wo<LF>rk.git`,
whose `To` line must say the remote whole, on one line. Spelled shortest
first, the remote's second line feed is left raw.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Lane: openreposhape-2 (openRepoShape-2)
…er a byte that is not UTF-8 is spelled whole where git names it too, as `run` reads it back, so `re<0xff><LF>mote` no longer splits git's `To` and `error:` lines (#1233)

`_output_unacted` looked for each path that holds a line feed as the
command was given it. git names a path by its bytes, and `run` decodes
what git printed with `replace`, so a byte that is not UTF-8, which the
path holds as a surrogate, is U+FFFD in git's lines: the path was not
found there, and its line feed still split them. Each such path is now
also looked for as `run` reads it back, `os.fsencode` (what `subprocess`
handed git) decoded with `replace`; a path that cannot be encoded is
looked for as it is, as before.

Measured with the real refused push, `--local-remote-dir <D>/re<0xff><LF>mote`
(exit 2, no traceback): before, `To <D>/re<U+FFFD>` and `mote/Thing-spec.git`,
2 lines of the block the path's; now `To <D>/re<U+FFFD>\nmote/Thing-spec.git`
and git's `error:` line each on one line, 0 split.

`tests/test_adopt_plan_and_remote_paths_spelled.py`: `REFUSED_CHARACTERS`
gains `byte-0xff-then-line-feed`, which fails on the head before this
commit; the raw-path check runs for every character that holds a line
feed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Lane: openreposhape-2 (openRepoShape-2)
@brettheap brettheap added this to the v1.2.1 milestone Nov 10, 2026
@sourcery-ai

sourcery-ai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Spell command output paths that contain line breaks—including the forms Git and run actually emit—and use the same spelling for adopt-mount-unaddable diagnostics.

  • adopt-project.py L15088-15142, L15156-15164, L16185-16192 (+1 small edits)

Tests

Add regression coverage for escaped refused-command and mount diagnostics, edge cases in matching and newline handling, and the mutants identified in review.

  • tests/test_adopt_plan_and_remote_paths_spelled.py L654-679, L781-795, L817-963 (+10 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

brettheap commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor Author

(lane openRepoShape-2, 2026-11-10T14:13:18Z) RV1311, lane openRepoShape-2's independent review of #1311 at ee535cf0e, posted as its reviewer wrote it. The fix round for SHOULD 1 and the two NITs runs in lane 2's next window. The usage stop came first, under Brett's 90% word.

RV1311: independent review of #1311 at ee535cf0e (for #1233)

Verdict: READY AFTER FIXES. No MUST, one SHOULD and two NITs. I wrote none of this PR and changed none of it. All runs went through lane openRepoShape-2's runner (run-l2.sh), in my own worktree, detached at ee535cf0e690e7a8a24d335f8302fce7093dd221. adopt-project.py sha256 was 4f429b8384a20a09b41d509ef849798df65cded4c72b171288cc0c41b841e140 before and after every mutant and probe, with a clean status each time. Bench: git 2.43.0 and Python 3.12. CI runs Python 3.14.

Runs (measured)

Run Result
all of tests/test_adopt_plan_and_remote_paths_spelled.py 199 passed in 121.93s
tests/test_adopt_github_exits.py 23 passed in 58.04s
the in-process rows with L2_KEEP_LANE=1 (LANES_LANE=openRepoShape-2), -k "said_spelled or holds_another or leg_remote_already_there" 23 passed: the PR's 18, plus 5 older leg_remote_already_there rows
test_adopt_mount_ignored.py, test_adopt_leg_path_collisions.py, test_refusal_default_remediation.py, test_scaffold_leg_path_collisions.py 245 passed in 115.97s

The count checks out: 188 + 2 refused-push cases + 2 SAID_CHARACTERS cases + 1 split case + the longest-first row + 5 mount cases = 199.

Mutants (measured)

Each mutant ran against the whole file (199 rows) and was then restored, with the sha256 and the status checked.

Mutant Rows that fail
R1 as I first wrote it (isprintable() and isascii(), otherwise _spelled_character) none, 199 passed. This mutant is equivalent, not a gap: _spelled_character (double_quoted) returns a printable character unchanged, so é stays é.
R1b: a printable character outside ASCII spelled ascii(char)[1:-1] (\xe9) 2: test_a_late_refused_command_is_said_spelled[printable-U+00E9] and test_a_refused_command_no_step_said_is_said_spelled[printable-U+00E9]
R10: the NOTE keyed on url.isascii() 1: test_the_split_line_names_the_source_as_a_path_is[printable-U+00E9]
R3: _output_unacted keeps a tab raw (kept="\n\t") 12: all six cases of both in-process rows
N1o: shortest first 1: test_a_path_that_holds_another_is_spelled_whole_where_git_names_it
Mfs (mine): no os.fsencode(...).decode(...) form 1: test_a_refused_command_names_the_remote_and_work_dirs_spelled[byte-0xff-then-line-feed]
Mfirst (mine): output.replace(part, ..., 1) 2: the same real-push row, [line-feed] and [byte-0xff-then-line-feed] (git's error: line splits)
Mmount (mine): the mount detail back to {exc.output} 2: test_a_mount_git_will_not_add_is_said_spelled[bidi-override-U+202E] and [line-feed]
Mnocwd (mine): only the arguments are looked for, not the directory 1: test_a_mount_git_will_not_add_is_said_spelled[line-feed]

The PR's figures for R3, R10 and N1o match mine exactly. For R1, its two rows are the ones that kill R1b.

Findings

SHOULD 1 (measured): a path that holds another control character beside its line feed still splits git's error: and fatal: lines

  • Where: adopt-project.py _output_unacted, at about :14491-14512 at this head.
  • The cause: git's vreportf, which writes every error: and fatal: line, replaces each control byte other than a tab and a line feed with ?. Measured on git 2.43, with git add --dry-run -- a<c>b in my worktree: ESC, CR, DEL and VT each print as ?, and a tab prints as itself. git's To line is not sanitized. So the error: line names the path in a third form, which neither the raw part nor the run form matches, and the line feed is kept.
  • The probe: I added \x1b\n and \r\n to REFUSED_CHARACTERS in my worktree, plus an in-process mount probe, then restored the file. A real refused push under --local-remote-dir <D>/re<ESC><LF>mote gives this block:
    --- output ---
    remote: this remote takes no push
    To <D>/re\x1b\nmote/Thing-spec.git
     ! [remote rejected] HEAD -> main (pre-receive hook declined)
    error: failed to push some refs to '<D>/re?
    mote/Thing-spec.git'
    --- end output ---
    
    CR+LF gives the same split. The mount route under a work directory wo<ESC><LF>rk gives a detail holding fatal: Unable to create '<D>/wo?\nrk/Thing/.git/index.lock', with a raw line feed, and so does CR+LF. With a line feed alone the mount probe passes. The probe run: 4 failed, 1 passed.
  • Why SHOULD: adopt-project.py and tests/test_adopt_plan_and_remote_paths_spelled.py: follow-up of PR #1225 (#1195) from its review: a line feed in a path git echoes still splits a refused command's --- output --- block, three mutants (R1, R3, R10) that none of its 188 rows kills, a spelling that cannot be undone, and adopt-mount-unaddable, a raw route its body leaves out #1233's "Done when" for N1 is "a path that holds a line feed ... puts no line of its own into the --- output --- block of a real refused push". This is a measured counterexample, and the PR says Closes #1233. The docstring and the body also claim that a path holding a line feed is spelled "wherever git's output names it". The user impact is small: the path is exotic, and the command line above already spells it.
  • The change I would make, either of:
    • (a) Also look for git's own form of each part: re.sub("[\x00-\x08\x0b-\x1f\x7f]", "?", form) for both the raw form and the run form. Add pytest.param("\x1b\n", "\\x1b\\n", id="escape-then-line-feed") to REFUSED_CHARACTERS and to the mount row, which then expects wo?\nrk spelled as wo?\\nrk.
    • (b) Keep the code, and say in _output_unacted's docstring and in the body that a path which also holds a control git writes as ? still splits git's error: and fatal: lines, with a row that pins it.

NIT 1 (measured in process): an argument made only of line feeds spells every line break in the output

  • Where: _output_unacted.
  • Evidence: CommandFailed(["git", "x", "\n"], None, 1, "line1\nline2\nline3") prints the old output as 3 lines and the new as 1 line, line1\nline2\nline3. "\n\n" does the same.
  • Why only a NIT: nothing is lost, and no command in adopt-project.py passes such an argument today. I read every argument that can hold a line feed: they are paths and gh pr create --body <message>, and gh does not echo the body.
  • The change: skip a part whose text is nothing but line breaks (part.strip("\n") empty), or leave a line in the docstring.

NIT 2 (measured in process): a path can merge git's own lines where its text continues into them

  • Evidence: an argument /w/a\nhint with git's output fatal: /w/a\nhint: do this gives one line. The replace fires only where the output holds the whole typed path, line feed included. Then the only change is that line feed becoming \n, and no character is lost.
  • The change: none needed. I mention it because the brief asked whether the replace can damage text it names only in passing.

Answers to the brief's questions

  • Prefix, nested and overlapping parts (measured in process): a path nested in another is spelled whole, longest first, and N1o shows a row pins that order. Two overlapping parts are both spelled. Overlapping fails only when two different arguments overlap on a control character, for example A\nB<ESC> and <ESC>\nC, which is contrived.
  • No new raises (measured): 20000 random cases with line-feed parts raised nothing, and they differ from the old text only where a line feed became \n. They also leave no raw character outside isprintable() other than a line feed.
  • Unchanged without a line feed (measured): 20000 random cases with no line-feed part give exactly the old text.
  • Edge cases (measured):
    • A surrogate outside U+DC80 to U+DCFF makes os.fsencode raise. suppress(UnicodeError) catches it, and there is no raise.
    • An empty argument, or an empty cwd, is skipped.
    • A bytes argument cannot reach _output_unacted, because CommandFailed.__init__ raises TypeError on one.
  • The run form (read): it can match only text that run's decoder produced from the same bytes, or from another path that decodes alike. In both cases the only change is that line feed becoming \n.
  • N4's claim (read): _checked_plan_values calls _refuse_bad_leg_paths("plan-bad-leg-path", ...) and then checked_value, whose SAFE_ARG_RE ^[A-Za-z0-9._/@+~-]{1,255}$ is applied with fullmatch. That happens before _commit_the_split and _mount_the_legs. In process, leg_path_problem refuses sp\nec, spec\n, U+202E, ESC, U+00E9, a space and CR. So {path} cannot hold a control character. I did not re-run the PR's check and execute refusals.
  • --work-dir is resolved (read): _work_root is os.path.realpath(args.work_dir), so in real runs git's index.lock path equals str(assembly).
  • N2 and N3 (read): the new rows match RV1225's wording. The N3 sentences in _loudly's docstring are ASCII, and \\u202e renders as U+202E (the character itself, left out here so it cannot reorder this comment). No added line holds a non-ASCII character.
  • Python version (read): no row asserts text that depends on the Python version. The only Unicode properties involved are isprintable of U+00E9, U+202E, ESC, LF, U+DCFF and U+FFFD.
  • git version (read): the rows tolerate git's wording.
    • The refused-push row asserts only To <D>/re...mote/Thing-spec.git and that no line starts with mote/.
    • The mount row asserts Thing/.git/index.lock and the spelled directory, but not how git writes ESC.
    • Its pytest.raises relies on git add --dry-run taking the index lock, as git 2.43 does.
    • The CI tests job is ubuntu-24.04, and I could not see its git version.

Checks not done

Lane: openreposhape-2 (openRepoShape-2)

Brett Heap and others added 2 commits November 10, 2026 16:27
…ide a control git writes as `?` is spelled whole where git's `error:` and `fatal:` lines name it too, and an argument of nothing but line feeds is not looked for, so `re<ESC><LF>mote` no longer splits a push's `error:` line, nor `wo<CR><LF>rk` the mount guard's `fatal:` line (#1233, RV1311)

git's `vreportf`, which writes every `error:` and `fatal:` line, writes
each control character but a tab and a line feed as `?`. Measured on git
2.43 (`git add --dry-run -- a<c>b`): exactly U+0001-U+0008, U+000B-U+001F
and U+007F, 30 characters; a tab, a line feed, the C1 controls and U+202E
come out as themselves, and git's `To` line is not sanitized. So the path
`re<ESC><LF>mote` is `re?<LF>mote` in the `error:` line, which neither
form `_output_unacted` looked for (the raw part, and the one `run` reads
back) matched, and its line feed split the line.

`_output_unacted` now also looks for git's form of each form it already
looked for, `GIT_WRITES_AS_QUERY` (`[\x00-\x08\x0b-\x1f\x7f]`) written as
`?`, and spells it with `_unacted`, so git's `?` stays as git wrote it and
only the line feed is spelled: `wo?<LF>rk` is `wo?\nrk`. The longest of
all the forms is still spelled first.

A part made only of line feeds is skipped (`part.strip("\n")`). Spelled
in what the command printed, it spelled every line break there:
`CommandFailed(["git", "x", "\n"], None, 1, "line1\nline2\nline3")` said
one line, `line1\nline2\nline3`, and `\n\n` did the same to an output
with a blank line.

`tests/test_adopt_plan_and_remote_paths_spelled.py`: `escape-then-line-feed`
in `REFUSED_CHARACTERS` (the real refused push); `MOUNT_CHARACTERS`, which
adds that and `carriage-return-then-line-feed` to the mount row, whose
expectation is git's form computed by the row's own rule, spelled; an
in-process row over fixed text git would say; and one for the arguments
`\n` and `\n\n`. All 6 new rows fail on the head before this commit.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Lane: openreposhape-2 (openRepoShape-2)
Base automatically changed from fix/1195-plan-and-remote-paths-leftovers to main November 10, 2026 16:54
Brett Heap and others added 2 commits November 10, 2026 17:00
…its (restack after #1225's squash, step 1 of 3)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Lane: openreposhape-2 (openRepoShape-2)
… this branch's side for #1225's own files, which equal the squash's (restack step 2 of 3)

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

Copy link
Copy Markdown
Contributor Author

(lane openRepoShape-2, 2026-11-10T17:03:28Z) This PR is restacked onto main, and RV1311b, the delta review of its fix round, reads READY AFTER FIXES.

RV1311b's review follows as the reviewer wrote it. The reviewer is an Opus agent that wrote none of this PR.


RV1311b: delta review of #1311's fix round, ee535cf0e..8649430ce (for #1233)

Verdict: READY AFTER FIXES. No MUST, one SHOULD and two NITs.

The fix round does what it says for ESC (and every other control git writes as ?) beside a line feed, in git's error: and fatal: lines, and for NIT 1. It leaves one case of RV1311's SHOULD 1 open: a path holding CR+LF still splits git's To line in a real refused push. I wrote none of this PR and changed none of it. Every pytest run went through lane openRepoShape-2's runner (run-l2.sh), one at a time, in my own worktree, detached at 8649430ce7d8865a3bc77e1ba2d938b7cc8a0eb6. After every mutant and probe, adopt-project.py's sha256 was 6e0230d6814e6c432d2fee2e038aaa88e1886dd4b638c8e4be68d5ecff958358 and the status was clean. Bench: git 2.43.0, Python 3.12. CI runs Python 3.14.

Runs (measured)

Run Result
all of tests/test_adopt_plan_and_remote_paths_spelled.py at the head 205 passed in 147.05s (START 16:57:42Z, END 17:00:11Z, rc=0, dirty=0)
the in-process rows with L2_KEEP_LANE=1 (lane=openRepoShape-2), -k "said_spelled or holds_another or leg_remote_already_there or in_its_own_lines or nothing_but_line_feeds" 28 passed, 177 deselected in 0.64s (START 17:00:11Z, END 17:00:12Z, rc=0)
the whole file on the code at ee535cf0e (M0: the old adopt-project.py over the head's, then restored) 6 failed, 199 passed in 154.09s: exactly the 6 new rows (listed below)

So the writer's claim holds: each new row fails on the old code, and no other row does. The 6 rows are:

  • test_a_refused_command_names_the_remote_and_work_dirs_spelled[escape-then-line-feed]
  • test_a_path_is_spelled_as_git_writes_it_in_its_own_lines
  • test_an_argument_of_nothing_but_line_feeds_spells_no_line_break[\n] and [\n\n]
  • test_a_mount_git_will_not_add_is_said_spelled[escape-then-line-feed] and [carriage-return-then-line-feed]

Mutants (measured)

Each mutant was applied to adopt-project.py, run, and restored with git checkout --, and the sha256 and status were checked each time. M1-M4 and M6 ran on the 30 rows that reach _output_unacted (-k "refused_command or said_spelled or holds_another or in_its_own_lines or nothing_but_line_feeds or mount_git_will_not_add"). M5 also ran on the whole file.

Mutant Rows that fail
M1: drop git's form (named |= forms) 4: the real push [escape-then-line-feed], in_its_own_lines, the mount [escape-then-line-feed] and [carriage-return-then-line-feed]
M2: CR taken out of the class ([\x00-\x08\x0b\x0c\x0e-\x1f\x7f]) 1: the mount [carriage-return-then-line-feed]
M3: NIT 1's skip dropped (if "\n" in part:) 2: nothing_but_line_feeds[\n] and [\n\n]
M4: git's form is found, but replaced by the raw part spelled (git's ? becomes \x1b) 3: in_its_own_lines, the mount [escape-then-line-feed] and [carriage-return-then-line-feed]. The real-push row passes: it asserts only the To line and that no line starts mote/.
M5: git's form of the typed part only, not of the form run reads back ({GIT_WRITES_AS_QUERY.sub("?", part)}) none: 30 passed, and 205 passed on the whole file. See NIT 2.
M6: shortest first 1: test_a_path_that_holds_another_is_spelled_whole_where_git_names_it

Answers to the brief's checks

  1. SHOULD 1 (measured):
    • ESC+LF: fixed. In a real refused push the To line is To <D>/re\x1b\nmote/Thing-spec.git and the error: line is ... '<D>/re?\nmote/Thing-spec.git', each on one line. The same holds for DEL+LF, TAB+LF, LF+ESC and 0xff+ESC+LF (probe P1).
    • The mount route: fixed for ESC+LF and CR+LF (the PR's rows, which pass).
    • CR+LF in the push: NOT fixed. See SHOULD 1 below.
    • The class: GIT_WRITES_AS_QUERY is exactly what git 2.43 writes as ?. Measured (probes-b/gitq.py, a read-only git rev-parse x<c>y, stderr as bytes): ? for U+0001-U+0008, U+000B-U+001F and U+007F, 30 characters. git writes as themselves TAB, LF, every raw byte 0x80-0xFF, U+0085, U+009B, U+2028, U+202E, U+200B, U+FEFF and U+00E9. The measured set equals the class.
    • git's ?: the replace keeps it as git wrote it and spells only the line feed (measured: re?\nmote; M4 shows a row pins it).
    • Longest first: kept across every form. It is read from sorted(named, ...) over the union, and M6 shows a row pins it.
  2. NIT 1 (measured in process):
    • A part of nothing but line feeds is skipped: "\n" and "\n\n" keep line1 / line2 / (blank) / line3 as 4 lines.
    • Nothing else is newly skipped. " \n", "\n ", "\t\n", "\r\n" and "\n<ESC>" give the same text as at ee535cf0e. The skip also covers the directory, which is what the docstring's "argument" means.
  3. New risks (measured in process, probes-b/inproc.py; the old code is the copy from ee535cf0e):
    • No part holds a LF: in 30000 random cases (ESC, CR, U+202E, 0xff, U+FFFD and ? in the arguments, the directory and the output), the output is identical to the old one and nothing raises.
    • LF parts without a class character, none all-LF: identical to the old output.
    • LF parts with class characters: in 30000 cases nothing raises, old or new. The only difference is a LF spelled \n, and no raw control is left.
    • git's ? matching text that is not the path: yes, for an argument made only of controls and line feeds. See NIT 1 below.
  4. The rows:
    • All 6 fail on ee535cf0e (measured, M0).
    • Python version (read): no new row depends on it. Expected text is built from double_quoted's fixed tables, and isprintable is asked only of ASCII controls.
    • git version (read): the real-push row passes whether or not git sanitizes either line, since it asserts only the To line's two ends and that no line starts mote/, and both the raw and git forms are looked for. The two new mount rows rely on git's fatal: line writing ESC and CR as ?. That is measured on 2.43, not on CI's git. The in-process rows ask no git.
    • CI: it lacks nothing the rows need. Linux file names carry ESC, CR and LF.
  5. Mutants: 6 of my own plus M0, above. Five are killed and M5 survives.
  6. The docstring (read, adopt-project.py:14497-14514):
    • It is accurate for git's form, the longest-first order and the LF-only skip.
    • The sentence "looked for as run reads it back: a byte that is not UTF-8 ... is U+FFFD there" (:14504-14506) is incomplete. run also reads a CR as a LF, which is SHOULD 1's cause.
    • GIT_WRITES_AS_QUERY's comment (:14491-14493) matches my measurement.

Findings

SHOULD 1 (measured): a path that holds CR+LF still splits git's To line in a real refused push

  • Where: adopt-project.py _output_unacted, the forms at :14517-14522, and the docstring sentence at :14504-14506.
  • Measured: probe P1 (probes-b/run_push_probe.sh, push-probe.log). The real refused push under --local-remote-dir <D>/re<CR><LF>mote at the head gives this block:
    --- output ---
    remote: this remote takes no push
    To <D>/re
    mote/Thing-spec.git
     ! [remote rejected] HEAD -> main (pre-receive hook declined)
    error: failed to push some refs to '<D>/re?\nmote/Thing-spec.git'
    --- end output ---
    
    The PR's own row assertions fail on it: told[0].endswith("mote/Thing-spec.git") is False. A lone CR (re<CR>mote) gives the same To split, with error: ... 're?mote/...'. That case predates this PR, and is outside N1's letter, since the path holds no line feed.
  • Cause (read, then measured):
    • run (scripts/shape_materialize.py:1380-1383) decodes with text=True. Its universal newlines turn CR+LF, and a lone CR, into LF. Measured on 3.12: a child printing To /re\r\nmote is read back as To /re\nmote.
    • git's To line is not sanitized, so the path reaches _output_unacted as re<LF>mote. None of the three forms is that: the typed re<CR><LF>mote, run's U+FFFD form, or git's re?<LF>mote.
    • In process, at ee535cf0e the same output split both lines. The fix round fixed the error: line only.
    • The rows pin CR+LF only in the mount route, where git turns CR into ? before run reads it, so this passed unseen.
  • Why SHOULD:
  • The change I would make: also look for the form run reads back with universal newlines, and spell it as the path holds it. For example (probes-b/fixsketch.py, checked in process):
    def _as_run_reads(text: str) -> str:
        return text.replace("\r\n", "\n").replace("\r", "\n")
    # for each part with "\n" in _as_run_reads(part), and each of its forms:
    #     spelled[form] = spelled[_as_run_reads(form)] = _unacted(form)
    #     spelled[GIT_WRITES_AS_QUERY.sub("?", form)] = _unacted(that git form)
    # then replace longest first, each found text by spelled[found]
    • In process: this puts the CR+LF and the lone-CR push on one line (To /re\r\nmote/T.git, To /re\rmote/T.git). It leaves the head's own cases unchanged: in_its_own_lines, \n\n, the mount CR+LF, and a lone surrogate.
    • The row: add pytest.param("\r\n", "\\r\\n", id="carriage-return-then-line-feed") to REFUSED_CHARACTERS (tests/test_adopt_plan_and_remote_paths_spelled.py:662-666). Probe P1 shows it fails at the head.
    • The docstring: make the run sentence name the CR.
    • The lone CR is optional: take it with the same test ("\n" in _as_run_reads(part)), or leave it to a follow-up issue.
    • Option (b): say in the docstring that a CR in a path still splits git's To line, and add a row that pins it.

NIT 1 (measured in process): git's ? form of an argument made only of controls and line feeds matches every ? that ends a line

  • Where: adopt-project.py:14521-14522.
  • Evidence (inproc.log Q1-Q3): CommandFailed(["git", "x", "\x1b\n"], None, 1, "Is this it?\nyes") prints one line, Is this it?\nyes, where ee535cf0e printed two. An argument "\r\n" does the same. "\x1b\n\x1b" merges why? and ?.
  • Why only a NIT:
    • It needs an argument holding nothing but ASCII controls and line feeds, and no command passes one today. The paths are absolute, or held to SAFE_ARG_RE, and RV1311 read the rest.
    • A typed ?\n argument did the same at ee535cf0e (Q5).
    • The damage is NIT 1's class: a line feed spelled \n, and nothing lost.
  • The change: keep a git form only where it holds more than ? and line feeds (if git_form.strip("?\n")), as NIT 1 skips a part of only line feeds. In process (fixsketch.log Q1, Q2) this gives two lines again. Or add a line to the docstring.

NIT 2 (measured): no row pins git's form of the form run reads back

  • Where: adopt-project.py:14521-14522, and REFUSED_CHARACTERS in tests/test_adopt_plan_and_remote_paths_spelled.py:662-666.
  • Evidence:
    • M5 keeps git's form of the typed part only, and passes the whole file (205 passed).
    • At the head, a real push under re<0xff><ESC><LF>mote holds error: ... 're<U+FFFD>?\nmote/Thing-spec.git' on one line (P1).
    • With M5 and that case added, the row fails (mutants-b/m5-row-probe.log: 1 failed, 2 passed). The error: line splits at re<U+FFFD>? / mote/Thing-spec.git'.
  • The change: add pytest.param("\udcff\x1b\n", "\\udcff\\x1b\\n", id="byte-0xff-then-escape-then-line-feed") to REFUSED_CHARACTERS. It passes at the head and kills M5.

Measured, against read only

  • Measured: git's class (gitq), the real refused push with ESC+LF, CR+LF, a lone CR, DEL+LF, TAB+LF, LF+ESC and 0xff+ESC+LF (P1), run's CR translation on 3.12, the in-process old-against-new fuzz (F1-F3) and the Q, S and C cases, M0-M6, the M5 row probe, the fix sketch in process, and the two required runs.
  • Read only: the docstrings and comments, the commit message (its git-class claims match my measurement), the rows' Python- and git-version dependence, and that no command passes an argument of only controls and line feeds (from RV1311's reading, not re-read).

Checks not done

  • CI's git version, and the PR's CI result on this head. The new mount rows rely on git writing ESC and CR as ? in fatal: lines; this is measured on 2.43 only.
  • A run on Python 3.14.
  • tests/test_shape_doctor.py, skipped by the brief (the writer reports 446 passed and 3 skipped). Also tests/test_scaffold_leg_path_collisions.py, tests/test_adopt_github_exits.py and the grep-matched files, which I did not re-run at this head (the writer reports 104, 23 and 244 passed).
  • A merge-tree against current main.

A note for main (not a PR finding)

8649430's trailer is Co-Authored-By: Claude Sonnet 5.5, while rules.md prescribes the Opus line. It is likely the writer's true model.

Lane: openreposhape-2 (openRepoShape-2)

Lane: openreposhape-2 (openRepoShape-2)

…CR+LF, or a lone CR, whole in git's `To` line, where `run` reads the CR as a line feed, and looks for git's `?` form of the byte-0xff form `run` reads back too, and no longer spells every `?` that ends a line for an argument of only controls and line feeds (#1233, RV1311b)

`_output_unacted` looks for each path with a line feed also as `run` reads it back with universal newlines (CR+LF, and a lone CR, are a line feed: `_as_run_reads`), spelled as the path holds it, so `--local-remote-dir <D>/re<CR><LF>mote` no longer splits git's `To` line (SHOULD 1). A git `?` form is kept only where it holds more than `?` and line feeds (NIT 1). A part of nothing but line feeds as `run` reads it is skipped, as before for `\n`. The longest form is still spelled first.

Rows: `carriage-return-then-line-feed` (the real refused push) and `byte-0xff-then-escape-then-line-feed` (NIT 2, kills the mutant that takes git's form of the typed part only) in REFUSED_CHARACTERS; two in-process rows for a CR in a path (CR+LF, lone CR) and one for an argument of only controls and line feeds (ESC+LF, CR+LF).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Lane: openreposhape-2 (openRepoShape-2)
@sonarqubecloud

Copy link
Copy Markdown

@brettheap

Copy link
Copy Markdown
Contributor Author

(lane openRepoShape-2, 2026-11-10T17:25:19Z) RV1311c, the delta review of the second fix round (c7749c1cf), reads READY, with no MUST and no SHOULD.

  • The round (for RV1311b's SHOULD 1, NIT 1 and NIT 2): a path that holds CR+LF, or a lone CR, now stays on one line in git's To line as well. Its rows fail on the restacked 447f8f7ee, or under RV1311b's M5.
  • The writer's runs at c7749c1cf: the test file 211 passed, test_adopt_github_exits.py 23, the in-process rows with LANES_LANE set 32, test_scaffold_leg_path_collisions.py 104, and test_shape_doctor.py 446 passed and 3 skipped.
  • CI at c7749c1cf: SonarCloud, package and tests-git-bash passed; tests is running. Lane 2 marks this PR ready when it passes, and then asks lane 3 for its place in v1.2.1's order.
  • RV1311c's three NITs each need an unusual input. The body lists them under "Not in this PR".

RV1311c's review follows as the reviewer wrote it. The reviewer is an Opus agent that wrote none of this PR.


RV1311c: second delta review of #1311, 447f8f7ee..c7749c1cf (for #1233)

Verdict: READY. No MUST, no SHOULD, three NITs.

The round fixes RV1311b's SHOULD 1, NIT 1 and NIT 2 as asked. A path holding CR+LF, or a lone CR, now stays on one line in git's To line in a real refused push. Every case RV1311b measured still holds. The three NITs are exotic, and none blocks the merge.

I wrote none of this PR and changed none of it. Every pytest run went through lane openRepoShape-2's runner (run-l2.sh), one at a time, in my own worktree, detached at c7749c1cf0ff80292512cec4806323c69a08b98b. After every mutant and probe, adopt-project.py's sha256 was 132684b4bfcb7747380596b4b75bb811e799e6d41e5cce4e77250477745d096f and the status was clean. Bench: git 2.43.0, Python 3.12. CI runs Python 3.14.

Runs (measured)

Run Result
all of tests/test_adopt_plan_and_remote_paths_spelled.py at the head 211 passed in 127.86s (START 17:16:49Z, END 17:18:58Z, rc=0, dirty=0)
the in-process rows with L2_KEEP_LANE=1 (lane=openRepoShape-2), -k "said_spelled or holds_another or leg_remote_already_there or in_its_own_lines or nothing_but_line_feeds or as_run_reads or only_controls" 32 passed, 179 deselected in 0.53s (START 17:18:58Z, END 17:19:00Z, rc=0)
C0: the code at 447f8f7ee over the head's, on the 36 rows that reach _output_unacted 5 failed, 31 passed: exactly the 5 new rows the writer names (below)
P2: the real refused push with 7 more cases added to REFUSED_CHARACTERS 11 passed in 14.61s (START 17:22:06Z, END 17:22:22Z, rc=0)

The 5 rows that fail at 447f8f7ee (C0) are:

  • test_a_refused_command_names_the_remote_and_work_dirs_spelled[carriage-return-then-line-feed]
  • test_a_path_with_a_carriage_return_is_spelled_as_run_reads_it[carriage-return-then-line-feed] and [carriage-return]
  • test_an_argument_of_only_controls_and_line_feeds_spells_no_question_mark[\x1b\n] and [\r\n]

[byte-0xff-then-escape-then-line-feed] passes at 447f8f7ee, as it should. NIT 2 asked for a row that kills a mutant, not for a change of behaviour (see C6).

Mutants (measured)

Each mutant was applied to adopt-project.py, run on the 36 targeted rows (-k "refused_command or said_spelled or holds_another or in_its_own_lines or nothing_but_line_feeds or mount_git_will_not_add or as_run_reads or only_controls"), and restored with git checkout --. The sha256 and the status were checked each time (c/summary.log).

Mutant Rows that fail
C1: no read-back key (for found in (form,)) 3: the real push [carriage-return-then-line-feed], and the in-process carriage_return rows [carriage-return-then-line-feed] and [carriage-return]
C2: the read-back form spelled as run reads it (_unacted(found)) 2: the in-process carriage_return rows. The real-push row passes, since it asserts only the To line's two ends. The in-process rows pin the spelling.
C3: _as_run_reads drops the lone CR (CR+LF only) 1: the in-process [carriage-return] row. A lone-CR real-push row (probe P1) also kills it: 1 failed.
C4: the skip tests the typed part, not the form run reads back 2: the in-process [carriage-return] row and only_controls[\r\n]
C5: NIT 1's guard dropped (if git_form:) 1: only_controls[\x1b\n]
C6: RV1311b's M5, git's form of the typed part only 1: the real push [byte-0xff-then-escape-then-line-feed]. NIT 2's row kills M5.
C7: shortest first 2: holds_another, and the in-process carriage_return[carriage-return-then-line-feed]

Answers to the brief's checks

  1. SHOULD 1 (measured, done):
    • The new row: the real-push row [carriage-return-then-line-feed] passes at the head and fails at 447f8f7ee (C0).
    • Probe P2 (c/run_p2.sh, c/p2.log) printed stderr for 11 cases. Each To line and error: line is on one line, and spelled as the path holds it, for: ESC, ESC+LF, CR+LF, 0xff+ESC+LF, DEL+LF, a lone CR, TAB+LF, LF+ESC, LF+CR, CR+CR+LF and 0xff+CR.
    • CR+LF gives: To <D>/re\r\nmote/Thing-spec.git, and error: failed to push some refs to '<D>/re?\nmote/Thing-spec.git'.
    • A lone CR gives: To <D>/re\rmote/Thing-spec.git, and error: ... '<D>/re?mote/Thing-spec.git'.
    • RV1311b's cases still hold: ESC+LF, DEL+LF, TAB+LF, LF+ESC and 0xff+ESC+LF, as listed above.
    • No row pins the lone CR in a real push. The in-process row [carriage-return] pins it, and P1 shows a real-push row would pass at the head and kill C3. Adding it is optional.
  2. NIT 1 and NIT 2 (measured, done):
    • NIT 1 is fixed as asked (if git_form.strip("?\n"), adopt-project.py:15136). only_controls[\x1b\n] fails at 447f8f7ee and under C5.
    • NIT 2's row is added (tests/test_adopt_plan_and_remote_paths_spelled.py:671-672), and it kills M5 (C6).
  3. New risks:
    • Text in the output that is not the path (measured in process, c/inproc.py, c/inproc.log): yes, in two exotic shapes. See NIT A and NIT B below.
    • Longest first (read, and measured): it is kept across every form. It is one sorted over all the keys in spelled (:15138), and C7 is killed by 2 rows.
    • Raises (measured in process): nothing raises, old or new. That held in 30000 random cases with no LF and no CR, 30000 with LF only, and 30000 with CR and LF. In the last set, no raw control is left in the result.
    • Output where no part holds a LF or a CR (measured in process): it is identical to 447f8f7ee's in 30000 of 30000 random cases (F1). With LF parts and no CR, the only difference in 30000 cases is NIT 1's own change (107 cases, F2).
  4. The rows (measured and read, done):
    • Each new row fails at 447f8f7ee (C0), or under its mutant (C6).
    • Python version (read): no new row depends on it. The in-process rows use fixed text and compute the expected text with adopter._unacted. The test keeps its own GIT_WRITES_AS_QUERY (:679). run_adopt decodes bytes, not universal newlines, so the raw-CR assertions are real.
    • git version (read): the CR+LF and 0xff+ESC+LF real-push rows pass whichever of git's lines is sanitized. The raw form, the read-back form and git's form are all looked for.
  5. Mutants (measured, done): 7 of my own (C1-C7) plus C0. All 7 are killed.
  6. The docstring (read, done): accurate for the CR, the read-back form, the LF-only skip and the longest-first order. One sentence over-claims (NIT C).

Findings

NIT A (measured in process): when two arguments of one command share a form, the output depends on PYTHONHASHSEED

  • Where: adopt-project.py:15125 (a set's iteration order), with spelled.setdefault at :15134 and :15137.
  • Cause:
    • At 447f8f7ee, every found text was spelled as itself, so the order did not matter.
    • Now the read-back form of a CR part is spelled as the part. Where two parts give the same found text two spellings, the first part in the set's order wins, and that order changes with the hash seed.
  • Evidence (c/seed6.py, c/seed6.log, seeds 0 to 9):
    • Parts /D/re<CR><LF>mote and /D/re<LF>mote, with the output To /D/re<LF>mote, give To /D/re\r\nmote under some seeds and To /D/re\nmote under others.
    • Parts /D/re?<CR><LF>mote and /D/re<ESC><LF>mote give error: '/D/re?\nmote' or '/D/re?\r\nmote'.
    • A 20000-case random digest is the same under seeds 0 to 3 (c/seedfuzz.log), so it takes forms that coincide exactly.
  • Why only a NIT: no command the tool runs has two path arguments that differ only by CR against LF, or by ? against a control.
  • The change: walk the parts in the command's order (dict.fromkeys(...)). Let a part's own forms win over read-back forms, and those over git's forms, for example by filling spelled tier by tier. My sketch (c/fixsketch.py, c/fixsketch.log, in process) is the same under seeds 0, 2, 6 and 9. It leaves every row's case unchanged: the CR+LF push, the lone-CR push, the two in-process CR rows, ESC+LF, and the mount CR+LF.

NIT B (measured in process): a part that ends in a CR, printed at a line end, takes git's line feed with it

  • Where: adopt-project.py:15133-15134.
  • Cause: run reads the part's CR and git's own LF as one LF. The read-back key <part><LF> then matches, and is spelled <part>\r with no line feed after it.
  • Evidence (c/inproc.log):
    • T1: for the argument /D/remote/T.git<CR>, To /D/remote/T.git / ! [remote rejected] ... becomes one line, To /D/remote/T.git\r ! [remote rejected] HEAD -> main. 447f8f7ee kept the two lines.
    • T2: a cwd /D/work<CR> does the same.
    • T3 and T4: short arguments " \r" and "?\r" merge every line that ends in a space or a ?. This is the CR twin of the typed "?\n" case RV1311b's Q5 found before this PR (T5).
  • Why only a NIT: in the push route the part git prints at a line end is the remote URL, which ends in -spec.git. A CR in --local-remote-dir or --work-dir is never last. I found no command that prints a CR-ended part raw at a line end. I read the push route only, not every command.
  • The change: for a form that ends in a CR, spell its read-back form as _unacted(form) + "\n".
    • Where git's line ends there (T1, T2), it keeps the line break.
    • Where more text follows, it keeps 447f8f7ee's split, and is no worse.
    • In my sketch it changes no row's case. Or say it in the docstring.

NIT C (read): the docstring's ? sentence is wider than the code

  • Where: adopt-project.py:15118-15119, "A form of nothing but ? and line feeds is not looked for".
  • What the code does: only git's form is tested (:15136). The typed form ?<LF> (T5, which predates this PR) and the read-back form ?<LF> of a typed ?<CR> (T4, new) are still looked for.
  • The change: say "git's form of nothing but ? and line feeds".
  • Also (read): the opening sentence (:15104-15105) says a part "that holds a line feed". A part with a lone CR is now looked for as well, so "that holds a line feed as run reads it" would be exact.

Note for main (not a PR finding)

  • The commit subject (read; C0 measured): it says the code now "looks for git's ? form of the byte-0xff form run reads back too". That was already so at 447f8f7ee: its {GIT_WRITES_AS_QUERY.sub("?", form) for form in forms} covered it, and C0 passes the new row. This round only adds the row that pins it. Worth keeping out of the squash message.
  • The trailer: c7749c1's trailer is Co-Authored-By: Claude Sonnet 5.5, as the writer's notes say. rules.md prescribes the Opus line.

Measured, against read only

  • Measured:
    • The two required runs, C0-C7, and P1/P1C3.
    • P2: 11 real refused pushes, stderr captured.
    • In process: the old-against-new fuzz (F1-F3), the named cases T1-T11, the hash-seed runs, and the fix sketch.
  • Read only:
    • The docstrings, and run's decoding (scripts/shape_materialize.py:1382-1383: text=True, encoding="utf-8", errors="replace").
    • The rows' Python- and git-version dependence, and the commit message.
    • That no command prints a CR-ended part raw at a line end, read for the push route only.

Checks not done

  • CI's git version, a run on Python 3.14, and the PR's CI result on this head.
  • tests/test_shape_doctor.py, skipped by the brief; the writer runs it at this head. Also tests/test_scaffold_leg_path_collisions.py and tests/test_adopt_github_exits.py, which I did not re-run (the writer reports 104 and 23 passed).
  • A merge-tree against current main.
  • A search of every command, beyond the push route, for a part that ends in a CR (NIT B's reachability).

Lane: openreposhape-2 (openRepoShape-2)

Lane: openreposhape-2 (openRepoShape-2)

@brettheap
brettheap marked this pull request as ready for review November 10, 2026 17:54
@sourcery-ai

sourcery-ai Bot commented Nov 10, 2026

Copy link
Copy Markdown

Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 4 days and 3 hours by commenting @sourcery-ai review. Upgrade to get a review now.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment