Skip to content

tests: check's gh reaches the guard in test_adopt_split_branch.py, "every machine" is said off Windows only, the condition names what ends check first, and the guard's summary names #798's answer (#938) - #966

Merged
brettheap merged 7 commits into
mainfrom
fix/938-gh-docstrings
Oct 19, 2026

Conversation

@brettheap

@brettheap brettheap commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openreposhape-1 (openRepoShape-1)
Claim: #938 (comment)

A v1.2.0 draft on main 01a2b016, which holds #881. It is #881's follow-up, #938, from lane 5's re-check of #881 at 1d21a850. It changes test docstrings and comments only, in 8 files under tests/: ast.dump of every changed file, outside its docstrings, is unchanged. Line numbers below are at the head, fc4c06a3.

What

  1. tests/test_adopt_split_branch.py:21-23 no longer says its gh "is never reached".

  2. "Every machine" is said off Windows only.

    • The places: tests/gh_guard.py:28-30 (the machine row: "off Windows a logged-in operator gets the output CI gets"), tests/gh_guard.py:49 (the NOTE), and tests/test_template_text_placeholders.py:32 ("NO NETWORK AND NO GITHUB, off Windows").
    • On Windows a bare gh skips the guard's gh.cmd (tests/conftest.py). Where a logged-in gh.exe is installed, it answers instead.
  3. The condition names what ends check first: "once nothing before it ends check and the plan's names and org: pass". That covers a mistyped plan, which ends check with exit 1 and findings, and a refusal, which ends it with exit 2. It is in seven places:

    • tests/gh_guard.py:45-46;
    • test_adopt_check_plan_name.py:38;
    • test_adopt_project_is_the_source.py:26;
    • test_adopt_tracking_branch.py:24;
    • test_adopt_origin_repository.py:33;
    • test_template_text_placeholders.py:36-37;
    • the new sentence in test_adopt_split_branch.py.
  4. The guard's own summary names adopt-project.py execute: each leg repository is asked about only as it is made, so a code leg whose name is taken leaves the spec leg created, on GitHub as under --local-remote-dir, and a --local-remote-dir that is a file or cannot be written ends in a traceback after check said plan ok #798's answer: tests/gh_guard.py:2 ("three answers, a refusal, every call logged"), :17-22, and tests/conftest.py:13-17, which now name gh repo view <owner>/<name> --json nameWithOwner, answered as a gh with no login answers it.

  5. tests/test_adopt_split_branch.py:732: check "reads no network for the branches".

Measured, with the guard's log

Tests

Known limits

  • Windows was not run. The Windows sentences rest on the comment in tests/conftest.py.
  • tests/test_gh_guard.py:203 keeps "on every machine", because that test is marked WINDOWS_SKIP.

Closes #938

🤖 Generated with Claude Code

Summary by Sourcery

Clarify the test suite's GitHub CLI guard behavior and adoption-check documentation, including platform-specific limitations and the conditions that trigger repository lookups.

Enhancements:

  • Clarify test documentation to accurately describe GitHub CLI calls made by adoption checks and the conditions under which they occur.
  • Document the guard's handling of repository metadata queries and distinguish its behavior from real GitHub CLI execution on Windows.

Brett Heap and others added 2 commits October 18, 2026 18:05
…"every machine" is said off Windows only, and the condition names a refusal that comes first (#938)

#881 (#880) rewrote five module docstrings and tests/gh_guard.py to say when `check` asks `gh repo view` of each leg, and lane 5's re-check of it at 1d21a85 left three things for here. Docstrings only: in each file the AST outside the module docstring, and the text after it, are unchanged.

1. `tests/test_adopt_split_branch.py` said a run without `--local-remote-dir` is redirected by `url.<base>.insteadOf` "and its `gh` is never reached". `check` there asks `gh repo view testorg/Northwind-spec|-code --json nameWithOwner` and the session's guard answers it: 86 calls in 31 of its 47 tests (20 make 2, 10 make 4, 1 makes 6), every one of that shape, logged as a probe. `insteadOf` redirects `git` and not `gh`. The docstring now says so, and that the in-process `execute` runs of the file have `run` replaced by `no_gh`, which refuses and records every `gh` command, so none of `execute`'s reaches the guard (the 8 tests that use `no_gh` and run no `check` log 0 calls).

2. "every machine" and an unqualified "NO NETWORK AND NO GITHUB" are said off Windows only, as `tests/test_template_text_placeholders.py` already said of the guard's answer. `tests/gh_guard.py` said `check` "prints, on every machine, the NOTE that it could not ask"; on Windows a bare `["gh", ...]` skips the guard's `gh.cmd` (`tests/conftest.py`, "WHAT REACHES THE GUARD ON WINDOWS IS LESS"), and where a logged-in `gh.exe` is installed it answers instead: no NOTE, and GitHub is reached. `tests/gh_guard.py` now says that; `tests/test_template_text_placeholders.py` opens "NO NETWORK AND NO GITHUB, off Windows".

3. The six docstrings said `check` asks "once the plan's names and `org:` pass". `cmd_check` refuses or reports before it gets there: a plan whose keys have the wrong type is reported before anything is opened, and `Plan.open_source` refuses what it cannot open. `test_check_of_a_plan_whose_branch_was_deleted_is_refused_by_name` (`tests/test_adopt_tracking_branch.py`) passes `plan`, then `check` refuses `source-default-branch-not-local`, exit 2, and the guard logs 0 calls for it. They now say "once nothing before it refuses and the plan's names and `org:` pass", lane 5's wording: `tests/gh_guard.py`, `tests/test_adopt_check_plan_name.py`, `tests/test_adopt_project_is_the_source.py`, `tests/test_adopt_tracking_branch.py`, `tests/test_adopt_origin_repository.py`, `tests/test_template_text_placeholders.py`, and the new sentence in `tests/test_adopt_split_branch.py`.

Checked: the 6 test files this touches, `tests/test_gh_guard.py` and `tests/test_no_auto_maintenance.py`, which read the guard, and `tests/test_repo_hygiene.py`: 450 passed, 2 skipped (`tests/test_no_auto_maintenance.py:222`, which skips when the session began with GIT_CONFIG_GLOBAL set, as the probe environment sets it).

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…chine" off Windows only, and the docstring says what a doctor run does on Windows, where the preflight's bare `gh` skips the guard (#938)

Follows ed17d56, which said `check`'s NOTE is printed "off Windows" in the same docstring. The paragraph "WHY THE PROBES ARE ANSWERED RATHER THAN REFUSED" still said the `machine` row "says the same thing on every machine" and that "a logged-in operator gets the output CI gets". `tests/conftest.py` ("WHAT REACHES THE GUARD ON WINDOWS IS LESS") says every tool starts `gh` as a bare `["gh", ...]`, which CreateProcess looks up as `gh.exe` alone, so on Windows a doctor run bypasses the guard and asks a real `gh.exe` where one is installed. Both claims are now said off Windows, and the paragraph says what happens on Windows.

Docstring only: the AST outside the module docstring, and the text after it, are unchanged against 01a2b01 and ed17d56. `tests/test_gh_guard.py`, `tests/test_template_text_placeholders.py` and `tests/test_repo_hygiene.py`: 231 passed.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@brettheap brettheap added this to the v1.2.0 milestone Oct 18, 2026
@sourcery-ai

sourcery-ai Bot commented Oct 18, 2026

Copy link
Copy Markdown

Reviewer's Guide

Documentation-only updates align test docstrings and comments with observed gh execution: adoption check can invoke guarded repository lookups, while Windows may bypass the guard, and execute uses its own stubbed command path.

File-Level Changes

Change Details Files
Correct test documentation to describe the actual gh reachability and guard behavior for adoption checks.
  • Explain that Git URL rewriting does not redirect gh, and that check reaches gh repo view after earlier validations pass.
  • Document the guard’s off-Windows scope and the possibility of a real logged-in gh.exe on Windows.
  • Clarify that in-process execute calls use no_gh and therefore do not reach the session guard.
  • Qualify repeated test-module descriptions with the prerequisite refusal and plan-name/org validation conditions.
tests/gh_guard.py
tests/test_adopt_split_branch.py
tests/test_adopt_check_plan_name.py
tests/test_adopt_project_is_the_source.py
tests/test_adopt_tracking_branch.py
tests/test_adopt_origin_repository.py
tests/test_template_text_placeholders.py

Assessment against linked issues

Issue Objective Addressed Explanation
#938 Correct the split-branch test docstring to explain that git's insteadOf redirect does not prevent check from running gh, and clarify that the session guard answers those calls off Windows while the in-process execute calls are stubbed. ✅
#938 Qualify claims that the guard answers gh or that GitHub is not reached so they apply off Windows, and describe the Windows behavior where a real gh.exe may answer instead. ✅
#938 Update the relevant docstrings and guard documentation to state that check asks gh only when nothing earlier refuses and the plan's names and org: pass. ✅

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

…heck`, the `machine` row's output is CI's off Windows, the guard's docstrings name #798's `repo view` answer, and one docstring says `check` reads no network for the branches (#938)

The independent review of #966 (r938) found it READY with one SHOULD and three NITs. Docstrings and comments only: with every docstring stripped, the AST of each of the 8 files, and the comments of each, are unchanged against 0b292a5 and against 01a2b01.

S1. "once nothing before it refuses and the plan's names and `org:` pass" said too much for a mistyped plan: its wrongly typed keys end `check` with exit 1 and findings, before the source is opened or a name is read, and that is no refusal. It is now "once nothing before it ends `check` and the plan's names and `org:` pass", which covers the exit 1 and the exit 2 alike and leaves out plan-stale, split-branch and entry findings, which do not stop the question. In all 7 places: `tests/gh_guard.py`, `tests/test_adopt_check_plan_name.py`, `tests/test_adopt_project_is_the_source.py`, `tests/test_adopt_split_branch.py`, `tests/test_adopt_tracking_branch.py`, `tests/test_adopt_origin_repository.py` and `tests/test_template_text_placeholders.py`, each paragraph rewrapped to the file's width.

NIT 4. `tests/gh_guard.py`: "to leave it out; there a logged-in operator gets the output CI gets" has no referent for "there"; it is now "off Windows a logged-in operator gets the output CI gets".

NIT 5. `tests/test_adopt_split_branch.py`: the docstring of `test_check_reads_github_as_the_sources_origin_last_fetched_it` said "`check` reads no network", beside a module paragraph saying `check` asks `gh`. It is now "reads no network for the branches".

NIT 6. `tests/conftest.py` and `tests/gh_guard.py` still said the guard answers two questions ("`gh --version` and `gh auth status`"; "two answers, one refusal"). `answer()` also answers `repo view <owner>/<name> --json nameWithOwner` (#798), exit 4 and gh's own words, as a `gh` with no login does. The conftest docstring now names it, and the guard's title says three answers, and its "WHAT IT DOES" paragraph says "Asked one of the two `PROBES`, or the `repo view` of #798 below, it answers".

Checked: the 9 files `tests/test_adopt_split_branch.py`, `tests/test_adopt_check_plan_name.py`, `tests/test_adopt_project_is_the_source.py`, `tests/test_adopt_tracking_branch.py`, `tests/test_adopt_origin_repository.py`, `tests/test_template_text_placeholders.py`, `tests/test_gh_guard.py`, `tests/test_no_auto_maintenance.py` and `tests/test_repo_hygiene.py`: 450 passed, 2 skipped (`tests/test_no_auto_maintenance.py:222`, which skips when the session began with GIT_CONFIG_GLOBAL set, as the probe environment sets it).

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@brettheap

Copy link
Copy Markdown
Contributor Author

(lane openRepoShape-1, 2026-10-18T18:47:18Z) Independent review of #966 by lane 1's reviewer r938 (sonnet), who is not its writer: READY at fc4c06a3, with no MUST, SHOULD or NIT left.

#966 takes its turn once its tests are green at fc4c06a3, gated over main as it then stands.

Lane: openreposhape-1 (openRepoShape-1)

@brettheap brettheap changed the title tests: check's gh reaches the guard in test_adopt_split_branch.py, "every machine" is said off Windows only, and the condition names a refusal that comes first (#938) tests: check's gh reaches the guard in test_adopt_split_branch.py, "every machine" is said off Windows only, the condition names what ends check first, and the guard's summary names #798's answer (#938) Oct 18, 2026
@sonarqubecloud

Copy link
Copy Markdown

@brettheap
brettheap marked this pull request as ready for review October 19, 2026 14:23
@sourcery-ai

sourcery-ai Bot commented Oct 19, 2026

Copy link
Copy Markdown

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant