Repository navigation
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
Conversation
…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]>
|
@codex review |
There was a problem hiding this comment.
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.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Reviewer's GuideFix 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 resolutionflowchart 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"]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
🟢 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.
…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]>
|



Lane: openreposhape-2 (openRepoShape-2)
Claim: #103 (comment)
Closes #103.
What was wrong
scaffold_command(shape, project, platform)makes three decisions aboutone line -- which entry point (
setup-project.pyorsetup.sh), whichinterpreter (
pythonorpython3), and how each value is quoted -- and since#102 only the first two read the
platformit was handed. Its ownquote_arg(...)calls passed nothing, so they fell back toquote_arg'sdefault, which reads the real host's
os.name.So with an explicit
platform, half the line followed the argument and halffollowed the machine:
One call, one set of arguments, two different strings.
\is inUNQUOTED_NTand 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
--jsonnextlines are consistent for the machinethat produced them. The argument exists for the tests, and PR #102's tests had
to route around the seam: their
ntrow used aPurePosixPath, because/is in both alphabets, after commit 1f513c5 found the Windows runnerrendering
\srv\...against a/srv/...expectation. But the whole reasonthis function takes a
platformis "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
--jsonconsumer asking for one platform'sspelling.
What landed
One resolution, used three times.
target = os.name if platform is None else platformis decided once at the top ofscaffold_command, and thebranch, 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_commandis the one that keeps the rawplatform:Nonetherereturns 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 toquote_arg(value, os.name), so the host-default line is unchanged, byte for byte -- whichis every line any real run prints.
The
way-inrow needs no change and is now proved not to. It is wherescaffold_commandis actually called and it names no platform at all, soevery part of both its lines -- entry point, interpreter and quoting -- is the
host's. That is asserted now rather than assumed, so a
platformthreadedinto the row later without being threaded through the quoting fails a test
instead of shipping half a line.
No
--helptext moved, sodocs/cli.mddoes not; nothing undertemplates/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.pygains a
PureWindowsPathimport, two fixture rows, two functions, and arewrite of the comment above
SCAFFOLD_COMMANDthat this commit makes stale (it explains why thentrowcould NOT be given a Windows path; it can now).
SCAFFOLD_COMMANDgains 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 onntandsingle-quoted on
posix, each asserted as the whole line, byte forbyte, from whichever host runs the suite -- the two
PurePosixPathrowsstay beside them because
/is in both alphabets, which is what makes themthe pair that isolates the entry point and the interpreter from the quoting.
test_the_scaffold_lines_quoting_is_the_asked_for_platforms_toosays thesame thing in one place and adds what the parametrized rows cannot: the
POSIX form read back by
shlex.split-- the shell's own reader -- handingthe path back whole, backslashes and all; a value neither alphabet
admits (
C:\Program Files\...) quoted on both, so the fix is not "neverquote for Windows" but "quote for the platform asked for"; and
scaffold_command(shape, "Atlas")with no platform equal to the explicithost spelling.
test_the_way_in_row_is_one_platforms_line_end_to_endbuilds the rowin-process from a
Contextand asserts its command is byte for byte whatscaffold_commandproduces for this machine -- and, once the same directoryis
git init-ed, that the adopt line is byte for byte whatquote_argproduces for it.
Both new assertions fail on
origin/mainand pass here:python3 -m pytest -q: 952 passed, 1 skipped, plus onepre-existing, location-dependent failure that is not this change's and
reproduces identically on a clean
origin/mainworktree cut in the samedirectory:
test_naming_policy.py::test_cli_reports_an_unread_link_as_a_warning_and_still_classifiesasserts a
declared-unverifiedwarning for a chain link no--link-sourceanswers for, and this workstation has real
openXdox/andopenDox/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:
Enhancements:
Tests: