Skip to content

scripts/shape_materialize.py and adopt-project.py: CommandFailed.loudly spells the step, the command, the directory and the output of the REFUSED block, so the four tools that print it no longer put a bidirectional control or an ESC there raw, and _init_refused, source-unclonable and both adopt-remote-unreadable routes spell the argument list and git's or gh's words as _unacted does (#1213) - #1322

Draft
brettheap wants to merge 12 commits into
mainfrom
fix/1213-raw-command-output-spelled

Conversation

@brettheap

@brettheap brettheap commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1213

Built on #1225's head cc230f2f, then restacked onto #1225's squash dc9a0bcc7 with 2 merges, carrying exactly the change (changed lines byte-equal, sha256 d113fc9d66390624c88c6ef4b4098c1d5fa2ba85f6e13df60a9a701de868d03a).

What

#1213 asks that three groups of sites print what a refused command says the way #1152 and #1195 print a plan's path:: every character a terminal acts on (U+202E and the other bidirectional controls, ESC, a carriage return, a lone surrogate) written as its escape, instead of reaching the terminal raw.

A printable command prints the block it always printed.

Measured (base dc9a0bcc7 = main with #1225, against this head 476bfdd3c)

Each site run with U+202E, ESC, a line feed and a lone surrogate (byte 0xff) in an argument, a directory or the output, in the rules' environment (a stub gh, GH_TOKEN=bogus, an empty GH_CONFIG_DIR, GIT_SSH_COMMAND=false). Raw ESC count / raw U+202E count / raw 0xff count on stdout and stderr together:

Site Raw ESC / U+202E / 0xff, base head
scaffold_main 3 / 3 / 0 0 / 0 / 0
scaffold_push 3 / 3 / 0 0 / 0 / 0
update_commit_undone_none 3 / 3 / 0 0 / 0 / 0
update_commit_undone 3 / 4 / 0 0 / 0 / 0
update_landing 3 / 3 / 0 0 / 0 / 0
update_main 3 / 3 / 0 0 / 0 / 0
family_init_push 3 / 2 / 0 0 / 0 / 0
family_add_dry_clone 1 / 2 / 0 0 / 0 / 0
family_add_clone 1 / 2 / 0 0 / 0 / 0
family_add_rollback 3 / 4 / 0 0 / 0 / 0
family_bump_resolve 0 / 2 / 0 0 / 0 / 0
family_put_back 4 / 3 / 0 0 / 0 / 0
family_remove_list 2 / 3 / 0 0 / 0 / 0
family_main 3 / 3 / 0 0 / 0 / 0
bump_put_back 3 / 3 / 0 0 / 0 / 0
bump_main 3 / 3 / 0 0 / 0 / 0
adopt_init_refused 2 / 2 / 0 0 / 0 / 0
adopt_init_refused_lf 0 / 0 / 0 0 / 0 / 0
adopt_unclonable 2 / 1 / 0 0 / 0 / 0
adopt_ls_remote_git_says 0 / 1 / 0 0 / 0 / 0
adopt_ls_remote_stub 2 / 1 / 0 0 / 0 / 0
adopt_ls_remote_oserror 1 / 1 / 0 0 / 0 / 0
adopt_gh_oserror 1 / 1 / 0 0 / 0 / 0

22 sites print a raw character at the base and none does at the head. At the base git writes ESC as ? itself in its own lines, but not U+202E. adopt_init_refused_lf (a line feed in --work-dir) has no ESC or U+202E on either side: it measures the line feed, which splits the NOTE in two at the base (a raw line feed in git init -q <dir>) and is written \n at the head. The probes are in the lane's scratch (measured-base.md, measured-head.md).

The "where" choice (the issue leaves it to the builder)

Spell once, inside CommandFailed.loudly; no tool spells at its call. The cost the issue names is that loudly moves every tool's REFUSED block, so a row that asserts raw text there would move. Measured, there is none:

  • Static: 14 test files assert the block's markers (THE EXACT COMMAND WAS, --- output ---). None asserts a raw bidirectional control or ESC in a block: tests/test_adopt_late_failure.py and tests/test_adopt_plan_and_remote_paths_spelled.py assert the spelled form, tests/test_scaffold_reuse_seeded_legs.py asserts the raw character is absent, and the rest name printable text. Rows that build the expected block with failed.loudly(...) itself stay equal.
  • Dynamic: the gate below (176 test files, four shards) has 0 failures and no row moved.
  • Spelling the step is beyond the issue's three groups: two family.py calls put a member's path in the step, so their rows cannot pass otherwise. A printable step is unchanged.

The choice and the measure are written at CommandFailed.loudly. Pinned copies: none. shape_materialize.py is not copied into templates/, a holder or an assembly root; no digest of any changed or called tool file exists in templates/ or contracts/; no test compares copies; README, AGENTS and the handbook have no sentence about the block's spelling.

Rows

tests/test_command_output_spelled.py: 110 rows (35 test functions): unacted and loudly themselves, a row per call of the 16, group 1 (a real check and the refs probe), group 2 (a stub gh, the 400-character cut, both OSError branches), and two real child runs (scaffold, family init). Each row asserts the block as it is spelled and that no raw U+202E, ESC or 0xff reaches stdout or stderr.

Mutants

Each put into a worktree at this head, run against the whole 110-row file, the file restored and its sha256 checked equal after every one. Every mutant fails at least one row.

Mutant What it puts back File Rows failed
L1 loudly prints the directory raw scripts/shape_materialize.py 34 of 110
L2 loudly prints the command raw scripts/shape_materialize.py 32 of 110
L3 loudly prints the output raw scripts/shape_materialize.py 34 of 110
L4 loudly prints the step raw scripts/shape_materialize.py 12 of 110
L5 loudly spells the output's line feeds too scripts/shape_materialize.py 48 of 110
L6 unacted spells every non-ASCII character scripts/shape_materialize.py 2 of 110
L7 loudly keeps a tab in the output scripts/shape_materialize.py 1 of 110
L8 loudly keeps a carriage return in the output scripts/shape_materialize.py 1 of 110
L9 unacted wraps a spelling in backticks scripts/shape_materialize.py 53 of 110
A1 _init_refused prints the command raw adopt-project.py 12 of 110
A2 source-unclonable prints gh's words raw adopt-project.py 4 of 110
A3 source-unclonable spells gh's words, then cuts them adopt-project.py 2 of 110
A4 source-unclonable drops gh's line breaks adopt-project.py 3 of 110
A5 adopt-remote-unreadable prints ls-remote's words raw adopt-project.py 3 of 110
A6 adopt-remote-unreadable prints an ls-remote OSError raw adopt-project.py 2 of 110
A7 adopt-remote-unreadable prints a gh OSError raw adopt-project.py 2 of 110
A8 adopt-remote-unreadable keeps ls-remote's line breaks adopt-project.py 3 of 110
A9 _init_refused wraps its spelled command in backticks adopt-project.py 15 of 110
S01 to S16 each of the 16 .loudly calls put back as the old raw block, one at a time (scaffold-project.py 2, update-shape.py 4, scripts/family.py 8, scripts/bump-leg.py 2) the tool's file 2 each; S02 (scaffold-project.py's refused push) 4

Gate

Run on this head 476bfdd3c (the merge with main dc9a0bcc7, #1225's squash), four shards of 44 files, in the rules' environment (env -u of the lane variables, EMAIL set, git filter-repo on PATH, a stub gh), at most 2 pytest runs in parallel. The list is gateset.sh's against this diff (176 files: the new rows, every test file that greps a function, refusal code or file changed, the four tools' files, test_adopt_plan_and_remote_paths_spelled.py, test_repo_hygiene.py, test_path_guard_hygiene.py, test_cli_reference.py, test_shape_doctor.py, test_scaffold_leg_path_collisions.py), united with W1213's earlier list.

Shard Files Passed Skipped Failed Time
0 44 2428 3 0 33:03
1 44 2675 4 0 33:43
2 44 3288 6 0 44:21
3 44 2868 25 0 37:28
All 176 11259 38 0

Each shard's junit file agrees (0 failures, 0 errors; 11297 tests in all), the four shard lists are exactly the 176 files of the list, and every shard ran on 476bfdd3c. The skips are the environment's: the reftable rows (this git is older than 2.45), the case-insensitive-disk rows, the Windows-only rows (junctions, PowerShell, the default stdout encoding) and the make jobserver row.

Main has moved since (see Merge-trees), and the gate ran on this head, not on its merge with the newer main; lane 4's landing pre-gate tests the predicted squash over it.

Merge-trees

git merge-tree --write-tree of this head against:

Not in this PR

Each defect below is outside #1213's three groups. The drafts named are in the lane's scratch; none is filed, because a follow-up candidate is filed only on Brett Heap's word.

🤖 Generated with Claude Code
Lane: openreposhape-4 (openRepoShape-4)

Summary by Sourcery

Ensure refused-command diagnostics render terminal-sensitive characters safely across materialization and project-adoption workflows.

Bug Fixes:

  • Escape terminal-control characters and other unsafe characters in refused-command messages so they cannot alter terminal display or output structure unexpectedly.
  • Escape command details and external tool errors reported by adoption workflows, including clone, remote-read, and initialization refusals.

Enhancements:

  • Centralize safe command-output rendering in a reusable helper while preserving ordinary printable text and output line breaks.

Tests:

  • Add comprehensive POSIX tests covering escaped commands, paths, steps, tool output, exception text, truncation behavior, and real refused-command flows.

Brett Heap and others added 11 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]>
…dly` spells the step, the command, the directory and the output of the REFUSED block, so the four tools that print it no longer put a bidirectional control or an ESC there raw, and `_init_refused`, `source-unclonable` and both `adopt-remote-unreadable` routes spell the argument list and git's or gh's words as `_unacted` does (#1213)

`loudly` printed what a refused command was, where it ran and what it
printed as they were, and sixteen calls in `scaffold-project.py`,
`update-shape.py`, `scripts/family.py` and `scripts/bump-leg.py` print what
it makes. It now writes each character `str.isprintable` refuses as the
plan's `path:` does (`shape_materialize.unacted`), keeping the output's line
breaks, as #1195's `adopt-project.py` `_loudly` does. The spelling is in
`loudly` once and no tool spells at its call; the choice and its measure are
written at `loudly`. A command of printable text prints the block it always
printed.

In `adopt-project.py`, `_init_refused` spells the `git init` it names,
`Source.clone` spells the up to 400 characters of gh's words it quotes in
`source-unclonable` (cut first), `_refuse_a_tracking_branch_the_remote_lacks`
spells git's one line and an `OSError`'s text in `adopt-remote-unreadable`,
and so does `_in_the_way_on_github` for an `OSError`. `_loudly` is not
touched: #1233 edits it.

tests/test_command_output_spelled.py holds a row per site: 110 rows, 83 of
them failing before this change.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Restacking the #1213 change from #1225's head cc230f2 onto the head #1225 landed
with, the update-branch merge of main f2a6527.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
#1225 landed as one squash commit on main, whose tree is the tree of the head
the branch was just merged with, so its files already hold #1225's final content.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@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

Add unacted and make CommandFailed.loudly spell the step, command, working directory, and output while preserving output line breaks.

  • scripts/shape_materialize.py L1263-1283, L1293-1328

Spell command arguments and error text in the adoption probe, clone, and remote-read refusal paths.

  • adopt-project.py L3240-3246, L5668-5672, L12457-12464 (+1 small edits)

Tests

Add POSIX regression coverage for safe command diagnostics across helper behavior, callers, adoption refusals, and real tool runs.

  • tests/test_command_output_spelled.py L1-929

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

RV1213: independent review of #1322 at 476bfdd3: READY

Independent review for lane openRepoShape-4 of #1322 (for #1213) at 476bfdd3c05cbdc2e165ef215b5de565988bed00, against origin/main 838358bf9 (#1171 landed at 19:15Z). I did not write it. No MUST, no SHOULD; four NITs, all follow-ups or wording. SonarCloud passed at this head (section 8). CI's tests job was still running at 19:41Z.

1. The design and unacted

  • Every code point measured. I ran all 1114112 code points through shape_materialize.unacted, at the head and on a scratch merge with today's main.
  • The named characters. Each is spelled:
    • all 32 C0 controls, DEL and the 32 C1 controls;
    • the 12 bidirectional controls U+061C, U+200E, U+200F, U+202A to U+202E and U+2066 to U+2069;
    • a lone surrogate (\udcff), a tab (\t) and a carriage return (\r).
  • Line feeds. loudly keeps a line feed in the output, and writes one as \n in the step, the command and the directory. Mutants R5, R6 and R7 below each fail one row.
  • Spelling once inside loudly is sound.
    • There is one CommandFailed and one loudly. Sixteen calls print its block (git grep at the head: 2 in scaffold-project.py, 4 in update-shape.py, 8 in scripts/family.py, 2 in scripts/bump-leg.py), plus adopt-project.py's _loudly.
    • No code outside tests/ reads the block back. Outside tests/, the markers appear only in loudly itself and in bump-leg.py's own validators block.
    • _loudly spells and then loudly spells again. That is harmless, because unacted is idempotent. It is also now redundant: mutant R14, which turns _loudly back into a bare exc.loudly(step), is equivalent. This matches the body's last follow-up candidate.
    • No caller can show a spelling twice, and no caller loses a character; a tab in git's words now shows as an escape (N1).
  • No pinned copy. templates/ names shape_materialize.py only in comments ("which no project carries"). No sha256 of either version of adopt-project.py or scripts/shape_materialize.py appears in the tree.

2. Groups 1 and 2 in adopt-project.py

  • _init_refused. The command is _unacted and the output is _spelled. The Refusal branch's detail can only come from check_program, whose text names the program by a constant.
  • Source.clone. The cut [:400] comes first, then _unacted(..., kept="\n"). My probe of 399 a and a U+202E ends in the whole \u202e, and mutant R11 (a wrong cut) is killed.
    • repository reaches this point only through _github_name, on all three callers, whose segments are [A-Za-z0-9_.-]+. So could not clone <repo> has no raw route.
    • A carriage return from gh cannot get there either. run reads in text mode, which turns CR and CRLF into LF (measured with printf). So mutant R10, which keeps a CR raw, is equivalent.
  • _refuse_a_tracking_branch_the_remote_lacks. The url and the branch are _spelled. Git's words are joined onto one line, then _unacted. An OSError is _unacted.
  • _in_the_way_on_github. gh's words go through _first_said, unchanged. An OSError is now _unacted.

No raw route is left in these four refusals.

3. My probes

The setup.

  • A probe git fails the subcommand it is told to. It prints fatal: rv1213 says <U+202E>evil <ESC>[31mred<LF>second line <0xff> end: <its own arguments>. Every other subcommand runs /usr/bin/git.
  • A probe gh fails with the same characters.
  • The directory and an argument hold U+202E, ESC, a line feed and the byte 0xff.
  • stdout and stderr are utf-8:surrogateescape. There is a stub gh, GH_TOKEN=bogus, an empty GH_CONFIG_DIR and GIT_SSH_COMMAND=false.
  • Real child runs: scaffold-project.py and family.py init, each with a hostile --work-dir, with a line feed, and with the byte 0xff; adopt-project.py check (GIT_DEFAULT_HASH=bogus); and adopt-project.py plan --source org/repo.
  • The other sites: each is called in a child process with a CommandFailed from a real run() of the probe git. Only the two OSError branches use a patched run.

Raw ESC / U+202E / 0xff on stdout and stderr together:

Probe base dc9a0bcc7 head 476bfdd3c
loudly_unit 5/5/0 0/0/0
scaffold_main 4/4/0 0/0/0
update_main 4/4/0 0/0/0
update_rolled_back 5/5/0 0/0/0
family_main 4/4/0 0/0/0
family_put_back 5/5/0 0/0/0
bump_main 4/4/0 0/0/0
bump_put_back 4/4/0 0/0/0
adopt_init_refused 1/1/1 0/0/0
adopt_ls_remote_stub 2/2/0 0/0/0
adopt_ls_remote_real_git 0/1/0 0/0/0
adopt_ls_remote_oserror 1/1/0 0/0/0
adopt_gh_oserror 1/1/1 0/0/0
adopt_gh_failed 0/0/0 0/0/0
adopt_cut 0/1/0 0/0/0
scaffold_push 2/2/0 0/0/0
family_init_push 2/2/0 0/0/0
scaffold_push_lf 1/1/0 0/0/0
family_init_push_lf 1/1/0 0/0/0
scaffold_push_byte 1/1/0 0/0/0
family_init_push_byte 1/1/0 0/0/0
adopt_check_init_bogus_hash 1/1/0 0/0/0
adopt_check_init_bogus_hash_lf 0/0/0 0/0/0
adopt_plan_unclonable 1/1/0 0/0/0
  • Every site that is raw at the base is clean at the head.
  • adopt_gh_failed is clean on both sides, because _first_said already spelled it.
  • Line feeds. In adopt_check_init_bogus_hash_lf, the base splits the NOTE at the line feed and the head writes \n. The *_lf and *_byte runs print (in .../wo\nrk/...) and (in .../wo\udcffrk/...) at the head.
  • git's own spelling. Git writes ESC as ? itself but not U+202E (adopt_ls_remote_real_git: wh?ere beside a raw U+202E at the base), as the body says.

4. My mutants, beyond the PR's table

Each mutant ran in rv1213-mut-wt at the head, against the whole 110-row file. Afterwards the file was copied back, its blob checked equal to HEAD's and its sha256 recorded. git status was clean at the end.

Id Mutant File Rows failed
R1 unacted spells only ESC scripts/shape_materialize.py 33 of 110
R2 unacted spells only the Cc controls, leaving Cf (bidi) and Cs raw scripts/shape_materialize.py 23 of 110
R3 unacted drops a refused character instead of spelling it scripts/shape_materialize.py 53 of 110
R4 unacted keeps double_quoted's quotes scripts/shape_materialize.py 53 of 110
R5 loudly keeps a line feed in the command scripts/shape_materialize.py 1 of 110
R6 loudly keeps a line feed in the directory scripts/shape_materialize.py 1 of 110
R7 loudly keeps a line feed in the step scripts/shape_materialize.py 1 of 110
R8 unacted passes a lone surrogate raw scripts/shape_materialize.py 3 of 110
R9 unacted spells only the first refused character scripts/shape_materialize.py 28 of 110
R10 source-unclonable keeps a carriage return raw adopt-project.py 0 of 110, survives (equivalent)
R11 source-unclonable cuts at 40, not 400 adopt-project.py 2 of 110
R12 _init_refused keeps a line feed in the command raw adopt-project.py 3 of 110
R13 ls-remote's words spelled whole (line feeds as escapes), not joined adopt-project.py 3 of 110
R14 adopt's _loudly reverted to a bare exc.loudly(step) adopt-project.py 0 of 110, survives (equivalent)
R15 family.py remove --dry-run's call prints the old raw block scripts/family.py 2 of 110
  • Two survive, R10 and R14, and both are equivalent. R10: run never hands a CR to Source.clone. R14: loudly spells what _loudly spelled.
  • R1, R2 and R9 are the "spells only some" mutants (only ESC, only Cc, only the first one). Each fails 23 to 33 rows, 17 to 24 of them per-site rows beside the unit rows.

5. The restack

  • Changed lines are equal. git diff cc230f2f1 1b8438d43 and git diff dc9a0bcc7 476bfdd3c each have 1004 changed lines, both with sha256 d113fc9d66390624c88c6ef4b4098c1d5fa2ba85f6e13df60a9a701de868d03a.
  • Files. git diff dc9a0bcc7 476bfdd3c --name-only names only adopt-project.py, scripts/shape_materialize.py and tests/test_command_output_spelled.py.
  • The commit. 1b8438d43's parent is cc230f2f1.

6. Today's main and the other PRs

7. Tests at the head

The rules' environment: env -u of the lane variables and GIT_SSH_COMMAND, EMAIL set, an empty GIT_CONFIG_GLOBAL, GIT_CONFIG_NOSYSTEM=1, test identities, a stub gh, GH_TOKEN=bogus, an empty GH_CONFIG_DIR, and git filter-repo on PATH.

Run Files Result
Rows tests/test_command_output_spelled.py 110 passed
scaffold, bump-leg, hygiene test_scaffold_reuse_seeded_legs.py, test_bump_leg_reachability_words.py, test_repo_hygiene.py 288 passed
update-shape, family test_update_shape_messages.py, test_family_dry_run.py 88 passed
The base dc9a0bcc7, rows file copied in tests/test_command_output_spelled.py 83 failed, 27 passed
  • The 27 that pass at the base are the 24 [plain-control] ids and the three the body names.
  • Of the 83 failures, 17 fail because unacted does not exist there (AttributeError), and 66 fail on their assertions.

8. SonarCloud

  • The check. SonarCloud Code Analysis passed on 476bfdd3c at 19:15:39Z.
  • The bot comment. sonarqubecloud[bot] posted at 19:15:41Z: Quality Gate passed, 0 new issues, 0 accepted, 0 security hotspots, 0.0% duplication on new code.
  • The API. qualitygates/project_status for this PR is OK on all five conditions. issues/search with resolved=false returns 0, and hotspots/search returns 0.
  • The other checks. package and tests-git-bash passed. tests was in progress at 19:41Z.

9. The body, fact by fact

Findings

Scratch: _lane4-scratch/tools/run/rv1213/ (probes in probe/, mutants in mutants.py, mutants-final.tsv and logs/mut/).

Lane: openreposhape-4 (openRepoShape-4)

…refuse every push also sets git's `sideband.allowControlCharacters`, so the two `[escape]` rows that push to a hook saying an ESC judge the tool's own spelling on a git that masks control characters on the sideband, where 2.56 handed the tool `^[` and the row looked for `\x1b` (#1213)

CI's `tests` on 476bfdd (run 42883271189, job 130064864499, git 2.56.0)
failed exactly two rows, `test_scaffold_names_a_refused_push_spelled[escape]`
and `test_family_init_names_a_refused_push_spelled[escape]`: 2 failed, 22359
passed. git 2.56 masks control characters that arrive on the sideband (its
`sideband.allowControlCharacters` defaults to `color`, which lets only ANSI
colour sequences through), so the hook's ESC reached the tool as `^[` and the
row's `remote: ... \x1bx` was not there. The bench's git is 2.43.0, which
does not mask, so the rows passed there.

The tool was right either way: no raw ESC reached the terminal. The rows'
premise, that git hands the hook's words over unmasked, is what fails on a new
git. `a_config_whose_hook_refuses_every_push` now writes
`[sideband]` and `allowControlCharacters = true`, so git hands the hook's
words over as the hook wrote them on every git; an older git ignores the key.
A `^[` is not accepted as a pass, because that would stop the rows judging
the tool on a new git. No other row of the file reaches a `remote:` line or
the sideband: the others build their `CommandFailed` by hand or run a local
command whose words never travel the sideband.

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

Copy link
Copy Markdown
Contributor Author

FX1322: #1322's two [escape] rows hold on git 2.56's sideband masking. New head db0eb87c. Please review the delta only.

The delta is one commit, db0eb87c3, on 476bfdd3c, and it changes one file: tests/test_command_output_spelled.py (+11, -2). scripts/shape_materialize.py and adopt-project.py are untouched.

What failed and why

CI's tests on 476bfdd3c failed 2 rows and passed 22359 (run 42883271189, job 130064864499, git 2.56.0 on the runner):

  • test_scaffold_names_a_refused_push_spelled[escape]
  • test_family_init_names_a_refused_push_spelled[escape]

git 2.56 masks control characters that arrive on the sideband. Its Documentation/config/sideband.adoc says: "By default, control characters that are delivered via the sideband are masked, except ANSI color sequences." The default is color, and true allows all control characters. So the hook's ESC reached the tool as ^[ (remote: this remote takes no push ^[x), and the row's expected \x1b was not there. The bench's /usr/bin/git is 2.43.0, which does not mask, so both rows passed on the bench.

The tool is right either way: no raw ESC reached the terminal. What failed is the rows' premise, that git hands the hook's words over unmasked.

The change

a_config_whose_hook_refuses_every_push now also writes

[sideband]
	allowControlCharacters = true

so git hands the hook's words to the tool as the hook wrote them, on every git, and the rows keep judging the tool's own spelling. An older git ignores the key. The docstring says so and names sideband.allowControlCharacters. I did not accept ^[ as a pass: that would stop the rows judging the tool on a new git. The new line is a plain string, not an f-string, since it has no field to fill.

Bytes read back with /usr/bin/python3: the line holds a backslash and n, a backslash and t, and a backslash and n (no raw tab or line feed); the file has no byte above 0x7f and no ESC, and it compiles.

Other routes: none. The two rows above are the only callers of the helper, and no other row of the file reaches a remote: line or the sideband. The rest build their CommandFailed by hand, run a local command (git init, git clone --bare, git ls-remote of a path, a gh stub) whose words never travel the sideband, or run no git. tests/test_adopt_plan_and_remote_paths_spelled.py has a hook of its own, but it says plain text with no control character and passed in CI; it is not a row of this PR.

Bench (git 2.43.0, the landing gate's environment, real gh unreachable)

  • tests/test_command_output_spelled.py: 110 passed (it was 110 rows at 476bfdd3c).
  • tests/test_repo_hygiene.py: 101 passed.
  • Probe: the helper's config written, then git config --file <it> --get sideband.allowControlCharacters printed true (exit 0), and core.hookspath read back as the hooks directory.
  • Mutant: with CommandFailed.loudly's spelling of the output undone (said = self.output), the rows file gave 34 failed, 76 passed, and both [escape] rows above (with the two [bidi-override-U+202E] rows) are among the failures: the raw ESC reached the block. I restored the file with git checkout; its sha256 reads f557aed5ee55fa61bda1505fbc67f681c502acadaf6ce255382edeeb82531b69 before and after.

The bench's git does not mask, so it cannot show the masking itself. CI's run on the new head is the check on a masking git.

Lane: openreposhape-4 (openRepoShape-4)

@sonarqubecloud

Copy link
Copy Markdown

@brettheap

Copy link
Copy Markdown
Contributor Author

RVD1322: delta review of FX1322's fix at db0eb87c: READY

Delta review for lane openRepoShape-4 of #1322 (for #1213). I did not write the fix. The question is only whether FX1322's one commit db0eb87c3ce12ce9b6a007a54c1c36a485f01dd9 is right and changes nothing else, on top of 476bfdd3c (graded READY by RV1213). No MUST, no SHOULD; one NIT. SonarCloud's quality gate passed on db0eb87c3 (section 8). CI's tests on db0eb87c3 is still running: see the note under check 8.

I also built git v2.56.0 from the upstream tag (a git that masks the sideband, the runner's version) in my own scratch folder, so the premise and the rows are measured on a masking git here, not only on the bench's 2.43.0.

1. Ancestry: PASS

git log --format='%H %P %an %ae %s' 476bfdd3c..db0eb87c3 prints exactly one line: db0eb87c3ce12ce9b6a007a54c1c36a485f01dd9 476bfdd3c05cbdc2e165ef215b5de565988bed00 Brett Heap <the estate's service address> .... Its parent is 476bfdd3c, and its author and committer are Brett Heap with the estate's service address (git log -1 --format='%cn' agrees). The PR's headRefOid read back from GitHub is the same hash, and the PR is still an open draft.

2. The diff: PASS

git diff --stat 476bfdd3c db0eb87c3 names one file: tests/test_command_output_spelled.py, 11 insertions and 2 deletions. I read every changed line.

  • The config line. Line 640 reads back, with /usr/bin/python3 -I, as '[sideband]\n\tallowControlCharacters = true\n': a backslash and n, a backslash and t, a backslash and n. The file holds 0 raw tabs, 0 ESC, 0 carriage returns and no byte above 0x7f. It is a plain string with no field, so it draws no f-string rule.
  • The docstring is true, with one wording NIT (N1): git's masking, its ^[ for an ESC on the runner's 2.56.0, true handing the words over as the hook wrote them, and an older git ignoring the key are all measured below.
  • Nothing else changed. No test function was added or removed (git diff ... | grep -c '^[-+]def test_' is 0), and scripts/shape_materialize.py and adopt-project.py are untouched. The commit message is ASCII and its facts match the CI log.

3. The premise: PASS

  • true lets every control character through. Git's Documentation/config/sideband.adoc (read with gh api) says: "color: Allow ANSI color sequences, line feeds and horizontal tabs, but mask all other control characters. This is the default." and "true: Allow all control characters to be sent to the terminal." In sideband.c, true sets ALLOW_ALL_CONTROL_CHARACTERS, and strbuf_add_sanitized then copies the bytes as they are. sideband.c at tag v2.56.0 is byte-identical to master (empty diff).
  • A push client reads it from the GIT_CONFIG_GLOBAL file the rows hand the tool. The masking is in the client's demultiplexer (demultiplex_sideband -> maybe_colorize_sideband -> strbuf_add_sanitized), and use_sideband_colors and sideband_apply_url_config read sideband.allowcontrolcharacters through repo_config, which includes the global file. run_tool builds the child's environment as {**os.environ, ..., **asked} with GIT_CONFIG_GLOBAL in asked. shape_materialize.run passes env=None (inherit) or {**os.environ, **env}. Neither scaffold-project.py nor scripts/family.py (the two tools whose push the rows run) sets or strips GIT_CONFIG_GLOBAL: git grep of the root scripts and scripts/ finds it once, in adopt-project.py's _probe_env for git check-attr, which no push row reaches; GIT_CONFIG_PARAMETERS appears in _offline_git's rollback path, not in a push. The same variable carries the helper's core.hooksPath, which is why the hook runs at all.
  • The receive side does not need the key. builtin/receive-pack.c only calls send_sideband for the hook's stderr (copy_to_sideband); it never calls strbuf_add_sanitized, and send-pack.c has the one recv_sideband the push client uses. A probe agrees.
  • Probe on the real 2.56.0 build. A pre-receive hook prints this remote takes no push ESC x and exits 1; git push -q to a bare path, with GIT_CONFIG_GLOBAL a file that includes the empty gate config and sets core.hooksPath:
Config What the client printed (od -c)
as at 476bfdd3c (no sideband key) remote: this remote takes no push ^[x
as at db0eb87c3 ([sideband] allowControlCharacters = true) remote: this remote takes no push 033 x (a raw ESC)

4. The rows still judge the tool: PASS

tests/test_command_output_spelled.py, the gate's environment (stub gh first on PATH, GH_TOKEN=bogus, empty GH_CONFIG_DIR, GIT_SSH_COMMAND=false, LANES_* unset, frvenv on PATH, EMAIL set):

Run git Result
rows at db0eb87c3 2.43.0 (bench) 110 passed
rows at db0eb87c3 2.56.0 (built) 110 passed
rows with the helper put back as at 476bfdd3c 2.56.0 (built) 2 failed, 108 passed: test_scaffold_names_a_refused_push_spelled[escape] and test_family_init_names_a_refused_push_spelled[escape], CI's two failures reproduced
rows with the helper put back as at 476bfdd3c 2.43.0 (bench) 110 passed (the bench cannot see the masking)
mutant said = self.output in CommandFailed.loudly (scripts/shape_materialize.py:1323) 2.43.0 34 failed, 76 passed
the same mutant 2.56.0 (built) 34 failed, 76 passed

Under the mutant, on both gits, the six push rows fail: the [escape] and [bidi-override-U+202E] rows of test_scaffold_says_a_refused_push_spelled, test_scaffold_names_a_refused_push_spelled and test_family_init_names_a_refused_push_spelled. So both [escape] rows (the two the fix touches) still fail when the tool stops spelling, and they no longer fail for a masking git. I restored the file with git checkout; sha256sum scripts/shape_materialize.py reads f557aed5ee55fa61bda1505fbc67f681c502acadaf6ce255382edeeb82531b69 before and after, and the rows file's blob is 3e7b8c1e96f8c8de36da0cb272bd0ed456241669 after each swap, as at the head.

5. Other routes: PASS

6. Tests at db0eb87c3: PASS

Gate environment, bench git 2.43.0, at most 2 pytest runs at a time:

  • tests/test_command_output_spelled.py: 110 passed.
  • tests/test_repo_hygiene.py: 101 passed.
  • On a scratch merge commit of origin/main a98fe7cb4 and the head (654ab1b0f, tree c6f84bcf4756ae5d0b6bf981082131e665a1a8f2): the rows file 110 passed (and 110 passed again with the built 2.56.0 first on PATH), tests/test_repo_hygiene.py 101 passed.

7. Today's main: PASS

git merge-tree --write-tree origin/main db0eb87c3 exits 0 with tree c6f84bcf4756ae5d0b6bf981082131e665a1a8f2. git diff --stat origin/main <that tree> names only the PR's three files: adopt-project.py, scripts/shape_materialize.py and tests/test_command_output_spelled.py.

8. SonarCloud and CI: PASS (tests pending)

  • SonarCloud: the check passes, and the newest sonarqubecloud[bot] comment (21:58:36Z) says "Quality Gate passed". Its API says the PR's analysed commit is db0eb87c3ce12ce9b6a007a54c1c36a485f01dd9 (21:57:36Z), the gate status is OK, and all five conditions read OK (reliability 1, security 1, maintainability 1, duplication 0.0%, hotspots reviewed 100%). New code has 0 open issues, 0 accepted issues, 0 hotspots, 0 bugs, 0 vulnerabilities and 0 code smells.
  • CI: package passes and tests-git-bash (Windows launcher and installer suites, not this file) passes. tests (job 130157862452) is still in progress, started 21:57:35Z; the run at 476bfdd3c took 1:56:50, so expect it near 23:55Z. A pending tests does not fail this check. CI's tests on db0eb87c3 is the only independent check on a masking git in CI itself; my build of git 2.56.0 is a second, scratch one. The landing must wait for tests to pass on the head it lands.

9. FX1322's comment (6780360968): PASS

Each fact checked:

  • One commit, one file, +11 -2, the other two files untouched: true (check 2).
  • CI at 476bfdd3c: 2 failed, 22359 passed (405 skipped), run 42883271189, job 130064864499, git 2.56.0, the two named rows, and remote: this remote takes no push ^[x in the log: true.
  • The quoted line from sideband.adoc is word for word; the default is color, true allows all: true (check 3).
  • The bench's git is 2.43.0 and does not mask, so the rows passed there: true (the old helper gives 110 passed on it).
  • The line is written in escaped form, with no raw tab, no ESC and no byte above 0x7f, and it compiles: true.
  • 110 rows at 476bfdd3c and at the head: true (no test function added or removed; the old helper on 2.56.0 gives 2 + 108 = 110).
  • "Other routes: none", and the two rows are the only callers: true (check 5).
  • Mutant: 34 failed, 76 passed, both [escape] rows and both [bidi-override-U+202E] rows among them, sha256 f557aed5...531b69 before and after: reproduced.
  • "I did not accept ^[ as a pass": right. Accepting it would stop the rows judging the tool on a new git.

Findings

  • NIT N1 (wording, not for landing): the docstring, and the commit message, say the default color "lets only ANSI colour sequences through". Git's text for color is "ANSI color sequences, line feeds and horizontal tabs". Concrete wording if it is touched again: "lets only ANSI colour sequences, line feeds and tabs through". No behaviour depends on it.
  • No MUST. No SHOULD.

Lane: openreposhape-4 (openRepoShape-4)

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

Labels

None yet

Projects

None yet

1 participant