Skip to content

shape-doctor.py: one platform-aware quoter, on every next command, so a root or a name with a space in it is a line that runs (#101) - #102

Merged
brettheap merged 5 commits into
mainfrom
fix/doctor-next-command-quoting
Sep 11, 2026
Merged

brettheap merged 5 commits into
mainfrom
fix/doctor-next-command-quoting

Conversation

@brettheap

@brettheap brettheap commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openreposhape-2 (openRepoShape-2)
Claim: #101 (comment)

Closes #101.

What was wrong

Copilot asked for shell quoting on PR #100, against the placement row. The
finding was real and was never that row's: every next command since #96
builds its arguments with an f-string, so a root at /srv/my projects/Atlas produced a line argparse reads as three arguments and refuses —
in front of whoever pasted it. That is exactly the failure validator_row
already carries a comment about (python3 validate-pins.py in <root>, Copilot
on PR #96), one class of value along.

Why one form will not do, and why not shlex.quote

The two shells are not one dialect, and each reads the other's form as a
different value with no error to say so
. sh reads PowerShell's doubled
apostrophe as two adjacent quoted strings and concatenates them, so 'O''Brien'
arrives as OBrien — a different path, silently. And \ is a literal character
to PowerShell, whose escape is the backtick. Both directions are asserted
(test_the_two_shells_are_not_one_dialect).

shlex.quote could not be the one function either. Its module is documented as
designed for Unix shells only, so it carries no promise at all about the shell a
Windows reader is in — and since #49 this standard has a native Windows entry
point and shape-doctor.py runs there by contract. Nor would its spelling do:
'C:\Users\Jane O'"'"'Neill\proj' is a line a person is meant to retype,
on a machine whose stock shell is Windows PowerShell 5.1 (setup-project.py's
own docstring), where that value is written 'C:\Users\Jane O''Neill\proj'.

What landed

One quote_arg(value, platform=None) in shape-doctor.py:

  • a value matching the bare alphabet (^[A-Za-z0-9_./:@%+=,-]+$, plus
    backslashes on Windows) is returned unchanged — a table whose whole job
    is to be read would be worse, not better, for --root '/srv/work/Atlas' on
    every line of every clean run;
  • otherwise '…' with '\'' for sh, and '…' with '' for PowerShell;
  • platform= so both forms are testable on either host.

It lives in shape-doctor.py, not in scripts/repo_shape.py — where the
standard's other platform-aware constant (PYTHON) sits — because that file is
a SHAPE COPY: scripts/shape_materialize.py writes it into every assembly root
and every family holder and the shape pin digests it, so one function added
there would put an upstream-changed scripts/repo_shape.py row in front of
every project in the estate on its next update-shape.py check, for a
helper no project's own copy would ever call. shape-doctor.py is in no copy
list, by its own contract: it compares a project against the checkout it is RUN
FROM. (repo_shape.SAFE_PATH_RE answers a different question anyway — what may
become an argument to git, where every command is a list run with
shell=False and the threat is argument injection, not a shell.)

Nineteen next-command strings now pass through it — every row of all three
root kinds, the two NOT A SHAPE ROOT way-in lines included, and the machine
row's. --json carries the same quoted strings, because they are commands.
<your-org> in the scaffold line is not quoted and must not be: it is a
placeholder the reader replaces, not a value this command knows.

The proof

  FINDING  naming      Some Thing: FINDING naming-unclassified: Some Thing
           NEXT        python3 …/validate-repository-naming.py --explain 'Some Thing'
  n/a      the way in  this is a git repository with no shape manifest…
           NEXT        python3 …/adopt-project.py plan --source '…/my proj'\''ects/Some Thing' --project 'Some thing'

33 tests added (8 functions), 0 existing tests changed —
tests/test_shape_doctor.py is pure addition, 0 lines removed, because the
fixtures' paths have no spaces and every command they assert is one the quoter
returns unchanged:

  • both forms parametrized over both platforms, over a space, an apostrophe,
    both at once, and a Windows drive path;
  • the POSIX form proved by shlex.split round-trip — the shell's own
    reader — rather than by a string the suite spelled;
  • the PowerShell form asserted exactly, apostrophes doubled;
  • the two dialects proved incompatible — sh reads 'O''Brien' as OBrien;
  • the same Windows path quoted on POSIX and bare on Windows, said out loud;
  • a whole report of a project at <tmp>/do ct'or/Atlas with five rows red
    at once, each next command read by shlex.split and the root asserted to
    arrive as one token;
  • end to end: the shape-currency row's line run verbatim through bash -c,
    trailing # comment and all — it reports the drift (exit 1, naming
    scripts/bootstrap.py), where the unquoted spelling of the same line exits 2
    before python3 is reached, with bash's own unexpected EOF while looking for matching complaint.

Housekeeping

  • git diff --stat origin/main -- templates/ — empty.
  • python3 scripts/render-cli-reference.py --check — [ok] docs/cli.md is what the generator produces; no --help text moved.
  • Rule 1 (test_no_committed_file_names_a_host_absolute_path): the example
    paths are /srv/... and C:\Users\Jane O'Neill\... — this repository's own
    convention of putting a space in the Windows user name, which is what the
    examples illustrate anyway (scripts/repo_shape.py: "Jane Doe").
  • No README/AGENTS.md change and therefore no cap moved: neither promises a
    copy-pasteable command, and Run the one the row names is unchanged prose
    that is now true in more cases. The Invoke-WebRequest single-match rule is
    untouched.

Neighbouring, not taken

update-shape.py check prints its own NEXT …apply --root {root} --upstream {upstream.label}… line with the same interpolation. It is out of #101's scope
(which names shape-doctor.py) and wants its own issue and its own decision
about where the quoter then lives.

A path with a non-ASCII character in it is still flattened by ascii_text,
which every row's text goes through — /srv/josé/proj prints as
/srv/jos?/proj, quoted or not. That is this file's documented PURE ASCII
rule ("a verdict a cp1252 console cannot render is a verdict nobody reads"),
and unpicking it for the next field alone is a separate decision about the
whole report, not a quoting bug.

🤖 Generated with Claude Code

Summary by Sourcery

Make every command emitted by shape-doctor.py safe to read and run on the target platform, including paths and names that require shell quoting.

New Features:

  • Add platform-aware shell argument quoting for commands emitted by shape-doctor.py, supporting POSIX shells and PowerShell.
  • Use platform-specific project setup commands so Windows reports setup-project.py while POSIX systems use setup.sh.

Bug Fixes:

  • Ensure paths, project names, and other interpolated values containing spaces, apostrophes, shell metacharacters, or newlines remain valid single command arguments.
  • Normalize values before quoting so subsequent report formatting cannot invalidate quoted apostrophes.

Enhancements:

  • Apply consistent quoting across all generated next-command strings, including JSON output and remediation commands.
  • Add platform-selectable interpreter formatting for cross-platform command generation.

Tests:

  • Add comprehensive coverage for POSIX and PowerShell quoting, shell dialect differences, platform-specific command generation, awkward paths, and normalization edge cases.
  • Verify complete reports and pasted commands handle roots containing spaces and apostrophes correctly.

… a root or a name with a space in it is a line that runs (#101)

Copilot asked for shell quoting on PR #100, against the placement row. The
finding was real and was never that row's: every next command since #96 builds
its arguments with an f-string, so a root at `/srv/my projects/Atlas`
produced a line argparse reads as three arguments and refuses -- in front of
whoever pasted it, which is exactly the failure `validator_row` already carries
a comment about (`python3 validate-pins.py in <root>`, Copilot on PR #96).

The two shells are not one dialect, and each reads the other's form as a
DIFFERENT value with no error to say so: `sh` hands PowerShell's `'O''Brien'`
on as `OBrien`, the apostrophe silently gone (asserted), and `\` is a literal
character to PowerShell, whose escape is the backtick. `shlex.quote` could not
be the one function either -- its module is documented as designed for Unix
shells only, so it promises nothing about the shell a Windows reader is in, and
its `'C:\Users\Jane O'"'"'Neill\proj'` is a line a person is meant to RETYPE on
a machine whose stock shell is Windows PowerShell 5.1. So: one
`quote_arg(value, platform=None)`, `'...'` with `'\''` for `sh` and `'...'`
with `''` for PowerShell, and a value matching the bare alphabet returned
UNCHANGED -- a table whose job is to be read would be worse for
`--root '/srv/work/Atlas'` on every line of every clean run.

It lives in `shape-doctor.py` and not in `scripts/repo_shape.py`, where the
standard's other platform-aware constant (`PYTHON`) sits, because that file is a
SHAPE COPY: `scripts/shape_materialize.py` writes it into every assembly root
and every family holder and the shape pin digests it, so one function added
there would put an `upstream-changed scripts/repo_shape.py` row in front of
every project in the estate for a helper no project's own copy would ever call.
`shape-doctor.py` is in no copy list by its own contract.

Nineteen next-command strings now pass through it -- every row of all three
root kinds, the two NOT A SHAPE ROOT way-in lines included -- and `--json`
carries the same quoted strings, because they are commands. `<your-org>` in the
scaffold line is NOT quoted and must not be: it is a placeholder the reader
replaces.

Thirty-three tests in eight functions: the two forms parametrized over both
platforms, over a space, an apostrophe, both at once and a Windows drive
path; the POSIX form proved by `shlex.split` ROUND-TRIP rather than by a
string this suite spelled; the PowerShell form asserted exactly; the two
dialects proved incompatible. Then a whole report of a root at
`<tmp>/do ct'or/Atlas` with five rows red at once, each next command read by
`shlex.split` and the root asserted to arrive as one token. Then, end to end,
the shape-currency row's line run VERBATIM through `bash -c`: it reports the
drift, exit 1, naming the file, where the unquoted spelling of the same line
exits 2 before `python3` is reached.

No existing test changed -- the fixtures' paths have no spaces, so every
command they assert is one the quoter returns unchanged. `templates/`
untouched; `docs/cli.md` unchanged (no `--help` moved); no README or
AGENTS.md line, so no cap moved.

Closes #101.

Lane: openreposhape-2 (openRepoShape-2)
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 11, 2026 10:26
@brettheap

Copy link
Copy Markdown
Contributor Author

@codex review

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 3 days and 7 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@sourcery-ai

sourcery-ai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR centralizes shell-specific quoting in shape-doctor.py and applies it to all generated next-command strings, preserving readable bare values while safely handling paths and names containing shell-significant characters. New tests verify both shell dialects, cross-platform behavior, whole-report coverage, and verbatim command execution.

Sequence diagram for platform-aware next-command quoting

sequenceDiagram
    participant Doctor as shape-doctor.py
    participant Quoter as quote_arg
    participant Report as Report row
    participant Shell as sh or PowerShell
    participant Command as Command target

    Doctor->>Quoter: quote_arg(value, platform)
    alt value matches platform-safe alphabet
        Quoter-->>Doctor: unchanged value
    else value needs quoting
        alt platform is Windows
            Quoter-->>Doctor: PowerShell single-quoted value
        else platform is POSIX
            Quoter-->>Doctor: sh single-quoted value
        end
    end
    Doctor->>Report: emit quoted next command
    Report->>Shell: user pastes command
    Shell->>Command: parse each value as one argument
Loading

File-Level Changes

Change Details Files
Add a platform-aware shell argument quoter and use it for every generated remediation command.
  • Return safe path/argument values unchanged to preserve report readability.
  • Emit POSIX single-quote escaping or PowerShell apostrophe doubling based on the target platform.
  • Support explicit platform selection for cross-platform testing while defaulting to the host platform.
  • Quote interpolated scripts, roots, paths, branch names, targets, project names, and validator arguments across all command-producing rows.
  • Keep scaffold placeholders such as <your-org> unquoted.
shape-doctor.py
Add comprehensive tests proving quoting correctness, shell compatibility, and report-wide coverage.
  • Test ordinary and awkward values on both platform modes, including spaces, apostrophes, empty strings, and Windows paths.
  • Validate POSIX output through shlex.split round-trips and assert PowerShell spellings exactly.
  • Demonstrate that POSIX and PowerShell quoting forms are not interchangeable.
  • Exercise a complete report rooted at a path containing spaces and apostrophes, ensuring each relevant command preserves the root as one token.
  • Run a generated shape-currency command through bash -c and contrast it with the pre-fix unquoted failure.
tests/test_shape_doctor.py

Assessment against linked issues

Issue Objective Addressed Explanation
#101 Implement a platform-aware shell argument quoter in shape-doctor.py that uses POSIX-compatible quoting on Unix-like systems and PowerShell-compatible quoting on Windows, rather than relying on shlex.quote. ✅
#101 Apply the quoter to every interpolated argument in every shape-doctor.py next-command row, including roots, leg paths, script paths, project names, and other command values that may contain spaces or shell-special characters. ✅
#101 Add tests covering paths with spaces and apostrophes, including platform-specific quoting behavior and verification that generated commands preserve paths as single arguments. ✅

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Four moderate findings remain unresolved in quoting and Windows command generation.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds platform-aware POSIX and PowerShell quoting to shape-doctor.py remediation commands, with comprehensive tests.

Changes:

  • Quotes commands across report rows and JSON output.
  • Preserves safe unquoted arguments and supports both platforms.
  • Adds shell round-trip and execution tests.
File summaries
File Summary
shape-doctor.py Implements quoting and updates remediation commands. Unresolved moderate findings: PowerShell ,/@ handling (3 votes), Unicode normalization order (1 vote), Windows entry point selection (3 votes), and full-string matching for trailing newlines (1 vote).
tests/test_shape_doctor.py Adds coverage for shell-specific quoting, round trips, and command generation.
Review details

Suppressed comments (2)

shape-doctor.py:425

  • Row.__init__ applies ascii_text after each quote_arg result. That helper maps Unicode curly apostrophes to ASCII ', so a path such as O’Neill becomes 'O'Neill' on POSIX (and an undoubled apostrophe inside the PowerShell literal), leaving the printed command syntactically broken. Normalize before shell quoting, or otherwise escape after ASCII normalization.
    text = str(value)
    windows = (os.name if platform is None else platform) == "nt"
    if (UNQUOTED_NT if windows else UNQUOTED).match(text):

shape-doctor.py:425

  • $ can match just before a final newline in Python, and .match() does not require the whole value to be consumed. Therefore a value such as a POSIX root or tracked path ending in \n is returned bare, leaving a literal newline in the emitted command instead of using the quoted form. Use a full-string match here so every character is covered by the shell-safe alphabet.
    if (UNQUOTED_NT if windows else UNQUOTED).match(text):
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread shape-doctor.py Resolved
Comment thread shape-doctor.py Resolved
… alphabet, and the Windows way in is `setup-project.py` and not a bash script

TWO FINDINGS, BOTH REAL, BOTH ABOUT THE PLATFORM THIS ISSUE IS ABOUT.

1. `UNQUOTED_NT` admitted `,` and `@`, which `sh` is indifferent to and
   PowerShell is not: `,` is its list separator, so `C:\work,old\Atlas` bare
   may reach the command as something other than one argument, and a LEADING
   `@` is splatting syntax, so `@Atlas` is read as an expansion rather than as
   itself -- neither with an error to say so, which is the failure mode a
   report cannot have. Both leave the Windows alphabet and stay in the POSIX
   one, which is the whole reason there are two constants rather than one; the
   POSIX one is renamed `UNQUOTED_POSIX` so the pair reads as a pair. `%` is
   NAMED as considered and kept: it is an alias for `ForEach-Object` in
   COMMAND position only, and every value this file interpolates is an
   argument.

2. The `way in` row's scaffold line named `setup.sh` on every platform.
   PowerShell cannot execute a bash script, so on Windows -- where this file
   runs by contract, and the only platform with no shell of ours to run it in
   -- the row was handing somebody a line that cannot run at all. The
   standard's answer there has been `setup-project.py` since #49: it IS the
   flow and `setup.sh` is a shim over it (#50), which is why the README's
   Windows two-liner downloads that file and runs it. A new
   `scaffold_command(shape, project, platform=None)` picks the reader's own
   entry point, with the same `platform` argument `quote_arg` has and for the
   same reason: both spellings are asserted on whichever host the suite runs
   on.

Six more tests (four metacharacter cases, both spellings of the scaffold
line), and ONE existing test changed --
`test_a_directory_that_is_not_a_repository_says_scaffold` now asserts the
host's own entry point, because it runs on the Windows runner too.

Lane: openreposhape-2 (openRepoShape-2)
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 11, 2026 10:44
@brettheap

Copy link
Copy Markdown
Contributor Author

Both findings taken, at 1bf5f83, and both are about the very platform this issue is about.

1. , and @ leave the Windows alphabet. Right, and the fix is free — quoting more is never wrong, and neither character is common in a path. , is PowerShell's list separator and a leading @ is splatting; both stay in the POSIX set, where they are ordinary bytes in a word and quoting them would be noise on a line whose whole job is to be read. That the two sets now genuinely differ is the point of there being two constants, so the POSIX one is renamed UNQUOTED_POSIX and the pair reads as a pair. Four regression cases, each asserting both platforms:

value on Windows on POSIX
@Atlas '@Atlas' @Atlas
a,b 'a,b' a,b
release,2026@main 'release,2026@main' release,2026@main
C:\work,old\Atlas 'C:\work,old\Atlas' 'C:\work,old\Atlas'

The last one is quoted on both, and for two different reasons — the comma on Windows, the backslashes on POSIX, where \ is an escape character and not a separator.

% is kept, and is now NAMED in the comment as considered rather than left for the next reader to wonder about: it is an alias for ForEach-Object in command position only — the first token of a pipeline element — and every value this file interpolates is an argument. (%VAR% expansion is cmd.exe's, and the Windows shell this standard documents is PowerShell; setup-project.py's own docstring: "Windows PowerShell 5.1 — still the default shell on a stock Windows install".)

2. setup.sh on Windows is a line that cannot run. A better catch than the first, and squarely the defect this PR exists to fix, one class along: a row whose whole job is to hand somebody a runnable line was naming a bash script on the one platform with no bash — and this file runs there by contract. There is now a scaffold_command(shape, project, platform=None) that picks the reader's own entry point:

posix   /srv/openRepoShape/setup.sh --org <your-org> --project Atlas   # without --yes; it asks
nt      python /srv/openRepoShape/setup-project.py --org <your-org> --project Atlas   # without --yes; it asks

setup-project.py because it IS the flow and setup.sh is a shim over it (#49, #50), which is why the README's Windows two-liner downloads that file and runs it; PYTHON because PowerShell cannot execute a .py by itself and python is what both python.org and the Microsoft Store put on PATH (scripts/repo_shape.py's own reasoning). platform= for the same reason quote_arg has one — both spellings are asserted on whichever host the suite is running on, rather than half of them only ever being exercised where nobody is looking.

adopt-project.py plan, the other way-in line, was already correct: it is Python, run through PYTHON.

One existing test changed by this round: test_a_directory_that_is_not_a_repository_says_scaffold now asserts the host's own entry point, because it runs on the Windows runner too. That is the first existing test this PR has had to touch.

Six new tests, 39 in total for #101; tests/test_shape_doctor.py is 96 passing (57 on main). templates/ still empty in the diff and docs/cli.md still what the generator produces.

🤖 Generated with Claude Code

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved critical and moderate findings affect normalization, newline handling, and platform-specific interpreter selection.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (2)

shape-doctor.py:438

  • Using .match() with $ allows a value ending in \n to match only the permitted prefix because $ also matches before a final newline. Such a root is returned unquoted, so the generated NEXT command is split at that newline; use a full-string match and cover this edge case.
    if (UNQUOTED_NT if windows else UNQUOTED_POSIX).match(text):

shape-doctor.py:1942

  • When platform='nt' is supplied on a POSIX host (as the new parametrized test does), this branch still uses the module-level PYTHON, which is python3 on that host. The helper therefore does not actually produce a Windows-runnable command for its platform override, despite the docstring promising reader-platform output; choose the interpreter from the same windows decision (and assert the exact spelling) so a Windows reader is not given python3.
    if (os.name if platform is None else platform) == "nt":
        return (f"{PYTHON} {quote_arg(shape / 'setup-project.py')} "
                f"--org <your-org> --project {quote_arg(project)}")
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread shape-doctor.py Resolved
Comment thread tests/test_shape_doctor.py Resolved
…ing and un-escaped the apostrophe it had just escaped, and `$` is not `fullmatch`

THE FIRST ONE IS A DEFECT IN THE QUOTER THIS PR ADDED, and it is the one
worth the round. `Row.__init__` runs `ascii_text` over the WHOLE assembled
`next_command`, after every value in it is already quoted -- and `ascii_text`
maps a curly apostrophe to a straight one. So a root at `/srv/O`’`Neill/Atlas`
was quoted correctly to `'/srv/O`’`Neill/Atlas'` and then had that apostrophe
flattened on the far side of the quoting, arriving as
`'/srv/O'Neill/Atlas'` -- an unterminated quotation to `sh` (`shlex.split`
raises "No closing quotation") and an un-doubled apostrophe inside
PowerShell's verbatim string. Proving `quote_arg` correct in isolation proved
nothing about what its caller then PRINTED, which is why the new test goes
through a real report and not through the function.

The fix is to normalize FIRST: `quote_arg` runs `ascii_text` on the value
before it tests the alphabet and before it quotes, so what it escapes is what
survives and the later pass has nothing left to touch. What the reader then
sees is the ASCII flattening of their path rather than its own bytes -- this
file's PURE ASCII rule, stated at the top and true of every other string in
the report -- and a command that names a path plainly and is refused by name
beats one no shell will parse.

THE SECOND IS THE ALPHABET CHECK ITSELF. `$` matches just before a trailing
newline, so `.match` called `"Atlas\n"` safe and printed it bare, newline and
all, in the middle of a line meant to run as one. `.fullmatch` is what
actually requires the alphabet to cover the whole value.

Also from that round: one duplicated word in a test comment.

Three more tests -- the curly apostrophe through `quote_arg`, the trailing
newline, and the curly apostrophe through a REAL report, where the bug
actually lived. `tests/test_shape_doctor.py` is 99 passing (57 on `main`).

Lane: openreposhape-2 (openRepoShape-2)
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 11, 2026 11:02
@brettheap

Copy link
Copy Markdown
Contributor Author

Second round taken too, at cae1741. The ascii_text one is the best finding on this PR: it is a defect in the quoter this PR added, and no test here could have caught it, because every one of them asked quote_arg and none of them asked a row.

1. ascii_text runs again, after quoting. Confirmed before fixing:

quote_arg('/srv/O’Neill/Atlas')  ->  '/srv/O’Neill/Atlas'
after Row.__init__               ->  '/srv/O'Neill/Atlas'
shlex.split                      ->  BROKEN: No closing quotation

Row.__init__ normalizes the whole assembled next_command, so the apostrophe quote_arg had just escaped was flattened on the far side of the quoting it sat inside — unterminated to sh, and un-doubled inside PowerShell's verbatim string. The fix is to normalize first: quote_arg runs ascii_text on the value before it tests the alphabet and before it quotes, so what it escapes is what survives and the later pass has nothing left to touch. After:

quote_arg('/srv/O’Neill/Atlas')  ->  '/srv/O'\''Neill/Atlas'   (nt: '/srv/O''Neill/Atlas')
through a real row               ->  cmd --root '/srv/O'\''Neill/Atlas'
shlex.split                      ->  ['cmd', '--root', "/srv/O'Neill/Atlas"]

What the reader then sees is the ASCII flattening of their path rather than its own bytes. That is this file's PURE ASCII rule — stated in its first docstring and true of every other string in the report — and the trade is the right way round: a command that names a path plainly and is refused by name beats one no shell will parse.

The test for it goes through a real report, not through the function, because that is where the bug was: proving quote_arg correct in isolation proved nothing about what its caller printed.

2. .match is not .fullmatch. Not one you raised, found while writing the first fix and it is the same class of thing. $ matches just before a trailing newline, so:

re.match(UNQUOTED_POSIX, "Atlas\n")      -> True     # waved through BARE
re.fullmatch(UNQUOTED_POSIX, "Atlas\n")  -> False    # quoted, correctly

A newline printed bare lands in the middle of a line meant to run as one. .fullmatch is what actually requires the alphabet to cover the whole value; a regression test pins it.

3. "the flow that shim shims". Fixed — it now reads "which IS the flow — and setup.sh a shim over it".

Three more tests (42 for #101 in total); tests/test_shape_doctor.py is 99 passing, against 57 on main. templates/ still empty in the diff.

🤖 Generated with Claude Code

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Unresolved moderate findings remain in platform-specific command generation and Windows report-level test coverage.

Review details

Suppressed comments (4)

Previously missed (1) — in code that hasn't changed since the last review.

shape-doctor.py:1976

  • When platform="nt" is supplied on a non-Windows host, this branch still uses the host PYTHON value and calls quote_arg without the requested platform. A project or checkout containing an apostrophe therefore gets POSIX \' escaping in a command advertised as PowerShell, and the cross-platform test does not catch it because it only uses a space. Derive the interpreter from the selected platform and pass platform through to every quote_arg call.

shape-doctor.py:1974

  • This changes the emitted Windows way-in command to setup-project.py, but the module-level usage/documentation above still describes the only scaffold path as setup.sh. A Windows reader following the tool's own documentation can therefore choose the non-executable Bash entry point; update the documentation to state the platform-specific entry point (and keep it aligned with scaffold_command).
    if (os.name if platform is None else platform) == "nt":
        return (f"{PYTHON} {quote_arg(shape / 'setup-project.py')} "
                f"--org <your-org> --project {quote_arg(project)}")

tests/test_shape_doctor.py:484

  • The PR description says tests/test_shape_doctor.py is pure addition with 0 existing tests changed, but this hunk replaces an assertion in the pre-existing test_a_directory_that_is_not_a_repository_says_scaffold test. Please correct the change summary (and the stated test counts) so the review record matches the diff.
    # THE READER'S OWN ENTRY POINT, which is not the same file on every
    # platform: `setup.sh` is bash and PowerShell cannot execute it, so on
    # Windows the way in is `setup-project.py`, which IS the flow -- and
    # `setup.sh` a shim over it (#49, #50; Copilot, PR #102).
    assert ("setup-project.py" if os.name == "nt" else "setup.sh") in \
        rows["way-in"]["next"], rows["way-in"]["next"]

tests/test_shape_doctor.py:1909

  • The whole-report integration test is skipped on Windows, so the actual Row builders are never exercised with an awkward path through the PowerShell quoting branch. The direct quote_arg(..., "nt") tests prove the helper in isolation, but a future call site can omit it or use the wrong platform and the Windows suite will remain green; add an equivalent Windows report-level assertion (or run the emitted command through PowerShell).
@pytest.mark.skipif(
    os.name == "nt",
    reason="shlex.split reads POSIX quoting; on Windows these commands are "
           "spelled for PowerShell, which the unit tests above assert")
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@brettheap

Copy link
Copy Markdown
Contributor Author

All six findings from this review round are now in, across two commits. The two comments above already cover findings 1-4 in full (Copilot's two rounds); this one adds the two SonarCloud findings that hadn't been written up anywhere yet, and gives the complete six-item accounting the round asked for.

  1. Copilot: , and @ left UNQUOTED_NT's alphabet. Fixed in 1bf5f83 — both are now excluded, and the POSIX constant is renamed UNQUOTED_POSIX so the pair reads as a pair.
  2. Copilot: the way-in row's scaffold command named setup.sh on Windows. Fixed in 1bf5f83 — a new scaffold_command(shape, project, platform) picks setup-project.py via PYTHON on nt and keeps setup.sh on POSIX.
  3. Copilot: ascii_text ran again, after quoting, and un-escaped the apostrophe quote_arg had just escaped. Fixed in cae1741 — quote_arg now runs ascii_text on the value before the alphabet check and before quoting, so Row.__init__'s later pass over the assembled command has nothing left to touch. The regression test goes through a real report row, not just the function, because that's where the bug actually lived.
  4. Copilot (found while fixing setup.sh: detect the org from origin, not from gh's remote preference #3, same site): .match is not .fullmatch. Fixed in cae1741 — $ matches just before a trailing newline, so .match alone waved a value like "Atlas\n" through bare; .fullmatch requires the whole value to be in the alphabet.
  5. SonarCloud, python:S9073: composite assertion in test_a_drifted_roots_next_command_runs_when_it_is_pasted (assert "usage:" not in whole and "unrecognized arguments" not in whole). Fixed in cae1741 — split into two separate assert statements, same messages kept.
  6. SonarCloud, python:S9073: composite assertion in the same test (assert broken.returncode == 2 and (...)). Fixed in cae1741 — split into two separate assert statements (returncode == 2, then the "unexpected EOF" in said or "unrecognized arguments" in said check), same messages kept.

SonarCloud's own comment on this PR confirms the quality gate passed with 0 new issues after cae1741, which covers 5 and 6.

python3 -m pytest tests/test_shape_doctor.py -q is 99 passing; the full suite (python3 -m pytest tests -q) is 947 passed, 1 skipped. python3 scripts/render-cli-reference.py --check prints [ok] docs/cli.md is what the generator produces.

Lane: openreposhape-2 (openRepoShape-2)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The platform-specific scaffold command still uses the host interpreter instead of the requested platform’s interpreter.

Review details

Suppressed comments (1)

shape-doctor.py:1973

  • platform is also the cross-host test hook, but this branch still uses the module-global PYTHON. On a POSIX runner, scaffold_command(..., "nt") therefore emits python3 setup-project.py, not the Windows spelling (python setup-project.py) that this function says it generates; the current startswith("python") assertion does not catch that. Select the interpreter from the requested platform (while retaining PYTHON for the host-default path) and assert the exact spelling.
        return (f"{PYTHON} {quote_arg(shape / 'setup-project.py')} "
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

… host's: `python_command(platform)`, and the test asserts the whole line rather than its first six characters

Copilot, PR #102. `repo_shape.PYTHON` is decided ONCE, at import, from
`os.name` -- rightly, because every other caller in this file is spelling a
command for the machine it is on. `scaffold_command` is the one that is not:
it takes a `platform` precisely so both spellings can be asserted from either
host, and then read the module constant anyway, so on a POSIX runner the
Windows branch emitted `python3 setup-project.py`. The function was claiming
a spelling it did not produce, in the one place written to be read from the
other platform.

`python_command(platform)` keeps the two readings apart. It MIRRORS
`repo_shape`'s rule rather than re-arguing it -- `python` on Windows, where
python.org and the Microsoft Store both put that name on PATH and there is
usually no `python3` at all, `python3` everywhere else -- and returns the
constant ITSELF when `platform is None`, so the host-default path stays the
same object every other line uses rather than a second derivation that could
drift from it.

AND THE ASSERTION WAS THE OTHER HALF OF THE DEFECT. `startswith("python")`
is true of `python3` too, so the test could not tell the two spellings apart
-- which is the one thing this function's `platform` argument exists to make
checkable. It now expects the WHOLE line, byte for byte, on both platforms,
and a second test pins `python_command` per platform and against `PYTHON`
itself for the host.

`tests/test_shape_doctor.py` is 101 passing;
`scripts/render-cli-reference.py --check` green.

Lane: openreposhape-2 (openRepoShape-2)
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 11, 2026 11:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Two moderate issues remain unresolved in command generation and argument handling.

Review details

Suppressed comments (3)

shape-doctor.py:2006

  • platform selects the reader's dialect for the executable, but these quote_arg calls still infer the host dialect. On a POSIX host, scaffold_command(..., platform="nt") therefore emits POSIX apostrophe escaping (for example \'\\\') in a PowerShell command; the reverse is also wrong on Windows. Pass platform through to every quote_arg in both branches so the helper's cross-platform contract is actually true, and add a test with an apostrophe in the shape/project value.
        return (f"{python_command(platform)} "
                f"{quote_arg(shape / 'setup-project.py')} "
                f"--org <your-org> --project {quote_arg(project)}")
    return (f"{quote_arg(shape / 'setup.sh')} --org <your-org> "
            f"--project {quote_arg(project)}")

shape-doctor.py:1863

  • Shell quoting does not protect a name that begins with -: quote_arg("--help") deliberately returns it bare, and run_validator(..., ["--explain", *names]) lets argparse consume it as the validator's --help option. A non-shape directory named --help therefore makes the doctor report naming OK without classifying the name, and the generated remediation has the same failure. Pass -- before the names both when invoking the validator and in the printed command.
    spelled = " ".join(quote_arg(name) for name in names)
    return Row("naming", "naming", OK if code == 0 else FINDING, reason,
               None if code == 0 else
               f"{PYTHON} {quote_arg(script)} --explain {spelled}", detail)

tests/test_shape_doctor.py:2064

  • This fixture contains U+2019 (CURLY_APOSTROPHE), but the comment shows a straight apostrophe on both sides of the ascii_text mapping. Spell the source as ’ and the normalized target as ' so the regression's purpose is clear.
    a different character: `ascii_text` maps `'` to `'`, which is exactly
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

…t is `PurePosixPath` per row now, after Windows CI rendered `\srv\...` against a hard-coded `/srv/...` line

`Path("/srv/openRepoShape")` is `WindowsPath` on a Windows runner, so
`shape / 'setup.sh'` came back `\srv\openRepoShape\setup.sh` against the
byte-exact `/srv/openRepoShape/setup.sh ...` this suite has asserted since
5661804 -- on BOTH parametrized rows, `posix` and `nt` alike, which is
exactly what job `tests-windows` showed (run 34594408797, 2 failed): actual
and expected differing only by `\` where the test wanted `/`. Linux and
macOS never saw it because `Path` is `PosixPath` there, matching the literal
by construction rather than by any guarantee the test made. `PurePosixPath`
is the same flavour on every host, Windows included, so the rendering is no
longer a question of which machine runs the suite.

BOTH ROWS TAKE THAT ONE FLAVOUR -- the `nt` row is deliberately not given a
`PureWindowsPath`, even though a real `C:\...` path would be the more literal
reading of "Windows". `scaffold_command`'s own `quote_arg(shape / ...)` calls
pass no `platform`, so each falls back to `quote_arg`'s default, which reads
the REAL host's `os.name` and not the `platform` a row names. `\` sits in
`UNQUOTED_NT` but not in `UNQUOTED_POSIX`, so a `PureWindowsPath` fixture
comes back bare on an actual Windows runner and single-quoted on a POSIX one
running the very same `nt` row -- confirmed by running
`scaffold_command(PureWindowsPath(r"C:\srv\openRepoShape"), "Atlas", "nt")`
on this checkout, which returns the path wrapped in `'...'`. That would trade
the Windows failure this commit fixes for a new Linux/macOS one. `/` sits in
both alphabets, so a `PurePosixPath` fixture is bare everywhere, and is what
both rows use.

Grepped the file for every other `Path("/` a byte-exact assertion might have
carried over from #101/#102: this fixture was the only hit.

`tests/test_shape_doctor.py` is 101 passing;
`scripts/render-cli-reference.py --check` green.

Lane: openreposhape-2 (openRepoShape-2)
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 11, 2026 12:01
@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Three moderate issues remain unresolved in shape-doctor.py.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (2)

Previously missed (1) — in code that hasn't changed since the last review.

shape-doctor.py:1863

  • Quoting does not stop argparse from treating a leading-dash repository name as an option. For a directory named --help, the validator invocation above enters help mode, while the emitted NEXT ... --explain '--help' has the same problem after the shell removes the quotes, so the doctor can report a false success or give an unrunnable remediation. Put -- before the names in both the validator invocation and the generated command.

shape-doctor.py:1096

  • On Windows PowerShell, cp resolves to Copy-Item, whose -Path parameter still treats wildcard characters as patterns even when the argument is single-quoted. A valid root such as C:\work[old]\Atlas can therefore make this remediation fail or select a different item; quote_arg only fixes shell tokenization. Emit Copy-Item -LiteralPath ... -Destination ... on nt and retain cp for POSIX.
            fix = (f"cp {quote_arg(source)} "
                   f"{quote_arg(ctx.root / rel / name)}")
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread shape-doctor.py Resolved
@brettheap
brettheap merged commit 32450eb into main Sep 11, 2026
6 checks passed
@brettheap
brettheap deleted the fix/doctor-next-command-quoting branch September 11, 2026 12:14
brettheap added a commit that referenced this pull request Sep 11, 2026
…KED for, not the host it is running on, so one call is one line on every machine (#103) (#106)

Lane: openreposhape-2 (openRepoShape-2)
Claim: #103 (comment)

Closes #103.

## What was wrong

`scaffold_command(shape, project, platform)` makes **three** decisions about
one line -- which entry point (`setup-project.py` or `setup.sh`), which
interpreter (`python` or `python3`), and how each value is quoted -- and since
#102 only the first two read the `platform` it was handed. Its own
`quote_arg(...)` calls passed nothing, so they fell back to `quote_arg`'s
default, which reads the **real host's** `os.name`.

So with an explicit `platform`, half the line followed the argument and half
followed the machine:

```
scaffold_command(PureWindowsPath(r"C:\srv\openRepoShape"), "Atlas", "nt")

  on Windows   python C:\srv\openRepoShape\setup-project.py   --org <your-org> ...
  on Linux     python 'C:\srv\openRepoShape\setup-project.py' --org <your-org> ...
```

One call, one set of arguments, two different strings. `\` is in `UNQUOTED_NT`
and not in `UNQUOTED_POSIX`, which is exactly where it shows.

Nothing a user sees is wrong today -- every real run passes `platform=None`,
so the report and the `--json` `next` lines are consistent for the machine
that produced them. The argument exists for the tests, and PR #102's tests had
to route **around** the seam: their `nt` row used a `PurePosixPath`, because
`/` is in both alphabets, after commit 1f513c5 found the Windows runner
rendering `\srv\...` against a `/srv/...` expectation. But the whole reason
this function takes a `platform` is "spell this line for the OTHER platform",
and a helper that honours that for the interpreter and the entry point and not
for the quoting is a trap for the next caller -- a report rendered on Linux
for a Windows reader, or a `--json` consumer asking for one platform's
spelling.

## What landed

**One resolution, used three times.** `target = os.name if platform is None
else platform` is decided once at the top of `scaffold_command`, and the
branch, the quoting and the interpreter all read it rather than each
re-deriving "which platform is this" from its own source -- which is the
defect above, stated as code.

`python_command` is the one that keeps the **raw** `platform`: `None` there
returns the module constant itself rather than a second derivation of the same
rule that could drift from it (its own docstring's reason, unchanged). And
`quote_arg(value, None)` resolves the host identically to `quote_arg(value,
os.name)`, so **the host-default line is unchanged, byte for byte** -- which
is every line any real run prints.

**The `way-in` row needs no change and is now proved not to.** It is where
`scaffold_command` is actually called and it names no platform at all, so
every part of both its lines -- entry point, interpreter and quoting -- is the
host's. That is asserted now rather than assumed, so a `platform` threaded
into the row later without being threaded through the quoting fails a test
instead of shipping half a line.

No `--help` text moved, so `docs/cli.md` does not; nothing under `templates/`
is touched; no other row, no other quoter, no README or AGENTS.md cap.

## The proof

**4 tests added (2 new parametrized cases, 2 new functions; 950 collected
before, 954 after), 0 existing tests changed** -- `tests/test_shape_doctor.py`
gains a `PureWindowsPath` import, two fixture rows, two functions, and a
rewrite of the comment above
`SCAFFOLD_COMMAND` that this commit makes stale (it explains why the `nt` row
could NOT be given a Windows path; it can now).

* `SCAFFOLD_COMMAND` gains the two rows #102 could not carry:
  `PureWindowsPath(r"C:\srv\openRepoShape")` **bare** on `nt` and
  **single-quoted** on `posix`, each asserted as the whole line, byte for
  byte, from whichever host runs the suite -- the two `PurePosixPath` rows
  stay beside them because `/` is in both alphabets, which is what makes them
  the pair that isolates the entry point and the interpreter from the quoting.
* `test_the_scaffold_lines_quoting_is_the_asked_for_platforms_too` says the
  same thing in one place and adds what the parametrized rows cannot: the
  POSIX form read back by `shlex.split` -- the shell's own reader -- handing
  the path back whole, backslashes and all; a value **neither** alphabet
  admits (`C:\Program Files\...`) quoted on **both**, so the fix is not "never
  quote for Windows" but "quote for the platform asked for"; and
  `scaffold_command(shape, "Atlas")` with no platform equal to the explicit
  host spelling.
* `test_the_way_in_row_is_one_platforms_line_end_to_end` builds the row
  in-process from a `Context` and asserts its command is byte for byte what
  `scaffold_command` produces for this machine -- and, once the same directory
  is `git init`-ed, that the adopt line is byte for byte what `quote_arg`
  produces for it.

Both new assertions **fail on `origin/main`** and pass here:

```
-  python C:\srv\openRepoShape\setup-project.py --org <your-org> --project Atlas
+  python 'C:\srv\openRepoShape\setup-project.py' --org <your-org> --project Atlas
```

`python3 -m pytest -q`: **952 passed, 1 skipped**, plus one
**pre-existing, location-dependent** failure that is not this change's and
reproduces identically on a clean `origin/main` worktree cut in the same
directory: `test_naming_policy.py::test_cli_reports_an_unread_link_as_a_warning_and_still_classifies`
asserts a `declared-unverified` warning for a chain link no `--link-source`
answers for, and this workstation has real `openXdox/` and `openDox/`
checkouts BESIDE the worktree, which the validator's documented "a checkout
beside the project is tried too" rule finds and verifies. The same test passes
from a worktree with no such siblings, and CI has none.

`python3 scripts/render-cli-reference.py --check`: `[ok] docs/cli.md is what
the generator produces`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

## Summary by Sourcery

Make scaffold command output consistently target the platform requested by the caller while preserving host-default behavior.

Bug Fixes:
- Ensure scaffold commands quote paths and project names for the explicitly requested platform rather than the host platform.

Enhancements:
- Centralize platform resolution in scaffold command generation so entry-point selection, interpreter selection, and quoting remain consistent.
- Add cross-platform coverage for Windows and POSIX path rendering, shell parsing, host-default behavior, and the end-to-end way-in row.

Tests:
- Add regression tests covering platform-specific scaffold quoting and host-platform way-in output.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
brettheap added a commit that referenced this pull request Sep 11, 2026
… `--help` and `-x` are names to argparse again, not options (#104) (#108)

Lane: openreposhape-2 (openRepoShape-2)
Claim: #104 (comment)

Closes #104.

## What was wrong

`check_not_a_root_naming` ran the validator as `run_validator(ctx, script,
["--explain", *names])` (`shape-doctor.py` ~:1854) and printed the same
argument list as its own remediation: `{PYTHON} {quote_arg(script)} --explain
{spelled}` (~:1863). Both hand the repository's own name to `argparse` as a
BARE POSITIONAL, with nothing to say "the options end here" — so a directory
named `--help` is not a name to argparse, it is the `-h`/`--help` flag every
`ArgumentParser` adds for free. `validate-repository-naming.py --explain
--help` exits 0 through that flag's own handler before either positional is
ever read, and this row took the 0 at face value: "classifies under the
naming policy" — a false COMPLIANT for a name that classifies under nothing,
and silent about it, because the row never turned red. `-x` fails a
different way — not a registered option, so argparse refuses with
`unrecognized arguments: -x` (exit 2) — which this row reported as a FINDING
with the argparse error text standing in for a naming reason.

Quoting (#101/#102) cannot reach either failure: `quote_arg` promises a value
survives the READER'S SHELL as one argument, and `--help` needs no shell
quoting at all to do that — the token argparse then reads is exactly what
was typed. The two bugs are independent, and this is the second one.

## What landed

`--` before the names, in both places: the argv list `run_validator` is
called with (`["--explain", "--", *names]`) and the remediation string
(`--explain -- {spelled}`). `--` is argparse's own end-of-options marker, and
`scripts/validate-repository-naming.py`'s parser accepts it because every
`argparse.ArgumentParser` does by default — its own `--help` text is
unchanged (`scripts/render-cli-reference.py --check` still says `docs/cli.md`
is current).

Checked every other row that runs a validator: `check_naming` passes
`--project <path> --quiet`; `check_manifest`, `check_pins` and `check_family`
each pass `--root <path>`; `check_machine` passes only `--preflight`, no
value at all. Every one of those paths is absolute and built by this file
itself — never a bare directory or origin name — so none of them can start
with `-` the way a repository's own name can, and `check_machine` carries no
repository-chosen value to begin with. `check_not_a_root_naming` was the only
row handing a bare, repository-chosen name to argparse; nothing else needed
the same fix.

## The proof

Before, doctoring a directory named `--help`:

    status:        ok
    reason:        --help: classifies under the naming policy
    detail.exit:   0
    detail.explain: [the validator's own --help usage banner]

After, the same directory:

    status:  FINDING
    reason:  --help: FINDING naming-unclassified: --help
    next:    python3 …/validate-repository-naming.py --explain -- --help
    detail.exit: 1

Two tests land beside the other NOT-A-ROOT naming tests in
`tests/test_shape_doctor.py`, not appended at the end of the file:
`test_a_root_named_like_an_option_still_gets_a_real_naming_verdict` proves the
row itself against a `--help`-named directory (JSON only, so it runs
identically on all three CI platforms — nothing in it spawns a shell) and
carries the before/after above as its own counterexample assertion, and
`test_the_naming_rows_next_command_runs_when_it_is_pasted` (`@WINDOWS_SKIP`,
needs `bash`) pastes the emitted `next` line into `bash -c` verbatim and
asserts it exits 1 with the real finding rather than 0 with a usage banner.

## Housekeeping

* 950 tests before this change, 952 after.
* `python3 -m pytest -q` is green from a cwd with no sibling checkouts on its
  path. This workstation keeps real `openXdox` and `openDox` clones beside
  its `projects/` directory, and from a cwd inside one of them,
  `test_cli_reports_an_unread_link_as_a_warning_and_still_classifies`
  (`tests/test_naming_policy.py`) resolves the "a checkout sitting BESIDE
  this project" fallback (`repo_shape.resolve_link_source`) to those real
  directories instead of finding nothing, and fails on an unrelated
  assertion. Reproduced identically against an untouched `main` checkout —
  it is a pre-existing local-environment hazard, not a regression from this
  change, and does not reproduce on a CI runner, which has no such siblings.
* `python3 scripts/render-cli-reference.py --check` —
  `[ok] docs/cli.md is what the generator produces`.
* `git diff --stat origin/main -- templates/` — empty.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

## Summary by Sourcery

Make repository naming validation handle names such as `--help` and `-x` as positional names rather than command-line options.

Bug Fixes:
- Ensure repository names beginning with option-like prefixes receive a real naming-policy verdict instead of being interpreted as argparse options.
- Include the end-of-options marker in emitted remediation commands so they work for option-like repository names.

Tests:
- Add coverage for option-like repository names and for executing the emitted remediation command through a shell.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
brettheap added a commit that referenced this pull request Sep 11, 2026
… `[old]` as a wildcard, so the drifted-file repair says `Copy-Item -LiteralPath` there (#105) (#107)

Lane: openreposhape-2 (openRepoShape-2)
Claim: #105 (comment)

Closes #105.

## What was wrong

Copilot's final review on PR #102, read after that merge. The `leg shape
files` row offers a repair for a leg file that is simply absent, and it
offered it as one string on every platform:

```python
fix = (f"cp {quote_arg(source)} {quote_arg(ctx.root / rel / name)}")
```

**On Windows `cp` is not a program, it is an alias of `Copy-Item`** — the
cmdlet reference says exactly that ("PowerShell includes the following
aliases for `Copy-Item`: ... Windows: `cp`") — and **`Copy-Item -Path` does
not take a path, it takes a pattern**: "Wildcard characters are permitted".
So `[`, `]`, `*` and `?` in the value are that cmdlet's syntax, and a
perfectly ordinary root at `C:\work[old]\Atlas` gives the reader one of two
outcomes from a line this tool told them to run:

* `Cannot find path` for a directory that is plainly there, or
* where `[old]` is a character class with a sibling that matches it — a
  `C:\workd\Atlas` next door — **a copy out of the wrong directory, silently.**

**`quote_arg` (#102) cannot reach this and is not wrong.** Quoting decides
where an argument ENDS; the cmdlet decides how to read what arrived. A
PowerShell verbatim `'...'` does not spare `[` from `-Path`. That is
tokenization; this is parameter semantics, one layer past it.

## What landed

One `copy_command(source, target, platform=None)` in `shape-doctor.py`,
beside its only caller, in the shape `scaffold_command` already has:

* `nt` → `Copy-Item -LiteralPath <source> -Destination <target>`.
  `-LiteralPath` is the parameter that means this path: "used exactly as
  it's typed. No characters are interpreted as wildcards."
* POSIX → `cp <source> <target>`, unchanged and correct: there `cp` is
  `/bin/cp`, the glob belongs to the shell, and `quote_arg`'s single quotes
  already hand the brackets through intact.
* Both values still go through `quote_arg`, because the two answer different
  questions — a destination with a space in it needs the quoting exactly as
  much as a bracket needs the literal parameter.

**The destination needs no twin and has none.** `Copy-Item` has no
`-LiteralDestination`, and wants none: `-Destination` is documented
"Supports wildcards: False" — it names where the copy LANDS rather than
searching for what to copy, so a `[` in it is already a character. Quoting
is all it needs, and quoting is what it gets.

**`platform` is passed ON, not merely branched on.** `quote_arg(value)` with
no platform reads the REAL host's `os.name`, so a Windows line built on a
POSIX runner would be quoted by `sh` rules — the function claiming a
spelling it did not produce. That is the defect #103 names next door in
`scaffold_command`; this function is written not to have it, which is also
what lets the `nt` expectations below use genuine `PureWindowsPath`
fixtures and hold on Linux, macOS and Windows alike.

**`--json` is fixed by the same line**: the `next` field carries the row's
command string, so it carries this one.

## Every other verb, checked rather than assumed

`shape-doctor.py` emitted exactly ONE shell verb, this `cp`. Every other
remediation is `python3 ...`, `git -C ... fetch --all` or
`git -C ... checkout -- <path>` — the same programs with the same parsing on
both platforms, no cmdlet aliases and no PowerShell parameter semantics.
(`git checkout -- 'file[old].txt'` over a file literally so named was run
here and restores that file; git pathspec wildcards would be a
platform-independent question of git's own, not this one.) A new test makes
that a rule rather than an observation.

## The proof

**9 tests added (5 functions), 1 existing test changed, 950 → 959** (the fifth function and its two cases came in from Copilot's review; see the bottom of this body).

* `copy_command` asserted BYTE FOR BYTE on both platforms, over a bracket in
  the TARGET (`/srv/work[old]/Atlas/...`, `C:\work[old]\Atlas\...`) and a
  bracket in the SOURCE (`/srv/shape[2]/...`, `C:\shape[2]\...`) — the half a
  fix that only guarded the destination would miss. `PurePosixPath` and
  `PureWindowsPath`, never `Path`, so the rendering does not depend on which
  runner ran it (the lesson of #102's `tests-windows` job, run 34594408797).
* `platform=None` is this host's, and the two spellings are proved to be two.
* **End to end, with the failure standing next door**: a project at
  `<tmp>/work[old]/Atlas` with a sibling `<tmp>/workd/Atlas` — what the
  character class `[old]` matches — its `spec/CLAUDE.md` deleted, and the
  row's own line pasted into `bash -c` exactly as printed. Quoted, the file
  is restored from the template and the sibling is untouched. Unquoted, the
  same line resolves to the SIBLING, overwrites a file in a repository the
  reader never named and leaves the one they were fixing still missing —
  which is the Windows failure written where a runner can actually execute
  it, since on PowerShell that expansion is `Copy-Item`'s own and only
  `-LiteralPath` stops it.
* A guard on the CLASS: `shape-doctor.py` may spell a bare `cp`, `mv`, `rm`,
  `ln`, `cat`, `touch`, `mkdir` or `chmod` in exactly one place, inside
  `copy_command` (found by `ast`, so the function's real line range). A
  future row that reaches for a shell verb fails in CI with that comment to
  read, rather than on somebody's Windows machine.
* The existing `test_a_missing_rendered_leg_file_is_not_offered_a_cp`
  hard-coded `startswith("cp ")` and ran on all three runners: on Windows it
  would now be asserting the very defect this fixes. It reads the host's verb
  and parses either spelling (`shlex` on POSIX; `Copy-Item -LiteralPath ...
  -Destination ...` on Windows, apostrophes un-doubled).

## Housekeeping

* `python3 scripts/render-cli-reference.py --check` — `[ok] docs/cli.md is
  what the generator produces`; no `--help` text moved.
* `git diff --stat origin/main -- templates/` — empty. No README/AGENTS.md
  change and therefore no cap moved.
* Locally 955 pass, 1 skipped, and one PRE-EXISTING environmental failure
  unrelated to this change: `test_naming_policy.py::test_cli_reports_an_unread_link_as_a_warning_and_still_classifies`
  expects the offline `declared-unverified` warning, and this workstation has
  a real `openXdox` checkout sitting beside the repository — precisely what
  the validator's "a checkout beside the project" rule verifies the link
  against. The same command prints the same unwarned line from the untouched
  main checkout at `origin/main` (32450eb), and CI has no such sibling.

## Review, taken

* **SonarCloud**, two `python:S9073` (composite assertion) findings, both in
  the new tests — taken in 186a514: each is two assertions now, so a failure
  names which half broke. The gate had passed either way.
* **Copilot**, on `copied_paths` — taken in 24cc7d9, and the suppressed half
  of the same finding with it. That helper is the SUITE's reader of the
  row's line, and `line.split("#")[0].split()` tore the one token
  `'C:\Users\Jane Doe\...'` in half at the space and truncated a path with
  a `#` in it, failing assertions about commands that were correct. It now
  uses `shlex.split(line, comments=True)` on POSIX and a `powershell_tokens`
  that knows verbatim `'...'`, doubled apostrophes and `#`-only-at-a-token-
  start on Windows, with a `platform` argument so either branch is asserted
  from either host — plus a round-trip test over a path with a space, an
  apostrophe and a `#` in it, with the row's real trailing comment appended.
  Nothing shipped changed.
* **Sourcery** and **Codex** both declined on quota (7-day diff budget and
  usage limits respectively); Sourcery's guide is on the PR, neither carries
  a finding.

## Neighbouring, not taken

* `scaffold_command`'s inner `quote_arg` calls (#103) and the `naming` row
  (#104) are being fixed in their own lanes; nothing here touches either, and
  the new tests sit NEXT TO the drifted-file tests rather than at the end of
  the file, so the three rebase clean.
* `update-shape.py check` prints its own `NEXT ...` lines with the same
  interpolation and is still outside this file's quoter, as #102 already
  noted.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

## Summary by Sourcery

Make drifted-file repair commands safe and platform-appropriate across POSIX shells and PowerShell.

Bug Fixes:
- Generate Windows repair commands with `Copy-Item -LiteralPath` so bracketed and other wildcard-like paths are copied literally instead of being misinterpreted by PowerShell.

Enhancements:
- Preserve POSIX `cp` repair commands while selecting shell-specific quoting and command syntax through a shared copy-command helper.

Tests:
- Add cross-platform command-rendering, parsing, wildcard-path, and end-to-end repair tests, including safeguards against introducing other bare shell verbs outside the shared helper.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
brettheap added a commit that referenced this pull request Sep 11, 2026
…newline in either is refused instead of reaching the commit message and argv (#111)

TWO HOLES OF ONE SHAPE, both found by Copilot on PR #112, and both about
"one line" being asserted by something that does not assert it.

`trailer_line` matched with `re.match` against a pattern ending in `$`, and
`$` stops just before a FINAL newline — so `--trailer "Lane: x\n"` was
accepted whole and the newline went into the message `git commit -F -` reads
and into the `--trailer` argument beside it. `.fullmatch` is what requires the
value whole, which is the lesson `shape-doctor.py`'s `quote_arg` took on PR
#102 against `"Atlas\n"`; this is the same defect one file along. And the
middle of the pattern was `[^\n]`, which is not "one line" either: `\r`, `\v`,
`\f` and a bare `\t` all went through, each a line break or a column jump to
some reader of the commit. Both classes now admit no control character at all,
and the refusal says so.

`lane_trailer` asked the alphabet about a `.strip()`ed name, so
`LANES_LANE="xfactory-1\n"` — the shape `$(cat …)` and a CRLF file produce —
was offered on the printed next command as `Lane: xfactory-1`: a name the
contract says is not offered, trimmed into one that is, with nothing said. The
raw bytes are what `LANE_NAME_RE` is now asked about, and a value with
whitespace around it is NOT a lane name, decided that way because `TRAILER_RE`
refuses a value starting or ending in whitespace — a printed line offering a
trailer this tool's own `--trailer` would then refuse is worse than one
offering none. Stripping decides exactly one thing now: that an all-whitespace
variable means no lane, which is `LANES_LANE=` spelled with a space in it.

Fourteen cases, including the trailing newline that got through, each control
character the interior class admitted, every whitespace-around-the-name shape,
and the invariant the two rules exist to keep: a lane the printer offers is a
trailer `--trailer` would accept.

The review's third finding — `AGENTS.md` at 434 lines against a cap of 433 —
does not reproduce: `wc -l AGENTS.md` is 433, the file carries 433 newlines
and 433 `splitlines()` entries and ends with one, and
`test_agents_md_is_short_enough_to_be_read` passes. The cap is untouched.

Lane: openreposhape-2 (openRepoShape-2)
Co-Authored-By: Claude Fable 5.1 <[email protected]>
brettheap added a commit that referenced this pull request Sep 11, 2026
…le `--trailer`, and the printed `apply` already carries the lane, so the commit they write ends with its `Lane:` line instead of being amended afterwards (#111) (#112)

* `update-shape.py apply --branch` and `family.py bump` take a repeatable `--trailer`, and the printed `apply` already carries the lane, so the commit they write ends with its `Lane:` line instead of being amended afterwards (#111)

Both tools compose their own commit message — "Re-sync the shape copies to
<repo> @ <sha12>", "Bump <Member> to <sha12> in the <Family> family" — so the
`Lane: <name>` line the lane-collision protocol wants on every artifact a lane
produces, and the `Co-Authored-By:` this estate adds beside it, reached those
commits through nothing at all. Four InkRouter re-pins landed on 2026-09-11
carrying neither, each one run exactly as a printed `NEXT` line said.

`--trailer "<Key>: <value>"` is repeatable, kept in the order given, and
validated at the argparse boundary, so a line that is not a trailer is refused
with the usage beside it and before a repository is opened. On `apply` it needs
`--branch`, refused under the same `update-branch-required` id as `--push` and
`--pr` and now naming whichever of the three was passed: a trailer is a line on
a commit, and without `--branch` there is no commit to put one on.

The write is `git commit --trailer` where the host git is 2.32 or newer, probed
once from `git --version` and parsed conservatively, and an append to the
message text where it is not — the same commit either way, which
`tests/test_commit_trailers.py` writes both of and compares. Passed no trailer,
the message and the `git commit` argv are the ones these tools always built.

`update-shape.py check`'s `NEXT` line and the doctor's `shape currency` row now
end with `--trailer "Lane: <$LANES_LANE>"` when the environment names a lane,
quoted through the doctor's own platform-aware `quote_arg` on its rows, so the
line survives being pasted; with no lane set nothing is added and both are
byte-identical to what they printed before. Only the lane is derived — a
co-author names a person or a model no environment variable knows.

What a trailer is, which git takes the option, and which variable names the
lane live in `scripts/shape_materialize.py`, imported by both tools already and
in no copy list; `scripts/repo_shape.py` would have put an `upstream-changed`
row in front of every project in the estate for a helper none of their copies
would call, which is the argument `shape-doctor.py` makes about its quoter.

Lane: openreposhape-2 (openRepoShape-2)
Co-Authored-By: Claude Fable 5.1 <[email protected]>

* A trailer is matched with `fullmatch` and the lane is read RAW, so a newline in either is refused instead of reaching the commit message and argv (#111)

TWO HOLES OF ONE SHAPE, both found by Copilot on PR #112, and both about
"one line" being asserted by something that does not assert it.

`trailer_line` matched with `re.match` against a pattern ending in `$`, and
`$` stops just before a FINAL newline — so `--trailer "Lane: x\n"` was
accepted whole and the newline went into the message `git commit -F -` reads
and into the `--trailer` argument beside it. `.fullmatch` is what requires the
value whole, which is the lesson `shape-doctor.py`'s `quote_arg` took on PR
#102 against `"Atlas\n"`; this is the same defect one file along. And the
middle of the pattern was `[^\n]`, which is not "one line" either: `\r`, `\v`,
`\f` and a bare `\t` all went through, each a line break or a column jump to
some reader of the commit. Both classes now admit no control character at all,
and the refusal says so.

`lane_trailer` asked the alphabet about a `.strip()`ed name, so
`LANES_LANE="xfactory-1\n"` — the shape `$(cat …)` and a CRLF file produce —
was offered on the printed next command as `Lane: xfactory-1`: a name the
contract says is not offered, trimmed into one that is, with nothing said. The
raw bytes are what `LANE_NAME_RE` is now asked about, and a value with
whitespace around it is NOT a lane name, decided that way because `TRAILER_RE`
refuses a value starting or ending in whitespace — a printed line offering a
trailer this tool's own `--trailer` would then refuse is worse than one
offering none. Stripping decides exactly one thing now: that an all-whitespace
variable means no lane, which is `LANES_LANE=` spelled with a space in it.

Fourteen cases, including the trailing newline that got through, each control
character the interior class admitted, every whitespace-around-the-name shape,
and the invariant the two rules exist to keep: a lane the printer offers is a
trailer `--trailer` would accept.

The review's third finding — `AGENTS.md` at 434 lines against a cap of 433 —
does not reproduce: `wc -l AGENTS.md` is 433, the file carries 433 newlines
and 433 `splitlines()` entries and ends with one, and
`test_agents_md_is_short_enough_to_be_read` passes. The cap is untouched.

Lane: openreposhape-2 (openRepoShape-2)
Co-Authored-By: Claude Fable 5.1 <[email protected]>

* A trailer is ONE line because `splitlines()` and `unicodedata` say so, not because an ASCII class does, and the holder's own instructions show `bump`'s trailers (#111)

THREE FINDINGS FROM COPILOT'S THIRD ROUND ON PR #112, one of them a hole in
the grammar the previous round opened and two of them about what a reader —
a person or a test — is told.

`[^\x00-\x1f\x7f]` READS AS "NO CONTROL CHARACTER" AND IS NOT ONE. It names
C0 and DEL and stops there, so the C1 block `\x80`-`\x9f`, U+0085 NEXT LINE,
U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR all went through a
pattern whose whole job was "one line" — and Python's own `str.splitlines()`
treats every one of them as a line boundary, so a value the tool called one
line arrived as two in anything that read the commit message back that way.
The `Cf` characters got through the same gap without even being breaks: two
trailers differing by a zero-width joiner look identical to a reader and are
not, which is the confusion a trailer exists to avoid.

A CHARACTER CLASS LARGE ENOUGH TO NAME THEM ALL WOULD BE A SECOND, WORSE COPY
OF THE UNICODE TABLES, so `one_printable_line` asks the two questions in
their own words instead: `value.splitlines() != [value]` is this
interpreter's own definition of a line boundary, and moves by itself the day
a future Python adds one; `unicodedata.category` then refuses `Cc`, `Cf`,
`Zl`, `Zp` and `Cs`. `Cs` is there because a byte the locale could not decode
reaches `sys.argv` as a lone surrogate, which is not text at all — git is
handed that undecodable byte straight back, or, on the pre-2.32 path that
appends trailers to the MESSAGE, `subprocess` raises `UnicodeEncodeError` on
a value `--trailer` had already accepted.

`is_trailer` IS THE WHOLE RULE AND BOTH CALLERS USE IT, so the invariant the
last round established — what `--trailer` refuses, no printed next command
offers — holds by construction rather than by two checks that agree today.
`LANE_NAME_RE` needs no second guard bolted on: it is a positive alphabet of
printable ASCII, so nothing `one_printable_line` refuses can be in a lane
name, and there is now a test saying that out loud for the day somebody
widens it.

`templates/family-root/AGENTS-shape.md` IS THE PINNED, AGENT-FACING MECHANICS
DOC copied into every holder, and its `family.py bump` example still showed a
bare bump. A procedure an agent reads in the holder it is standing in is the
one it follows, so the example carries `--trailer` and a paragraph says what
it is for: `bump` composes its own message, so a `Lane:` line reaches that
commit this way and no other, and `add` and `remove` do not take it. This
repository's `AGENTS.md` said it already; the copy every holder carries did
not.

THE BASELINE HALF OF A WITH/WITHOUT COMPARISON INHERITED THE RUNNER'S LANE.
`tests/conftest.py::run_script` now blanks `LANES_LANE` for every tool under
test unless the CALLER names it — which is how a test asks for a lane — so a
suite run inside a lane asserts the same lines as one run outside it. The
baseline of the test that compares the two pins it explicitly as well: the
assertion there is "the lane run is the plain one PLUS the trailer", and a
baseline that had quietly been a second lane run would have compared two
identical lines and passed.

Sixty-five new cases in `tests/test_commit_trailers.py`, 60 to 125: every
line boundary, every invisible and every lone surrogate in the middle of a
value and at the end of one, each of the two checks proved to be the one that
catches its own half, the lane alphabet proved to exclude all of them, and
`is_trailer` proved to be the single predicate both callers use. `docs/cli.md`
regenerates byte-identical — no `--help` text moved. 1131 passed, 1 skipped;
the one red is the machine-dependent
`test_cli_reports_an_unread_link_as_a_warning_and_still_classifies` in
`tests/test_naming_policy.py`, which is pre-existing and not this branch's.

Lane: openreposhape-2 (openRepoShape-2)
Co-Authored-By: Claude Fable 5.1 <[email protected]>

* The re-pin trailers reach a scaffolded project through its OWN pinned `AGENTS-shape.md`, and `LANES_LANE` is promised to carry a `Lane:` argument only for a name that survives a paste (#111)

BOTH OF COPILOT'S FOURTH ROUND ON PR #112 — two suppressed documentation
findings on the same two lines of `AGENTS.md`, and neither is about what the
tools do. They are about who is told, and about a promise wider than the code
behind it.

A PROJECT READS ITS OWN `AGENTS-shape.md`, NOT THIS CHECKOUT'S `AGENTS.md`.
`scripts/shape_materialize.py` copies `templates/assembly-root/AGENTS-shape.md`
verbatim into every scaffolded assembly root and digest-pins it, and that file
is where an agent standing in such a project learns the shape's mechanics —
including how a re-pin is run. Its "never edit a pinned file" section named the
exit (upstream, then `update-shape.py` from a checkout of the standard, landed
as a pull request) and stopped there, so the one thing the previous commits
added to that procedure reached the standard's own readers and no project's.
The section now carries the two-command block and a paragraph in the file's own
voice: `apply` takes a repeatable `--trailer`, appended in the order given, and
only alongside `--branch` because without one there is no commit to put a line
on; `apply` composes that message itself, so a `Lane:` line or a
`Co-Authored-By:` reaches the re-pin commit this way and no other rather than
by amending it afterwards; `check` writes nothing and takes none. This is the
same fix round 3 took in `templates/family-root/AGENTS-shape.md` for
`family.py bump`, applied to the other holder of the same kind of doc.

Both are pinned copies, so this moves the digest of
`templates/assembly-root/AGENTS-shape.md` and every scaffolded project will
report `upstream-changed` for it until its estate re-pins — the ordinary cost
of changing a copy, and the reason the change is one section rather than a
rewrite. `tests/test_scaffold_e2e.py` and `tests/test_family.py` recompute
those digests from the bytes on disk, so nothing is hard-coded to move with
them; each now also asserts `--trailer` is IN the file it checks, because a
procedure that reached only the standard once can do so again.

"WHERE `LANES_LANE` IS SET" PROMISED MORE THAN `lane_trailer` DELIVERS. That
function deliberately offers nothing for a lane name that would not survive
being pasted — a quote, a `$`, a backtick, a backslash, a newline, surrounding
whitespace — because a printed next command is there to be copied, and one that
breaks or expands when it is copied is worse than no line at all. A reader with
such a name, told the `NEXT` line "already carries the `Lane:` argument", would
go looking for a bug. The sentence now says what is true on both sides: where
`LANES_LANE` holds a name that survives being pasted the two printed lines
carry the argument already, and one that would not is offered on neither. Seven
lines to seven, so the 433-line cap in `tests/test_repo_hygiene.py` is
untouched.

THE THIRD ITEM THIS ROUND RAISED WAS ALREADY TAKEN. `unicodedata.category` of a
lone surrogate is `Cs`, and `UNPRINTABLE_CATEGORIES` has listed `Cs` since the
previous commit, with the grammar cases in `tests/test_commit_trailers.py`
(`NOT_TEXT`) to prove it. Verified again here rather than assumed:
`subprocess.run(["true", "Lane: a\ud800b"])` raises `UnicodeEncodeError`
instead of mangling the value, which is exactly the failure `--trailer` must
refuse at the boundary rather than let reach `git commit`.

PROVEN ON A TREE REBASED ONTO `origin/main` AT e9fa826 (#116, #117 and #121
landed under this branch while it was open) — the rebase was conflict-free,
because #121 touched `scripts/repo_shape.py`,
`scripts/render-cli-reference.py`, `setup-project.py` and the leg-template
validators and this branch edits none of them. The commit itself sits on
c19a595 unrebased: the branch ruleset refuses a force-push, which is the
correct answer, and GitHub tests the merge with `main` regardless. 1131
passed, 1 skipped on the rebased tree; the one red is the machine-dependent
`test_cli_reports_an_unread_link_as_a_warning_and_still_classifies` in
`tests/test_naming_policy.py`, pre-existing and not this branch's.
`docs/cli.md` regenerates byte-identical on both trees — through the old
`render-cli-reference.py` and through #121's new one — so no `--help` text
moved.

Lane: openreposhape-2 (openRepoShape-2)
Co-Authored-By: Claude Fable 5.1 <[email protected]>

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
brettheap added a commit that referenced this pull request Oct 13, 2026
…am, `--accept-local` paths, branch and lane trailer with `shlex.quote`, so `check`'s `apply`, `apply --branch`'s `git -C <root> push && gh pr create` and `apply`'s own `git -C <root> checkout -b && git -C <root> commit` paste whole from a root under `my projects/`, `it's here/` or `$HOME/` (#325) (#374)

`landing_failed`'s NEXT line and the rollback's hand-fix lines were quoted
for a POSIX shell by #202 and #204. The three NEXT lines a run prints before
anything has gone wrong were not: each put the root in bare, so a project
under a directory with a space was two arguments, one with an apostrophe was
a quotation nothing closes, and one with a `$` or a backtick was expanded.
The first run of the pasted line then went to the wrong directory or did not
parse, in front of the person it was printed for.

- `check`'s `apply` is built by one function, `apply_command`, from an argv:
  the root, the `--upstream` label (a path on somebody's disk when it is not
  `owner/repo`), every `--accept-local` path (read from the project's own
  pin) and the branch are each one word under `shlex.join`.
- The lane's trailer goes through the same quoter. It was wrapped in double
  quotes by hand (`LANE_NAME_RE` keeps those safe), and is now
  `--trailer 'Lane: <name>'`, the spelling the doctor's `shape currency` row
  has always printed. This is the one visible change for a run in a lane; the
  argv the shell reads out of it is the same.
- `apply --branch`'s `git -C <root> push -u origin <branch>` is `shlex.join`
  of its words, and the branch of the `gh pr create` is `shlex.quote`d.
  `checked_branch`'s alphabet is one `shlex.quote` leaves alone, so no byte
  of a branch moves; it is quoted so that widening the alphabet cannot reopen
  the line.
- `apply` without `--branch` quotes the root in each of the `git -C <root>`
  words of its checkout, its `--add` staging and its commit.
- The doctor's `shape currency` row was already right: every value in it goes
  through `quote_arg` (#101, #102), which is POSIX quoting on POSIX and
  PowerShell's on Windows. It is unchanged and now has a test for the roots
  above, `$` included.
- `scripts/shape_materialize.py`'s `lane_trailer_argument` docstring said
  `update-shape.py`'s NEXT line "quotes nothing"; it now says what that line
  passes. No code there changes.

Unchanged, and diffed: a root and an upstream that need no quoting print the
bytes they printed before, for all three lines and for the `--push` line
(`tests/test_update_shape_next_quoting.py` spells the old lines out and
passes on main and on this head). On Windows every root holds a backslash,
which `shlex` quotes, so a Windows root now prints in single quotes where it
printed bare; that is what `_by_hand` already says of its own lines. These
are lines for a POSIX shell, Git Bash included. PowerShell reads a
single-quoted string as itself, so they still paste there unless the root
holds an apostrophe, whose POSIX spelling is not PowerShell's; no PowerShell
mode is added.

Left out: the `Remediation:` line `--branch` prints when the branch exists
(`git -C <root> checkout <branch>`) is the same defect outside a NEXT line.

Lane: openreposhape-3 (openRepoShape-3)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 13, 2026
…s a runnable `scripts/family.py`, printed commands quote paths, and `add`, `bump` and `remove` refuse the tracking branch and print their branch's push (#488, #486, #487) (#507)

Three defects from lane 3's v1.0.0 acceptance pass of AGENTS.md's "Creating a family, and adding a member", one commit each, in this order, then one review commit for #486 and one for #487. All three change `scripts/family.py` and `add`'s NEXT line, so they are one pull request.

**What was wrong.**
- AGENTS.md spelled the command `python3 scripts/family.py init --org <org> --family <Name>`, a path that runs from the standard's root. `--into` defaults to where the person stands.
- So the command, followed exactly, printed `landing <standard>/Orbit/Orbit` with no word, and `make siblings` would then clone every member into the standard's checkout too.
- `init`'s NEXT STEPS printed `python3 family.py add …`, built from `Path(__file__).name`. From the root that fails `can't open file`, exit 2.

**What changed** (commit 1).
- With neither `--into` nor `--work-dir`, `init` refuses a landing inside a checkout of openRepoShape: `family-landing-in-standard`. A checkout is a directory holding `scripts/family.py` beside `templates/family-root/`, found in the landing's ancestry, so another clone or an install counts too.
  - The refusal comes before anything is created, under `--dry-run` alike.
  - The remedy names `--into ..` from the root. From deeper inside the checkout it names the relative path that reaches the checkout's parent.
  - An explicit `--into` or `--work-dir` is not second-guessed. `family-holder-already-here` is still asked first.
- NEXT STEPS, and the `family-holder-already-here` remedy, name this file relative to the directory `init` ran in. From the root that is `scripts/family.py`, as setup-project.py, validate-family.py, AGENTS.md and README spell it. It is absolute where no relative path exists.
- AGENTS.md's init command passes `--into ..`, as README's already does, and step 1 says why. The edit is line-neutral: step 1 is one line shorter.
- `init --into --help` says it too, and docs/cli.md is regenerated.

**How tested.** `tests/test_family_init_landing.py`, 9 tests:
- the old command from the root is refused, as a dry run, so nothing can land in the checkout;
- a real run inside a fake checkout creates nothing;
- the remedy from a subdirectory names the right parent;
- an explicit `--into .` or `--work-dir .` passes;
- outside a checkout the default is unchanged;
- AGENTS.md's line, as written, lands beside the checkout;
- the printed NEXT runs, both from the root and from elsewhere.

On origin/main code 6 of them fail. Removing the refusal turns 3 red, and putting `Path(__file__).name` back turns 2 red.

**What was wrong.** `family.py` and the holder's `siblings.py` printed every path in their pasteable commands bare. Under a holder at `…/my work/Sonata/Sonata`:
- the `member-git-dir-cached` remedy `rm -rf <store>` split into `rm -rf …/my`, an absolute directory that is NOT the store, and a relative `work/…`;
- `init`'s NEXT STEPS and `add`'s NEXT split `--family-root` and `git -C` (`fatal: cannot change to '…/my'`, exit 128);
- the `mv` lines for a misnamed family folder pasted as four arguments.

**What changed** (commit 2, and the review commit after #487's).
- `scripts/repo_shape.py` gains `shell_quoted(value, platform=None)` and `shell_line(words, platform=None)`, in a new section at its end, the library `family.py` already imports.
  - It is the doctor's `quote_arg` rule (#101/#102): the same two alphabets, and the same two escapes, `sh`'s `'\''` and PowerShell's doubled apostrophe. The dialect comes from `os.name` or a `platform` argument. An ordinary word is left bare.
  - It does not flatten to ASCII, as the doctor's report does by contract. A command that deletes or moves a directory has to name that directory. So PowerShell's typographic single quotes are doubled too.
  - A word that begins with `=` is quoted, in both dialects. zsh, macOS's login shell, expands a bare `=word` to a command's path (`=ls` reaches the command as `/bin/ls`). This is the one place it differs from the doctor's rule on ASCII.
- `family.py`:
  - `init`'s NEXT STEPS print the `add` on ONE line. It used to paste only into a POSIX shell, because of its `\` continuation. `cd <holder>` and `make siblings` are two lines, with no `&&`, which Windows PowerShell 5.1 rejects between two statements.
  - Those lines and the `family-holder-already-here` remedy quote every path.
  - `add`'s NEXT quotes `git -C <holder>`, and `member-path-taken` quotes each spelling it names.
  - `member-git-dir-cached`, and `remove`'s note about the same store, print the directory alone on its own line. Then comes `rm -rf` with its one argument quoted for the POSIX shell `rm -rf` belongs to, and the sentence names that shell: Git Bash on Windows. PowerShell refuses `-rf` and deletes nothing.
- `siblings.py`: the parent-folder warning's `mv` and `mkdir -p` lines are quoted for a POSIX shell with the standard library's `shlex.join`, and the warning says which shell. It does NOT import the new quoter: a holder that kept its own `repo_shape.py` through `update-shape.py apply --accept-local` takes the new `siblings.py` without it, and an import of a name its copy lacks stopped `make siblings`, `park` and `resume` with an ImportError that `check` and the validator never reported.
- `setup-project.py`'s family hand-over quotes the holder in its `add` line (and names the branch first, see #487). It runs before any checkout of the standard exists, so it carries its own copy of the rule, and a test holds that copy to `shell_quoted`.

**How tested.** `tests/test_family_printed_quoting.py`, 69 tests:
- The quoter round-trips through `shlex.split`, and through a PowerShell reader, for a space and an apostrophe, `é` and a typographic apostrophe, shell syntax, the empty string, and every printable ASCII character alone and before, inside and after a word.
- The host's own `sh`, `bash` and `zsh` hand each quoted word back byte for byte through `printf`, a leading `=` among them (skipped where a shell is absent, and on Windows).
- It agrees with the doctor's `quote_arg` on every one of those ASCII values but a leading `=`, and its two alphabets are the doctor's two patterns.
- Under a holder in `my work` and in `Dana's work`, each of these splits into the argv it means: `init`'s NEXT (with `cd` and `make siblings` on their own lines), `add`'s NEXT, the cached-store remedy and note, the `mv` lines, and setup-project's `switch` and `add`.
  - The `rm -rf`, run as split, deletes the store, and the decoy `<tmp>/my` survives.
  - The `mv` lines, run as split, move the holder.
- The holder's own `siblings.py` runs `--help`, the misnamed-folder warning and `--make park` beside a `repo_shape.py` that lacks every name this change added.
- Three existing tests' expected lines follow the new wording.

Mutations, each turning tests red:
- a bare quoter: 35 red;
- bare `mv` lines in `siblings.py`: 3 red;
- a bare `rm -rf`, a bare `add` NEXT, a bare `init` `add` (round 1, on the 85-test file): 2 red each;
- `siblings.py` importing `shell_line` again: 1 red (the older-`repo_shape.py` test);
- `%` dropped from the POSIX alphabet: 2 red (the every-ASCII agreement and the alphabet test). The round-1 sample test passed it, 36 of 36;
- a leading `=` left bare: 10 red, among them the real-`zsh` test;
- `cd … && make siblings` back on one line: 2 red;
- setup-project's holder unquoted: 2 red.

**What was wrong.**
- AGENTS.md says each act's ONE commit lands as a pull request, and no step made the branch that pull request needs.
- After `init` the holder stands on `main`, and all three acts committed straight onto it.
- `add` printed `NEXT  git -C <holder> push -u origin <branch> && open a pull request`. No branch is called `<branch>`, so the push failed: `src refspec … does not match any`.
- `bump` and `remove` printed no NEXT at all.
- `bump-leg.py` refuses exactly this for a leg (`bump-leg-on-tracking-branch`).

**What changed** (commit 3, and the review commit after it).
- The real run of each act refuses the holder's tracking branch, the one `family.yaml` declares (`family-on-tracking-branch`), and a HEAD on no branch (`family-holder-detached`, which is what `bump-leg.py`'s `bump-leg-root-detached` refuses too).
  - The check comes after the refusals about the arguments and the holder, and before the member is read, fetched or cloned, and before anything is written.
  - The remedy is a quoted `git -C <holder> switch -c <branch>`. The branch is `family/add-<project>`, `family/bump-<id>-<sha12>` or `family/remove-<id>`, and a name that is not a plain branch word becomes `member`.
- `--dry-run` runs on any branch. On a work branch it prints where the commit would land. On the tracking branch it prints that the real run refuses there, with the refusal's code, and the `switch` command on a line of its own. The module's EXIT CODES paragraph names this as the one refusal a dry run does not make.
- Each act that commits ends with ONE pasteable line: `NEXT  git -C <holder> push -u origin <the branch it committed on>`, quoted, then `then open a pull request against <tracking>; never push to it directly`. `bump` and `remove` gain that NEXT.
- `init`'s NEXT STEPS open with the `switch` before the `add`.
- `add`, `bump` and `remove` `--help` say the branch rule, and that each ends by PRINTING the push; docs/cli.md is regenerated.
- AGENTS.md's family block gains the `switch` step before the `add`, and step 3 says the tracking branch is refused, as `family-on-tracking-branch`, and that the branch is pushed as its NEXT line says. README's InkRouter block gains the same step, and its paragraph says it. Both edits are line-neutral: AGENTS.md tightens steps 2 and 5, and README tightens the `make bootstrap` paragraph. `docs/handbook.html` mirrors the block and the sentence, and its footer names #487 and the new README blob.
- The holder's own docs, `templates/family-root/AGENTS-shape.md` and `templates/family-root/README.md`, open their add/bump/remove block with the `switch` and say the act refuses the tracking branch. `setup-project.py`'s family hand-over prints the `switch` before its `add`.
- Test fixtures that committed on `main` now commit on a branch:
  - `tests/test_family.py`'s module fixture grows the family on `family/members` and pushes that branch to the remote's `main`, as the merged pull request would leave it;
  - `test_shape_doctor.py`'s holder fixture and `test_family_add_excludes.py`'s `empty_holder` switch to a branch;
  - `test_family_add_refusals.py` changes in four places: the `NEXT` expectation, `unborn_holder`, the empty-family test, and the corrupt-HEAD test. In that last test, the tag state's branch check is answered in-process, because the test is about the rollback's reading of HEAD.

**How tested.** `tests/test_family_tracking_branch.py`, 17 tests:
- For each act, on `main`: refused, with the holder byte for byte as it was, and for `add` nothing cloned. Then the printed `switch`, run as split, makes the branch; the act goes through on it; and its printed NEXT, run as split, pushes the branch, which the remote then holds at the act's commit.
- A detached HEAD is refused.
- Dry runs on `main` and on a branch say what they should.
- A family made with `--tracking-branch trunk` refuses `add` on `trunk`; on a branch named `main` the dry run says the commit lands there for a pull request against `trunk`, the real run commits, and its NEXT pushes `main`.
- The suggested names pass `git check-ref-format --branch`.
- `init`'s NEXT STEPS open with the `switch`.
- AGENTS.md, README.md and the holder's two docs show the `switch` in the same block as, and before, the first `add`.

Mutations, each turning tests red: the branch check letting `main` through, 4 red; the NEXT line naming `<branch>` again, 3 red; `init`'s NEXT STEPS without the `switch`, 1 red; the tracking branch hard-coded to `"main"`, 1 red (the `trunk` test; every family test passed it before); the holder docs without the `switch`, 2 red; setup-project without the `switch`, 2 red.

An independent review at 10c93de gave CHANGES NEEDED (0 blockers, 1 should-fix, 6 nits). The should-fix was a holder that kept an older `scripts/repo_shape.py` through `apply --accept-local`: its new `siblings.py` could not import the shared quoter, so `make siblings`, `park` and `resume` died. The round at bb11b63 fixes it and all six nits, as described above. Re-verified at bb11b63: APPROVE WITH NITS (0 blockers, 0 should-fixes, 3 nits), with SonarCloud's quality gate OK and 0.0% new duplication. The nits were the holder README's pointer to the push (now "as its `NEXT` line says"), two Sonar smells (S1192: `refs/heads/` is now `HEADS_PREFIX`; S3415: the two expected-first assertions now put the actual value first, as the file's other 32 do), and this description's list of other pull requests. All three are fixed at 3451a56: commit 11ae0a8, then a clean merge of main 994be39. The family set gave 566 passed, 8 skipped there. GitHub's update-branch then merged main cac6bb2 as 8e1471c, and main aa4e1f5 (#508, after #490, #474 and #468) was merged as 708f3bb. There only the `docs/handbook.html` footer conflicted: it takes main's clauses, #468's (#424) included, with the README blob recomputed, and `docs/cli.md` auto-merged and passes `--check`. Main 47b1e06 (#505 and #395, after #376, #374, #384, #495, #493 and #491) was then merged as fcbc7a2, again with only the footer in conflict: main's clauses stay in main's order, this branch's (#487) moves to the end, after (#483), and the README blob is recomputed.

Every run used `/usr/bin/python3 -m pytest -q -p no:cacheprovider`, with a stub `gh` first on PATH, a bogus `GH_TOKEN`, an empty `GH_CONFIG_DIR` and git's identity blanked. Run on Linux. At e42ef74 (main d41cc29, #402, merged in by GitHub's update-branch), on its tree 655c927: the first set listed below for fcbc7a2, plus every `tests/test_update_shape*.py`, gave **1242 passed, 22 skipped**; the second set, plus `tests/test_leg_path_yaml_scalars.py`, `tests/test_ruleset_hint_tracking_branch.py`, `tests/test_scaffold_reuse_seeded_legs.py`, `tests/test_scaffold_pin_and_reuse.py` and `tests/test_doctor_validator_rows.py`, gave **1260 passed, 12 skipped**. The skips are the same as at 5a2776d, below.

At 654df49 (main 8cd7dbe merged in, with #506 and #347): the first set listed below for fcbc7a2, plus every `tests/test_update_shape*.py`, gave **1242 passed, 22 skipped**; the second set, plus `tests/test_leg_path_yaml_scalars.py`, `tests/test_ruleset_hint_tracking_branch.py`, `tests/test_scaffold_reuse_seeded_legs.py` and `tests/test_scaffold_pin_and_reuse.py`, gave **1231 passed, 12 skipped**. The skips are the same as at 5a2776d, below.

At 5a2776d (main f391e58 merged in, with #266, #509, #496 and #435): the first set listed below for fcbc7a2, plus every `tests/test_update_shape*.py`, gave **1213 passed, 22 skipped** (the template-quoting skips below, and three NTFS-junction cases, Windows only); the second set, plus `tests/test_leg_path_yaml_scalars.py`, gave **1171 passed, 12 skipped** (the four Windows-only skips below, and eight in that file, main's new one, whose cases the quoted templates (#259) leave with nothing to refuse).

At 22733ce (main 631f087, #503, merged in by GitHub's update-branch): the first set listed below for fcbc7a2, plus every `tests/test_update_shape*.py`, gave **1213 passed, 22 skipped** (the template-quoting skips below, and three NTFS-junction cases, Windows only); the second set gave **944 passed, 4 skipped**.

At fcbc7a2 (origin/main 47b1e06 merged in, with #505 and #395):

- every `tests/test_family*.py`, `tests/test_validate_family*.py`, `tests/test_park_resume_targets.py`, `tests/test_free_plan_hint.py` and `tests/test_template_text_placeholders.py`: **844 passed, 19 skipped** (`tests/test_family_init_values.py:219` and `:291`, which skip because the template now quotes the placeholder and `id:`).
- `tests/test_repo_hygiene.py tests/test_agents_md_codes.py tests/test_cli_reference.py tests/test_shape_doctor.py tests/test_setup_project_py.py tests/test_setup_sh.py tests/test_template_quoted_values.py tests/test_stdout_encoding.py tests/test_windows_paths.py tests/test_commit_trailers.py`: **944 passed, 4 skipped** (the doctor's PowerShell line and `tests/test_stdout_encoding.py:286`, Windows only).

At 708f3bb (origin/main aa4e1f5 merged in):

- every `tests/test_family*.py`, `tests/test_validate_family*.py`, `tests/test_park_resume_targets.py` and `tests/test_free_plan_hint.py`: **718 passed, 8 skipped** (`tests/test_family_init_values.py:242`).
- `tests/test_repo_hygiene.py tests/test_agents_md_codes.py tests/test_cli_reference.py tests/test_shape_doctor.py tests/test_update_shape_landing.py tests/test_doctor_unfinished_merge.py tests/test_template_values_single_pass.py tests/test_stdout_encoding.py tests/test_windows_paths.py`: **813 passed, 4 skipped** (the doctor's PowerShell line and `tests/test_stdout_encoding.py:286`, Windows only).

Earlier, with origin/main 48585e6 merged in:

- `tests/test_family*.py tests/test_validate_family*.py tests/test_stdout_encoding.py tests/test_windows_paths.py tests/test_repo_hygiene.py tests/test_agents_md_codes.py tests/test_cli_reference.py tests/test_park_resume_targets.py tests/test_bootstrap_spelling.py tests/test_free_plan_hint.py tests/test_template_values_single_pass.py`: **1303 passed, 9 skipped**.
- `tests/test_shape_doctor.py tests/test_update_shape*.py tests/test_commit_trailers.py tests/test_tracking_branch_ref.py tests/test_scaffold_ignored_shape_files.py tests/test_ruleset_hint_tracking_branch.py tests/test_bump_leg_dry_run_tracking.py tests/test_setup_project_py.py`: **999 passed, 6 skipped**.
- The new files alone: `test_family_init_landing.py` 9, `test_family_printed_quoting.py` 69, `test_family_tracking_branch.py` 17, all passed.

The full suite was not run locally. CI's three jobs are the check.

#505 and #395 have since landed, and both are merged here at fcbc7a2. Each of #505's family sentences was read against this branch's code, and none is false: AGENTS.md 3 and 233; README 569, 822, 1152, 1269 and 1348; the handbook 1126 and 1506. #395 landed with its test switching to `family/members` before its real `add`, as the last bullet below says, and the first run above includes it. #503 then landed as 631f087, and GitHub's update-branch merged it here as 22733ce with no conflict. Main f391e58 (#266, #509, #496 and #435) was then merged by hand as 5a2776d, again with only the footer in conflict: main's clauses stay in main's order, this branch's (#487) moves after #509's (#498), and the README blob is recomputed; `git show --remerge-diff` shows nothing else. #509's reworded sentences in AGENTS.md, README.md and the handbook were read beside this branch's, and none contradicts or repeats another. Its `setup-project.py` changes (the clone-path check, the plan line, the step-(7) backstop and `_main`) and this branch's `shell_word` lines in the hand-over do not meet, and `docs/cli.md` passes `--check`. Main 8cd7dbe (#506 and #347) was then merged by hand as 654df49, again with only the footer in conflict: this branch's (#487) moves after #506's (#462), the README blob is recomputed, and `docs/cli.md`, which both sides changed, still passes `--check`. #506's two `scripts/family.py` hunks (the `FAMILY_RULESET_HINT` import, and its print when the holder's push is refused) sit unchanged inside this branch's code, and that hint prints no path. Under `--reuse-empty-repo`, `init` still refuses its default `--into` inside a checkout of this standard (`family-landing-in-standard`) before it reads the remote, as a dry run with a stub `gh` showed. #506's sentences in AGENTS.md, README.md and the handbook are still true beside this branch's. Main d41cc29 (#402, for #277), which rewrote the doctor's NEXT lines and `tests/test_shape_doctor.py`, was then merged by GitHub's update-branch as e42ef74, with no conflict; the `holder` fixture still switches to `family/members` before its `add`. AGENTS.md stays at 490 lines and README.md at 1422.

`git merge-tree --write-tree` of 708f3bb, at 04:47Z on 2026-10-13:

- **Clean:** #503 (`fix/family-makefile-without-siblings`) and #395. Each merged tree keeps AGENTS.md at 490 lines and README.md at 1422.
- **`docs/handbook.html` footer only:** #505 (`docs/v1-accuracy`) and #491. #468 has landed and is merged here. #506 conflicts there too, and in `scaffold-project.py`, as it does with main. README.md and AGENTS.md merge clean with #505, and `setup-project.py` merges clean with #491. Whichever lands second keeps every footer clause and recomputes the README blob.
- **#395 merges clean but one of its tests fails with this branch.** `tests/test_template_text_placeholders.py::test_a_member_whose_id_yaml_would_misread_is_pinned_under_that_id` inits its own holder and runs a real `add` on `main`, which #487 refuses with `family-on-tracking-branch`. Whichever of the two lands second adds `git("switch", "-q", "-c", "family/members", cwd=root)` after that test's `init`; lane 5 is adding it on #395's own branch now, so this branch needs no change for it. (#395's head d526f76 also conflicts with this head in `tests/test_adopt_manifest_values.py`, a file this branch does not touch: that is #395 against main, which the same round resolves.)

- On Windows `shell_quoted` speaks PowerShell, the native shell this standard documents (`setup-project.py`), as the doctor's NEXT lines do. `git -C …`, `python scripts\family.py …` and `cd …` are shell-agnostic, so they get the platform's quoting, and no printed line joins two commands with `&&`, which Windows PowerShell 5.1 rejects.
- `rm -rf`, `mv` and `mkdir -p` are POSIX commands. They are quoted for a POSIX shell on every host, and the text says "in a POSIX shell (Git Bash on Windows)". PowerShell refuses `rm -rf`'s `-rf` and deletes nothing.
- The tests split a host-quoted line with a PowerShell reader on Windows and with `shlex` elsewhere, and split a POSIX-only line with `shlex` everywhere. The real-shell test is skipped on Windows.
- On Windows the tests do not execute `rm` or the `mv` lines. They delete the split path with `shutil.rmtree`, and stop after checking the `mv` argv.
- Paths: the cached store keeps git's POSIX spelling (`as_posix`), as before. Test paths are `resolve()`d, which expands an 8.3 short name such as `RUNNER~1`.
- Nothing here was run on Windows or macOS locally. The `tests-windows` and `tests-macos` CI jobs are the check; on macOS the real-shell test runs the shipped `zsh`.

- **A shipped template that imports a newer shared helper can break a holder that kept an older copy.** This change no longer does (`siblings.py` uses `shlex.join`), but nothing stops the next one: `update-shape.py apply --accept-local scripts/repo_shape.py` keeps a `repo_shape.py` that lacks a name a newly copied file imports, and `check` and the validator then read the holder as fine. The general guard is for `apply` to refuse that, as rv456 found for `bootstrap.py` and `spelled` (#456).
- **The doctor's `quote_arg` leaves a word that begins with `=` bare**, which zsh expands. `shell_quoted` quotes it; the doctor is left as it is here, and the agreement test excludes that one case.
- **The doctor and `update-shape.py` keep their own quoters.** The doctor's `quote_arg` flattens to ASCII by its report's contract, so moving it onto `repo_shape.shell_quoted` is more than an import change. `update-shape.py`'s POSIX `shlex` lines are lane 3's open #374. A test holds `shell_quoted` and `quote_arg` to one answer on every printable ASCII value but a leading `=`.
- **`family.py`'s by-hand rollback commands (#365) and its `git config -f .gitmodules` removals (#317, #360) keep `shlex.quote`.** They were already quoted, they are POSIX-only (`printf … | git update-index`), and they are worded for a POSIX shell.
- **The holder's `validate-family.py` remedies that name `family.py add`** (`member-gitlink-absent`, `member-gitlink-unnamed`) print no branch step: they are a holder copy, and the `add` they name refuses the tracking branch with its own `switch` remedy.
- **`remove`'s store note still computes `.git/modules/<path>`** rather than asking `git rev-parse --git-path`, as `add` does. In a linked worktree it therefore prints no note. That predates this change.
- **PowerShell verbs** (`Remove-Item`, `Move-Item`) are not printed for the POSIX-only commands.
- **README's `--into` sentence gives the default but not the refusal.** README.md (861) and the handbook (1246) say `--into <dir>` is the PARENT directory, "the directory you are standing in, by default". They do not say that `init` refuses that default inside a checkout of this standard (`family-landing-in-standard`). AGENTS.md item 1 says so, and the README's own example passes `--into ..`. README.md is at its 1422-line cap, so the sentence is on #459's checklist.
- **`setup-project.py`'s own `cd <clone>` line and its step-(7) backstop lines print their paths unquoted.** This change quotes only the family lines it prints. Those two predate it and #509, and they are on #459's checklist.

Reviewed independently at 10c93de: CHANGES NEEDED (0 blockers, 1 should-fix, 6 nits). The round at bb11b63 fixed the should-fix and all six nits, and its re-verification gave APPROVE WITH NITS (0/0/3), with SonarCloud's quality gate OK; those three are fixed at 3451a56. Main was then merged by GitHub's update-branch (8e1471c), by hand at 708f3bb and at fcbc7a2, where each time only the handbook footer conflicted, and by update-branch again at 22733ce (main 631f087, #503), with no conflict. CI was green there on Linux, macOS and Windows, with SonarCloud passing, but main had moved on: main f391e58 (#266, #509, #496 and #435) was merged by hand at 5a2776d, where again only the footer conflicted. CI was green there too, but main moved on again: main 8cd7dbe (#506 and #347) was merged by hand at 654df49, where once more only the footer conflicted. CI was green there as well, and main d41cc29 (#402) then came in by update-branch at e42ef74, with no conflict. CI is green on Linux and macOS, with SonarCloud passing, at e42ef74, a clean merge of main. All three OSes and SonarCloud passed at 654df49, and under Brett Heap's landing rule of 22:08:06Z (ruling 27) macOS and Windows carry over from that head. Main e6fbd74 (#515, for #514), which landed after it, touches none of its files, and the combined tree passed `tests/test_adopt_pins.py`, `tests/test_shape_doctor.py`, `tests/test_scaffold_leg_path_collisions.py`, the hygiene, AGENTS-code and CLI-reference tests, `tests/test_family_printed_quoting.py` and `tests/test_family_tracking_branch.py` (777 passed, 3 skipped).

Closes #488
Closes #486
Closes #487

Lane: openreposhape-5 (openRepoShape-5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants