Repository navigation
shape-doctor.py: the naming row puts -- before repository names, so --help and -x are names to argparse again, not options (#104) - #108
Conversation
… `--help` and `-x` are names to argparse again, not options (#104) 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`, `check_manifest`, `check_pins`, `check_family`, `check_machine`): each passes its values behind a named flag (`--project`, `--root`), and every one of those values is an absolute path this file builds itself, never a bare directory or origin name — so none of them can start with `-` the way a repository's own name can. `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. 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 GuideThe PR fixes false compliance and misleading failures for repository names beginning with Sequence diagram for safe validation of option-like repository namessequenceDiagram
participant Doctor as shape-doctor.py
participant Validator as validate-repository-naming.py
participant Argparse
Doctor->>Validator: run_validator(ctx, script, [--explain, --, name])
Validator->>Argparse: parse arguments
Argparse-->>Validator: Treat name after -- as positional
Validator-->>Doctor: Exit 1 with naming finding
Doctor-->>Doctor: Emit remediation with -- before name
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 fix and regression coverage address the parsing issue with no unresolved review comments.
Pull request overview
Fixes repository names beginning with - being misinterpreted as argparse options.
Changes:
- Adds
--before repository names in validator commands. - Adds regression tests for
--help-like names and remediation commands.
File summaries
| File | Description |
|---|---|
tests/test_shape_doctor.py |
Verifies correct findings and runnable remediation. |
shape-doctor.py |
Terminates validator options before repository names. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…lumns Lane: openreposhape-2 (openRepoShape-2) Claim: #104 (comment) Follow-up to the previous commit on this branch (#104): the fixed `run_validator(ctx, script, ["--explain", "--", *names])` call ran to 81 columns, past this file's own ~79-column convention. Wrapped the argument list onto its own line; no behavior change. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|



Lane: openreposhape-2 (openRepoShape-2)
Claim: #104 (comment)
Closes #104.
What was wrong
check_not_a_root_namingran the validator asrun_validator(ctx, script, ["--explain", *names])(shape-doctor.py:1854) and printed the same:1863). Both hand the repository's own name toargument list as its own remediation:
{PYTHON} {quote_arg(script)} --explain {spelled}(argparseas aBARE POSITIONAL, with nothing to say "the options end here" — so a directory
named
--helpis not a name to argparse, it is the-h/--helpflag everyArgumentParseradds for free.validate-repository-naming.py --explain --helpexits 0 through that flag's own handler before either positional isever 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.
-xfails adifferent way — not a registered option, so argparse refuses with
unrecognized arguments: -x(exit 2) — which this row reported as a FINDINGwith the argparse error text standing in for a naming reason.
Quoting (#101/#102) cannot reach either failure:
quote_argpromises a valuesurvives the READER'S SHELL as one argument, and
--helpneeds no shellquoting 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 listrun_validatoriscalled with (
["--explain", "--", *names]) and the remediation string(
--explain -- {spelled}).--is argparse's own end-of-options marker, andscripts/validate-repository-naming.py's parser accepts it because everyargparse.ArgumentParserdoes by default — its own--helptext isunchanged (
scripts/render-cli-reference.py --checkstill saysdocs/cli.mdis current).
Checked every other row that runs a validator:
check_namingpasses--project <path> --quiet;check_manifest,check_pinsandcheck_familyeach pass
--root <path>;check_machinepasses only--preflight, novalue 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, andcheck_machinecarries norepository-chosen value to begin with.
check_not_a_root_namingwas the onlyrow handing a bare, repository-chosen name to argparse; nothing else needed
the same fix.
The proof
Before, doctoring a directory named
--help:After, the same directory:
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_verdictproves therow itself against a
--help-named directory (JSON only, so it runsidentically 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 emittednextline intobash -cverbatim andasserts it exits 1 with the real finding rather than 0 with a usage banner.
Housekeeping
python3 -m pytest -qis green from a cwd with no sibling checkouts on itspath. This workstation keeps real
openXdoxandopenDoxclones besideits
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 BESIDEthis project" fallback (
repo_shape.resolve_link_source) to those realdirectories instead of finding nothing, and fails on an unrelated
assertion. Reproduced identically against an untouched
maincheckout —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
Summary by Sourcery
Make repository naming validation handle names such as
--helpand-xas positional names rather than command-line options.Bug Fixes:
Tests: