Skip to content

shape-doctor.py: the naming row puts -- before repository names, so --help and -x are names to argparse again, not options (#104) - #108

Merged
brettheap merged 3 commits into
mainfrom
fix/doctor-naming-row-double-dash
Sep 11, 2026
Merged

brettheap merged 3 commits into
mainfrom
fix/doctor-naming-row-double-dash

Conversation

@brettheap

@brettheap brettheap commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

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

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.

… `--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]>
Copilot AI lite review requested due to automatic review settings September 11, 2026 13:31
@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

The PR fixes false compliance and misleading failures for repository names beginning with - by placing argparse’s -- end-of-options marker before names in both validator execution and remediation output, with direct and shell-level regression tests.

Sequence diagram for safe validation of option-like repository names

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

File-Level Changes

Change Details Files
Terminate argparse option parsing before repository names in the not-a-root naming check and its remediation command.
  • Pass -- between --explain and repository names when invoking the validator.
  • Include the same end-of-options marker in the emitted next command.
  • Document why shell quoting does not address argparse option interpretation.
shape-doctor.py
Add regression coverage for repository names that resemble command-line options and verify the remediation command end to end.
  • Assert a --help-named root receives a real naming finding with validator exit 1.
  • Retain a counterexample showing the old invocation incorrectly triggers argparse help.
  • Paste the emitted command into Bash and verify it reports the naming finding rather than usage output.
tests/test_shape_doctor.py

Assessment against linked issues

Issue Objective Addressed Explanation
#104 Pass an argparse end-of-options marker before repository names when invoking the naming validator, so names such as --help and -x are interpreted as positional names rather than options. ✅
#104 Include the same -- marker in the emitted naming remediation command so the pasted --explain command correctly handles repository names beginning with a dash. ✅
#104 Verify that the validator/parser accepts the marker and that both the naming verdict and emitted command work for a repository named --help. ✅

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 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]>
Copilot AI review requested due to automatic review settings September 11, 2026 13:34

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 blocking issues were identified.

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

Copilot AI review requested due to automatic review settings September 11, 2026 13:50
@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

The fix is covered by targeted regression tests.

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-11T14:35:27Z, PR #108 into opensoft/openRepoShape main (naming row puts -- before repository names in run_validator and the emitted --explain next line; closes #104)

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