Skip to content

shape-doctor.py: scaffold_command quotes for the platform it was ASKED for, not the host it is running on, so one call is one line on every machine (#103) - #106

Merged
brettheap merged 2 commits into
mainfrom
fix/doctor-scaffold-command-platform-quoting
Sep 11, 2026
Merged

brettheap merged 2 commits into
mainfrom
fix/doctor-scaffold-command-platform-quoting

Conversation

@brettheap

@brettheap brettheap commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

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 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 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

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.

…KED for, not the host it is running on, so one call is one line on every machine (#103)

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`.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 11, 2026 13:23
@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 3 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

Fix scaffold_command so entry point selection, interpreter selection, and argument quoting all use one resolved target platform, while preserving host-default output and adding cross-platform and end-to-end regression tests.

Flow diagram for platform-aware scaffold command resolution

flowchart TD
    A["scaffold_command(shape, project, platform)"] --> B["target = os.name if platform is None else platform"]
    B --> C{"target == nt?"}
    C -->|yes| D["python_command(platform)"]
    C -->|yes| E["quote_arg(setup-project.py, target)"]
    C -->|no| F["quote_arg(setup.sh, target)"]
    D --> G["quote_arg(project, target)"]
    E --> G
    F --> G
    G --> H["One platform-consistent command line"]
Loading

File-Level Changes

Change Details Files
Make scaffold command rendering consistently target the requested platform.
  • Resolve the effective platform once, preserving host behavior when no platform is supplied.
  • Pass the resolved platform to all path and project-name quoting decisions.
  • Continue passing the raw platform to interpreter selection so the existing default semantics remain intact.
shape-doctor.py
Add cross-platform regression coverage for platform-specific quoting and host-default behavior.
  • Add Windows-path fixtures asserting bare Windows spelling and quoted POSIX spelling regardless of the test host.
  • Cover paths requiring quoting on both platforms and validate POSIX parsing with shlex.
  • Assert that omitted-platform rendering remains identical to the current host spelling.
tests/test_shape_doctor.py
Verify the end-to-end way-in row remains internally consistent.
  • Assert the generated scaffold command matches scaffold_command for the host platform.
  • Assert the repository-adoption command uses host-consistent quoting for its path arguments.
tests/test_shape_doctor.py

Assessment against linked issues

Issue Objective Addressed Explanation
#103 Ensure that every argument quoted by scaffold_command uses the explicitly requested platform rather than the host platform, while preserving host-based behavior when platform is None. ✅
#103 Add cross-platform tests using a genuine Windows path to verify that scaffold_command produces identical, platform-appropriate command lines regardless of the host running the tests. ✅
#103 Verify that the way-in row and generated CLI reference remain correct and unchanged. ✅

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.

🟢 Approval recommended

The only remaining comment is a non-blocking naming nit.

Pull request overview

Fixes scaffold_command so platform-specific entry points, interpreters, and quoting consistently use the requested platform.

Changes:

  • Centralizes platform selection.
  • Adds Windows/POSIX quoting and end-to-end regression tests.
  • Preserves host-default behavior.
File summaries
File Summary
tests/test_shape_doctor.py Adds cross-platform command and integration coverage; includes a non-blocking test-name nit.
shape-doctor.py Applies the requested platform consistently when generating scaffold commands.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • 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 tests/test_shape_doctor.py Resolved
…Copilot, PR #106)

Lane: openreposhape-2 (openRepoShape-2)

`test_the_way_in_row_is_one_platforms_line_end_to_end` reads as a count
rather than as a possessive, and the invariant it guards is exactly the one
a reader should be able to find by name: the row names no platform, so its
line is the HOST's, whole. Renamed to
`test_the_way_in_row_matches_the_host_platform_end_to_end`, which says that.

Name only -- no assertion, no fixture and no shipped file changes.
`tests/test_shape_doctor.py`: 105 passed.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 11, 2026 13:29
@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.

🟢 Approval recommended

No unresolved issues; targeted cross-platform tests cover the change.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@brettheap

Copy link
Copy Markdown
Contributor Author

LANDING — lane openreposhape-2 (openRepoShape-2), session 8706b0f5, 2026-09-11T13:46:33Z, PR #106 into opensoft/openRepoShape main (scaffold_command resolves the platform once and threads it through both quote_arg calls, way-in row asserted host-only; closes #103)

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